Package com.sun.identity.saml.common
Class SAMLUtilsCommon
- java.lang.Object
-
- com.sun.identity.saml.common.SAMLUtilsCommon
-
-
Field Summary
Fields Modifier and Type Field Description static ResourceBundlebundleSAML resource bundle object.static DebugdebugSAML debug object.static SecureRandomrandomSecureRandominstance.static StringSAMLID_PREFIXPrefix for ids used in SAML service.static SAMLConstantsscA handle forSAMLConstants.
-
Constructor Summary
Constructors Constructor Description SAMLUtilsCommon()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringbyteArrayToHexString(byte[] byteArray)Converts a byte array to a hex string.static StringbyteArrayToString(byte[] bytes)Converts byte array to string.static booleancheckStatement(Element element, String statementname)Verifies if an element is a type of a specific statement.static StringdecodePassword(String password)Decodes a password.static StringgenerateAssertionID()Generates an ID String with length of SAMLConstants.ID_LENGTH.static StringgenerateID()Generates an ID String with length of SAMLConstants.ID_LENGTH.static StringgetDecodedSourceIDString(String encodedID)Decodes the Base64 encodedsourceidand returns a String of the raw-byte source id.static StringmakeEndElementTagXML(String elementName, boolean includeNS)Generates end element tag.static StringmakeStartElementTagXML(String elementName, boolean includeNS, boolean declareNS)Generates xml element start tag.static StringremoveNewLineChars(String s)Removes new line charactors.static voidsetDebugInstance(Debug dbg)Sets theDebugof the service.static voidsetResourceBundle(ResourceBundle resBundle)Sets theResourceBundleof the service.
-
-
-
Field Detail
-
random
public static SecureRandom random
SecureRandominstance.
-
SAMLID_PREFIX
public static final String SAMLID_PREFIX
Prefix for ids used in SAML service.- See Also:
- Constant Field Values
-
sc
public static SAMLConstants sc
A handle forSAMLConstants.
-
bundle
public static ResourceBundle bundle
SAML resource bundle object.
-
debug
public static Debug debug
SAML debug object.
-
-
Method Detail
-
setResourceBundle
public static void setResourceBundle(ResourceBundle resBundle)
Sets theResourceBundleof the service.- Parameters:
resBundle-ResourceBundleinstance to be set.
-
setDebugInstance
public static void setDebugInstance(Debug dbg)
Sets theDebugof the service.- Parameters:
dbg-Debuginstance to be set.
-
generateAssertionID
public static String generateAssertionID()
Generates an ID String with length of SAMLConstants.ID_LENGTH.- Returns:
- string the ID String; or null if it fails.
-
generateID
public static String generateID()
Generates an ID String with length of SAMLConstants.ID_LENGTH.- Returns:
- string the ID String; or null if it fails.
-
byteArrayToHexString
public static String byteArrayToHexString(byte[] byteArray)
Converts a byte array to a hex string.
-
makeEndElementTagXML
public static String makeEndElementTagXML(String elementName, boolean includeNS)
Generates end element tag. It takes in the name of element and produces a String as output which is in XML format. For example given "SubjectConfirmation", It produces output like </saml:SubjectConfirmation> if includeNS is true else produces </SubjectConfirmation>- Parameters:
elementName- name of an elementincludeNS- true to include namespace prefix; false otherwise.- Returns:
- String which is an xml element end tag.
-
makeStartElementTagXML
public static String makeStartElementTagXML(String elementName, boolean includeNS, boolean declareNS)
Generates xml element start tag. This utility method takes in the name fo element and produces a String as output which is in XML format. For example given "SubjectConfirmation". It produces output like <saml:SubjectConfirmation xmlns:saml= "http://www.oasis-open.org/committees/security/docs/ draft-sstc-schema-assertion-16.xsd"> where nameSpace is defined inAssertionBaseclass if declareNS and includeNS are true.- Parameters:
elementName- name of the element.includeNS- true to include namespace prefix; false otherwise.declareNS- true to include namespace declaration; false otherwise.- Returns:
- xml element start tag.
-
checkStatement
public static boolean checkStatement(Element element, String statementname)
Verifies if an element is a type of a specific statement. Currently, this method is used by class AuthenticationStatement, AuthorizationDecisionStatement and AttributeStatement.- Parameters:
element- a DOM Element which needs to be verified.statementname- A specific name of a statement, for example, AuthenticationStatement, AuthorizationDecisionStatement or AttributeStatement- Returns:
- true if the element is of the specified type; false otherwise.
-
decodePassword
public static String decodePassword(String password)
Decodes a password. The value passed is the value to be decoded using the decoder class defined in FederationConfig.properties. The decoded value will be returned unless the decoder class is not defined, or cannot be located. In that case, the original value will be returned.- Parameters:
password- original password.- Returns:
- decoded password.
-
removeNewLineChars
public static String removeNewLineChars(String s)
Removes new line charactors.- Parameters:
s- A String to be checked.- Returns:
- a String with new line charactor removed.
-
getDecodedSourceIDString
public static String getDecodedSourceIDString(String encodedID)
Decodes the Base64 encodedsourceidand returns a String of the raw-byte source id.- Parameters:
encodedID- A String representing the Base64 encoded source id.- Returns:
- A String representing the raw byte source id.
-
byteArrayToString
public static String byteArrayToString(byte[] bytes)
Converts byte array to string.- Parameters:
bytes- byte array to be converted.- Returns:
- result string.
-
-