public class SAML2Utils extends SAML2SDKUtils
SAML2Utils
contains utility methods for SAML 2.0
implementation.ACTION, ADVICE, ARTIFACT, ARTIFACT_RESOLVE, ARTIFACT_RESPONSE, ASSERTION, ASSERTION_ID_REF, ASSERTION_ID_REQUEST, ATTRIBUTE, ATTRIBUTE_QUERY, ATTRIBUTE_STATEMENT, AUDIENCE_RESTRICTION, AUTHN_CONTEXT, AUTHN_QUERY, AUTHN_REQUEST, AUTHN_STATEMENT, AUTHZ_DECISION_STATEMENT, BASEID, bundle, BUNDLE_NAME, CONDITION, CONDITIONS, debug, ECP_RELAY_STATE, ECP_REQUEST, ECP_RESPONSE, ENCRYPTED_ASSERTION, ENCRYPTED_ATTRIBUTE, ENCRYPTED_ELEMENT, ENCRYPTEDID, EVIDENCE, EXTENSIONS, GET_COMPLETE, IDPENTRY, IDPLIST, ISSUER, KEYINFO_CONFIRMATION_DATA, LOGOUT_REQUEST, LOGOUT_RESPONSE, MANAGE_NAMEID_REQUEST, MANAGE_NAMEID_RESPONSE, NAMEID, NAMEID_POLICY, NAMEIDMAPPING_REQ, NAMEIDMAPPING_RES, NEW_ENCRYPTEDID, NEWID, ONE_TIME_USE, PROXY_RESTRICTION, random, REQUESTED_AUTHN_CONTEXT, REQUESTERID, RESPONSE, SAML2ID_PREFIX, SCOPING, SESSION_INDEX, STATEMENT, STATUS, STATUS_CODE, STATUS_DETAIL, STATUS_MESSAGE, STATUS_RESPONSE, SUBJECT, SUBJECT_CONFIRMATION, SUBJECT_CONFIRMATION_DATA, SUBJECT_LOCALITY
Constructor and Description |
---|
SAML2Utils() |
Modifier and Type | Method and Description |
---|---|
static Object |
checkSession(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String metaAlias,
Map paramsMap)
Parses the request parameters and return session object
or redirect to login url.
|
static javax.servlet.http.Cookie |
createCookie(String cookieName,
String cookieValue,
String cookieDomain,
String path)
Creates a Cookie with the
cookieName ,
cookieValue for the cookie domains specified. |
static Issuer |
createIssuer(String entityID)
Returns url for redirection.
|
static String |
createNameIdentifier()
Returns a Name Identifier
|
static String |
decodeFromRedirect(String str)
Decodes the request message.
|
static String |
encodeForPOST(String str)
Returns the encoded request message.
|
static String |
encodeForRedirect(String str)
Returns the encoded request message.
|
static String |
extractServerId(String id)
Extracts serverID from the specified id.
|
static String |
generateIDWithServerID()
Generates ID with server id at the end.
|
static String |
generateMessageHandleWithServerID()
Generates message handle with server id used in an
Artifact . |
static String |
generateSourceID(String entityID)
Generates provider Source ID based on provider Entity ID.
|
static Status |
generateStatus(String code,
String message)
Generates SAMLv2 Status object
|
static Status |
generateStatus(String code,
String subCode,
String message)
Generates SAMLv2 Status object
|
static List<String> |
getAllAttributeValueFromSSOConfig(String realm,
String hostEntityId,
String entityRole,
String attrName)
Returns all values of specified attribute from SSOConfig.
|
static String |
getAttributeValueFromSPSSOConfig(SPSSOConfigElement config,
String attrName)
Retrieves attribute value for a given attribute name from
SPSSOConfig . |
static String |
getAttributeValueFromSSOConfig(String realm,
String hostEntityId,
String entityRole,
String attrName)
Returns single value of specified attribute from SSOConfig.
|
static String |
getAttributeValueFromXACMLConfig(String realm,
String entityRole,
String entityID,
String attrName)
Returns the value of attribute from entity configuration.
|
static String |
getBaseURL(javax.servlet.http.HttpServletRequest request)
Returns the Request URL.
|
static boolean |
getBooleanAttributeValueFromSSOConfig(String realm,
String hostEntityId,
String entityRole,
String attrName)
Returns boolean value of specified attribute from SSOConfig.
|
static Map |
getConfigAttributeMap(String realm,
String hostEntityID,
String role)
Returns the attribute map by parsing the configured map in hosted
provider configuration
|
static String |
getCookiesString(javax.servlet.http.HttpServletRequest request) |
static DataStoreProvider |
getDataStoreProvider()
Returns
DataStoreProvider object. |
static SAML2IDPFinder |
getECPIDPFinder(String realm,
String spEntityID)
Returns an
SAML2IDPFinder which is used to find a list
of IDP's for ECP Request. |
static List<String> |
getEncryptionCertAliases(String realm,
String hostEntityId,
String entityRole)
Returns encryption certificate alias names.
|
static Response |
getErrorResponse(RequestAbstract request,
String code,
String subCode,
String statusMsg,
String issuerEntityID)
Returns a
SAML Response object containing error status |
static FedletAdapter |
getFedletAdapterClass(String spEntityID,
String realm)
Returns a
Fedlet adapter class. |
static String |
getHostEntityRole(Map paramsMap)
Returns the role of host entity.
|
static IDPAccountMapper |
getIDPAccountMapper(String realm,
String idpEntityID)
Returns an
IDPAccountMapper |
static SAML2IdentityProviderAdapter |
getIDPAdapterClass(String realm,
String idpEntityID)
Returns a
SAML2IdentityProviderAdapter |
static String |
getLocalServerID()
Returns the server id of the local server
|
static Map<String,String> |
getMappedAttributes(List<String> mappedAttributes)
For the list of Strings containing mappings, return a map of name value pairs that match the mapping string
|
static Map |
getNameIDKeyMap(NameID nameID,
String hostEntityID,
String remoteEntityID,
String realm,
String hostEntityRole)
Returns the
NameIDInfoKey key value pair that can
be used for searching the user. |
static String |
getNameIDStringFromResponse(Response response)
Obtains the value of NameID from Response.
|
static String |
getParameter(Map<String,String> paramsMap,
String attributeName)
Returns the query parameter value for the param specified from the given Map.
|
static Map<String,List<String>> |
getParamsMap(javax.servlet.http.HttpServletRequest request)
Returns a Map of parameters retrieved from the Query parameters
in the HttpServletRequest.
|
static String |
getPreferredIDP(javax.servlet.http.HttpServletRequest request)
Returns the Identity Provider Entity Identifier.
|
static String |
getReaderURL(String spMetaAlias) |
static String |
getRealm(String realm)
Returns the realm.
|
static String |
getRedirectURL(String readerURL,
String requestID,
javax.servlet.http.HttpServletRequest request)
Returns the redirect URL.
|
static String |
getRelayState(javax.servlet.http.HttpServletRequest request)
Returns the URL to which redirection will happen after
Single-Signon / Federation.
|
static String |
getRemoteServiceURL(String id)
Gets remote service URL according to server id embedded in the provided ID.
|
static Map |
getSAEAttrs(String realm,
String entityId,
String role,
String appUrl)
Retrieves SAE related attributes from exended metadata.
|
static SAML2MetaManager |
getSAML2MetaManager()
Returns an instance of
SAML2MetaManger . |
static Attribute |
getSAMLAttribute(String name,
String[] values)
Returns the SAML
Attribute object. |
static String |
getSigningCertAlias(String realm,
String hostEntityId,
String entityRole)
Returns signing certificate alias name.
|
static String |
getSigningCertEncryptedKeyPass(String realm,
String hostEntityId,
String entityRole)
Returns signing certificate key password (encrypted).
|
static String |
getSingleValuedSessionProperty(Object session,
String propertyName)
Returns the first value of the session property.
|
static SPAccountMapper |
getSPAccountMapper(String realm,
String spEntityID)
Returns an
SPAccountMapper |
static SAML2ServiceProviderAdapter |
getSPAdapterClass(String spEntityID,
String realm)
Returns an
SP adapter class |
static SPAttributeMapper |
getSPAttributeMapper(String realm,
String spEntityID)
Gets the
SPAttributeMapper . |
static SPAuthnContextMapper |
getSPAuthnContextMapper(String realm,
String hostEntityID,
String authnCtxClassName)
Returns the Service Provider AuthnContext Mapper Object.
|
static List |
getStrAssertions(List assertions)
Gets List of 'String' assertions from the list of 'Assertion' assertions
|
static boolean |
getWantArtifactResolveSigned(String realm,
String hostEntityId,
String entityRole)
Returns true if wantArtifactResolveSigned has
String true. |
static boolean |
getWantArtifactResponseSigned(String realm,
String hostEntityId,
String entityRole)
Returns true if wantArtifactResponseSigned has
String true. |
static boolean |
getWantAssertionEncrypted(String realm,
String hostEntityId,
String entityRole)
Returns true if wantAssertionEncrypted has
String true. |
static boolean |
getWantAttributeEncrypted(String realm,
String hostEntityId,
String entityRole)
Returns true if wantAttributeEncrypted has
String true. |
static boolean |
getWantLogoutRequestSigned(String realm,
String hostEntityId,
String entityRole)
Returns true if wantLogoutRequestSigned has
String true. |
static boolean |
getWantLogoutResponseSigned(String realm,
String hostEntityId,
String entityRole)
Returns true if wantLogoutResponseSigned has
String true. |
static boolean |
getWantMNIRequestSigned(String realm,
String hostEntityId,
String entityRole)
Returns true if wantMNIRequestSigned has
String true. |
static boolean |
getWantMNIResponseSigned(String realm,
String hostEntityId,
String entityRole)
Returns true if wantMNIResponseSigned has
String true. |
static boolean |
getWantNameIDEncrypted(String realm,
String hostEntityId,
String entityRole)
Returns true if wantNameIDEncrypted has
String true. |
static boolean |
getWantXACMLAuthzDecisionQuerySigned(String realm,
String entityID,
String entityRole)
Returns true if wantXACMLAuthzDecisionQuerySigned has
true true. |
static boolean |
isAuthnContextMatching(List requestedACClassRefs,
String acClassRef,
String comparison,
Map acClassRefLevelMap)
Returns true if the specified AuthnContextClassRef matches a list of
requested AuthnContextClassRef.
|
static boolean |
isDualRole(String hostEntityId,
String realm)
Returns true if this entity is acting as both SP and IDP.
|
static boolean |
isFedInfoExists(String userName,
String hostEntityID,
String remoteEntityId,
NameID nameID)
Checks if the federation information for the user exists or not.
|
static boolean |
isIDPProfileBindingSupported(String realm,
String idpEntityID,
String profile,
String binding)
Checks if a profile binding is suppported by an IDP.
|
static boolean |
isIgnoreProfileSet(Object session)
Return true if the User for this session has a profile set to Ignore
|
static boolean |
isPersistentNameID(NameID nameId)
Checks if it is a persistent request or not.
|
static boolean |
isRelayStateURLValid(javax.servlet.http.HttpServletRequest request,
String relayState,
String role)
Convenience method to validate a SAML2 relay state (goto) URL, often called from a JSP.
|
static boolean |
isRelayStateURLValid(String metaAlias,
String relayState,
String role)
Convenience method to validate a SAML2 relay state (goto) URL, often called from a JSP.
|
static boolean |
isSourceSiteValid(Issuer issuer,
String orgName,
String hostEntityId)
Returns
true if Issuer is valid. |
static boolean |
isSPProfileBindingSupported(String realm,
String spEntityID,
String profile,
String binding)
Checks if a profile binding is suppported by a SP.
|
static void |
logAccess(Level lvl,
String msgid,
String[] data,
Object tok,
String ipaddr,
String userid,
String org,
String module,
Map props)
Writes a log record in SAML2 access log.
|
static void |
logError(Level lvl,
String msgid,
String[] data,
Object tok,
String ipaddr,
String userid,
String org,
String module,
Map props)
Writes error occurred in SAML2 component into a log
(fmSAML2.error)
|
static void |
postToAppLogout(javax.servlet.http.HttpServletRequest request,
String appLogoutURL,
Object session)
Processes logout for external application.
|
static void |
postToTarget(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String SAMLmessageName,
String SAMLmessageValue,
String relayStateName,
String relayStateValue,
String targetURL) |
static void |
putHeaders(MimeHeaders headers,
javax.servlet.http.HttpServletResponse response)
Sets mime headers in HTTP servlet response.
|
static void |
redirectAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String realm,
String hostEntityID,
String entityRole)
Returns url for redirection.
|
static String |
removeNewLineChars(String string)
Removes new line character from a String.
|
static HashMap |
sendRequestToOrigServer(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String sloServerUrl)
Sends the request to the original Federation server and receives the result
data.
|
static String |
signQueryString(String queryString,
String realm,
String hostEntity,
String hostEntityRole)
Sign Query string.
|
static boolean |
validateCertificate(X509Certificate cert)
Checks certificate validity with configured CRL
|
static void |
validateRecipient(SPSSODescriptorElement spDesc,
String assertionID,
SubjectConfirmationData subjectConfData)
Validates the Recipient value stored within the SubjectConfirmationData element based on the following rules:
The value MUST not be null.
|
static void |
validateRelayStateURL(String orgName,
String hostEntityId,
String relayState,
String role)
Validates the Relay State URL against a list of valid Relay State
URLs created on the hosted service provider.
|
static boolean |
verifyDestination(String destination,
String location)
Compares the destination and location
|
static String |
verifyNameIDFormat(String nameIDFormat,
SPSSODescriptorElement spsso,
IDPSSODescriptorElement idpsso)
Verifies specified name ID format and returns it.
|
static boolean |
verifyQueryString(String queryString,
String realm,
String hostEntityRole,
String remoteEntity)
Verify Signed Query string.
|
static boolean |
verifyRequestIssuer(String realm,
String hostEntity,
Issuer reqIssuer,
String requestId)
Verifies
Issuer in Request and returns
true if the Issuer is part of COT
SAML2 auth module only. |
static Map |
verifyResponse(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
Response response,
String orgName,
String hostEntityId,
String profileBinding)
Verifies single sign on
Response and returns information
to SAML2 auth module for further processing. |
static boolean |
verifyResponseIssuer(String realm,
String hostEntity,
Issuer resIssuer,
String requestId)
Verifies
Issuer in Response and returns
true if the Issuer is part of COT |
static boolean |
wantPOSTResponseSigned(String realm,
String hostEntityId,
String entityRole)
Returns value of attribute
wantPOSTResponseSigned
as a boolean value true to false. |
booleanValueOf, byteArrayToHexString, byteArrayToString, checkStatement, createSOAPMessageString, decodeXMLToDebugLog, fillInBasicAuthInfo, generateID, generateMessageHandle, getDiscoveryBootStrapCredentials, getDiscoveryBootStrapResourceOffering, getObjectInstance, getObjectInstance, getObjectInstance, getObjectInstance, hexStringToByteArray, intToTwoBytes, isSAMLDecryptionDebugEnabled, removeDeployUri, StringToBoolean, stringToByteArray, twoBytesToInt
public static Map verifyResponse(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, Response response, String orgName, String hostEntityId, String profileBinding) throws SAML2Exception
Response
and returns information
to SAML2 auth module for further processing. This method is used by
SAML2 auth module only.httpRequest
- HttpServletRequesthttpResponse
- HttpServletResponseresponse
- Single Sign On Response
.orgName
- name of the realm or organization the provider is in.hostEntityId
- Entity ID of the hosted provider.profileBinding
- Profile binding used.SAML2Constants.SUBJECT
,
SAML2Constants.POST_ASSERTION
,
SAML2Constants.ASSERTIONS
,
SAML2Constants.SESSION_INDEX
,
SAML2Constants.AUTH_LEVEL
,
SAML2Constants.MAX_SESSION_TIME
.SAML2Exception
- if the Response is not valid according to the
processing rules.public static void validateRecipient(SPSSODescriptorElement spDesc, String assertionID, SubjectConfirmationData subjectConfData) throws SAML2Exception
spDesc
- The standard SAML metadata of the hosted SP.assertionID
- The ID of the assertion to be used when creating audit log entries.subjectConfData
- The SubjectConfirmationData
element to validate.SAML2Exception
- If there was a validation error.public static String getAttributeValueFromSPSSOConfig(SPSSOConfigElement config, String attrName)
SPSSOConfig
.config
- SPSSOConfigElement
instance.attrName
- name of the attribute whose value ot be retrived.null
if the attribute
if not configured, or an error occured in the process.public static List getStrAssertions(List assertions)
assertions
- A list of Assertionspublic static boolean isPersistentNameID(NameID nameId)
nameId
- Name ID objectpublic static boolean isFedInfoExists(String userName, String hostEntityID, String remoteEntityId, NameID nameID)
userName
- user id for which account federation needs to be
returned.hostEntityID
- EntityID
of the hosted entity.remoteEntityId
- EntityID
of the remote entity.public static Map getNameIDKeyMap(NameID nameID, String hostEntityID, String remoteEntityID, String realm, String hostEntityRole) throws SAML2Exception
NameIDInfoKey
key value pair that can
be used for searching the user.nameID
- NameID
object.hostEntityID
- hosted EntityID
.remoteEntityID
- remote EntityID
.hostEntityRole
- the role of hosted entity.SAML2Exception
- if any failure.SAML2Exception
public static boolean isSourceSiteValid(Issuer issuer, String orgName, String hostEntityId)
true
if Issuer
is valid.issuer
- to be checked Issuer
instance.orgName
- the name of the realm or organization.hostEntityId
- Entity ID of the hosted provider.true
if the Issuer
is trusted;
false
otherwise.public static DataStoreProvider getDataStoreProvider() throws SAML2Exception
DataStoreProvider
object.DataStoreProvider
configured for the SAML2 plugin.SAML2Exception
- if any failure.public static String encodeForPOST(String str)
str
- String to be encoded.public static String encodeForRedirect(String str)
str
- String to be encoded.public static String decodeFromRedirect(String str)
str
- String to be decoded.public static String removeNewLineChars(String string)
string
- String to remove newline characters from.public static SAML2MetaManager getSAML2MetaManager()
SAML2MetaManger
.SAML2MetaManager
public static String getRealm(String realm)
realm
- Realm object.public static String getParameter(Map<String,String> paramsMap, String attributeName)
paramsMap
- a map of parametersattributeName
- name of the parameterpublic static Map<String,List<String>> getParamsMap(javax.servlet.http.HttpServletRequest request)
request
- the HttpServletRequest
.public static String generateSourceID(String entityID)
entityID
- Entity ID for example http://host.sun.com:81
public static String extractServerId(String id)
id
- an id.public static String getRemoteServiceURL(String id)
id
- The server's ID or a user's sessionIndex.public static String generateIDWithServerID()
public static String generateMessageHandleWithServerID()
Artifact
.public static String getLocalServerID()
public static void putHeaders(MimeHeaders headers, javax.servlet.http.HttpServletResponse response)
headers
- mime headers to be set.response
- HTTP servlet response.public static Status generateStatus(String code, String message)
code
- Status code value.message
- Status message.public static Status generateStatus(String code, String subCode, String message)
code
- Status code value.subCode
- second-level status codemessage
- Status message.public static Response getErrorResponse(RequestAbstract request, String code, String subCode, String statusMsg, String issuerEntityID) throws SAML2Exception
SAML Response
object containing error statusrequest
- the RequestAbstract
objectcode
- the error codesubCode
- teh second-level error codestatusMsg
- the error messageissuerEntityID
- the entity id of the issuerSAML Response
object containing error statusSAML2Exception
- if the operation is not successfulpublic static List<String> getEncryptionCertAliases(String realm, String hostEntityId, String entityRole)
realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.public static String getSigningCertAlias(String realm, String hostEntityId, String entityRole)
realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.public static String getSigningCertEncryptedKeyPass(String realm, String hostEntityId, String entityRole)
realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.public static boolean getWantAssertionEncrypted(String realm, String hostEntityId, String entityRole)
String
true.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean getWantAttributeEncrypted(String realm, String hostEntityId, String entityRole)
String
true.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean getWantNameIDEncrypted(String realm, String hostEntityId, String entityRole)
String
true.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean getWantArtifactResolveSigned(String realm, String hostEntityId, String entityRole)
String
true.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean getWantArtifactResponseSigned(String realm, String hostEntityId, String entityRole)
String
true.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean getWantLogoutRequestSigned(String realm, String hostEntityId, String entityRole)
String
true.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean getWantLogoutResponseSigned(String realm, String hostEntityId, String entityRole)
String
true.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean getWantMNIRequestSigned(String realm, String hostEntityId, String entityRole)
String
true.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean getWantMNIResponseSigned(String realm, String hostEntityId, String entityRole)
String
true.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean getBooleanAttributeValueFromSSOConfig(String realm, String hostEntityId, String entityRole, String attrName)
realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.attrName
- attribute name for the value.public static String getAttributeValueFromSSOConfig(String realm, String hostEntityId, String entityRole, String attrName)
realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.attrName
- attribute name for the value.public static List<String> getAllAttributeValueFromSSOConfig(String realm, String hostEntityId, String entityRole, String attrName)
realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.attrName
- attribute name for the value.public static String getHostEntityRole(Map paramsMap) throws SAML2Exception
paramsMap
- Map
includes parameters.SAML2Exception
- if error in retrieving the parameters.public static boolean isDualRole(String hostEntityId, String realm)
hostEntityId
- entity ID of the hosted entity.realm
- the realm the entity resides.public static void redirectAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String realm, String hostEntityID, String entityRole) throws IOException
request
- HttpServletRequest
for redirecting.response
- HttpServletResponse
for redirecting.realm
- realm of hosted entity.hostEntityID
- name of hosted entity.entityRole
- role of hosted entity.IOException
- if error in redirecting request.public static Issuer createIssuer(String entityID) throws SAML2Exception
entityID
- entityID for Issuer.SAML2Exception
- if error in creating Issuer element.public static String signQueryString(String queryString, String realm, String hostEntity, String hostEntityRole) throws SAML2Exception
queryString
- URL query string that will be signed.realm
- realm of host entity.hostEntity
- entityID of host entity.hostEntityRole
- entity role of host entity.SAML2Exception
- if error in signing the query string.public static boolean verifyQueryString(String queryString, String realm, String hostEntityRole, String remoteEntity) throws SAML2Exception
queryString
- URL query string that will be verified.realm
- realm of host entity.hostEntityRole
- entity role of host entity.remoteEntity
- entityID of peer entity.SAML2Exception
- if error in verifying the signature.public static Object checkSession(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String metaAlias, Map paramsMap) throws SAML2Exception
request
- the HttpServletRequest.response
- the HttpServletResponse.metaAlias
- entityID of hosted entity.paramsMap
- Map of all other parameters.HttpServletRequest
.SAML2Exception
- if error initiating request to remote entity.public static String createNameIdentifier()
public static SPAuthnContextMapper getSPAuthnContextMapper(String realm, String hostEntityID, String authnCtxClassName)
authnCtxClassName
- Service Provider AuthnContext Mapper Class Name.public static boolean verifyRequestIssuer(String realm, String hostEntity, Issuer reqIssuer, String requestId) throws SAML2Exception
Issuer
in Request
and returns
true if the Issuer is part of COT
SAML2 auth module only.realm
- realm of hosted entity.hostEntity
- name of hosted entity.reqIssuer
- Issuer
of Request.requestId
- request IDSAML2Exception
public static boolean verifyResponseIssuer(String realm, String hostEntity, Issuer resIssuer, String requestId) throws SAML2Exception
Issuer
in Response
and returns
true if the Issuer is part of COTrealm
- realm of hosted entity.hostEntity
- name of hosted entity.resIssuer
- Issuer
of Response.requestId
- request ID for the response.SAML2Exception
public static String getBaseURL(javax.servlet.http.HttpServletRequest request)
request
- the HttpServletRequest
.public static String getPreferredIDP(javax.servlet.http.HttpServletRequest request)
request
- the HttpServletRequest
.public static String getRedirectURL(String readerURL, String requestID, javax.servlet.http.HttpServletRequest request)
readerURL
- the readerURL to redirect to.requestID
- the unique identifier to identify the request.request
- the HttpServletRequest.public static IDPAccountMapper getIDPAccountMapper(String realm, String idpEntityID) throws SAML2Exception
IDPAccountMapper
realm
- the realm nameidpEntityID
- the entity id of the identity providerIDPAccountMapper
SAML2Exception
- if the operation is not successfulpublic static SAML2IdentityProviderAdapter getIDPAdapterClass(String realm, String idpEntityID) throws SAML2Exception
SAML2IdentityProviderAdapter
realm
- the realm nameidpEntityID
- the entity id of the identity providerSAML2IdentityProviderAdapter
SAML2Exception
- if the operation is not successfulpublic static SAML2ServiceProviderAdapter getSPAdapterClass(String spEntityID, String realm) throws SAML2Exception
SP
adapter classspEntityID
- the entity id of the service providerrealm
- the realm nameSP
adapter classSAML2Exception
- if the operation is not successfulpublic static FedletAdapter getFedletAdapterClass(String spEntityID, String realm) throws SAML2Exception
Fedlet
adapter class.spEntityID
- the entity id of the service providerrealm
- the realm nameFedlet
adapter classSAML2Exception
- if the operation is not successfulpublic static SPAccountMapper getSPAccountMapper(String realm, String spEntityID) throws SAML2Exception
SPAccountMapper
realm
- the realm namespEntityID
- the entity id of the service providerSPAccountMapper
SAML2Exception
- if the operation is not successfulpublic static SAML2IDPFinder getECPIDPFinder(String realm, String spEntityID) throws SAML2Exception
SAML2IDPFinder
which is used to find a list
of IDP's for ECP Request.realm
- the realm namespEntityID
- the entity id of the service providerSAML2IDPFinder
SAML2Exception
- if the operation is not successfulpublic static String getRelayState(javax.servlet.http.HttpServletRequest request)
request
- the HttpServletRequest
object.public static boolean verifyDestination(String destination, String location)
destination
- Destinationlocation
- the URL from the metatrue
if the input are the same,
otherwise, return false
public static Map getSAEAttrs(String realm, String entityId, String role, String appUrl)
realm
- realm the FM provider is inentityId
- the entity ID of the FM providerrole
- Role of the FM providerappUrl
- application urlpublic static String getNameIDStringFromResponse(Response response)
response
- Response
objectpublic static void logAccess(Level lvl, String msgid, String[] data, Object tok, String ipaddr, String userid, String org, String module, Map props)
lvl
- indicating log levelmsgid
- Message iddata
- string array of dynamic data only known during run timetok
- Session of authenticated useripaddr
- IP Address.userid
- User Id.org
- Organization.module
- Module Name.props
- log record columns - used if tok is not available
to specify log record columns such as ip address, realm, etcpublic static void logError(Level lvl, String msgid, String[] data, Object tok, String ipaddr, String userid, String org, String module, Map props)
lvl
- indicating log levelmsgid
- Message iddata
- string array of dynamic data only known during run timetok
- Session of authenticated useripaddr
- IP Addressuserid
- User Idorg
- Organizationmodule
- Module Nameprops
- log record columns - used if tok is not available
to specify log record columns such as ip address, realm, etcpublic static String getAttributeValueFromXACMLConfig(String realm, String entityRole, String entityID, String attrName)
realm
- the realm of the entity.entityRole
- role of the entity (PEP or PDP).entityID
- identity of the entity.attrName
- name of attribute whose value is to be retreived.public static boolean getWantXACMLAuthzDecisionQuerySigned(String realm, String entityID, String entityRole)
true
true.realm
- realm of hosted entity.entityID
- name of hosted entity.entityRole
- role of hosted entity.String
true.public static boolean validateCertificate(X509Certificate cert)
cert
- x509 certificatetrue
if the certificate is not in CRL,
otherwise, return false
public static SPAttributeMapper getSPAttributeMapper(String realm, String spEntityID) throws SAML2Exception
SPAttributeMapper
.realm
- The realm the SP belongs to.spEntityID
- The entity ID of the SP.SPAttributeMapper
defined in the configuration.SAML2Exception
- if the processing failed.public static Map getConfigAttributeMap(String realm, String hostEntityID, String role) throws SAML2Exception
realm
- realm name.hostEntityID
- EntityID
of the hosted provider.SAML2Exception
- if any failured.SAML2Exception
public static Map<String,String> getMappedAttributes(List<String> mappedAttributes)
mappedAttributes
- a non-null list of strings in the form of name=value or name="static value"public static Attribute getSAMLAttribute(String name, String[] values) throws SAML2Exception
Attribute
object.name
- attribute name.values
- attribute values.SAML2Exception
- if any failure.public static void postToTarget(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String SAMLmessageName, String SAMLmessageValue, String relayStateName, String relayStateValue, String targetURL) throws SAML2Exception
SAML2Exception
public static String verifyNameIDFormat(String nameIDFormat, SPSSODescriptorElement spsso, IDPSSODescriptorElement idpsso) throws SAML2Exception
nameIDFormat
- name ID format.spsso
- SP meta data desciptor.idpsso
- IDP meta data desciptor.SAML2Exception
- if name ID format is not supported.public static boolean isAuthnContextMatching(List requestedACClassRefs, String acClassRef, String comparison, Map acClassRefLevelMap)
requestedACClassRefs
- a list of requested AuthnContextClassRef'sacClassRef
- AuthnContextClassRefcomparison
- the type of comparisonacClassRefLevelMap
- a AuthnContextClassRef to AuthLevel map. Key
is AuthnContextClassRef in String
and value is
AuthLevel in Integer
public static void postToAppLogout(javax.servlet.http.HttpServletRequest request, String appLogoutURL, Object session)
request
- HttpServletRequestappLogoutURL
- external application logout URLsession
- session object of the userpublic static String getCookiesString(javax.servlet.http.HttpServletRequest request)
public static boolean wantPOSTResponseSigned(String realm, String hostEntityId, String entityRole)
wantPOSTResponseSigned
as a boolean value true to false.realm
- realm of hosted entity.hostEntityId
- name of hosted entity.entityRole
- role of hosted entity.String
true,
otherwise false.public static boolean isSPProfileBindingSupported(String realm, String spEntityID, String profile, String binding)
realm
- Realm the SP is in.spEntityID
- SP entity id.profile
- name of the profile/servicebinding
- binding to be checked ontrue
if the binding is supported;
false
otherwise.public static boolean isIDPProfileBindingSupported(String realm, String idpEntityID, String profile, String binding)
realm
- Realm the IDP is in.idpEntityID
- IDP entity id.profile
- name of the profile/servicebinding
- binding to be checked ontrue
if the binding is supported;
false
otherwise.public static boolean isRelayStateURLValid(javax.servlet.http.HttpServletRequest request, String relayState, String role)
request
- Used to help establish the realm and hostEntityID.relayState
- The URL to validate.role
- The role of the caller.true
if the relayState is valid.public static boolean isRelayStateURLValid(String metaAlias, String relayState, String role)
metaAlias
- The metaAlias of the hosted entity.relayState
- The URL to validate.role
- The role of the caller.true
if the relayState is valid.public static void validateRelayStateURL(String orgName, String hostEntityId, String relayState, String role) throws SAML2Exception
orgName
- realm or organization name the provider resides in.hostEntityId
- Entity ID of the hosted provider.relayState
- Relay State URL.role
- IDP/SP Role.SAML2Exception
- if the processing failed.public static HashMap sendRequestToOrigServer(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String sloServerUrl)
request
- HttpServletRequest to be sentresponse
- HttpServletResponse to be receivedsloServerUrl
- URL of the original federation server to be
connectedpublic static javax.servlet.http.Cookie createCookie(String cookieName, String cookieValue, String cookieDomain, String path)
cookieName
,
cookieValue
for the cookie domains specified.
TODO: Copied from AuthClientUtils RefactorcookieName
- is the name of the cookiecookieValue
- is the value fo the cookiecookieDomain
- Domain for which the cookie is to be set.path
- The path into which the cookie shall be setpublic static boolean isIgnoreProfileSet(Object session) throws SessionException
session
- session object of the userSessionException
public static String getSingleValuedSessionProperty(Object session, String propertyName) throws SessionException
session
- The session object.propertyName
- The property's name that needs to be returned.SessionException
- If there was a problem while retrieving the session property.Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.