public class SPACSUtils extends Object
Modifier and Type | Method and Description |
---|---|
static List<Attribute> |
getAttrs(Assertion authnAssertion,
boolean needAttributeEncrypted,
Set<PrivateKey> decryptionKeys)
Gets the attributes for this assertion in a new List.
|
static String |
getIntermediateURL(String orgName,
String hostEntityId,
SAML2MetaManager sm)
Retrieves intermediate redirect url from SP sso config.
|
static boolean |
getNeedAttributeEncrypted(boolean needAssertionEncrypted,
SPSSOConfigElement spssoconfig) |
static String |
getPrincipalWithoutLogin(Subject assertionSubject,
Assertion authnAssertion,
String realm,
String spEntityId,
SAML2MetaManager metaManager,
String idpEntityId,
String storageKey)
Returns the username if there was one from the Assertion we were able to map into a local user account.
|
static String |
getRelayState(String relayStateID,
String orgName,
String hostEntityId,
SAML2MetaManager sm)
Obtains relay state.
|
static ResponseInfo |
getResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String orgName,
String hostEntityId,
SAML2MetaManager metaManager)
Retrieves
SAML Response from http request. |
static List<Attribute> |
getSAMLAttributes(Assertion assertion,
boolean needAttributeEncrypted,
Set<PrivateKey> privateKeys)
Gets the attributes from an assert's AttributeStates.
|
static String |
prepareForLocalLogin(String realm,
String hostEntityId,
SAML2MetaManager sm,
ResponseInfo respInfo,
String requestURI)
Saves response for later retrieval and retrieves local auth url from
SPSSOConfig . |
static Object |
processResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
PrintWriter out,
String metaAlias,
Object session,
ResponseInfo respInfo,
String realm,
String hostEntityId,
SAML2MetaManager metaManager,
SAML2EventLogger auditor)
Authenticates user with
Response . |
static Map |
processResponseForFedlet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
PrintWriter out)
Processes response from Identity Provider to Fedlet (SP).
|
static void |
saveInfoInMemory(SessionProvider sessionProvider,
Object session,
String sessionIndex,
String metaAlias,
NameIDInfo info,
boolean isIDPProxy,
boolean isTransient) |
static void |
setAttrMapInSession(SessionProvider sessionProvider,
Map attrMap,
Object session)
Sets the attribute map in the session
|
public static ResponseInfo getResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String orgName, String hostEntityId, SAML2MetaManager metaManager) throws SAML2Exception, IOException
SAML
Response
from http request.
It handles three cases:
1. using http method get using request parameter "resID". This is the case after local login is done. 2. using http method get using request parameter "SAMLart". This is the case for artifact profile. 3. using http method post. This is the case for post profile.
request
- http servlet requestresponse
- http servlet responseorgName
- realm or organization name the service provider resides inhostEntityId
- Entity ID of the hosted service providermetaManager
- SAML2MetaManager
instance.ResponseInfo
instance.SAML2Exception,IOException
- if it fails in the process.SAML2Exception
IOException
public static Object processResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, PrintWriter out, String metaAlias, Object session, ResponseInfo respInfo, String realm, String hostEntityId, SAML2MetaManager metaManager, SAML2EventLogger auditor) throws SAML2Exception
Response
.
Auth session upgrade will be called if input session is
not null.
Otherwise, saml2 auth module is called. The name of the auth module
is retrieved from SPSSOConfig
. If not found, "SAML2" will
be used.request
- HTTP Servlet requestresponse
- HTTP Servlet response.out
- the print writer for writing out presentationmetaAlias
- metaAlias for the service providersession
- input session object. It could be null.respInfo
- ResponseInfo
to be verified.realm
- realm or organization name of the service provider.hostEntityId
- hosted service provider Entity ID.metaManager
- SAML2MetaManager
instance for meta operation.auditor
- a SAML2EventLogger
auditor object to hook into
tracking information for the saml requestObject
which holds result of the session.SAML2Exception
- if the processing failed.public static boolean getNeedAttributeEncrypted(boolean needAssertionEncrypted, SPSSOConfigElement spssoconfig)
public static void saveInfoInMemory(SessionProvider sessionProvider, Object session, String sessionIndex, String metaAlias, NameIDInfo info, boolean isIDPProxy, boolean isTransient) throws SAML2Exception
SAML2Exception
public static void setAttrMapInSession(SessionProvider sessionProvider, Map attrMap, Object session) throws SessionException
sessionProvider
- Session providerattrMap
- the Attribute Mapsession
- the valid session objectSessionException
public static String getRelayState(String relayStateID, String orgName, String hostEntityId, SAML2MetaManager sm)
SPSSOConfig
.relayStateID
- relay state value received from http request.orgName
- realm or organization name the service provider resides inhostEntityId
- Entity ID of the hosted service providersm
- SAML2MetaManager
instance.null
if the input
relayStateID is null and no default relay state is configured.public static String getIntermediateURL(String orgName, String hostEntityId, SAML2MetaManager sm)
orgName
- realm or organization name the service provider resides inhostEntityId
- Entity ID of the hosted service providersm
- SAML2MetaManager
instance.null
if the url is
is not configured or an error occured during the retrieval
process.public static String prepareForLocalLogin(String realm, String hostEntityId, SAML2MetaManager sm, ResponseInfo respInfo, String requestURI)
SPSSOConfig
.
If the url does not exist, generate one from request URI.
If still cannot get it, (shouldn't happen), get it from SystemConfigurationUtil
.realm
- Realm or organization name the service provider resides in.hostEntityId
- Entity ID of the hosted service provider.sm
- SAML2MetaManager
instance to perform metadata operations.respInfo
- The to be cached ResponseInfo
.requestURI
- The HTTP request URI.public static List<Attribute> getSAMLAttributes(Assertion assertion, boolean needAttributeEncrypted, Set<PrivateKey> privateKeys)
assertion
- The assertion from which to pull the AttributeStates.needAttributeEncrypted
- Whether attributes must be encrypted (or else rejected).privateKeys
- Private keys used to decrypt those encrypted attributes.public static Map processResponseForFedlet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, PrintWriter out) throws SAML2Exception, IOException, SessionException, javax.servlet.ServletException
java.util.Map
whose keys
are attribute names and values are
java.util.Set
of string
values for the attributes. request
- HTTP Servlet requestresponse
- HTTP Servlet response.out
- the print writer for writing out presentationMap
which holds result of the processing.SAML2Exception
- if the processing failed due to server error.IOException
- if the processing failed due to IO error.SessionException
- if the processing failed due to session error.javax.servlet.ServletException
- if the processing failed due to request error.public static String getPrincipalWithoutLogin(Subject assertionSubject, Assertion authnAssertion, String realm, String spEntityId, SAML2MetaManager metaManager, String idpEntityId, String storageKey) throws SAML2Exception
SAML2Exception
public static List<Attribute> getAttrs(Assertion authnAssertion, boolean needAttributeEncrypted, Set<PrivateKey> decryptionKeys)
authnAssertion
- Assertion from which to reead the attributes.needAttributeEncrypted
- Whether the attributes must be encrypted.decryptionKeys
- The keys used to decrypt the attributes, if they're encrypted.Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.