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

公開メンバ関数

 ClientAuthenticationFlow (AuthenticationProcessor processor, AuthenticationFlowModel flow)
 
Response processAction (String actionExecution)
 
Response processFlow ()
 
Response sendChallenge (AuthenticationProcessor.Result result, AuthenticationExecutionModel execution)
 

限定公開メンバ関数

List< AuthenticationExecutionModel > findExecutionsToRun ()
 
Response processResult (AuthenticationProcessor.Result result)
 

変数

Response alternativeChallenge = null
 
AuthenticationProcessor processor
 
AuthenticationFlowModel flow
 

静的非公開変数類

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

詳解

著者
Marek Posolda

構築子と解体子

◆ ClientAuthenticationFlow()

org.keycloak.authentication.ClientAuthenticationFlow.ClientAuthenticationFlow ( AuthenticationProcessor  processor,
AuthenticationFlowModel  flow 
)
inline
45  {
46  this.processor = processor;
47  this.flow = flow;
48  }
AuthenticationFlowModel flow
Definition: ClientAuthenticationFlow.java:43
AuthenticationProcessor processor
Definition: ClientAuthenticationFlow.java:42

関数詳解

◆ findExecutionsToRun()

List<AuthenticationExecutionModel> org.keycloak.authentication.ClientAuthenticationFlow.findExecutionsToRun ( )
inlineprotected
104  {
105  List<AuthenticationExecutionModel> executions = processor.getRealm().getAuthenticationExecutions(flow.getId());
106  List<AuthenticationExecutionModel> executionsToRun = new ArrayList<>();
107 
108  for (AuthenticationExecutionModel execution : executions) {
109  if (execution.isRequired()) {
110  executionsToRun = Arrays.asList(execution);
111  break;
112  }
113 
114  if (execution.isAlternative()) {
115  executionsToRun.add(execution);
116  }
117  }
118 
119  if (logger.isTraceEnabled()) {
120  List<String> exIds = new ArrayList<>();
121  for (AuthenticationExecutionModel execution : executionsToRun) {
122  exIds.add(execution.getId());
123  }
124  logger.tracef("Using executions for client authentication: %s", exIds.toString());
125  }
126 
127  return executionsToRun;
128  }
static final Logger logger
Definition: ClientAuthenticationFlow.java:39
AuthenticationFlowModel flow
Definition: ClientAuthenticationFlow.java:43
AuthenticationProcessor processor
Definition: ClientAuthenticationFlow.java:42
RealmModel getRealm()
Definition: AuthenticationProcessor.java:128

◆ processAction()

Response org.keycloak.authentication.ClientAuthenticationFlow.processAction ( String  actionExecution)
inline
51  {
52  throw new IllegalStateException("Not supposed to be invoked");
53  }

◆ processFlow()

Response org.keycloak.authentication.ClientAuthenticationFlow.processFlow ( )
inline
56  {
57  List<AuthenticationExecutionModel> executions = findExecutionsToRun();
58 
59  for (AuthenticationExecutionModel model : executions) {
60  ClientAuthenticatorFactory factory = (ClientAuthenticatorFactory) processor.getSession().getKeycloakSessionFactory().getProviderFactory(ClientAuthenticator.class, model.getAuthenticator());
61  if (factory == null) {
62  throw new AuthenticationFlowException("Could not find ClientAuthenticatorFactory for: " + model.getAuthenticator(), AuthenticationFlowError.INTERNAL_ERROR);
63  }
64  ClientAuthenticator authenticator = factory.create();
65  logger.debugv("client authenticator: {0}", factory.getId());
66 
67  AuthenticationProcessor.Result context = processor.createClientAuthenticatorContext(model, authenticator, executions);
68  authenticator.authenticateClient(context);
69 
70  ClientModel client = processor.getClient();
71  if (client != null) {
72  String expectedClientAuthType = client.getClientAuthenticatorType();
73 
74  // Fallback to secret just in case (for backwards compatibility)
75  if (expectedClientAuthType == null) {
76  expectedClientAuthType = KeycloakModelUtils.getDefaultClientAuthenticatorType();
77  ServicesLogger.LOGGER.authMethodFallback(client.getClientId(), expectedClientAuthType);
78  }
79 
80  // Check if client authentication matches
81  if (factory.getId().equals(expectedClientAuthType)) {
82  Response response = processResult(context);
83  if (response != null) return response;
84 
85  if (!context.getStatus().equals(FlowStatus.SUCCESS)) {
86  throw new AuthenticationFlowException("Expected success, but for an unknown reason the status was " + context.getStatus(), AuthenticationFlowError.INTERNAL_ERROR);
87  }
88 
89  logger.debugv("Client {0} authenticated by {1}", client.getClientId(), factory.getId());
90  processor.getEvent().detail(Details.CLIENT_AUTH_METHOD, factory.getId());
91  return null;
92  }
93  }
94  }
95 
96  // Check if any alternative challenge was identified
97  if (alternativeChallenge != null) {
98  processor.getEvent().error(Errors.INVALID_CLIENT);
99  return alternativeChallenge;
100  }
101  throw new AuthenticationFlowException("Invalid client credentials", AuthenticationFlowError.INVALID_CREDENTIALS);
102  }
static final Logger logger
Definition: ClientAuthenticationFlow.java:39
AuthenticationProcessor.Result createClientAuthenticatorContext(AuthenticationExecutionModel model, ClientAuthenticator clientAuthenticator, List< AuthenticationExecutionModel > executions)
Definition: AuthenticationProcessor.java:1020
List< AuthenticationExecutionModel > findExecutionsToRun()
Definition: ClientAuthenticationFlow.java:104
KeycloakSession getSession()
Definition: AuthenticationProcessor.java:156
Response processResult(AuthenticationProcessor.Result result)
Definition: ClientAuthenticationFlow.java:130
Response authenticateClient()
Definition: AuthenticationProcessor.java:784
ClientModel getClient()
Definition: AuthenticationProcessor.java:132
Response alternativeChallenge
Definition: ClientAuthenticationFlow.java:41
EventBuilder getEvent()
Definition: AuthenticationProcessor.java:235
AuthenticationProcessor processor
Definition: ClientAuthenticationFlow.java:42

◆ processResult()

Response org.keycloak.authentication.ClientAuthenticationFlow.processResult ( AuthenticationProcessor.Result  result)
inlineprotected
130  {
131  AuthenticationExecutionModel execution = result.getExecution();
132  FlowStatus status = result.getStatus();
133 
134  logger.debugv("client authenticator {0}: {1}", status.toString(), execution.getAuthenticator());
135 
136  if (status == FlowStatus.SUCCESS) {
137  return null;
138  }
139 
140  if (status == FlowStatus.FAILED) {
141  if (result.getChallenge() != null) {
142  return sendChallenge(result, execution);
143  } else {
144  throw new AuthenticationFlowException(result.getError());
145  }
146  } else if (status == FlowStatus.FORCE_CHALLENGE) {
147  return sendChallenge(result, execution);
148  } else if (status == FlowStatus.CHALLENGE) {
149 
150  // Make sure the first priority alternative challenge is used
151  if (alternativeChallenge == null) {
152  alternativeChallenge = result.getChallenge();
153  }
154  return sendChallenge(result, execution);
155  } else if (status == FlowStatus.FAILURE_CHALLENGE) {
156  return sendChallenge(result, execution);
157  } else {
158  ServicesLogger.LOGGER.unknownResultStatus();
159  throw new AuthenticationFlowException(AuthenticationFlowError.INTERNAL_ERROR);
160  }
161  }
static final Logger logger
Definition: ClientAuthenticationFlow.java:39
Response sendChallenge(AuthenticationProcessor.Result result, AuthenticationExecutionModel execution)
Definition: ClientAuthenticationFlow.java:163
Response alternativeChallenge
Definition: ClientAuthenticationFlow.java:41

◆ sendChallenge()

Response org.keycloak.authentication.ClientAuthenticationFlow.sendChallenge ( AuthenticationProcessor.Result  result,
AuthenticationExecutionModel  execution 
)
inline
163  {
164  logger.debugv("client authenticator: sending challenge for authentication execution {0}", execution.getAuthenticator());
165 
166  if (result.getError() != null) {
167  String errorAsString = result.getError().toString().toLowerCase();
168  result.getEvent().error(errorAsString);
169  } else {
170  if (result.getClient() == null) {
171  result.getEvent().error(Errors.INVALID_CLIENT);
172  } else {
173  result.getEvent().error(Errors.INVALID_CLIENT_CREDENTIALS);
174  }
175  }
176 
177  return result.getChallenge();
178  }
static final Logger logger
Definition: ClientAuthenticationFlow.java:39

メンバ詳解

◆ alternativeChallenge

Response org.keycloak.authentication.ClientAuthenticationFlow.alternativeChallenge = null
package

◆ flow

AuthenticationFlowModel org.keycloak.authentication.ClientAuthenticationFlow.flow
package

◆ logger

final Logger org.keycloak.authentication.ClientAuthenticationFlow.logger = Logger.getLogger(ClientAuthenticationFlow.class)
staticprivate

◆ processor

AuthenticationProcessor org.keycloak.authentication.ClientAuthenticationFlow.processor
package

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