keycloak
クラス | 公開メンバ関数 | 公開変数類 | 変数 | 非公開変数類 | 全メンバ一覧
org.keycloak.authentication.FormAuthenticationFlow クラス
org.keycloak.authentication.FormAuthenticationFlow の継承関係図
Inheritance graph
org.keycloak.authentication.FormAuthenticationFlow 連携図
Collaboration graph

クラス

class  FormContextImpl
 
class  ValidationContextImpl
 

公開メンバ関数

 FormAuthenticationFlow (AuthenticationProcessor processor, AuthenticationExecutionModel execution)
 
Response processAction (String actionExecution)
 
URI getActionUrl (String executionId, String code)
 
Response processFlow ()
 
Response renderForm (MultivaluedMap< String, String > formData, List< FormMessage > errors)
 

公開変数類

String BASIC_FLOW = "basic-flow"
 
String FORM_FLOW = "form-flow"
 
String CLIENT_FLOW = "client-flow"
 

変数

AuthenticationProcessor processor
 
AuthenticationExecutionModel formExecution
 

非公開変数類

final List< AuthenticationExecutionModelformActionExecutions
 
final FormAuthenticator formAuthenticator
 

詳解

著者
Bill Burke
バージョン
Revision
1

構築子と解体子

◆ FormAuthenticationFlow()

org.keycloak.authentication.FormAuthenticationFlow.FormAuthenticationFlow ( AuthenticationProcessor  processor,
AuthenticationExecutionModel  execution 
)
inline
58  {
59  this.processor = processor;
60  this.formExecution = execution;
62  formAuthenticator = processor.getSession().getProvider(FormAuthenticator.class, execution.getAuthenticator());
63  }
List< AuthenticationExecutionModel > getAuthenticationExecutions(String flowId)
KeycloakSession getSession()
Definition: AuthenticationProcessor.java:156
final FormAuthenticator formAuthenticator
Definition: FormAuthenticationFlow.java:55
AuthenticationExecutionModel formExecution
Definition: FormAuthenticationFlow.java:53
RealmModel getRealm()
Definition: AuthenticationProcessor.java:128
AuthenticationProcessor processor
Definition: FormAuthenticationFlow.java:52
< T extends Provider > T getProvider(Class< T > clazz)
final List< AuthenticationExecutionModel > formActionExecutions
Definition: FormAuthenticationFlow.java:54

関数詳解

◆ getActionUrl()

URI org.keycloak.authentication.FormAuthenticationFlow.getActionUrl ( String  executionId,
String  code 
)
inline
266  {
267  ClientModel client = processor.getAuthenticationSession().getClient();
268  return LoginActionsService.registrationFormProcessor(processor.getUriInfo())
269  .queryParam(LoginActionsService.SESSION_CODE, code)
270  .queryParam(Constants.EXECUTION, executionId)
271  .queryParam(Constants.CLIENT_ID, client.getClientId())
272  .queryParam(Constants.TAB_ID, processor.getAuthenticationSession().getTabId())
273  .build(processor.getRealm().getName());
274  }
AuthenticationSessionModel getAuthenticationSession()
Definition: AuthenticationProcessor.java:144
RealmModel getRealm()
Definition: AuthenticationProcessor.java:128
AuthenticationProcessor processor
Definition: FormAuthenticationFlow.java:52
UriInfo getUriInfo()
Definition: AuthenticationProcessor.java:152

◆ processAction()

Response org.keycloak.authentication.FormAuthenticationFlow.processAction ( String  actionExecution)
inline

org.keycloak.authentication.AuthenticationFlowを実装しています。

173  {
174  if (!actionExecution.equals(formExecution.getId())) {
175  throw new AuthenticationFlowException("action is not current execution", AuthenticationFlowError.INTERNAL_ERROR);
176  }
177  Map<String, AuthenticationSessionModel.ExecutionStatus> executionStatus = new HashMap<>();
178  List<FormAction> requiredActions = new LinkedList<>();
179  List<ValidationContextImpl> successes = new LinkedList<>();
180  List<ValidationContextImpl> errors = new LinkedList<>();
181  for (AuthenticationExecutionModel formActionExecution : formActionExecutions) {
182  if (!formActionExecution.isEnabled()) {
183  executionStatus.put(formActionExecution.getId(), AuthenticationSessionModel.ExecutionStatus.SKIPPED);
184  continue;
185  }
186  FormActionFactory factory = (FormActionFactory)processor.getSession().getKeycloakSessionFactory().getProviderFactory(FormAction.class, formActionExecution.getAuthenticator());
187  FormAction action = factory.create(processor.getSession());
188 
190  if (action.requiresUser() && authUser == null) {
191  throw new AuthenticationFlowException("form action: " + formExecution.getAuthenticator() + " requires user", AuthenticationFlowError.UNKNOWN_USER);
192  }
193  boolean configuredFor = false;
194  if (action.requiresUser() && authUser != null) {
195  configuredFor = action.configuredFor(processor.getSession(), processor.getRealm(), authUser);
196  if (!configuredFor) {
197  if (formActionExecution.isRequired()) {
198  if (factory.isUserSetupAllowed()) {
199  AuthenticationProcessor.logger.debugv("authenticator SETUP_REQUIRED: {0}", formExecution.getAuthenticator());
200  executionStatus.put(formActionExecution.getId(), AuthenticationSessionModel.ExecutionStatus.SETUP_REQUIRED);
201  requiredActions.add(action);
202  continue;
203  } else {
204  throw new AuthenticationFlowException(AuthenticationFlowError.CREDENTIAL_SETUP_REQUIRED);
205  }
206  } else if (formActionExecution.isOptional()) {
207  executionStatus.put(formActionExecution.getId(), AuthenticationSessionModel.ExecutionStatus.SKIPPED);
208  continue;
209  }
210  }
211  }
212 
213  ValidationContextImpl result = new ValidationContextImpl(formActionExecution, action);
214  action.validate(result);
215  if (result.success) {
216  executionStatus.put(formActionExecution.getId(), AuthenticationSessionModel.ExecutionStatus.SUCCESS);
217  successes.add(result);
218  } else {
219  executionStatus.put(formActionExecution.getId(), AuthenticationSessionModel.ExecutionStatus.CHALLENGED);
220  errors.add(result);
221  }
222  }
223 
224  if (!errors.isEmpty()) {
226  List<FormMessage> messages = new LinkedList<>();
227  Set<String> fields = new HashSet<>();
228  for (ValidationContextImpl v : errors) {
229  for (FormMessage m : v.errors) {
230  if (!fields.contains(m.getField())) {
231  if (v.excludeOthers) {
232  fields.clear();
233  messages.clear();
234  }
235 
236  fields.add(m.getField());
237  messages.add(m);
238 
239  if (v.excludeOthers) {
240  break;
241  }
242  }
243  }
244  }
245  ValidationContextImpl first = errors.get(0);
246  first.getEvent().error(first.error);
247  return renderForm(first.formData, messages);
248  }
249 
250  for (ValidationContextImpl context : successes) {
251  context.action.success(context);
252  }
253  // set status and required actions only if form is fully successful
254  for (Map.Entry<String, AuthenticationSessionModel.ExecutionStatus> entry : executionStatus.entrySet()) {
255  processor.getAuthenticationSession().setExecutionStatus(entry.getKey(), entry.getValue());
256  }
257  for (FormAction action : requiredActions) {
259 
260  }
261  processor.getAuthenticationSession().setExecutionStatus(actionExecution, AuthenticationSessionModel.ExecutionStatus.SUCCESS);
262  processor.getAuthenticationSession().removeAuthNote(AuthenticationProcessor.CURRENT_AUTHENTICATION_EXECUTION);
263  return null;
264  }
KeycloakSessionFactory getKeycloakSessionFactory()
KeycloakSession getSession()
Definition: AuthenticationProcessor.java:156
AuthenticationSessionModel getAuthenticationSession()
Definition: AuthenticationProcessor.java:144
String getAuthenticator()
Definition: AuthenticationExecutionModel.java:63
void setExecutionStatus(String authenticator, ExecutionStatus status)
AuthenticationExecutionModel formExecution
Definition: FormAuthenticationFlow.java:53
RealmModel getRealm()
Definition: AuthenticationProcessor.java:128
Response renderForm(MultivaluedMap< String, String > formData, List< FormMessage > errors)
Definition: FormAuthenticationFlow.java:282
AuthenticationProcessor processor
Definition: FormAuthenticationFlow.java:52
String getId()
Definition: AuthenticationExecutionModel.java:47
final List< AuthenticationExecutionModel > formActionExecutions
Definition: FormAuthenticationFlow.java:54
< T extends Provider > ProviderFactory< T > getProviderFactory(Class< T > clazz)
void logFailure()
Definition: AuthenticationProcessor.java:619

◆ processFlow()

Response org.keycloak.authentication.FormAuthenticationFlow.processFlow ( )
inline

org.keycloak.authentication.AuthenticationFlowを実装しています。

278  {
279  return renderForm(null, null);
280  }
Response renderForm(MultivaluedMap< String, String > formData, List< FormMessage > errors)
Definition: FormAuthenticationFlow.java:282

◆ renderForm()

Response org.keycloak.authentication.FormAuthenticationFlow.renderForm ( MultivaluedMap< String, String >  formData,
List< FormMessage errors 
)
inline
282  {
283  String executionId = formExecution.getId();
284  processor.getAuthenticationSession().setAuthNote(AuthenticationProcessor.CURRENT_AUTHENTICATION_EXECUTION, executionId);
285  String code = processor.generateCode();
286  URI actionUrl = getActionUrl(executionId, code);
287  LoginFormsProvider form = processor.getSession().getProvider(LoginFormsProvider.class)
288  .setAuthenticationSession(processor.getAuthenticationSession())
289  .setActionUri(actionUrl)
290  .setExecution(executionId)
291  .setClientSessionCode(code)
292  .setFormData(formData)
293  .setErrors(errors);
294  for (AuthenticationExecutionModel formActionExecution : formActionExecutions) {
295  if (!formActionExecution.isEnabled()) continue;
296  FormAction action = processor.getSession().getProvider(FormAction.class, formActionExecution.getAuthenticator());
297  FormContext result = new FormContextImpl(formActionExecution);
298  action.buildPage(result, form);
299  }
300  FormContext context = new FormContextImpl(formExecution);
301  return formAuthenticator.render(context, form);
302  }
KeycloakSession getSession()
Definition: AuthenticationProcessor.java:156
void setAuthNote(String name, String value)
AuthenticationSessionModel getAuthenticationSession()
Definition: AuthenticationProcessor.java:144
final FormAuthenticator formAuthenticator
Definition: FormAuthenticationFlow.java:55
AuthenticationExecutionModel formExecution
Definition: FormAuthenticationFlow.java:53
AuthenticationProcessor processor
Definition: FormAuthenticationFlow.java:52
String getId()
Definition: AuthenticationExecutionModel.java:47
< T extends Provider > T getProvider(Class< T > clazz)
final List< AuthenticationExecutionModel > formActionExecutions
Definition: FormAuthenticationFlow.java:54
URI getActionUrl(String executionId, String code)
Definition: FormAuthenticationFlow.java:266
Response render(FormContext context, LoginFormsProvider form)
String generateCode()
Definition: AuthenticationProcessor.java:224

メンバ詳解

◆ BASIC_FLOW

String org.keycloak.authentication.AuthenticationFlow.BASIC_FLOW = "basic-flow"
inherited

◆ CLIENT_FLOW

String org.keycloak.authentication.AuthenticationFlow.CLIENT_FLOW = "client-flow"
inherited

◆ FORM_FLOW

String org.keycloak.authentication.AuthenticationFlow.FORM_FLOW = "form-flow"
inherited

◆ formActionExecutions

final List<AuthenticationExecutionModel> org.keycloak.authentication.FormAuthenticationFlow.formActionExecutions
private

◆ formAuthenticator

final FormAuthenticator org.keycloak.authentication.FormAuthenticationFlow.formAuthenticator
private

◆ formExecution

AuthenticationExecutionModel org.keycloak.authentication.FormAuthenticationFlow.formExecution
package

◆ processor

AuthenticationProcessor org.keycloak.authentication.FormAuthenticationFlow.processor
package

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