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

公開メンバ関数

boolean requiresUser ()
 
boolean configuredFor (KeycloakSession session, RealmModel realm, UserModel user)
 
void authenticate (AuthenticationFlowContext context)
 
void action (AuthenticationFlowContext context)
 
void setRequiredActions (KeycloakSession session, RealmModel realm, UserModel user)
 
void close ()
 

静的公開メンバ関数

static UserModel getExistingUser (KeycloakSession session, RealmModel realm, AuthenticationSessionModel authSession)
 

静的公開変数類

static final String BROKERED_CONTEXT_NOTE = "BROKERED_CONTEXT"
 
static final String EXISTING_USER_INFO = "EXISTING_USER_INFO"
 
static final String UPDATE_PROFILE_EMAIL_CHANGED = "UPDATE_PROFILE_EMAIL_CHANGED"
 
static final String ENFORCE_UPDATE_PROFILE = "ENFORCE_UPDATE_PROFILE"
 
static final String BROKER_REGISTERED_NEW_USER = "BROKER_REGISTERED_NEW_USER"
 
static final String FIRST_BROKER_LOGIN_SUCCESS = "FIRST_BROKER_LOGIN_SUCCESS"
 

限定公開メンバ関数

void authenticateImpl (AuthenticationFlowContext context, SerializedBrokeredIdentityContext userCtx, BrokeredIdentityContext brokerContext)
 
boolean requiresUpdateProfilePage (AuthenticationFlowContext context, SerializedBrokeredIdentityContext userCtx, BrokeredIdentityContext brokerContext)
 
void actionImpl (AuthenticationFlowContext context, SerializedBrokeredIdentityContext userCtx, BrokeredIdentityContext brokerContext)
 
void sendFailureChallenge (AuthenticationFlowContext context, Response.Status status, String eventError, String errorMessage, AuthenticationFlowError flowError)
 

静的非公開変数類

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

詳解

著者
Marek Posolda

関数詳解

◆ action()

void org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.action ( AuthenticationFlowContext  context)
inlineinherited
78  {
79  AuthenticationSessionModel clientSession = context.getAuthenticationSession();
80 
81  SerializedBrokeredIdentityContext serializedCtx = SerializedBrokeredIdentityContext.readFromAuthenticationSession(clientSession, BROKERED_CONTEXT_NOTE);
82  if (serializedCtx == null) {
83  throw new AuthenticationFlowException("Not found serialized context in clientSession", AuthenticationFlowError.IDENTITY_PROVIDER_ERROR);
84  }
85  BrokeredIdentityContext brokerContext = serializedCtx.deserialize(context.getSession(), clientSession);
86 
87  if (!brokerContext.getIdpConfig().isEnabled()) {
88  sendFailureChallenge(context, Response.Status.BAD_REQUEST, Errors.IDENTITY_PROVIDER_ERROR, Messages.IDENTITY_PROVIDER_UNEXPECTED_ERROR, AuthenticationFlowError.IDENTITY_PROVIDER_ERROR);
89  }
90 
91  actionImpl(context, serializedCtx, brokerContext);
92  }
static final String BROKERED_CONTEXT_NOTE
Definition: AbstractIdpAuthenticator.java:42
void sendFailureChallenge(AuthenticationFlowContext context, Response.Status status, String eventError, String errorMessage, AuthenticationFlowError flowError)
Definition: AbstractIdpAuthenticator.java:97
abstract void actionImpl(AuthenticationFlowContext context, SerializedBrokeredIdentityContext serializedCtx, BrokeredIdentityContext brokerContext)

◆ actionImpl()

void org.keycloak.authentication.authenticators.broker.IdpReviewProfileAuthenticator.actionImpl ( AuthenticationFlowContext  context,
SerializedBrokeredIdentityContext  userCtx,
BrokeredIdentityContext  brokerContext 
)
inlineprotected
95  {
96  EventBuilder event = context.getEvent();
97  event.event(EventType.UPDATE_PROFILE);
98  MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
99 
100  RealmModel realm = context.getRealm();
101 
102  List<FormMessage> errors = Validation.validateUpdateProfileForm(realm, formData);
103  if (errors != null && !errors.isEmpty()) {
104  Response challenge = context.form()
105  .setErrors(errors)
106  .setAttribute(LoginFormsProvider.UPDATE_PROFILE_CONTEXT_ATTR, userCtx)
107  .setFormData(formData)
108  .createUpdateProfilePage();
109  context.challenge(challenge);
110  return;
111  }
112 
113  String username = realm.isRegistrationEmailAsUsername() ? formData.getFirst(UserModel.EMAIL) : formData.getFirst(UserModel.USERNAME);
114  userCtx.setUsername(username);
115  userCtx.setFirstName(formData.getFirst(UserModel.FIRST_NAME));
116  userCtx.setLastName(formData.getFirst(UserModel.LAST_NAME));
117 
118  String email = formData.getFirst(UserModel.EMAIL);
119  if (!ObjectUtil.isEqualOrBothNull(email, userCtx.getEmail())) {
120  if (logger.isTraceEnabled()) {
121  logger.tracef("Email updated on updateProfile page to '%s' ", email);
122  }
123 
124  userCtx.setEmail(email);
125  context.getAuthenticationSession().setAuthNote(UPDATE_PROFILE_EMAIL_CHANGED, "true");
126  }
127 
128  AttributeFormDataProcessor.process(formData, realm, userCtx);
129 
130  userCtx.saveToAuthenticationSession(context.getAuthenticationSession(), BROKERED_CONTEXT_NOTE);
131 
132  logger.debugf("Profile updated successfully after first authentication with identity provider '%s' for broker user '%s'.", brokerContext.getIdpConfig().getAlias(), userCtx.getUsername());
133 
134  event.detail(Details.UPDATED_EMAIL, email);
135  context.success();
136  }
static final String BROKERED_CONTEXT_NOTE
Definition: AbstractIdpAuthenticator.java:42
static final Logger logger
Definition: IdpReviewProfileAuthenticator.java:48
static final String UPDATE_PROFILE_EMAIL_CHANGED
Definition: AbstractIdpAuthenticator.java:48

◆ authenticate()

void org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.authenticate ( AuthenticationFlowContext  context)
inlineinherited
61  {
62  AuthenticationSessionModel authSession = context.getAuthenticationSession();
63 
64  SerializedBrokeredIdentityContext serializedCtx = SerializedBrokeredIdentityContext.readFromAuthenticationSession(authSession, BROKERED_CONTEXT_NOTE);
65  if (serializedCtx == null) {
66  throw new AuthenticationFlowException("Not found serialized context in clientSession", AuthenticationFlowError.IDENTITY_PROVIDER_ERROR);
67  }
68  BrokeredIdentityContext brokerContext = serializedCtx.deserialize(context.getSession(), authSession);
69 
70  if (!brokerContext.getIdpConfig().isEnabled()) {
71  sendFailureChallenge(context, Response.Status.BAD_REQUEST, Errors.IDENTITY_PROVIDER_ERROR, Messages.IDENTITY_PROVIDER_UNEXPECTED_ERROR, AuthenticationFlowError.IDENTITY_PROVIDER_ERROR);
72  }
73 
74  authenticateImpl(context, serializedCtx, brokerContext);
75  }
static final String BROKERED_CONTEXT_NOTE
Definition: AbstractIdpAuthenticator.java:42
void sendFailureChallenge(AuthenticationFlowContext context, Response.Status status, String eventError, String errorMessage, AuthenticationFlowError flowError)
Definition: AbstractIdpAuthenticator.java:97
abstract void authenticateImpl(AuthenticationFlowContext context, SerializedBrokeredIdentityContext serializedCtx, BrokeredIdentityContext brokerContext)

◆ authenticateImpl()

void org.keycloak.authentication.authenticators.broker.IdpReviewProfileAuthenticator.authenticateImpl ( AuthenticationFlowContext  context,
SerializedBrokeredIdentityContext  userCtx,
BrokeredIdentityContext  brokerContext 
)
inlineprotected
56  {
57  IdentityProviderModel idpConfig = brokerContext.getIdpConfig();
58 
59  if (requiresUpdateProfilePage(context, userCtx, brokerContext)) {
60 
61  logger.debugf("Identity provider '%s' requires update profile action for broker user '%s'.", idpConfig.getAlias(), userCtx.getUsername());
62 
63  // No formData for first render. The profile is rendered from userCtx
64  Response challengeResponse = context.form()
65  .setAttribute(LoginFormsProvider.UPDATE_PROFILE_CONTEXT_ATTR, userCtx)
66  .setFormData(null)
67  .createUpdateProfilePage();
68  context.challenge(challengeResponse);
69  } else {
70  // Not required to update profile. Marked success
71  context.success();
72  }
73  }
boolean requiresUpdateProfilePage(AuthenticationFlowContext context, SerializedBrokeredIdentityContext userCtx, BrokeredIdentityContext brokerContext)
Definition: IdpReviewProfileAuthenticator.java:75
static final Logger logger
Definition: IdpReviewProfileAuthenticator.java:48

◆ close()

void org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.close ( )
inlineinherited
111  {
112 
113  }

◆ configuredFor()

boolean org.keycloak.authentication.authenticators.broker.IdpReviewProfileAuthenticator.configuredFor ( KeycloakSession  session,
RealmModel  realm,
UserModel  user 
)
inline
139  {
140  return true;
141  }

◆ getExistingUser()

static UserModel org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.getExistingUser ( KeycloakSession  session,
RealmModel  realm,
AuthenticationSessionModel  authSession 
)
inlinestaticinherited
115  {
116  String existingUserId = authSession.getAuthNote(EXISTING_USER_INFO);
117  if (existingUserId == null) {
118  throw new AuthenticationFlowException("Unexpected state. There is no existing duplicated user identified in ClientSession",
119  AuthenticationFlowError.INTERNAL_ERROR);
120  }
121 
122  ExistingUserInfo duplication = ExistingUserInfo.deserialize(existingUserId);
123 
124  UserModel existingUser = session.users().getUserById(duplication.getExistingUserId(), realm);
125  if (existingUser == null) {
126  throw new AuthenticationFlowException("User with ID '" + existingUserId + "' not found.", AuthenticationFlowError.INVALID_USER);
127  }
128 
129  if (!existingUser.isEnabled()) {
130  throw new AuthenticationFlowException("User with ID '" + existingUserId + "', username '" + existingUser.getUsername() + "' disabled.", AuthenticationFlowError.USER_DISABLED);
131  }
132 
133  return existingUser;
134  }
static final String EXISTING_USER_INFO
Definition: AbstractIdpAuthenticator.java:45

◆ requiresUpdateProfilePage()

boolean org.keycloak.authentication.authenticators.broker.IdpReviewProfileAuthenticator.requiresUpdateProfilePage ( AuthenticationFlowContext  context,
SerializedBrokeredIdentityContext  userCtx,
BrokeredIdentityContext  brokerContext 
)
inlineprotected
75  {
76  String enforceUpdateProfile = context.getAuthenticationSession().getAuthNote(ENFORCE_UPDATE_PROFILE);
77  if (Boolean.parseBoolean(enforceUpdateProfile)) {
78  return true;
79  }
80 
81  String updateProfileFirstLogin;
82  AuthenticatorConfigModel authenticatorConfig = context.getAuthenticatorConfig();
83  if (authenticatorConfig == null || !authenticatorConfig.getConfig().containsKey(IdpReviewProfileAuthenticatorFactory.UPDATE_PROFILE_ON_FIRST_LOGIN)) {
84  updateProfileFirstLogin = IdentityProviderRepresentation.UPFLM_MISSING;
85  } else {
86  updateProfileFirstLogin = authenticatorConfig.getConfig().get(IdpReviewProfileAuthenticatorFactory.UPDATE_PROFILE_ON_FIRST_LOGIN);
87  }
88 
89  RealmModel realm = context.getRealm();
90  return IdentityProviderRepresentation.UPFLM_ON.equals(updateProfileFirstLogin)
91  || (IdentityProviderRepresentation.UPFLM_MISSING.equals(updateProfileFirstLogin) && !Validation.validateUserMandatoryFields(realm, userCtx));
92  }
static final String ENFORCE_UPDATE_PROFILE
Definition: AbstractIdpAuthenticator.java:51

◆ requiresUser()

boolean org.keycloak.authentication.authenticators.broker.IdpReviewProfileAuthenticator.requiresUser ( )
inline
51  {
52  return false;
53  }

◆ sendFailureChallenge()

void org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.sendFailureChallenge ( AuthenticationFlowContext  context,
Response.Status  status,
String  eventError,
String  errorMessage,
AuthenticationFlowError  flowError 
)
inlineprotectedinherited
97  {
98  context.getEvent().user(context.getUser())
99  .error(eventError);
100  Response challengeResponse = context.form()
101  .setError(errorMessage)
102  .createErrorPage(status);
103  context.failureChallenge(flowError, challengeResponse);
104  }

◆ setRequiredActions()

void org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.setRequiredActions ( KeycloakSession  session,
RealmModel  realm,
UserModel  user 
)
inlineinherited
107  {
108  }

メンバ詳解

◆ BROKER_REGISTERED_NEW_USER

final String org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.BROKER_REGISTERED_NEW_USER = "BROKER_REGISTERED_NEW_USER"
staticinherited

◆ BROKERED_CONTEXT_NOTE

final String org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.BROKERED_CONTEXT_NOTE = "BROKERED_CONTEXT"
staticinherited

◆ ENFORCE_UPDATE_PROFILE

final String org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.ENFORCE_UPDATE_PROFILE = "ENFORCE_UPDATE_PROFILE"
staticinherited

◆ EXISTING_USER_INFO

final String org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.EXISTING_USER_INFO = "EXISTING_USER_INFO"
staticinherited

◆ FIRST_BROKER_LOGIN_SUCCESS

final String org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.FIRST_BROKER_LOGIN_SUCCESS = "FIRST_BROKER_LOGIN_SUCCESS"
staticinherited

◆ logger

final Logger org.keycloak.authentication.authenticators.broker.IdpReviewProfileAuthenticator.logger = Logger.getLogger(IdpReviewProfileAuthenticator.class)
staticprivate

◆ UPDATE_PROFILE_EMAIL_CHANGED

final String org.keycloak.authentication.authenticators.broker.AbstractIdpAuthenticator.UPDATE_PROFILE_EMAIL_CHANGED = "UPDATE_PROFILE_EMAIL_CHANGED"
staticinherited

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