keycloak-service
クラス | 公開メンバ関数 | 静的公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | 限定公開変数類 | 静的限定公開変数類 | 非公開メンバ関数 | 全メンバ一覧
org.keycloak.protocol.saml.SamlProtocol クラス
org.keycloak.protocol.saml.SamlProtocol の継承関係図
Inheritance graph
org.keycloak.protocol.saml.SamlProtocol 連携図
Collaboration graph

クラス

class  ProtocolMapperProcessor
 

公開メンバ関数

SamlProtocol setSession (KeycloakSession session)
 
SamlProtocol setRealm (RealmModel realm)
 
SamlProtocol setUriInfo (UriInfo uriInfo)
 
SamlProtocol setHttpHeaders (HttpHeaders headers)
 
SamlProtocol setEventBuilder (EventBuilder event)
 
Response sendError (AuthenticationSessionModel authSession, Error error)
 
Response authenticated (UserSessionModel userSession, ClientSessionContext clientSessionCtx)
 
AttributeStatementType populateAttributeStatements (List< ProtocolMapperProcessor< SAMLAttributeStatementMapper >> attributeStatementMappers, KeycloakSession session, UserSessionModel userSession, AuthenticatedClientSessionModel clientSession)
 
ResponseType transformLoginResponse (List< ProtocolMapperProcessor< SAMLLoginResponseMapper >> mappers, ResponseType response, KeycloakSession session, UserSessionModel userSession, AuthenticatedClientSessionModel clientSession)
 
void populateRoles (ProtocolMapperProcessor< SAMLRoleListMapper > roleListMapper, KeycloakSession session, UserSessionModel userSession, ClientSessionContext clientSessionCtx, final AttributeStatementType existingAttributeStatement)
 
Response frontchannelLogout (UserSessionModel userSession, AuthenticatedClientSessionModel clientSession)
 
Response finishLogout (UserSessionModel userSession)
 
void backchannelLogout (UserSessionModel userSession, AuthenticatedClientSessionModel clientSession)
 
boolean requireReauthentication (UserSessionModel userSession, AuthenticationSessionModel authSession)
 
void close ()
 

静的公開メンバ関数

static boolean isLogoutPostBindingForInitiator (UserSessionModel session)
 
static String getLogoutServiceUrl (UriInfo uriInfo, ClientModel client, String bindingType)
 

静的公開変数類

static final String ATTRIBUTE_TRUE_VALUE = "true"
 
static final String ATTRIBUTE_FALSE_VALUE = "false"
 
static final String SAML_ASSERTION_CONSUMER_URL_POST_ATTRIBUTE = "saml_assertion_consumer_url_post"
 
static final String SAML_ASSERTION_CONSUMER_URL_REDIRECT_ATTRIBUTE = "saml_assertion_consumer_url_redirect"
 
static final String SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTE = "saml_single_logout_service_url_post"
 
static final String SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT_ATTRIBUTE = "saml_single_logout_service_url_redirect"
 
static final String LOGIN_PROTOCOL = "saml"
 
static final String SAML_BINDING = "saml_binding"
 
static final String SAML_IDP_INITIATED_LOGIN = "saml_idp_initiated_login"
 
static final String SAML_POST_BINDING = "post"
 
static final String SAML_SOAP_BINDING = "soap"
 
static final String SAML_REDIRECT_BINDING = "get"
 
static final String SAML_REQUEST_ID = "SAML_REQUEST_ID"
 
static final String SAML_LOGOUT_BINDING = "saml.logout.binding"
 
static final String SAML_LOGOUT_ADD_EXTENSIONS_ELEMENT_WITH_KEY_INFO = "saml.logout.addExtensionsElementWithKeyInfo"
 
static final String SAML_SERVER_SIGNATURE_KEYINFO_KEY_NAME_TRANSFORMER = "SAML_SERVER_SIGNATURE_KEYINFO_KEY_NAME_TRANSFORMER"
 
static final String SAML_LOGOUT_REQUEST_ID = "SAML_LOGOUT_REQUEST_ID"
 
static final String SAML_LOGOUT_RELAY_STATE = "SAML_LOGOUT_RELAY_STATE"
 
static final String SAML_LOGOUT_CANONICALIZATION = "SAML_LOGOUT_CANONICALIZATION"
 
static final String SAML_LOGOUT_BINDING_URI = "SAML_LOGOUT_BINDING_URI"
 
static final String SAML_LOGOUT_SIGNATURE_ALGORITHM = "saml.logout.signature.algorithm"
 
static final String SAML_NAME_ID = "SAML_NAME_ID"
 
static final String SAML_NAME_ID_FORMAT = "SAML_NAME_ID_FORMAT"
 
static final String SAML_DEFAULT_NAMEID_FORMAT = JBossSAMLURIConstants.NAMEID_FORMAT_UNSPECIFIED.get()
 
static final String SAML_PERSISTENT_NAME_ID_FOR = "saml.persistent.name.id.for"
 
static final String SAML_IDP_INITIATED_SSO_RELAY_STATE = "saml_idp_initiated_sso_relay_state"
 
static final String SAML_IDP_INITIATED_SSO_URL_NAME = "saml_idp_initiated_sso_url_name"
 

限定公開メンバ関数

Response buildErrorResponse (boolean isPostBinding, String destination, JaxrsSAML2BindingBuilder binding, Document document) throws ConfigurationException, ProcessingException, IOException
 
String getResponseIssuer (RealmModel realm)
 
boolean isPostBinding (AuthenticationSessionModel authSession)
 
boolean isPostBinding (AuthenticatedClientSessionModel clientSession)
 
boolean isLogoutPostBindingForClient (AuthenticatedClientSessionModel clientSession)
 
String getNameIdFormat (SamlClient samlClient, AuthenticatedClientSessionModel clientSession)
 
String getNameId (String nameIdFormat, CommonClientSessionModel clientSession, UserSessionModel userSession)
 
String getPersistentNameId (final CommonClientSessionModel clientSession, final UserSessionModel userSession)
 
Response buildAuthenticatedResponse (AuthenticatedClientSessionModel clientSession, String redirectUri, Document samlDocument, JaxrsSAML2BindingBuilder bindingBuilder) throws ConfigurationException, ProcessingException, IOException
 
Response buildLogoutResponse (UserSessionModel userSession, String logoutBindingUri, SAML2LogoutResponseBuilder builder, JaxrsSAML2BindingBuilder binding) throws ConfigurationException, ProcessingException, IOException
 
SAML2LogoutRequestBuilder createLogoutRequest (String logoutUrl, AuthenticatedClientSessionModel clientSession, ClientModel client)
 

限定公開変数類

KeycloakSession session
 
RealmModel realm
 
UriInfo uriInfo
 
HttpHeaders headers
 
EventBuilder event
 

静的限定公開変数類

static final Logger logger = Logger.getLogger(SamlProtocol.class)
 

非公開メンバ関数

Response samlErrorMessage (AuthenticationSessionModel authSession, SamlClient samlClient, boolean isPostBinding, String destination, JBossSAMLURIConstants statusDetail, String relayState)
 
JBossSAMLURIConstants translateErrorToSAMLStatus (Error error)
 
String translateErrorToIdpInitiatedErrorMessage (Error error)
 
JaxrsSAML2BindingBuilder createBindingBuilder (SamlClient samlClient)
 

詳解

著者
Bill Burke
バージョン
Revision
1

関数詳解

◆ authenticated()

Response org.keycloak.protocol.saml.SamlProtocol.authenticated ( UserSessionModel  userSession,
ClientSessionContext  clientSessionCtx 
)
inline
370  {
371  AuthenticatedClientSessionModel clientSession = clientSessionCtx.getClientSession();
372  ClientModel client = clientSession.getClient();
373  SamlClient samlClient = new SamlClient(client);
374  String requestID = clientSession.getNote(SAML_REQUEST_ID);
375  String relayState = clientSession.getNote(GeneralConstants.RELAY_STATE);
376  String redirectUri = clientSession.getRedirectUri();
377  String responseIssuer = getResponseIssuer(realm);
378  String nameIdFormat = getNameIdFormat(samlClient, clientSession);
379  String nameId = getNameId(nameIdFormat, clientSession, userSession);
380 
381  if (nameId == null) {
382  return samlErrorMessage(
383  null, samlClient, isPostBinding(clientSession),
384  redirectUri, JBossSAMLURIConstants.STATUS_INVALID_NAMEIDPOLICY, relayState
385  );
386  }
387 
388  // save NAME_ID and format in clientSession as they may be persistent or transient or email and not username
389  // we'll need to send this back on a logout
390  clientSession.setNote(SAML_NAME_ID, nameId);
391  clientSession.setNote(SAML_NAME_ID_FORMAT, nameIdFormat);
392 
393  SAML2LoginResponseBuilder builder = new SAML2LoginResponseBuilder();
394  builder.requestID(requestID).destination(redirectUri).issuer(responseIssuer).assertionExpiration(realm.getAccessCodeLifespan()).subjectExpiration(realm.getAccessTokenLifespan())
395  .requestIssuer(clientSession.getClient().getClientId()).nameIdentifier(nameIdFormat, nameId).authMethod(JBossSAMLURIConstants.AC_UNSPECIFIED.get());
396 
397  String sessionIndex = SamlSessionUtils.getSessionIndex(clientSession);
398  builder.sessionIndex(sessionIndex);
399 
400  if (!samlClient.includeAuthnStatement()) {
401  builder.disableAuthnStatement(true);
402  }
403 
404  builder.includeOneTimeUseCondition(samlClient.includeOneTimeUseCondition());
405 
406  List<ProtocolMapperProcessor<SAMLAttributeStatementMapper>> attributeStatementMappers = new LinkedList<>();
407  List<ProtocolMapperProcessor<SAMLLoginResponseMapper>> loginResponseMappers = new LinkedList<>();
408  ProtocolMapperProcessor<SAMLRoleListMapper> roleListMapper = null;
409 
410  Set<ProtocolMapperModel> mappings = clientSessionCtx.getProtocolMappers();
411  for (ProtocolMapperModel mapping : mappings) {
412 
413  ProtocolMapper mapper = (ProtocolMapper) session.getKeycloakSessionFactory().getProviderFactory(ProtocolMapper.class, mapping.getProtocolMapper());
414  if (mapper == null)
415  continue;
416  if (mapper instanceof SAMLAttributeStatementMapper) {
417  attributeStatementMappers.add(new ProtocolMapperProcessor<SAMLAttributeStatementMapper>((SAMLAttributeStatementMapper) mapper, mapping));
418  }
419  if (mapper instanceof SAMLLoginResponseMapper) {
420  loginResponseMappers.add(new ProtocolMapperProcessor<SAMLLoginResponseMapper>((SAMLLoginResponseMapper) mapper, mapping));
421  }
422  if (mapper instanceof SAMLRoleListMapper) {
423  roleListMapper = new ProtocolMapperProcessor<SAMLRoleListMapper>((SAMLRoleListMapper) mapper, mapping);
424  }
425  }
426 
427  Document samlDocument = null;
428  KeyManager keyManager = session.keys();
429  KeyManager.ActiveRsaKey keys = keyManager.getActiveRsaKey(realm);
430  boolean postBinding = isPostBinding(clientSession);
431  String keyName = samlClient.getXmlSigKeyInfoKeyNameTransformer().getKeyName(keys.getKid(), keys.getCertificate());
432 
433  try {
434  if ((! postBinding) && samlClient.requiresRealmSignature() && samlClient.addExtensionsElementWithKeyInfo()) {
435  builder.addExtension(new KeycloakKeySamlExtensionGenerator(keyName));
436  }
437 
438  ResponseType samlModel = builder.buildModel();
439  final AttributeStatementType attributeStatement = populateAttributeStatements(attributeStatementMappers, session, userSession, clientSession);
440  populateRoles(roleListMapper, session, userSession, clientSessionCtx, attributeStatement);
441 
442  // SAML Spec 2.7.3 AttributeStatement must contain one or more Attribute or EncryptedAttribute
443  if (attributeStatement.getAttributes().size() > 0) {
444  AssertionType assertion = samlModel.getAssertions().get(0).getAssertion();
445  assertion.addStatement(attributeStatement);
446  }
447 
448  samlModel = transformLoginResponse(loginResponseMappers, samlModel, session, userSession, clientSession);
449  samlDocument = builder.buildDocument(samlModel);
450  } catch (Exception e) {
451  logger.error("failed", e);
452  return ErrorPage.error(session, null, Response.Status.BAD_REQUEST, Messages.FAILED_TO_PROCESS_RESPONSE);
453  }
454 
455  JaxrsSAML2BindingBuilder bindingBuilder = new JaxrsSAML2BindingBuilder();
456  bindingBuilder.relayState(relayState);
457 
458  if (samlClient.requiresRealmSignature()) {
459  String canonicalization = samlClient.getCanonicalizationMethod();
460  if (canonicalization != null) {
461  bindingBuilder.canonicalizationMethod(canonicalization);
462  }
463  bindingBuilder.signatureAlgorithm(samlClient.getSignatureAlgorithm()).signWith(keyName, keys.getPrivateKey(), keys.getPublicKey(), keys.getCertificate()).signDocument();
464  }
465  if (samlClient.requiresAssertionSignature()) {
466  String canonicalization = samlClient.getCanonicalizationMethod();
467  if (canonicalization != null) {
468  bindingBuilder.canonicalizationMethod(canonicalization);
469  }
470  bindingBuilder.signatureAlgorithm(samlClient.getSignatureAlgorithm()).signWith(keyName, keys.getPrivateKey(), keys.getPublicKey(), keys.getCertificate()).signAssertions();
471  }
472  if (samlClient.requiresEncryption()) {
473  PublicKey publicKey = null;
474  try {
475  publicKey = SamlProtocolUtils.getEncryptionKey(client);
476  } catch (Exception e) {
477  logger.error("failed", e);
478  return ErrorPage.error(session, null, Response.Status.BAD_REQUEST, Messages.FAILED_TO_PROCESS_RESPONSE);
479  }
480  bindingBuilder.encrypt(publicKey);
481  }
482  try {
483  return buildAuthenticatedResponse(clientSession, redirectUri, samlDocument, bindingBuilder);
484  } catch (Exception e) {
485  logger.error("failed", e);
486  return ErrorPage.error(session, null, Response.Status.BAD_REQUEST, Messages.FAILED_TO_PROCESS_RESPONSE);
487  }
488  }
String getResponseIssuer(RealmModel realm)
Definition: SamlProtocol.java:253
static final String SAML_REQUEST_ID
Definition: SamlProtocol.java:107
String getNameIdFormat(SamlClient samlClient, AuthenticatedClientSessionModel clientSession)
Definition: SamlProtocol.java:299
KeycloakSession session
Definition: SamlProtocol.java:123
AttributeStatementType populateAttributeStatements(List< ProtocolMapperProcessor< SAMLAttributeStatementMapper >> attributeStatementMappers, KeycloakSession session, UserSessionModel userSession, AuthenticatedClientSessionModel clientSession)
Definition: SamlProtocol.java:508
static final String SAML_NAME_ID_FORMAT
Definition: SamlProtocol.java:117
RealmModel realm
Definition: SamlProtocol.java:125
boolean isPostBinding(AuthenticationSessionModel authSession)
Definition: SamlProtocol.java:257
static final String SAML_NAME_ID
Definition: SamlProtocol.java:116
Response buildAuthenticatedResponse(AuthenticatedClientSessionModel clientSession, String redirectUri, Document samlDocument, JaxrsSAML2BindingBuilder bindingBuilder)
Definition: SamlProtocol.java:490
String getNameId(String nameIdFormat, CommonClientSessionModel clientSession, UserSessionModel userSession)
Definition: SamlProtocol.java:312
Response samlErrorMessage(AuthenticationSessionModel authSession, SamlClient samlClient, boolean isPostBinding, String destination, JBossSAMLURIConstants statusDetail, String relayState)
Definition: SamlProtocol.java:191
ResponseType transformLoginResponse(List< ProtocolMapperProcessor< SAMLLoginResponseMapper >> mappers, ResponseType response, KeycloakSession session, UserSessionModel userSession, AuthenticatedClientSessionModel clientSession)
Definition: SamlProtocol.java:518
static final Logger logger
Definition: SamlProtocol.java:93
void populateRoles(ProtocolMapperProcessor< SAMLRoleListMapper > roleListMapper, KeycloakSession session, UserSessionModel userSession, ClientSessionContext clientSessionCtx, final AttributeStatementType existingAttributeStatement)
Definition: SamlProtocol.java:525

◆ backchannelLogout()

void org.keycloak.protocol.saml.SamlProtocol.backchannelLogout ( UserSessionModel  userSession,
AuthenticatedClientSessionModel  clientSession 
)
inline
652  {
653  ClientModel client = clientSession.getClient();
654  SamlClient samlClient = new SamlClient(client);
655  String logoutUrl = getLogoutServiceUrl(uriInfo, client, SAML_POST_BINDING);
656  if (logoutUrl == null) {
657  logger.warnf("Can't do backchannel logout. No SingleLogoutService POST Binding registered for client: %s", client.getClientId());
658  return;
659  }
660  SAML2LogoutRequestBuilder logoutBuilder = createLogoutRequest(logoutUrl, clientSession, client);
661 
662  String logoutRequestString = null;
663  try {
664  JaxrsSAML2BindingBuilder binding = createBindingBuilder(samlClient);
665  // This is POST binding, hence KeyID is included in dsig:KeyInfo/dsig:KeyName, no need to add <samlp:Extensions> element
666  logoutRequestString = binding.postBinding(logoutBuilder.buildDocument()).encoded();
667  } catch (Exception e) {
668  logger.warn("failed to send saml logout", e);
669  return;
670  }
671 
672  HttpClient httpClient = session.getProvider(HttpClientProvider.class).getHttpClient();
673  for (int i = 0; i < 2; i++) { // follow redirects once
674  try {
675  List<NameValuePair> formparams = new ArrayList<NameValuePair>();
676  formparams.add(new BasicNameValuePair(GeneralConstants.SAML_REQUEST_KEY, logoutRequestString));
677  formparams.add(new BasicNameValuePair("BACK_CHANNEL_LOGOUT", "BACK_CHANNEL_LOGOUT")); // for Picketlink
678  // todo remove
679  // this
680  UrlEncodedFormEntity form = new UrlEncodedFormEntity(formparams, "UTF-8");
681  HttpPost post = new HttpPost(logoutUrl);
682  post.setEntity(form);
683  HttpResponse response = httpClient.execute(post);
684  try {
685  int status = response.getStatusLine().getStatusCode();
686  if (status == 302 && !logoutUrl.endsWith("/")) {
687  String redirect = response.getFirstHeader(HttpHeaders.LOCATION).getValue();
688  String withSlash = logoutUrl + "/";
689  if (withSlash.equals(redirect)) {
690  logoutUrl = withSlash;
691  continue;
692  }
693  }
694  } finally {
695  HttpEntity entity = response.getEntity();
696  if (entity != null) {
697  InputStream is = entity.getContent();
698  if (is != null)
699  is.close();
700  }
701 
702  }
703  } catch (IOException e) {
704  logger.warn("failed to send saml logout", e);
705  }
706  break;
707  }
708 
709  }
SAML2LogoutRequestBuilder createLogoutRequest(String logoutUrl, AuthenticatedClientSessionModel clientSession, ClientModel client)
Definition: SamlProtocol.java:711
static String getLogoutServiceUrl(UriInfo uriInfo, ClientModel client, String bindingType)
Definition: SamlProtocol.java:532
KeycloakSession session
Definition: SamlProtocol.java:123
JaxrsSAML2BindingBuilder createBindingBuilder(SamlClient samlClient)
Definition: SamlProtocol.java:728
UriInfo uriInfo
Definition: SamlProtocol.java:127
static final Logger logger
Definition: SamlProtocol.java:93
static final String SAML_POST_BINDING
Definition: SamlProtocol.java:104

◆ buildAuthenticatedResponse()

Response org.keycloak.protocol.saml.SamlProtocol.buildAuthenticatedResponse ( AuthenticatedClientSessionModel  clientSession,
String  redirectUri,
Document  samlDocument,
JaxrsSAML2BindingBuilder  bindingBuilder 
) throws ConfigurationException, ProcessingException, IOException
inlineprotected
490  {
491  if (isPostBinding(clientSession)) {
492  return bindingBuilder.postBinding(samlDocument).response(redirectUri);
493  } else {
494  return bindingBuilder.redirectBinding(samlDocument).response(redirectUri);
495  }
496  }
boolean isPostBinding(AuthenticationSessionModel authSession)
Definition: SamlProtocol.java:257

◆ buildErrorResponse()

Response org.keycloak.protocol.saml.SamlProtocol.buildErrorResponse ( boolean  isPostBinding,
String  destination,
JaxrsSAML2BindingBuilder  binding,
Document  document 
) throws ConfigurationException, ProcessingException, IOException
inlineprotected
218  {
219  if (isPostBinding) {
220  return binding.postBinding(document).response(destination);
221  } else {
222  return binding.redirectBinding(document).response(destination);
223  }
224  }
boolean isPostBinding(AuthenticationSessionModel authSession)
Definition: SamlProtocol.java:257

◆ buildLogoutResponse()

Response org.keycloak.protocol.saml.SamlProtocol.buildLogoutResponse ( UserSessionModel  userSession,
String  logoutBindingUri,
SAML2LogoutResponseBuilder  builder,
JaxrsSAML2BindingBuilder  binding 
) throws ConfigurationException, ProcessingException, IOException
inlineprotected
643  {
644  if (isLogoutPostBindingForInitiator(userSession)) {
645  return binding.postBinding(builder.buildDocument()).response(logoutBindingUri);
646  } else {
647  return binding.redirectBinding(builder.buildDocument()).response(logoutBindingUri);
648  }
649  }
static boolean isLogoutPostBindingForInitiator(UserSessionModel session)
Definition: SamlProtocol.java:269

◆ close()

void org.keycloak.protocol.saml.SamlProtocol.close ( )
inline
739  {
740 
741  }

◆ createBindingBuilder()

JaxrsSAML2BindingBuilder org.keycloak.protocol.saml.SamlProtocol.createBindingBuilder ( SamlClient  samlClient)
inlineprivate
728  {
729  JaxrsSAML2BindingBuilder binding = new JaxrsSAML2BindingBuilder();
730  if (samlClient.requiresRealmSignature()) {
731  KeyManager.ActiveRsaKey keys = session.keys().getActiveRsaKey(realm);
732  String keyName = samlClient.getXmlSigKeyInfoKeyNameTransformer().getKeyName(keys.getKid(), keys.getCertificate());
733  binding.signatureAlgorithm(samlClient.getSignatureAlgorithm()).signWith(keyName, keys.getPrivateKey(), keys.getPublicKey(), keys.getCertificate()).signDocument();
734  }
735  return binding;
736  }
KeycloakSession session
Definition: SamlProtocol.java:123
RealmModel realm
Definition: SamlProtocol.java:125

◆ createLogoutRequest()

SAML2LogoutRequestBuilder org.keycloak.protocol.saml.SamlProtocol.createLogoutRequest ( String  logoutUrl,
AuthenticatedClientSessionModel  clientSession,
ClientModel  client 
)
inlineprotected
711  {
712  // build userPrincipal with subject used at login
713  SAML2LogoutRequestBuilder logoutBuilder = new SAML2LogoutRequestBuilder().assertionExpiration(realm.getAccessCodeLifespan()).issuer(getResponseIssuer(realm))
714  .userPrincipal(clientSession.getNote(SAML_NAME_ID), clientSession.getNote(SAML_NAME_ID_FORMAT)).destination(logoutUrl);
715 
716  String sessionIndex = SamlSessionUtils.getSessionIndex(clientSession);
717  logoutBuilder.sessionIndex(sessionIndex);
718 
719  return logoutBuilder;
720  }
String getResponseIssuer(RealmModel realm)
Definition: SamlProtocol.java:253
static final String SAML_NAME_ID_FORMAT
Definition: SamlProtocol.java:117
RealmModel realm
Definition: SamlProtocol.java:125
static final String SAML_NAME_ID
Definition: SamlProtocol.java:116

◆ finishLogout()

Response org.keycloak.protocol.saml.SamlProtocol.finishLogout ( UserSessionModel  userSession)
inline
588  {
589  logger.debug("finishLogout");
590  String logoutBindingUri = userSession.getNote(SAML_LOGOUT_BINDING_URI);
591  if (logoutBindingUri == null) {
592  logger.error("Can't finish SAML logout as there is no logout binding set. Please configure the logout service url in the admin console for your client applications.");
593  return ErrorPage.error(session, null, Response.Status.BAD_REQUEST, Messages.FAILED_LOGOUT);
594 
595  }
596  String logoutRelayState = userSession.getNote(SAML_LOGOUT_RELAY_STATE);
597  SAML2LogoutResponseBuilder builder = new SAML2LogoutResponseBuilder();
598  builder.logoutRequestID(userSession.getNote(SAML_LOGOUT_REQUEST_ID));
599  builder.destination(logoutBindingUri);
600  builder.issuer(getResponseIssuer(realm));
601  JaxrsSAML2BindingBuilder binding = new JaxrsSAML2BindingBuilder();
602  binding.relayState(logoutRelayState);
603  String signingAlgorithm = userSession.getNote(SAML_LOGOUT_SIGNATURE_ALGORITHM);
604  boolean postBinding = isLogoutPostBindingForInitiator(userSession);
605  if (signingAlgorithm != null) {
606  SignatureAlgorithm algorithm = SignatureAlgorithm.valueOf(signingAlgorithm);
607  String canonicalization = userSession.getNote(SAML_LOGOUT_CANONICALIZATION);
608  if (canonicalization != null) {
609  binding.canonicalizationMethod(canonicalization);
610  }
611  KeyManager.ActiveRsaKey keys = session.keys().getActiveRsaKey(realm);
612  XmlKeyInfoKeyNameTransformer transformer = XmlKeyInfoKeyNameTransformer.from(
614  SamlClient.DEFAULT_XML_KEY_INFO_KEY_NAME_TRANSFORMER);
615  String keyName = transformer.getKeyName(keys.getKid(), keys.getCertificate());
616  binding.signatureAlgorithm(algorithm).signWith(keyName, keys.getPrivateKey(), keys.getPublicKey(), keys.getCertificate()).signDocument();
617  boolean addExtension = (! postBinding) && Objects.equals("true", userSession.getNote(SamlProtocol.SAML_LOGOUT_ADD_EXTENSIONS_ELEMENT_WITH_KEY_INFO));
618  if (addExtension) { // Only include extension if REDIRECT binding and signing whole SAML protocol message
619  builder.addExtension(new KeycloakKeySamlExtensionGenerator(keyName));
620  }
621  }
622  Response response;
623  try {
624  response = buildLogoutResponse(userSession, logoutBindingUri, builder, binding);
625  } catch (ConfigurationException | ProcessingException | IOException e) {
626  throw new RuntimeException(e);
627  }
628  if (logoutBindingUri != null) {
629  event.detail(Details.REDIRECT_URI, logoutBindingUri);
630  }
631  event.event(EventType.LOGOUT)
632  .detail(Details.AUTH_METHOD, userSession.getAuthMethod())
633  .client(session.getContext().getClient())
634  .user(userSession.getUser())
635  .session(userSession)
636  .detail(Details.USERNAME, userSession.getLoginUsername())
637  .detail(Details.RESPONSE_MODE, postBinding ? SamlProtocol.SAML_POST_BINDING : SamlProtocol.SAML_REDIRECT_BINDING)
638  .detail(SamlProtocol.SAML_LOGOUT_REQUEST_ID, userSession.getNote(SAML_LOGOUT_REQUEST_ID))
639  .success();
640  return response;
641  }
static boolean isLogoutPostBindingForInitiator(UserSessionModel session)
Definition: SamlProtocol.java:269
static final String SAML_LOGOUT_SIGNATURE_ALGORITHM
Definition: SamlProtocol.java:115
String getResponseIssuer(RealmModel realm)
Definition: SamlProtocol.java:253
KeycloakSession session
Definition: SamlProtocol.java:123
RealmModel realm
Definition: SamlProtocol.java:125
Response buildLogoutResponse(UserSessionModel userSession, String logoutBindingUri, SAML2LogoutResponseBuilder builder, JaxrsSAML2BindingBuilder binding)
Definition: SamlProtocol.java:643
static final String SAML_LOGOUT_CANONICALIZATION
Definition: SamlProtocol.java:113
static final String SAML_LOGOUT_RELAY_STATE
Definition: SamlProtocol.java:112
static final String SAML_SERVER_SIGNATURE_KEYINFO_KEY_NAME_TRANSFORMER
Definition: SamlProtocol.java:110
static final Logger logger
Definition: SamlProtocol.java:93
static final String SAML_LOGOUT_BINDING_URI
Definition: SamlProtocol.java:114
static final String SAML_LOGOUT_REQUEST_ID
Definition: SamlProtocol.java:111

◆ frontchannelLogout()

Response org.keycloak.protocol.saml.SamlProtocol.frontchannelLogout ( UserSessionModel  userSession,
AuthenticatedClientSessionModel  clientSession 
)
inline
548  {
549  ClientModel client = clientSession.getClient();
550  SamlClient samlClient = new SamlClient(client);
551  try {
552  boolean postBinding = isLogoutPostBindingForClient(clientSession);
553  String bindingUri = getLogoutServiceUrl(uriInfo, client, postBinding ? SAML_POST_BINDING : SAML_REDIRECT_BINDING);
554  if (bindingUri == null) {
555  logger.warnf("Failed to logout client %s, skipping this client. Please configure the logout service url in the admin console for your client applications.", client.getClientId());
556  return null;
557  }
558 
559  if (postBinding) {
560  SAML2LogoutRequestBuilder logoutBuilder = createLogoutRequest(bindingUri, clientSession, client);
561  // This is POST binding, hence KeyID is included in dsig:KeyInfo/dsig:KeyName, no need to add <samlp:Extensions> element
562  JaxrsSAML2BindingBuilder binding = createBindingBuilder(samlClient);
563  return binding.postBinding(logoutBuilder.buildDocument()).request(bindingUri);
564  } else {
565  logger.debug("frontchannel redirect binding");
566  SAML2LogoutRequestBuilder logoutBuilder = createLogoutRequest(bindingUri, clientSession, client);
567  if (samlClient.requiresRealmSignature() && samlClient.addExtensionsElementWithKeyInfo()) {
568  KeyManager.ActiveRsaKey keys = session.keys().getActiveRsaKey(realm);
569  String keyName = samlClient.getXmlSigKeyInfoKeyNameTransformer().getKeyName(keys.getKid(), keys.getCertificate());
570  logoutBuilder.addExtension(new KeycloakKeySamlExtensionGenerator(keyName));
571  }
572  JaxrsSAML2BindingBuilder binding = createBindingBuilder(samlClient);
573  return binding.redirectBinding(logoutBuilder.buildDocument()).request(bindingUri);
574  }
575  } catch (ConfigurationException e) {
576  throw new RuntimeException(e);
577  } catch (ProcessingException e) {
578  throw new RuntimeException(e);
579  } catch (IOException e) {
580  throw new RuntimeException(e);
581  } catch (ParsingException e) {
582  throw new RuntimeException(e);
583  }
584 
585  }
SAML2LogoutRequestBuilder createLogoutRequest(String logoutUrl, AuthenticatedClientSessionModel clientSession, ClientModel client)
Definition: SamlProtocol.java:711
static String getLogoutServiceUrl(UriInfo uriInfo, ClientModel client, String bindingType)
Definition: SamlProtocol.java:532
KeycloakSession session
Definition: SamlProtocol.java:123
RealmModel realm
Definition: SamlProtocol.java:125
boolean isLogoutPostBindingForClient(AuthenticatedClientSessionModel clientSession)
Definition: SamlProtocol.java:274
static final String SAML_REDIRECT_BINDING
Definition: SamlProtocol.java:106
JaxrsSAML2BindingBuilder createBindingBuilder(SamlClient samlClient)
Definition: SamlProtocol.java:728
UriInfo uriInfo
Definition: SamlProtocol.java:127
static final Logger logger
Definition: SamlProtocol.java:93
static final String SAML_POST_BINDING
Definition: SamlProtocol.java:104

◆ getLogoutServiceUrl()

static String org.keycloak.protocol.saml.SamlProtocol.getLogoutServiceUrl ( UriInfo  uriInfo,
ClientModel  client,
String  bindingType 
)
inlinestatic
532  {
533  String logoutServiceUrl = null;
534  if (SAML_POST_BINDING.equals(bindingType)) {
535  logoutServiceUrl = client.getAttribute(SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTE);
536  } else {
537  logoutServiceUrl = client.getAttribute(SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT_ATTRIBUTE);
538  }
539  if (logoutServiceUrl == null)
540  logoutServiceUrl = client.getManagementUrl();
541  if (logoutServiceUrl == null || logoutServiceUrl.trim().equals(""))
542  return null;
543  return ResourceAdminManager.resolveUri(uriInfo.getRequestUri(), client.getRootUrl(), logoutServiceUrl);
544 
545  }
static final String SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTE
Definition: SamlProtocol.java:99
static final String SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT_ATTRIBUTE
Definition: SamlProtocol.java:100
UriInfo uriInfo
Definition: SamlProtocol.java:127
static final String SAML_POST_BINDING
Definition: SamlProtocol.java:104

◆ getNameId()

String org.keycloak.protocol.saml.SamlProtocol.getNameId ( String  nameIdFormat,
CommonClientSessionModel  clientSession,
UserSessionModel  userSession 
)
inlineprotected
312  {
313  if (nameIdFormat.equals(JBossSAMLURIConstants.NAMEID_FORMAT_EMAIL.get())) {
314  final String email = userSession.getUser().getEmail();
315  if (email == null) {
316  logger.debugf("E-mail of the user %s has to be set for %s NameIDFormat", userSession.getUser().getUsername(), JBossSAMLURIConstants.NAMEID_FORMAT_EMAIL.get());
317  }
318  return email;
319  } else if (nameIdFormat.equals(JBossSAMLURIConstants.NAMEID_FORMAT_TRANSIENT.get())) {
320  // "G-" stands for "generated" Add this for the slight possibility of collisions.
321  return "G-" + UUID.randomUUID().toString();
322  } else if (nameIdFormat.equals(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get())) {
323  return getPersistentNameId(clientSession, userSession);
324  } else if (nameIdFormat.equals(JBossSAMLURIConstants.NAMEID_FORMAT_UNSPECIFIED.get())) {
325  // TODO: Support for persistent NameID (pseudo-random identifier persisted in user object)
326  return userSession.getUser().getUsername();
327  } else {
328  return userSession.getUser().getUsername();
329  }
330  }
String getPersistentNameId(final CommonClientSessionModel clientSession, final UserSessionModel userSession)
Definition: SamlProtocol.java:346
static final Logger logger
Definition: SamlProtocol.java:93

◆ getNameIdFormat()

String org.keycloak.protocol.saml.SamlProtocol.getNameIdFormat ( SamlClient  samlClient,
AuthenticatedClientSessionModel  clientSession 
)
inlineprotected
299  {
300  String nameIdFormat = clientSession.getNote(GeneralConstants.NAMEID_FORMAT);
301 
302  boolean forceFormat = samlClient.forceNameIDFormat();
303  String configuredNameIdFormat = samlClient.getNameIDFormat();
304  if ((nameIdFormat == null || forceFormat) && configuredNameIdFormat != null) {
305  nameIdFormat = configuredNameIdFormat;
306  }
307  if (nameIdFormat == null)
309  return nameIdFormat;
310  }
static final String SAML_DEFAULT_NAMEID_FORMAT
Definition: SamlProtocol.java:118

◆ getPersistentNameId()

String org.keycloak.protocol.saml.SamlProtocol.getPersistentNameId ( final CommonClientSessionModel  clientSession,
final UserSessionModel  userSession 
)
inlineprotected

Attempts to retrieve the persistent type NameId as follows:

  1. saml.persistent.name.id.for.$clientId user attribute
  2. saml.persistent.name.id.for.* user attribute
  3. 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.

戻り値
the user's persistent NameId
346  {
347  // attempt to retrieve the UserID for the client-specific attribute
348  final UserModel user = userSession.getUser();
349  final String clientNameId = String.format("%s.%s", SAML_PERSISTENT_NAME_ID_FOR,
350  clientSession.getClient().getClientId());
351  String samlPersistentNameId = user.getFirstAttribute(clientNameId);
352  if (samlPersistentNameId != null) {
353  return samlPersistentNameId;
354  }
355 
356  // check for a wildcard attribute
357  final String wildcardNameId = String.format("%s.*", SAML_PERSISTENT_NAME_ID_FOR);
358  samlPersistentNameId = user.getFirstAttribute(wildcardNameId);
359  if (samlPersistentNameId != null) {
360  return samlPersistentNameId;
361  }
362 
363  // default to generated. "G-" stands for "generated"
364  samlPersistentNameId = "G-" + UUID.randomUUID().toString();
365  user.setSingleAttribute(clientNameId, samlPersistentNameId);
366  return samlPersistentNameId;
367  }
static final String SAML_PERSISTENT_NAME_ID_FOR
Definition: SamlProtocol.java:119

◆ getResponseIssuer()

String org.keycloak.protocol.saml.SamlProtocol.getResponseIssuer ( RealmModel  realm)
inlineprotected
253  {
254  return RealmsResource.realmBaseUrl(uriInfo).build(realm.getName()).toString();
255  }
RealmModel realm
Definition: SamlProtocol.java:125
UriInfo uriInfo
Definition: SamlProtocol.java:127

◆ isLogoutPostBindingForClient()

boolean org.keycloak.protocol.saml.SamlProtocol.isLogoutPostBindingForClient ( AuthenticatedClientSessionModel  clientSession)
inlineprotected
274  {
275  ClientModel client = clientSession.getClient();
276  SamlClient samlClient = new SamlClient(client);
277  String logoutPostUrl = client.getAttribute(SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTE);
278  String logoutRedirectUrl = client.getAttribute(SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT_ATTRIBUTE);
279 
280  if (logoutPostUrl == null || logoutPostUrl.trim().isEmpty()) {
281  // if we don't have a redirect uri either, return true and default to the admin url + POST binding
282  return (logoutRedirectUrl == null || logoutRedirectUrl.trim().isEmpty());
283  }
284 
285  if (samlClient.forcePostBinding()) {
286  return true; // configured to force a post binding and post binding logout url is not null
287  }
288 
289  String bindingType = clientSession.getNote(SAML_BINDING);
290 
291  // if the login binding was POST, return true
292  if (SAML_POST_BINDING.equals(bindingType))
293  return true;
294 
295  // true if we don't have a redirect binding url, so use post binding, false for redirect binding
296  return (logoutRedirectUrl == null || logoutRedirectUrl.trim().isEmpty());
297  }
static final String SAML_BINDING
Definition: SamlProtocol.java:102
static final String SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTE
Definition: SamlProtocol.java:99
static final String SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT_ATTRIBUTE
Definition: SamlProtocol.java:100
static final String SAML_POST_BINDING
Definition: SamlProtocol.java:104

◆ isLogoutPostBindingForInitiator()

static boolean org.keycloak.protocol.saml.SamlProtocol.isLogoutPostBindingForInitiator ( UserSessionModel  session)
inlinestatic
269  {
270  String note = session.getNote(SamlProtocol.SAML_LOGOUT_BINDING);
271  return SamlProtocol.SAML_POST_BINDING.equals(note);
272  }
KeycloakSession session
Definition: SamlProtocol.java:123

◆ isPostBinding() [1/2]

boolean org.keycloak.protocol.saml.SamlProtocol.isPostBinding ( AuthenticationSessionModel  authSession)
inlineprotected
257  {
258  ClientModel client = authSession.getClient();
259  SamlClient samlClient = new SamlClient(client);
260  return SamlProtocol.SAML_POST_BINDING.equals(authSession.getClientNote(SamlProtocol.SAML_BINDING)) || samlClient.forcePostBinding();
261  }

◆ isPostBinding() [2/2]

boolean org.keycloak.protocol.saml.SamlProtocol.isPostBinding ( AuthenticatedClientSessionModel  clientSession)
inlineprotected
263  {
264  ClientModel client = clientSession.getClient();
265  SamlClient samlClient = new SamlClient(client);
266  return SamlProtocol.SAML_POST_BINDING.equals(clientSession.getNote(SamlProtocol.SAML_BINDING)) || samlClient.forcePostBinding();
267  }

◆ populateAttributeStatements()

AttributeStatementType org.keycloak.protocol.saml.SamlProtocol.populateAttributeStatements ( List< ProtocolMapperProcessor< SAMLAttributeStatementMapper >>  attributeStatementMappers,
KeycloakSession  session,
UserSessionModel  userSession,
AuthenticatedClientSessionModel  clientSession 
)
inline
509  {
510  AttributeStatementType attributeStatement = new AttributeStatementType();
511  for (ProtocolMapperProcessor<SAMLAttributeStatementMapper> processor : attributeStatementMappers) {
512  processor.mapper.transformAttributeStatement(attributeStatement, processor.model, session, userSession, clientSession);
513  }
514 
515  return attributeStatement;
516  }
KeycloakSession session
Definition: SamlProtocol.java:123

◆ populateRoles()

void org.keycloak.protocol.saml.SamlProtocol.populateRoles ( ProtocolMapperProcessor< SAMLRoleListMapper roleListMapper,
KeycloakSession  session,
UserSessionModel  userSession,
ClientSessionContext  clientSessionCtx,
final AttributeStatementType  existingAttributeStatement 
)
inline
526  {
527  if (roleListMapper == null)
528  return;
529  roleListMapper.mapper.mapRoles(existingAttributeStatement, roleListMapper.model, session, userSession, clientSessionCtx);
530  }
KeycloakSession session
Definition: SamlProtocol.java:123

◆ requireReauthentication()

boolean org.keycloak.protocol.saml.SamlProtocol.requireReauthentication ( UserSessionModel  userSession,
AuthenticationSessionModel  authSession 
)
inline
723  {
724  // Not yet supported
725  return false;
726  }

◆ samlErrorMessage()

Response org.keycloak.protocol.saml.SamlProtocol.samlErrorMessage ( AuthenticationSessionModel  authSession,
SamlClient  samlClient,
boolean  isPostBinding,
String  destination,
JBossSAMLURIConstants  statusDetail,
String  relayState 
)
inlineprivate
193  {
194  JaxrsSAML2BindingBuilder binding = new JaxrsSAML2BindingBuilder().relayState(relayState);
195  SAML2ErrorResponseBuilder builder = new SAML2ErrorResponseBuilder().destination(destination).issuer(getResponseIssuer(realm)).status(statusDetail.get());
196  KeyManager keyManager = session.keys();
197  if (samlClient.requiresRealmSignature()) {
198  KeyManager.ActiveRsaKey keys = keyManager.getActiveRsaKey(realm);
199  String keyName = samlClient.getXmlSigKeyInfoKeyNameTransformer().getKeyName(keys.getKid(), keys.getCertificate());
200  String canonicalization = samlClient.getCanonicalizationMethod();
201  if (canonicalization != null) {
202  binding.canonicalizationMethod(canonicalization);
203  }
204  binding.signatureAlgorithm(samlClient.getSignatureAlgorithm()).signWith(keyName, keys.getPrivateKey(), keys.getPublicKey(), keys.getCertificate()).signDocument();
205  }
206 
207  try {
208  // There is no support for encrypting status messages in SAML.
209  // Only assertions, attributes, base ID and name ID can be encrypted
210  // See Chapter 6 of saml-core-2.0-os.pdf
211  Document document = builder.buildDocument();
212  return buildErrorResponse(isPostBinding, destination, binding, document);
213  } catch (Exception e) {
214  return ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, Messages.FAILED_TO_PROCESS_RESPONSE);
215  }
216  }
String getResponseIssuer(RealmModel realm)
Definition: SamlProtocol.java:253
KeycloakSession session
Definition: SamlProtocol.java:123
RealmModel realm
Definition: SamlProtocol.java:125
boolean isPostBinding(AuthenticationSessionModel authSession)
Definition: SamlProtocol.java:257
Response buildErrorResponse(boolean isPostBinding, String destination, JaxrsSAML2BindingBuilder binding, Document document)
Definition: SamlProtocol.java:218

◆ sendError()

Response org.keycloak.protocol.saml.SamlProtocol.sendError ( AuthenticationSessionModel  authSession,
Error  error 
)
inline
164  {
165  try {
166  ClientModel client = authSession.getClient();
167 
168  if ("true".equals(authSession.getClientNote(SAML_IDP_INITIATED_LOGIN))) {
169  if (error == Error.CANCELLED_BY_USER) {
170  UriBuilder builder = RealmsResource.protocolUrl(uriInfo).path(SamlService.class, "idpInitiatedSSO");
171  Map<String, String> params = new HashMap<>();
172  params.put("realm", realm.getName());
173  params.put("protocol", LOGIN_PROTOCOL);
174  params.put("client", client.getAttribute(SAML_IDP_INITIATED_SSO_URL_NAME));
175  URI redirect = builder.buildFromMap(params);
176  return Response.status(302).location(redirect).build();
177  } else {
178  return ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, translateErrorToIdpInitiatedErrorMessage(error));
179  }
180  } else {
181  return samlErrorMessage(
182  authSession, new SamlClient(client), isPostBinding(authSession),
183  authSession.getRedirectUri(), translateErrorToSAMLStatus(error), authSession.getClientNote(GeneralConstants.RELAY_STATE)
184  );
185  }
186  } finally {
187  new AuthenticationSessionManager(session).removeAuthenticationSession(realm, authSession, true);
188  }
189  }
String translateErrorToIdpInitiatedErrorMessage(Error error)
Definition: SamlProtocol.java:240
KeycloakSession session
Definition: SamlProtocol.java:123
RealmModel realm
Definition: SamlProtocol.java:125
boolean isPostBinding(AuthenticationSessionModel authSession)
Definition: SamlProtocol.java:257
static final String SAML_IDP_INITIATED_LOGIN
Definition: SamlProtocol.java:103
static final String SAML_IDP_INITIATED_SSO_URL_NAME
Definition: SamlProtocol.java:121
Response samlErrorMessage(AuthenticationSessionModel authSession, SamlClient samlClient, boolean isPostBinding, String destination, JBossSAMLURIConstants statusDetail, String relayState)
Definition: SamlProtocol.java:191
UriInfo uriInfo
Definition: SamlProtocol.java:127
static final String LOGIN_PROTOCOL
Definition: SamlProtocol.java:101
JBossSAMLURIConstants translateErrorToSAMLStatus(Error error)
Definition: SamlProtocol.java:226

◆ setEventBuilder()

SamlProtocol org.keycloak.protocol.saml.SamlProtocol.setEventBuilder ( EventBuilder  event)
inline
158  {
159  this.event = event;
160  return this;
161  }
EventBuilder event
Definition: SamlProtocol.java:131

◆ setHttpHeaders()

SamlProtocol org.keycloak.protocol.saml.SamlProtocol.setHttpHeaders ( HttpHeaders  headers)
inline
152  {
153  this.headers = headers;
154  return this;
155  }
HttpHeaders headers
Definition: SamlProtocol.java:129

◆ setRealm()

SamlProtocol org.keycloak.protocol.saml.SamlProtocol.setRealm ( RealmModel  realm)
inline
140  {
141  this.realm = realm;
142  return this;
143  }
RealmModel realm
Definition: SamlProtocol.java:125

◆ setSession()

SamlProtocol org.keycloak.protocol.saml.SamlProtocol.setSession ( KeycloakSession  session)
inline
134  {
135  this.session = session;
136  return this;
137  }
KeycloakSession session
Definition: SamlProtocol.java:123

◆ setUriInfo()

SamlProtocol org.keycloak.protocol.saml.SamlProtocol.setUriInfo ( UriInfo  uriInfo)
inline
146  {
147  this.uriInfo = uriInfo;
148  return this;
149  }
UriInfo uriInfo
Definition: SamlProtocol.java:127

◆ transformLoginResponse()

ResponseType org.keycloak.protocol.saml.SamlProtocol.transformLoginResponse ( List< ProtocolMapperProcessor< SAMLLoginResponseMapper >>  mappers,
ResponseType  response,
KeycloakSession  session,
UserSessionModel  userSession,
AuthenticatedClientSessionModel  clientSession 
)
inline
518  {
519  for (ProtocolMapperProcessor<SAMLLoginResponseMapper> processor : mappers) {
520  response = processor.mapper.transformLoginResponse(response, processor.model, session, userSession, clientSession);
521  }
522  return response;
523  }
KeycloakSession session
Definition: SamlProtocol.java:123

◆ translateErrorToIdpInitiatedErrorMessage()

String org.keycloak.protocol.saml.SamlProtocol.translateErrorToIdpInitiatedErrorMessage ( Error  error)
inlineprivate
240  {
241  switch (error) {
242  case CONSENT_DENIED:
243  return Messages.CONSENT_DENIED;
244  case PASSIVE_INTERACTION_REQUIRED:
245  case PASSIVE_LOGIN_REQUIRED:
246  return Messages.UNEXPECTED_ERROR_HANDLING_REQUEST;
247  default:
248  logger.warn("Untranslated protocol Error: " + error.name() + " so we return default error message");
249  return Messages.UNEXPECTED_ERROR_HANDLING_REQUEST;
250  }
251  }
static final Logger logger
Definition: SamlProtocol.java:93

◆ translateErrorToSAMLStatus()

JBossSAMLURIConstants org.keycloak.protocol.saml.SamlProtocol.translateErrorToSAMLStatus ( Error  error)
inlineprivate
226  {
227  switch (error) {
228  case CANCELLED_BY_USER:
229  case CONSENT_DENIED:
230  return JBossSAMLURIConstants.STATUS_REQUEST_DENIED;
231  case PASSIVE_INTERACTION_REQUIRED:
232  case PASSIVE_LOGIN_REQUIRED:
233  return JBossSAMLURIConstants.STATUS_NO_PASSIVE;
234  default:
235  logger.warn("Untranslated protocol Error: " + error.name() + " so we return default SAML error");
236  return JBossSAMLURIConstants.STATUS_REQUEST_DENIED;
237  }
238  }
static final Logger logger
Definition: SamlProtocol.java:93

メンバ詳解

◆ ATTRIBUTE_FALSE_VALUE

final String org.keycloak.protocol.saml.SamlProtocol.ATTRIBUTE_FALSE_VALUE = "false"
static

◆ ATTRIBUTE_TRUE_VALUE

final String org.keycloak.protocol.saml.SamlProtocol.ATTRIBUTE_TRUE_VALUE = "true"
static

◆ event

EventBuilder org.keycloak.protocol.saml.SamlProtocol.event
protected

◆ headers

HttpHeaders org.keycloak.protocol.saml.SamlProtocol.headers
protected

◆ logger

final Logger org.keycloak.protocol.saml.SamlProtocol.logger = Logger.getLogger(SamlProtocol.class)
staticprotected

◆ LOGIN_PROTOCOL

final String org.keycloak.protocol.saml.SamlProtocol.LOGIN_PROTOCOL = "saml"
static

◆ realm

RealmModel org.keycloak.protocol.saml.SamlProtocol.realm
protected

◆ SAML_ASSERTION_CONSUMER_URL_POST_ATTRIBUTE

final String org.keycloak.protocol.saml.SamlProtocol.SAML_ASSERTION_CONSUMER_URL_POST_ATTRIBUTE = "saml_assertion_consumer_url_post"
static

◆ SAML_ASSERTION_CONSUMER_URL_REDIRECT_ATTRIBUTE

final String org.keycloak.protocol.saml.SamlProtocol.SAML_ASSERTION_CONSUMER_URL_REDIRECT_ATTRIBUTE = "saml_assertion_consumer_url_redirect"
static

◆ SAML_BINDING

final String org.keycloak.protocol.saml.SamlProtocol.SAML_BINDING = "saml_binding"
static

◆ SAML_DEFAULT_NAMEID_FORMAT

final String org.keycloak.protocol.saml.SamlProtocol.SAML_DEFAULT_NAMEID_FORMAT = JBossSAMLURIConstants.NAMEID_FORMAT_UNSPECIFIED.get()
static

◆ SAML_IDP_INITIATED_LOGIN

final String org.keycloak.protocol.saml.SamlProtocol.SAML_IDP_INITIATED_LOGIN = "saml_idp_initiated_login"
static

◆ SAML_IDP_INITIATED_SSO_RELAY_STATE

final String org.keycloak.protocol.saml.SamlProtocol.SAML_IDP_INITIATED_SSO_RELAY_STATE = "saml_idp_initiated_sso_relay_state"
static

◆ SAML_IDP_INITIATED_SSO_URL_NAME

final String org.keycloak.protocol.saml.SamlProtocol.SAML_IDP_INITIATED_SSO_URL_NAME = "saml_idp_initiated_sso_url_name"
static

◆ SAML_LOGOUT_ADD_EXTENSIONS_ELEMENT_WITH_KEY_INFO

final String org.keycloak.protocol.saml.SamlProtocol.SAML_LOGOUT_ADD_EXTENSIONS_ELEMENT_WITH_KEY_INFO = "saml.logout.addExtensionsElementWithKeyInfo"
static

◆ SAML_LOGOUT_BINDING

final String org.keycloak.protocol.saml.SamlProtocol.SAML_LOGOUT_BINDING = "saml.logout.binding"
static

◆ SAML_LOGOUT_BINDING_URI

final String org.keycloak.protocol.saml.SamlProtocol.SAML_LOGOUT_BINDING_URI = "SAML_LOGOUT_BINDING_URI"
static

◆ SAML_LOGOUT_CANONICALIZATION

final String org.keycloak.protocol.saml.SamlProtocol.SAML_LOGOUT_CANONICALIZATION = "SAML_LOGOUT_CANONICALIZATION"
static

◆ SAML_LOGOUT_RELAY_STATE

final String org.keycloak.protocol.saml.SamlProtocol.SAML_LOGOUT_RELAY_STATE = "SAML_LOGOUT_RELAY_STATE"
static

◆ SAML_LOGOUT_REQUEST_ID

final String org.keycloak.protocol.saml.SamlProtocol.SAML_LOGOUT_REQUEST_ID = "SAML_LOGOUT_REQUEST_ID"
static

◆ SAML_LOGOUT_SIGNATURE_ALGORITHM

final String org.keycloak.protocol.saml.SamlProtocol.SAML_LOGOUT_SIGNATURE_ALGORITHM = "saml.logout.signature.algorithm"
static

◆ SAML_NAME_ID

final String org.keycloak.protocol.saml.SamlProtocol.SAML_NAME_ID = "SAML_NAME_ID"
static

◆ SAML_NAME_ID_FORMAT

final String org.keycloak.protocol.saml.SamlProtocol.SAML_NAME_ID_FORMAT = "SAML_NAME_ID_FORMAT"
static

◆ SAML_PERSISTENT_NAME_ID_FOR

final String org.keycloak.protocol.saml.SamlProtocol.SAML_PERSISTENT_NAME_ID_FOR = "saml.persistent.name.id.for"
static

◆ SAML_POST_BINDING

final String org.keycloak.protocol.saml.SamlProtocol.SAML_POST_BINDING = "post"
static

◆ SAML_REDIRECT_BINDING

final String org.keycloak.protocol.saml.SamlProtocol.SAML_REDIRECT_BINDING = "get"
static

◆ SAML_REQUEST_ID

final String org.keycloak.protocol.saml.SamlProtocol.SAML_REQUEST_ID = "SAML_REQUEST_ID"
static

◆ SAML_SERVER_SIGNATURE_KEYINFO_KEY_NAME_TRANSFORMER

final String org.keycloak.protocol.saml.SamlProtocol.SAML_SERVER_SIGNATURE_KEYINFO_KEY_NAME_TRANSFORMER = "SAML_SERVER_SIGNATURE_KEYINFO_KEY_NAME_TRANSFORMER"
static

◆ SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTE

final String org.keycloak.protocol.saml.SamlProtocol.SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTE = "saml_single_logout_service_url_post"
static

◆ SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT_ATTRIBUTE

final String org.keycloak.protocol.saml.SamlProtocol.SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT_ATTRIBUTE = "saml_single_logout_service_url_redirect"
static

◆ SAML_SOAP_BINDING

final String org.keycloak.protocol.saml.SamlProtocol.SAML_SOAP_BINDING = "soap"
static

◆ session

KeycloakSession org.keycloak.protocol.saml.SamlProtocol.session
protected

◆ uriInfo

UriInfo org.keycloak.protocol.saml.SamlProtocol.uriInfo
protected

このクラス詳解は次のファイルから抽出されました: