Package com.sun.identity.saml2.common
Class SAML2SDKUtils
java.lang.Object
com.sun.identity.saml2.common.SAML2SDKUtils
- Direct Known Subclasses:
SAML2Utils
,XACMLSDKUtils
The
SAML2SDKUtils
contains utility methods for SAML 2.0
implementation.-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static ResourceBundle
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static SecureRandom
static final String
static final String
static final String
protected static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Boolean
booleanValueOf
(String value) Returns the boolean value as aBoolean
object.static String
byteArrayToHexString
(byte[] byteArray) Deprecated.static String
byteArrayToString
(byte[] bytes) Converts byte array to String.static boolean
checkStatement
(Element element, String statementname) Verifies if an element is a type of a specific statement.static String
createSOAPMessageString
(String xmlString) CreatesSOAPMessage
with the input XML String as message body.static void
decodeXMLToDebugLog
(String callerName, Element xmlElement) If enabled, decodes the provided XML element and prints it out to the decryption debug log.static String
fillInBasicAuthInfo
(javax.xml.bind.JAXBElement<com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType> config, String locationURL) Fills in basic auth user and password inside the location URL if configuration is done properlystatic String
fillInBasicAuthInfo
(javax.xml.bind.JAXBElement<com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType> config, String locationURL, String realm) Fills in basic auth user and password inside the location URL if configuration is done properly.static String
Generates ID.static String
Generates message handle used in anArtifact
.static Object
getObjectInstance
(String iName) Returns default object instance for a given interface.static Object
getObjectInstance
(String iName, byte[] typecode, int endpointIndex, String sourceID, String messageHandle) Returns new object instance with given parameters.static Object
getObjectInstance
(String iName, String value) Returns new object instance taking String parameter in constructor.static Object
getObjectInstance
(String iName, Element value) Returns new object instance taking Element parameter in constructor.static byte[]
hexStringToByteArray
(String hexString) Deprecated.This method is deprecated, useHex.decode(String)
instead.static byte[]
intToTwoBytes
(int i) Converts integer to byte array.static boolean
Tells whether SAML SP decryption debug mode is enabled.static String
removeDeployUri
(String uri) Removes deployment URI from the pass down string.static Boolean
StringToBoolean
(String str) Converts a value of XML boolean type to Boolean object.static byte[]
stringToByteArray
(String input) Converts String to Byte Array.static int
twoBytesToInt
(byte[] bytes) Converts two bytes to an integer.
-
Field Details
-
BUNDLE_NAME
- See Also:
-
bundle
-
SAML2ID_PREFIX
- See Also:
-
random
-
ACTION
- See Also:
-
ADVICE
- See Also:
-
ASSERTION
- See Also:
-
ASSERTION_ID_REF
- See Also:
-
ASSERTION_ID_REQUEST
- See Also:
-
ATTRIBUTE
- See Also:
-
ATTRIBUTE_STATEMENT
- See Also:
-
AUDIENCE_RESTRICTION
- See Also:
-
AUTHN_CONTEXT
- See Also:
-
AUTHN_STATEMENT
- See Also:
-
AUTHZ_DECISION_STATEMENT
- See Also:
-
BASEID
- See Also:
-
CONDITION
- See Also:
-
CONDITIONS
- See Also:
-
ENCRYPTED_ASSERTION
- See Also:
-
ENCRYPTED_ATTRIBUTE
- See Also:
-
ENCRYPTED_ELEMENT
- See Also:
-
ENCRYPTEDID
- See Also:
-
EVIDENCE
- See Also:
-
ISSUER
- See Also:
-
KEYINFO_CONFIRMATION_DATA
- See Also:
-
NAMEID
- See Also:
-
ONE_TIME_USE
- See Also:
-
PROXY_RESTRICTION
- See Also:
-
STATEMENT
- See Also:
-
SUBJECT_CONFIRMATION_DATA
- See Also:
-
SUBJECT_CONFIRMATION
- See Also:
-
SUBJECT
- See Also:
-
SUBJECT_LOCALITY
- See Also:
-
ARTIFACT
- See Also:
-
ARTIFACT_RESOLVE
- See Also:
-
ARTIFACT_RESPONSE
- See Also:
-
ATTRIBUTE_QUERY
- See Also:
-
AUTHN_QUERY
- See Also:
-
AUTHN_REQUEST
- See Also:
-
ECP_RELAY_STATE
- See Also:
-
ECP_REQUEST
- See Also:
-
ECP_RESPONSE
- See Also:
-
EXTENSIONS
- See Also:
-
GET_COMPLETE
- See Also:
-
IDPENTRY
- See Also:
-
IDPLIST
- See Also:
-
LOGOUT_REQUEST
- See Also:
-
LOGOUT_RESPONSE
- See Also:
-
MANAGE_NAMEID_REQUEST
- See Also:
-
MANAGE_NAMEID_RESPONSE
- See Also:
-
NAMEID_POLICY
- See Also:
-
NEW_ENCRYPTEDID
- See Also:
-
NEWID
- See Also:
-
REQUESTED_AUTHN_CONTEXT
- See Also:
-
REQUESTERID
- See Also:
-
RESPONSE
- See Also:
-
SCOPING
- See Also:
-
SESSION_INDEX
- See Also:
-
STATUS_CODE
- See Also:
-
STATUS_DETAIL
- See Also:
-
STATUS
- See Also:
-
STATUS_MESSAGE
- See Also:
-
STATUS_RESPONSE
- See Also:
-
NAMEIDMAPPING_REQ
- See Also:
-
NAMEIDMAPPING_RES
- See Also:
-
-
Constructor Details
-
SAML2SDKUtils
protected SAML2SDKUtils()Protected contstructor.
-
-
Method Details
-
getObjectInstance
Returns default object instance for a given interface.- Parameters:
iName
- name of the interface.- Returns:
- object instance corresponding to the interface implementation. return null if the object instance could not be obtained.
-
getObjectInstance
Returns new object instance taking String parameter in constructor.- Parameters:
iName
- name of the interface.value
- String value to be used as parameter in constructor.- Returns:
- object instance corresponding to the interface implementation. return null if the object instance could not be obtained.
-
getObjectInstance
Returns new object instance taking Element parameter in constructor.- Parameters:
iName
- name of the interface.value
- Element value to be used as parameter in constructor.- Returns:
- object instance corresponding to the interface implementation. return null if the object instance could not be obtained.
-
getObjectInstance
public static Object getObjectInstance(String iName, byte[] typecode, int endpointIndex, String sourceID, String messageHandle) Returns new object instance with given parameters.- Parameters:
iName
- name of the interface.typecode
- type code.endpointIndex
- end point index.sourceID
- source ID.messageHandle
- message handler.- Returns:
- object instance corresponding to the interface implementation. return null if the object instance could not be obtained.
-
checkStatement
Verifies if an element is a type of a specific statement. Currently, this method is used by class AuthnStatementImpl, AuthzDecisionStatement and AttributeStatementImpl.- Parameters:
element
- a DOM Element which needs to be verified.statementname
- A specific name of a statement, for example, AuthnStatement, AuthzStatement or AttributeStatement- Returns:
true
if the element is of the specific type;false
otherwise.
-
byteArrayToString
Converts byte array to String.- Parameters:
bytes
- Byte Array to be converted.- Returns:
- result of the conversion.
-
intToTwoBytes
public static byte[] intToTwoBytes(int i) throws com.sun.identity.saml2.common.SAML2Exception Converts integer to byte array.- Parameters:
i
- an integer value between 0 and 65535.- Returns:
- a byte array whose length is 2.
- Throws:
com.sun.identity.saml2.common.SAML2Exception
- if the input is not between 0 and 65535.
-
twoBytesToInt
public static int twoBytesToInt(byte[] bytes) throws com.sun.identity.saml2.common.SAML2Exception Converts two bytes to an integer.- Parameters:
bytes
- byte array whose length is 2.- Returns:
- an integer value between 0 and 65535.
- Throws:
com.sun.identity.saml2.common.SAML2Exception
- if the input is null or the length is not 2.
-
generateMessageHandle
Generates message handle used in anArtifact
.- Returns:
- String format of 20-byte sequence identifying a message.
-
stringToByteArray
Converts String to Byte Array.- Parameters:
input
- String to be converted.- Returns:
- result of the conversion.
-
byteArrayToHexString
Deprecated.This method is deprecated, useHex.encode(byte[])
} instead. Converts byte array toHex
String.- Parameters:
byteArray
- Byte Array to be converted.- Returns:
- result of the conversion.
-
hexStringToByteArray
Deprecated.This method is deprecated, useHex.decode(String)
instead. ConvertsHex
String to Byte Array.- Parameters:
hexString
-Hex
String to be converted.- Returns:
- result of the conversion.
-
generateID
Generates ID.- Returns:
- ID value.
-
createSOAPMessageString
public static String createSOAPMessageString(String xmlString) throws javax.xml.soap.SOAPException, com.sun.identity.saml2.common.SAML2Exception CreatesSOAPMessage
with the input XML String as message body.- Parameters:
xmlString
- XML string to be put intoSOAPMessage
body.- Returns:
- newly created
SOAPMessage
. - Throws:
javax.xml.soap.SOAPException
- if it cannot create theSOAPMessage
.com.sun.identity.saml2.common.SAML2Exception
-
fillInBasicAuthInfo
public static String fillInBasicAuthInfo(javax.xml.bind.JAXBElement<com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType> config, String locationURL) Fills in basic auth user and password inside the location URL if configuration is done properly- Parameters:
config
- Either an SPSSOConfigElement object , an IDPSSOConfigElement object or PEPConfigElement.locationURL
- The original location URL which is to be inserted with user:password@ before the hostname part and after //- Returns:
- The modified location URL with the basic auth user and password if configured properly
-
fillInBasicAuthInfo
public static String fillInBasicAuthInfo(javax.xml.bind.JAXBElement<com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType> config, String locationURL, String realm) Fills in basic auth user and password inside the location URL if configuration is done properly. It will retrieve the password from the realm's secret store if the secret mapping is set.- Parameters:
config
- Either an SPSSOConfigElement object , an IDPSSOConfigElement object or PEPConfigElement.locationURL
- The original location URL which is to be inserted with user:password@ before the hostname part and after //realm
- the realm in which the secret mapping is to be looked up.- Returns:
- The modified location URL with the basic auth user and password if configured properly
-
StringToBoolean
public static Boolean StringToBoolean(String str) throws com.sun.identity.saml2.common.SAML2Exception Converts a value of XML boolean type to Boolean object.- Parameters:
str
- a value of XML boolean type- Returns:
- a Boolean object.
- Throws:
com.sun.identity.saml2.common.SAML2Exception
- if there is a syntax error
-
removeDeployUri
Removes deployment URI from the pass down string. i.e. from "/opensso/ArtifactResolver/metaAlias/idp" to "/ArtifactResolver/metaAlias/idp".- Parameters:
uri
- the URI string which the deployment uri is to be removed return string without deployment uri
-
booleanValueOf
Returns the boolean value as aBoolean
object.- Parameters:
value
- boolean value true or false.
-
decodeXMLToDebugLog
If enabled, decodes the provided XML element and prints it out to the decryption debug log.- Parameters:
callerName
- String representing the name of the calling method.xmlElement
- String representing an XML document with decrypted data.
-
isSAMLDecryptionDebugEnabled
public static boolean isSAMLDecryptionDebugEnabled()Tells whether SAML SP decryption debug mode is enabled.- Returns:
true
if SAML decryption debug mode is enabled, orfalse
otherwise or if the property is not found.
-
Hex.encode(byte[])
} instead.