Package org.keycloak.protocol.saml
Class SamlProtocol
- java.lang.Object
- 
- org.keycloak.protocol.saml.SamlProtocol
 
- 
- All Implemented Interfaces:
- LoginProtocol,- Provider
 - Direct Known Subclasses:
- TokenEndpoint.TokenExchangeSamlProtocol
 
 public class SamlProtocol extends Object implements LoginProtocol - Version:
- $Revision: 1 $
- Author:
- Bill Burke
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classSamlProtocol.ProtocolMapperProcessor<T>- 
Nested classes/interfaces inherited from interface org.keycloak.protocol.LoginProtocolLoginProtocol.Error
 
- 
 - 
Field Summary
 - 
Constructor SummaryConstructors Constructor Description SamlProtocol()
 - 
Method Summary- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.protocol.LoginProtocolsendPushRevocationPolicyRequest
 
- 
 
- 
- 
- 
Field Detail- 
ATTRIBUTE_TRUE_VALUEpublic static final String ATTRIBUTE_TRUE_VALUE - See Also:
- Constant Field Values
 
 - 
ATTRIBUTE_FALSE_VALUEpublic static final String ATTRIBUTE_FALSE_VALUE - See Also:
- Constant Field Values
 
 - 
SAML_ASSERTION_CONSUMER_URL_POST_ATTRIBUTEpublic static final String SAML_ASSERTION_CONSUMER_URL_POST_ATTRIBUTE - See Also:
- Constant Field Values
 
 - 
SAML_ASSERTION_CONSUMER_URL_REDIRECT_ATTRIBUTEpublic static final String SAML_ASSERTION_CONSUMER_URL_REDIRECT_ATTRIBUTE - See Also:
- Constant Field Values
 
 - 
SAML_ASSERTION_CONSUMER_URL_ARTIFACT_ATTRIBUTEpublic static final String SAML_ASSERTION_CONSUMER_URL_ARTIFACT_ATTRIBUTE - See Also:
- Constant Field Values
 
 - 
SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTEpublic static final String SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTE - See Also:
- Constant Field Values
 
 - 
SAML_SINGLE_LOGOUT_SERVICE_URL_ARTIFACT_ATTRIBUTEpublic static final String SAML_SINGLE_LOGOUT_SERVICE_URL_ARTIFACT_ATTRIBUTE - See Also:
- Constant Field Values
 
 - 
SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT_ATTRIBUTEpublic static final String SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT_ATTRIBUTE - See Also:
- Constant Field Values
 
 - 
SAML_SINGLE_LOGOUT_SERVICE_URL_SOAP_ATTRIBUTEpublic static final String SAML_SINGLE_LOGOUT_SERVICE_URL_SOAP_ATTRIBUTE - See Also:
- Constant Field Values
 
 - 
SAML_ARTIFACT_RESOLUTION_SERVICE_URL_ATTRIBUTEpublic static final String SAML_ARTIFACT_RESOLUTION_SERVICE_URL_ATTRIBUTE - See Also:
- Constant Field Values
 
 - 
LOGIN_PROTOCOLpublic static final String LOGIN_PROTOCOL - See Also:
- Constant Field Values
 
 - 
SAML_BINDINGpublic static final String SAML_BINDING - See Also:
- Constant Field Values
 
 - 
SAML_IDP_INITIATED_LOGINpublic static final String SAML_IDP_INITIATED_LOGIN - See Also:
- Constant Field Values
 
 - 
SAML_POST_BINDINGpublic static final String SAML_POST_BINDING - See Also:
- Constant Field Values
 
 - 
SAML_SOAP_BINDINGpublic static final String SAML_SOAP_BINDING - See Also:
- Constant Field Values
 
 - 
SAML_REDIRECT_BINDINGpublic static final String SAML_REDIRECT_BINDING - See Also:
- Constant Field Values
 
 - 
SAML_REQUEST_IDpublic static final String SAML_REQUEST_ID - See Also:
- Constant Field Values
 
 - 
SAML_REQUEST_ID_BROKERpublic static final String SAML_REQUEST_ID_BROKER - See Also:
- Constant Field Values
 
 - 
SAML_LOGOUT_BINDINGpublic static final String SAML_LOGOUT_BINDING - See Also:
- Constant Field Values
 
 - 
SAML_LOGOUT_ADD_EXTENSIONS_ELEMENT_WITH_KEY_INFOpublic static final String SAML_LOGOUT_ADD_EXTENSIONS_ELEMENT_WITH_KEY_INFO - See Also:
- Constant Field Values
 
 - 
SAML_SERVER_SIGNATURE_KEYINFO_KEY_NAME_TRANSFORMERpublic static final String SAML_SERVER_SIGNATURE_KEYINFO_KEY_NAME_TRANSFORMER - See Also:
- Constant Field Values
 
 - 
SAML_LOGOUT_REQUEST_IDpublic static final String SAML_LOGOUT_REQUEST_ID - See Also:
- Constant Field Values
 
 - 
SAML_LOGOUT_RELAY_STATEpublic static final String SAML_LOGOUT_RELAY_STATE - See Also:
- Constant Field Values
 
 - 
SAML_LOGOUT_CANONICALIZATIONpublic static final String SAML_LOGOUT_CANONICALIZATION - See Also:
- Constant Field Values
 
 - 
SAML_LOGOUT_BINDING_URIpublic static final String SAML_LOGOUT_BINDING_URI - See Also:
- Constant Field Values
 
 - 
SAML_LOGOUT_SIGNATURE_ALGORITHMpublic static final String SAML_LOGOUT_SIGNATURE_ALGORITHM - See Also:
- Constant Field Values
 
 - 
SAML_NAME_IDpublic static final String SAML_NAME_ID - See Also:
- Constant Field Values
 
 - 
SAML_NAME_ID_FORMATpublic static final String SAML_NAME_ID_FORMAT - See Also:
- Constant Field Values
 
 - 
SAML_DEFAULT_NAMEID_FORMATpublic static final String SAML_DEFAULT_NAMEID_FORMAT 
 - 
SAML_PERSISTENT_NAME_ID_FORpublic static final String SAML_PERSISTENT_NAME_ID_FOR - See Also:
- Constant Field Values
 
 - 
SAML_IDP_INITIATED_SSO_RELAY_STATEpublic static final String SAML_IDP_INITIATED_SSO_RELAY_STATE - See Also:
- Constant Field Values
 
 - 
SAML_IDP_INITIATED_SSO_URL_NAMEpublic static final String SAML_IDP_INITIATED_SSO_URL_NAME - See Also:
- Constant Field Values
 
 - 
SAML_LOGIN_REQUEST_FORCEAUTHNpublic static final String SAML_LOGIN_REQUEST_FORCEAUTHN - See Also:
- Constant Field Values
 
 - 
SAML_FORCEAUTHN_REQUIREMENTpublic static final String SAML_FORCEAUTHN_REQUIREMENT - See Also:
- Constant Field Values
 
 - 
SAML_LOGOUT_INITIATOR_CLIENT_IDpublic static final String SAML_LOGOUT_INITIATOR_CLIENT_ID - See Also:
- Constant Field Values
 
 - 
USER_SESSION_IDpublic static final String USER_SESSION_ID - See Also:
- Constant Field Values
 
 - 
CLIENT_SESSION_IDpublic static final String CLIENT_SESSION_ID - See Also:
- Constant Field Values
 
 - 
loggerprotected static final org.jboss.logging.Logger logger 
 - 
sessionprotected KeycloakSession session 
 - 
realmprotected RealmModel realm 
 - 
uriInfoprotected javax.ws.rs.core.UriInfo uriInfo 
 - 
headersprotected javax.ws.rs.core.HttpHeaders headers 
 - 
eventprotected EventBuilder event 
 - 
artifactResolverprotected ArtifactResolver artifactResolver 
 - 
singleUseStoreprotected SingleUseObjectProvider singleUseStore 
 
- 
 - 
Method Detail- 
setSessionpublic SamlProtocol setSession(KeycloakSession session) - Specified by:
- setSessionin interface- LoginProtocol
 
 - 
setRealmpublic SamlProtocol setRealm(RealmModel realm) - Specified by:
- setRealmin interface- LoginProtocol
 
 - 
setUriInfopublic SamlProtocol setUriInfo(javax.ws.rs.core.UriInfo uriInfo) - Specified by:
- setUriInfoin interface- LoginProtocol
 
 - 
setHttpHeaderspublic SamlProtocol setHttpHeaders(javax.ws.rs.core.HttpHeaders headers) - Specified by:
- setHttpHeadersin interface- LoginProtocol
 
 - 
setEventBuilderpublic SamlProtocol setEventBuilder(EventBuilder event) - Specified by:
- setEventBuilderin interface- LoginProtocol
 
 - 
sendErrorpublic javax.ws.rs.core.Response sendError(AuthenticationSessionModel authSession, LoginProtocol.Error error) - Specified by:
- sendErrorin interface- LoginProtocol
 
 - 
buildErrorResponseprotected javax.ws.rs.core.Response buildErrorResponse(boolean isPostBinding, String destination, JaxrsSAML2BindingBuilder binding, Document document) throws ConfigurationException, ProcessingException, IOException
 - 
getResponseIssuerprotected String getResponseIssuer(RealmModel realm) 
 - 
isPostBindingprotected boolean isPostBinding(AuthenticationSessionModel authSession) 
 - 
isPostBindingprotected boolean isPostBinding(AuthenticatedClientSessionModel clientSession) 
 - 
isLogoutPostBindingForInitiatorpublic static boolean isLogoutPostBindingForInitiator(UserSessionModel session) 
 - 
isLogoutPostBindingForClientprotected boolean isLogoutPostBindingForClient(AuthenticatedClientSessionModel clientSession) 
 - 
getNameIdFormatprotected String getNameIdFormat(SamlClient samlClient, AuthenticationSessionModel authSession) 
 - 
getNameIdprotected String getNameId(String nameIdFormat, CommonClientSessionModel clientSession, UserSessionModel userSession) 
 - 
getPersistentNameIdprotected String getPersistentNameId(CommonClientSessionModel clientSession, UserSessionModel userSession) Attempts to retrieve the persistent type NameId as follows:- saml.persistent.name.id.for.$clientId user attribute
- saml.persistent.name.id.for.* user attribute
- G-$randomUuid
 If a randomUuid is generated, an attribute for the given saml.persistent.name.id.for.$clientId will be generated, otherwise no state change will occur with respect to the user's attributes. - Returns:
- the user's persistent NameId
 
 - 
authenticatedpublic javax.ws.rs.core.Response authenticated(AuthenticationSessionModel authSession, UserSessionModel userSession, ClientSessionContext clientSessionCtx) - Specified by:
- authenticatedin interface- LoginProtocol
 
 - 
buildAuthenticatedResponseprotected javax.ws.rs.core.Response buildAuthenticatedResponse(AuthenticatedClientSessionModel clientSession, String redirectUri, Document samlDocument, JaxrsSAML2BindingBuilder bindingBuilder) throws ConfigurationException, ProcessingException, IOException 
 - 
populateAttributeStatementspublic AttributeStatementType populateAttributeStatements(List<SamlProtocol.ProtocolMapperProcessor<SAMLAttributeStatementMapper>> attributeStatementMappers, KeycloakSession session, UserSessionModel userSession, AuthenticatedClientSessionModel clientSession) 
 - 
transformLoginResponsepublic ResponseType transformLoginResponse(List<SamlProtocol.ProtocolMapperProcessor<SAMLLoginResponseMapper>> mappers, ResponseType response, KeycloakSession session, UserSessionModel userSession, ClientSessionContext clientSessionCtx) 
 - 
populateRolespublic void populateRoles(SamlProtocol.ProtocolMapperProcessor<SAMLRoleListMapper> roleListMapper, KeycloakSession session, UserSessionModel userSession, ClientSessionContext clientSessionCtx, AttributeStatementType existingAttributeStatement) 
 - 
getSAMLNameIdprotected String getSAMLNameId(List<SamlProtocol.ProtocolMapperProcessor<SAMLNameIdMapper>> samlNameIdMappers, String nameIdFormat, KeycloakSession session, UserSessionModel userSession, AuthenticatedClientSessionModel clientSession) 
 - 
getLogoutServiceUrlpublic static String getLogoutServiceUrl(KeycloakSession session, ClientModel client, String bindingType, boolean backChannelLogout) 
 - 
useArtifactForLogoutpublic static boolean useArtifactForLogout(ClientModel client) 
 - 
frontchannelLogoutpublic javax.ws.rs.core.Response frontchannelLogout(UserSessionModel userSession, AuthenticatedClientSessionModel clientSession) - Specified by:
- frontchannelLogoutin interface- LoginProtocol
 
 - 
finishBrowserLogoutpublic javax.ws.rs.core.Response finishBrowserLogout(UserSessionModel userSession, AuthenticationSessionModel logoutSession) Description copied from interface:LoginProtocolThis method is called when browser logout is going to be finished. It is not triggered during backchannel logout- Specified by:
- finishBrowserLogoutin interface- LoginProtocol
- Parameters:
- userSession- user session, which was logged out
- logoutSession- authentication session, which was used during logout to track the logout state
- Returns:
- response to be sent to the client
 
 - 
buildLogoutResponseprotected javax.ws.rs.core.Response buildLogoutResponse(UserSessionModel userSession, String logoutBindingUri, SAML2LogoutResponseBuilder builder, JaxrsSAML2BindingBuilder binding) throws ConfigurationException, ProcessingException, IOException 
 - 
backchannelLogoutpublic javax.ws.rs.core.Response backchannelLogout(UserSessionModel userSession, AuthenticatedClientSessionModel clientSession) - Specified by:
- backchannelLogoutin interface- LoginProtocol
 
 - 
createLogoutRequestprotected LogoutRequestType createLogoutRequest(String logoutUrl, AuthenticatedClientSessionModel clientSession, ClientModel client, SamlProtocolExtensionsAwareBuilder.NodeGenerator... extensions) throws ConfigurationException - Throws:
- ConfigurationException
 
 - 
requireReauthenticationpublic boolean requireReauthentication(UserSessionModel userSession, AuthenticationSessionModel authSession) - Specified by:
- requireReauthenticationin interface- LoginProtocol
- Returns:
- true if SSO cookie authentication can't be used. User will need to "actively" reauthenticate
 
 - 
buildArtifactAuthenticatedResponseprotected javax.ws.rs.core.Response buildArtifactAuthenticatedResponse(AuthenticatedClientSessionModel clientSession, String redirectUri, SAML2Object samlDocument, JaxrsSAML2BindingBuilder bindingBuilder) throws ProcessingException, ConfigurationException This method, instead of sending the actual response with the token sends the artifact message via post or redirect.- Parameters:
- clientSession- the current authenticated client session
- redirectUri- the redirect uri to the client
- samlDocument- a Document containing the saml Response
- bindingBuilder- the current JaxrsSAML2BindingBuilder configured with information for signing and encryption
- Returns:
- A response (POSTed form or redirect) with a newly generated artifact
- Throws:
- ConfigurationException
- ProcessingException
- IOException
 
 - 
buildLogoutArtifactResponseprotected javax.ws.rs.core.Response buildLogoutArtifactResponse(UserSessionModel userSession, String redirectUri, StatusResponseType statusResponseType, JaxrsSAML2BindingBuilder bindingBuilder) throws ProcessingException, ConfigurationException This method, instead of sending the actual response with the token, sends the artifact message via post or redirect. This method is only to be used for the final LogoutResponse.- Parameters:
- userSession- The current user session being logged out
- redirectUri- the redirect uri to the client
- statusResponseType- a Document containing the saml Response
- bindingBuilder- the current JaxrsSAML2BindingBuilder configured with information for signing and encryption
- Returns:
- A response (POSTed form or redirect) with a newly generated artifact
- Throws:
- ProcessingException
- IOException
- ConfigurationException
 
 - 
buildArtifactAndStoreResponseprotected String buildArtifactAndStoreResponse(SAML2Object statusResponseType, UserSessionModel userSession) throws ArtifactResolverProcessingException, ConfigurationException, ProcessingException 
 - 
buildArtifactAndStoreResponseprotected String buildArtifactAndStoreResponse(SAML2Object saml2Object, AuthenticatedClientSessionModel clientSessionModel) throws ArtifactResolverProcessingException, ProcessingException, ConfigurationException 
 
- 
 
-