public class PolicyUtils extends Object
PolicyUtils
provides utility(static) methods
that would be used by policy pacakgeModifier and Type | Field and Description |
---|---|
static String |
ADVICES_END_TAG |
static String |
ADVICES_START_TAG |
static String |
ADVICES_TAG_NAME |
static String |
EMPTY_STRING |
static boolean |
logStatus |
static String |
NEW_LINE |
static String |
NULL_STRING |
Constructor and Description |
---|
PolicyUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
advicesToXMLString(Map advices)
Returns XML string representation of a
Map of policy advices |
static Map |
appendElementToMap(String key,
Set values,
Map toMap)
Appends a key/value pair to a map
|
static Map |
appendMapToMap(Map mapToAdd,
Map toMap)
Appends a map to another map
|
static String |
attributeValuePairToXMLString(String name,
Set values)
Converts an attribute value pair into
its XML string representation.
|
static Map |
cloneMap(Map map)
Returns deep copy of a
Map
The passed in |
static String |
constructUserFilter(SSOToken token,
String userRDNAttrName,
String userName,
boolean aliasEnabled)
Constructs a search filter used in subject evaluation.
|
static void |
createOrReplacePolicies(PolicyManager pm,
InputStream xmlPolicies,
boolean replace)
Creates or replaces policy objects given an input stream of policy XML
which confines to
com/sun/identity/policy/policyAdmin.dtd . |
static void |
createPolicies(PolicyManager pm,
InputStream xmlPolicies)
Creates policy objects given an input stream of policy XML which
confines to
com/sun/identity/policy/policyAdmin.dtd . |
static String |
decrypt(String encryptedText) |
static Set |
delimStringToSet(String str,
String delimiter)
Parses a string into a set using the specified delimiter
|
static String |
encrypt(String plainText) |
static String |
envParametersToXMLString(Map envMap)
Converts a map which stores a set of
environment parameters into its XML string representation.
|
static String |
getAttributeName(Node pNode)
Parses an XML node which represents an
AttributeValuePair and returns the attribute name.
|
static Set |
getAttributeValues(Node pNode)
Parses an XML node which represents an
AttributeValuePair and returns the attribute values.
|
static String |
getDisplayName(String dn)
Returns the display name for a given dn
This implementation assumes the display name to be the value of
the naming attribute of the entry.
|
static String |
getDNDisplayString(String strDN)
Returns a display string for an LDAP distinguished name.
|
static String |
getISDSHostName()
Returns the LDAP server host used by Access Manager SDK stored
in
serverconfig.xml file. |
static boolean |
isLocalDS(String hostName)
Checks if the
hostName is the same as
the one used by the OpenAM SDK. |
static void |
logAccessMessage(String msgIdName,
String[] data,
SSOToken token)
Logs an access message
|
static void |
logAccessMessage(String msgIdName,
String[] data,
SSOToken token,
String serviceType) |
static void |
logErrorMessage(String msgIdName,
String[] data,
SSOToken token)
Logs an error message
|
static String |
mapToXMLString(Map envMap)
Converts a map
to its XML string representation.
|
static Map |
parseAdvicesXML(String advicesXML)
Parses an XML string representation of policy advices and
returns a Map of advices.
|
static Map |
parseAttributeValuePairs(Node pNode)
Parses an XML node which represents Attribute-Value pairs
and returns a map of such values.
|
static Map |
parseEnvParameters(Node pNode)
Parses an XML node which represents a collection of
the environment parameters and returns a map which contains
these parameters.
|
static Set |
parseResponseAttributes(Node pNode)
Parses an XML node which represents a collection of
user response attributes and returns a set which contains the
names of these attributes
|
static boolean |
principalNameEqualsUuid(SSOToken token)
Checks if principal name and uuid are same in the session
|
static String |
quote(int i)
Return a quoted string, quoting an
int . |
static String |
quote(long l)
Return a quoted string, quoting a
long . |
static String |
quote(String s)
Return a quoted string
Surrounds a string on either side with double quote and returns
the quoted string
|
static void |
removePolicyRules(SSOToken token,
String serviceName)
Removes policy rules defined for a service.
|
static String |
responseAttributesToXMLString(Set attrs)
Converts a set which stores a set of
response attribute names into its XML string representation.
|
public static boolean logStatus
public static final String EMPTY_STRING
public static final String NULL_STRING
public static final String NEW_LINE
public static final String ADVICES_TAG_NAME
public static final String ADVICES_START_TAG
public static final String ADVICES_END_TAG
public static Map appendMapToMap(Map mapToAdd, Map toMap)
mapToAdd
- map that needs to be added
Each key should be a String
Each value would be a Set of String valuestoMap
- map the map to which the mapToAdd would be added
Each key should be a String
Each value would be a Set of String valuespublic static Map appendElementToMap(String key, Set values, Map toMap)
key
- a String valued keyvalues
- a set of String valuestoMap
- the map to which to append the key/value pair
Each key of the map should be a String
Each value of the map should be a Set of String valuespublic static String getDisplayName(String dn)
dn
- dn of the entry for which to get the display namepublic static Map parseEnvParameters(Node pNode) throws PolicyException
pNode
- the XML DOM node for the environment parameters.PolicyException
- if the node can not be parsed into a mappublic static Set parseResponseAttributes(Node pNode) throws PolicyException
pNode
- the XML DOM node for the response attributesPolicyException
- if the node can not be parsed into a setpublic static Map parseAttributeValuePairs(Node pNode)
pNode
- the XML DOM node containing Attribute-Value pairs
as child nodes.public static String getAttributeName(Node pNode)
pNode
- the XML DOM node for an AttributeValuePairpublic static Set getAttributeValues(Node pNode)
pNode
- the XML DOM node for an AttributeValuePairpublic static String envParametersToXMLString(Map envMap)
envMap
- a map respresents a collection of the parameterspublic static String responseAttributesToXMLString(Set attrs)
attrs
- a set of response attribute namespublic static String mapToXMLString(Map envMap)
envMap
- a map that has String valued keys. Value corresponding
to each key should be a set of String(s).public static String attributeValuePairToXMLString(String name, Set values)
name
- the attribute name of the attribute value pairvalues
- the attribute values of the attribute value pairpublic static String quote(String s)
s
- string to be quotedpublic static String quote(int i)
int
.
Converts an int
to string and quotes it on either side
with double quote and returns the quoted stringi
- int
to be quotedpublic static String quote(long l)
long
.
Converts a long
to string and quotes it
on either side
with double quote and returns the quoted stringl
- long
to be quotedpublic static void logAccessMessage(String msgIdName, String[] data, SSOToken token) throws SSOException
msgIdName
- name of message iddata
- array of data to be loggedtoken
- session token of the user who did the operation
that triggered this loggingSSOException
public static void logAccessMessage(String msgIdName, String[] data, SSOToken token, String serviceType) throws SSOException
SSOException
public static void logErrorMessage(String msgIdName, String[] data, SSOToken token) throws SSOException
msgIdName
- name of message iddata
- array of data to be loggedtoken
- session token of the user who did the operation
that triggered this loggingSSOException
public static String getISDSHostName()
serverconfig.xml
file.
For multiple hosts, the returned value is a space-delimited list
of hosts.public static boolean isLocalDS(String hostName) throws PolicyException
hostName
is the same as
the one used by the OpenAM SDK.hostName
- host name to compare against OpenAM SDK config store hosthostName
is the same as the one used by the
OpenAM SDK, false otherwisePolicyException
- if host names comparison does not succeedpublic static String constructUserFilter(SSOToken token, String userRDNAttrName, String userName, boolean aliasEnabled) throws SSOException
token
- SSO tokenuserRDNAttrName
- naming attributeuserName
- the value of the user namealiasEnabled
- if true, user alias list will be used to construct
the search filterSSOException
- if there is error when trying to retrieve
token propertiespublic static void removePolicyRules(SSOToken token, String serviceName) throws SSOException, AMException
token
- session token of the user doing the operationserviceName
- name of the serviceSSOException
AMException
public static Set delimStringToSet(String str, String delimiter)
str
- string to be parseddelimiter
- delimiter used in the stringpublic static String getDNDisplayString(String strDN)
strDN
- distinguished name.public static Map parseAdvicesXML(String advicesXML) throws PolicyException
advicesXML
- XML string representation of policy advices conforming
to the following DTD. The input string may not be validated against the
dtd for performance reasons.
PolicyException
- if there is any error parsing the passed in
advicesXMLpublic static String advicesToXMLString(Map advices) throws PolicyException
Map
of policy advicesadvices
- Map
of policy advicesPolicyException
- if there is any error while convertingpublic static boolean principalNameEqualsUuid(SSOToken token) throws SSOException
token
- session tokentrue
if the principal name and uuid
are same in the session. Otherwise, false
SSOException
- if the session token is not validpublic static void createPolicies(PolicyManager pm, InputStream xmlPolicies) throws PolicyException, SSOException
com/sun/identity/policy/policyAdmin.dtd
.pm
- Policy manager.xmlPolicies
- Policy XML input stream.PolicyException
- if policies cannot be created.SSOException
- if Single Sign On token used to create policy
manager is no longer valid.public static void createOrReplacePolicies(PolicyManager pm, InputStream xmlPolicies, boolean replace) throws PolicyException, SSOException
com/sun/identity/policy/policyAdmin.dtd
.pm
- Policy manager.xmlPolicies
- Policy XML input stream.replace
- True if the policies should be replaced, otherwise create.PolicyException
- if policies cannot be updated.SSOException
- if Single Sign On token used to update policy
manager is no longer valid.public static Map cloneMap(Map map)
Map
The passed in Map
should have String
object as keys and Set
of String
objects as values
map
- Map
that needs to be copiedMap
Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.