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

公開メンバ関数

 TestProvider (OAuth2IdentityProviderConfig config)
 
Object callback (RealmModel realm, AuthenticationCallback callback, EventBuilder event)
 
Response performLogin (AuthenticationRequest request)
 
Response retrieveToken (KeycloakSession session, FederatedIdentityModel identity)
 
getConfig ()
 
Response exchangeFromToken (UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject, MultivaluedMap< String, String > params)
 
BrokeredIdentityContext getFederatedIdentity (String response)
 
String getJsonProperty (JsonNode jsonNode, String name)
 
JsonNode asJsonNode (String json) throws IOException
 
void authenticationFinished (AuthenticationSessionModel authSession, BrokeredIdentityContext context)
 
boolean isIssuer (String issuer, MultivaluedMap< String, String > params)
 
final BrokeredIdentityContext exchangeExternal (EventBuilder event, MultivaluedMap< String, String > params)
 
void exchangeExternalComplete (UserSessionModel userSession, BrokeredIdentityContext context, MultivaluedMap< String, String > params)
 

静的公開変数類

static final String OAUTH2_GRANT_TYPE_REFRESH_TOKEN = "refresh_token"
 
static final String OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE = "authorization_code"
 
static final String FEDERATED_REFRESH_TOKEN = "FEDERATED_REFRESH_TOKEN"
 
static final String FEDERATED_TOKEN_EXPIRATION = "FEDERATED_TOKEN_EXPIRATION"
 
static final String ACCESS_DENIED = "access_denied"
 
static final String OAUTH2_PARAMETER_ACCESS_TOKEN = "access_token"
 
static final String OAUTH2_PARAMETER_SCOPE = "scope"
 
static final String OAUTH2_PARAMETER_STATE = "state"
 
static final String OAUTH2_PARAMETER_RESPONSE_TYPE = "response_type"
 
static final String OAUTH2_PARAMETER_REDIRECT_URI = "redirect_uri"
 
static final String OAUTH2_PARAMETER_CODE = "code"
 
static final String OAUTH2_PARAMETER_CLIENT_ID = "client_id"
 
static final String OAUTH2_PARAMETER_CLIENT_SECRET = "client_secret"
 
static final String OAUTH2_PARAMETER_GRANT_TYPE = "grant_type"
 

限定公開メンバ関数

String getDefaultScopes ()
 
BrokeredIdentityContext doGetFederatedIdentity (String accessToken)
 
String extractTokenFromResponse (String response, String tokenName)
 
Response hasExternalExchangeToken (EventBuilder event, UserSessionModel tokenUserSession, MultivaluedMap< String, String > params)
 
Response exchangeStoredToken (UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject)
 
Response exchangeSessionToken (UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject)
 
String getAccessTokenResponseParameter ()
 
UriBuilder createAuthorizationUrl (AuthenticationRequest request)
 
String getProfileEndpointForValidation (EventBuilder event)
 
BrokeredIdentityContext extractIdentityFromProfile (EventBuilder event, JsonNode node)
 
BrokeredIdentityContext validateExternalTokenThroughUserInfo (EventBuilder event, String subjectToken, String subjectTokenType)
 
SimpleHttp buildUserInfoRequest (String subjectToken, String userInfoUrl)
 
boolean supportsExternalExchange ()
 
BrokeredIdentityContext exchangeExternalImpl (EventBuilder event, MultivaluedMap< String, String > params)
 
BrokeredIdentityContext exchangeExternalUserInfoValidationOnly (EventBuilder event, MultivaluedMap< String, String > params)
 

静的限定公開変数類

static final Logger logger = Logger.getLogger(AbstractOAuth2IdentityProvider.class)
 
static ObjectMapper mapper = new ObjectMapper()
 

詳解

構築子と解体子

◆ TestProvider()

org.keycloak.test.broker.oidc.AbstractOAuth2IdentityProviderTest.TestProvider.TestProvider ( OAuth2IdentityProviderConfig  config)
inline
139  {
140  super(null, config);
141  }

関数詳解

◆ asJsonNode()

JsonNode org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.asJsonNode ( String  json) throws IOException
inlineinherited
370  {
371  return mapper.readTree(json);
372  }
static ObjectMapper mapper
Definition: AbstractOAuth2IdentityProvider.java:83

◆ authenticationFinished()

void org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.authenticationFinished ( AuthenticationSessionModel  authSession,
BrokeredIdentityContext  context 
)
inlineinherited
377  {
378  String token = (String) context.getContextData().get(FEDERATED_ACCESS_TOKEN);
379  if (token != null) authSession.setUserSessionNote(FEDERATED_ACCESS_TOKEN, token);
380  }

◆ buildUserInfoRequest()

SimpleHttp org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.buildUserInfoRequest ( String  subjectToken,
String  userInfoUrl 
)
inlineprotectedinherited
500  {
501  return SimpleHttp.doGet(userInfoUrl, session)
502  .header("Authorization", "Bearer " + subjectToken);
503  }

◆ callback()

Object org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.callback ( RealmModel  realm,
AuthenticationCallback  callback,
EventBuilder  event 
)
inlineinherited
105  {
106  return new Endpoint(callback, realm, event);
107  }
Object callback(RealmModel realm, AuthenticationCallback callback, EventBuilder event)
Definition: AbstractOAuth2IdentityProvider.java:105

◆ createAuthorizationUrl()

UriBuilder org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.createAuthorizationUrl ( AuthenticationRequest  request)
inlineprotectedinherited
303  {
304  final UriBuilder uriBuilder = UriBuilder.fromUri(getConfig().getAuthorizationUrl())
305  .queryParam(OAUTH2_PARAMETER_SCOPE, getConfig().getDefaultScope())
306  .queryParam(OAUTH2_PARAMETER_STATE, request.getState().getEncoded())
307  .queryParam(OAUTH2_PARAMETER_RESPONSE_TYPE, "code")
308  .queryParam(OAUTH2_PARAMETER_CLIENT_ID, getConfig().getClientId())
309  .queryParam(OAUTH2_PARAMETER_REDIRECT_URI, request.getRedirectUri());
310 
311  String loginHint = request.getAuthenticationSession().getClientNote(OIDCLoginProtocol.LOGIN_HINT_PARAM);
312  if (getConfig().isLoginHint() && loginHint != null) {
313  uriBuilder.queryParam(OIDCLoginProtocol.LOGIN_HINT_PARAM, loginHint);
314  }
315 
316  if (getConfig().isUiLocales()) {
317  uriBuilder.queryParam(OIDCLoginProtocol.UI_LOCALES_PARAM, session.getContext().resolveLocale(null).toLanguageTag());
318  }
319 
320  String prompt = getConfig().getPrompt();
321  if (prompt == null || prompt.isEmpty()) {
322  prompt = request.getAuthenticationSession().getClientNote(OAuth2Constants.PROMPT);
323  }
324  if (prompt != null) {
325  uriBuilder.queryParam(OAuth2Constants.PROMPT, prompt);
326  }
327 
328  String nonce = request.getAuthenticationSession().getClientNote(OIDCLoginProtocol.NONCE_PARAM);
329  if (nonce == null || nonce.isEmpty()) {
330  nonce = UUID.randomUUID().toString();
331  request.getAuthenticationSession().setClientNote(OIDCLoginProtocol.NONCE_PARAM, nonce);
332  }
333  uriBuilder.queryParam(OIDCLoginProtocol.NONCE_PARAM, nonce);
334 
335  String acr = request.getAuthenticationSession().getClientNote(OAuth2Constants.ACR_VALUES);
336  if (acr != null) {
337  uriBuilder.queryParam(OAuth2Constants.ACR_VALUES, acr);
338  }
339  String forwardParameterConfig = getConfig().getForwardParameters() != null ? getConfig().getForwardParameters(): "";
340  List<String> forwardParameters = Arrays.asList(forwardParameterConfig.split("\\s*,\\s*"));
341  for(String forwardParameter: forwardParameters) {
342  String name = AuthorizationEndpoint.LOGIN_SESSION_NOTE_ADDITIONAL_REQ_PARAMS_PREFIX + forwardParameter.trim();
343  String parameter = request.getAuthenticationSession().getClientNote(name);
344  if(parameter != null && !parameter.isEmpty()) {
345  uriBuilder.queryParam(forwardParameter, parameter);
346  }
347  }
348  return uriBuilder;
349  }
static final String OAUTH2_PARAMETER_RESPONSE_TYPE
Definition: AbstractOAuth2IdentityProvider.java:88
static final String OAUTH2_PARAMETER_STATE
Definition: AbstractOAuth2IdentityProvider.java:87
C getConfig()
Definition: AbstractOAuth2IdentityProvider.java:126
static final String OAUTH2_PARAMETER_SCOPE
Definition: AbstractOAuth2IdentityProvider.java:86
static final String OAUTH2_PARAMETER_CLIENT_ID
Definition: AbstractOAuth2IdentityProvider.java:91
static final String OAUTH2_PARAMETER_REDIRECT_URI
Definition: AbstractOAuth2IdentityProvider.java:89

◆ doGetFederatedIdentity()

BrokeredIdentityContext org.keycloak.test.broker.oidc.AbstractOAuth2IdentityProviderTest.TestProvider.doGetFederatedIdentity ( String  accessToken)
inlineprotected
148  {
149  return new BrokeredIdentityContext(accessToken);
150  };

◆ exchangeExternal()

final BrokeredIdentityContext org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.exchangeExternal ( EventBuilder  event,
MultivaluedMap< String, String >  params 
)
inlineinherited
519  {
520  if (!supportsExternalExchange()) return null;
521  BrokeredIdentityContext context = exchangeExternalImpl(event, params);
522  if (context != null) {
523  context.setIdp(this);
524  context.setIdpConfig(getConfig());
525  }
526  return context;
527  }
C getConfig()
Definition: AbstractOAuth2IdentityProvider.java:126
boolean supportsExternalExchange()
Definition: AbstractOAuth2IdentityProvider.java:506
BrokeredIdentityContext exchangeExternalImpl(EventBuilder event, MultivaluedMap< String, String > params)
Definition: AbstractOAuth2IdentityProvider.java:529

◆ exchangeExternalComplete()

void org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.exchangeExternalComplete ( UserSessionModel  userSession,
BrokeredIdentityContext  context,
MultivaluedMap< String, String >  params 
)
inlineinherited
554  {
555  if (context.getContextData().containsKey(OIDCIdentityProvider.VALIDATED_ID_TOKEN))
556  userSession.setNote(FEDERATED_ACCESS_TOKEN, params.getFirst(OAuth2Constants.SUBJECT_TOKEN));
557  if (context.getContextData().containsKey(OIDCIdentityProvider.VALIDATED_ID_TOKEN))
558  userSession.setNote(OIDCIdentityProvider.FEDERATED_ID_TOKEN, params.getFirst(OAuth2Constants.SUBJECT_TOKEN));
559  userSession.setNote(OIDCIdentityProvider.EXCHANGE_PROVIDER, getConfig().getAlias());
560 
561  }
C getConfig()
Definition: AbstractOAuth2IdentityProvider.java:126

◆ exchangeExternalImpl()

BrokeredIdentityContext org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.exchangeExternalImpl ( EventBuilder  event,
MultivaluedMap< String, String >  params 
)
inlineprotectedinherited
529  {
530  return exchangeExternalUserInfoValidationOnly(event, params);
531 
532  }
BrokeredIdentityContext exchangeExternalUserInfoValidationOnly(EventBuilder event, MultivaluedMap< String, String > params)
Definition: AbstractOAuth2IdentityProvider.java:534

◆ exchangeExternalUserInfoValidationOnly()

BrokeredIdentityContext org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.exchangeExternalUserInfoValidationOnly ( EventBuilder  event,
MultivaluedMap< String, String >  params 
)
inlineprotectedinherited
534  {
535  String subjectToken = params.getFirst(OAuth2Constants.SUBJECT_TOKEN);
536  if (subjectToken == null) {
537  event.detail(Details.REASON, OAuth2Constants.SUBJECT_TOKEN + " param unset");
538  event.error(Errors.INVALID_TOKEN);
539  throw new ErrorResponseException(OAuthErrorException.INVALID_TOKEN, "token not set", Response.Status.BAD_REQUEST);
540  }
541  String subjectTokenType = params.getFirst(OAuth2Constants.SUBJECT_TOKEN_TYPE);
542  if (subjectTokenType == null) {
543  subjectTokenType = OAuth2Constants.ACCESS_TOKEN_TYPE;
544  }
545  if (!OAuth2Constants.ACCESS_TOKEN_TYPE.equals(subjectTokenType)) {
546  event.detail(Details.REASON, OAuth2Constants.SUBJECT_TOKEN_TYPE + " invalid");
547  event.error(Errors.INVALID_TOKEN_TYPE);
548  throw new ErrorResponseException(OAuthErrorException.INVALID_TOKEN, "invalid token type", Response.Status.BAD_REQUEST);
549  }
550  return validateExternalTokenThroughUserInfo(event, subjectToken, subjectTokenType);
551  }
BrokeredIdentityContext validateExternalTokenThroughUserInfo(EventBuilder event, String subjectToken, String subjectTokenType)
Definition: AbstractOAuth2IdentityProvider.java:466

◆ exchangeFromToken()

Response org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.exchangeFromToken ( UriInfo  uriInfo,
EventBuilder  event,
ClientModel  authorizedClient,
UserSessionModel  tokenUserSession,
UserModel  tokenSubject,
MultivaluedMap< String, String >  params 
)
inlineinherited
160  {
161  // check to see if we have a token exchange in session
162  // in other words check to see if this session was created by an external exchange
163  Response tokenResponse = hasExternalExchangeToken(event, tokenUserSession, params);
164  if (tokenResponse != null) return tokenResponse;
165 
166  // going further we only support access token type? Why?
167  String requestedType = params.getFirst(OAuth2Constants.REQUESTED_TOKEN_TYPE);
168  if (requestedType != null && !requestedType.equals(OAuth2Constants.ACCESS_TOKEN_TYPE)) {
169  event.detail(Details.REASON, "requested_token_type unsupported");
170  event.error(Errors.INVALID_REQUEST);
171  return exchangeUnsupportedRequiredType();
172  }
173  if (!getConfig().isStoreToken()) {
174  // if token isn't stored, we need to see if this session has been linked
175  String brokerId = tokenUserSession.getNote(Details.IDENTITY_PROVIDER);
176  brokerId = brokerId == null ? tokenUserSession.getNote(IdentityProvider.EXTERNAL_IDENTITY_PROVIDER) : brokerId;
177  if (brokerId == null || !brokerId.equals(getConfig().getAlias())) {
178  event.detail(Details.REASON, "requested_issuer has not linked");
179  event.error(Errors.INVALID_REQUEST);
180  return exchangeNotLinkedNoStore(uriInfo, authorizedClient, tokenUserSession, tokenSubject);
181  }
182  return exchangeSessionToken(uriInfo, event, authorizedClient, tokenUserSession, tokenSubject);
183  } else {
184  return exchangeStoredToken(uriInfo, event, authorizedClient, tokenUserSession, tokenSubject);
185  }
186  }
Response exchangeStoredToken(UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject)
Definition: AbstractOAuth2IdentityProvider.java:234
Response hasExternalExchangeToken(EventBuilder event, UserSessionModel tokenUserSession, MultivaluedMap< String, String > params)
Definition: AbstractOAuth2IdentityProvider.java:195
C getConfig()
Definition: AbstractOAuth2IdentityProvider.java:126
Response exchangeSessionToken(UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject)
Definition: AbstractOAuth2IdentityProvider.java:261

◆ exchangeSessionToken()

Response org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.exchangeSessionToken ( UriInfo  uriInfo,
EventBuilder  event,
ClientModel  authorizedClient,
UserSessionModel  tokenUserSession,
UserModel  tokenSubject 
)
inlineprotectedinherited
261  {
262  String accessToken = tokenUserSession.getNote(FEDERATED_ACCESS_TOKEN);
263  if (accessToken == null) {
264  event.detail(Details.REASON, "requested_issuer is not linked");
265  event.error(Errors.INVALID_TOKEN);
266  return exchangeTokenExpired(uriInfo, authorizedClient, tokenUserSession, tokenSubject);
267  }
268  AccessTokenResponse tokenResponse = new AccessTokenResponse();
269  tokenResponse.setToken(accessToken);
270  tokenResponse.setIdToken(null);
271  tokenResponse.setRefreshToken(null);
272  tokenResponse.setRefreshExpiresIn(0);
273  tokenResponse.getOtherClaims().clear();
274  tokenResponse.getOtherClaims().put(OAuth2Constants.ISSUED_TOKEN_TYPE, OAuth2Constants.ACCESS_TOKEN_TYPE);
275  tokenResponse.getOtherClaims().put(ACCOUNT_LINK_URL, getLinkingUrl(uriInfo, authorizedClient, tokenUserSession));
276  event.success();
277  return Response.ok(tokenResponse).type(MediaType.APPLICATION_JSON_TYPE).build();
278  }

◆ exchangeStoredToken()

Response org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.exchangeStoredToken ( UriInfo  uriInfo,
EventBuilder  event,
ClientModel  authorizedClient,
UserSessionModel  tokenUserSession,
UserModel  tokenSubject 
)
inlineprotectedinherited
234  {
235  FederatedIdentityModel model = session.users().getFederatedIdentity(tokenSubject, getConfig().getAlias(), authorizedClient.getRealm());
236  if (model == null || model.getToken() == null) {
237  event.detail(Details.REASON, "requested_issuer is not linked");
238  event.error(Errors.INVALID_TOKEN);
239  return exchangeNotLinked(uriInfo, authorizedClient, tokenUserSession, tokenSubject);
240  }
241  String accessToken = extractTokenFromResponse(model.getToken(), getAccessTokenResponseParameter());
242  if (accessToken == null) {
243  model.setToken(null);
244  session.users().updateFederatedIdentity(authorizedClient.getRealm(), tokenSubject, model);
245  event.detail(Details.REASON, "requested_issuer token expired");
246  event.error(Errors.INVALID_TOKEN);
247  return exchangeTokenExpired(uriInfo, authorizedClient, tokenUserSession, tokenSubject);
248  }
249  AccessTokenResponse tokenResponse = new AccessTokenResponse();
250  tokenResponse.setToken(accessToken);
251  tokenResponse.setIdToken(null);
252  tokenResponse.setRefreshToken(null);
253  tokenResponse.setRefreshExpiresIn(0);
254  tokenResponse.getOtherClaims().clear();
255  tokenResponse.getOtherClaims().put(OAuth2Constants.ISSUED_TOKEN_TYPE, OAuth2Constants.ACCESS_TOKEN_TYPE);
256  tokenResponse.getOtherClaims().put(ACCOUNT_LINK_URL, getLinkingUrl(uriInfo, authorizedClient, tokenUserSession));
257  event.success();
258  return Response.ok(tokenResponse).type(MediaType.APPLICATION_JSON_TYPE).build();
259  }
C getConfig()
Definition: AbstractOAuth2IdentityProvider.java:126
String extractTokenFromResponse(String response, String tokenName)
Definition: AbstractOAuth2IdentityProvider.java:130
String getAccessTokenResponseParameter()
Definition: AbstractOAuth2IdentityProvider.java:293

◆ extractIdentityFromProfile()

BrokeredIdentityContext org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.extractIdentityFromProfile ( EventBuilder  event,
JsonNode  node 
)
inlineprotectedinherited
462  {
463  return null;
464  }

◆ extractTokenFromResponse()

String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.extractTokenFromResponse ( String  response,
String  tokenName 
)
inlineprotectedinherited
130  {
131  if(response == null)
132  return null;
133 
134  if (response.startsWith("{")) {
135  try {
136  JsonNode node = mapper.readTree(response);
137  if(node.has(tokenName)){
138  String s = node.get(tokenName).textValue();
139  if(s == null || s.trim().isEmpty())
140  return null;
141  return s;
142  } else {
143  return null;
144  }
145  } catch (IOException e) {
146  throw new IdentityBrokerException("Could not extract token [" + tokenName + "] from response [" + response + "] due: " + e.getMessage(), e);
147  }
148  } else {
149  Matcher matcher = Pattern.compile(tokenName + "=([^&]+)").matcher(response);
150 
151  if (matcher.find()) {
152  return matcher.group(1);
153  }
154  }
155 
156  return null;
157  }
static ObjectMapper mapper
Definition: AbstractOAuth2IdentityProvider.java:83

◆ getAccessTokenResponseParameter()

String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.getAccessTokenResponseParameter ( )
inlineprotectedinherited
293  {
295  }
static final String OAUTH2_PARAMETER_ACCESS_TOKEN
Definition: AbstractOAuth2IdentityProvider.java:85

◆ getConfig()

126  {
127  return super.getConfig();
128  }

◆ getDefaultScopes()

String org.keycloak.test.broker.oidc.AbstractOAuth2IdentityProviderTest.TestProvider.getDefaultScopes ( )
inlineprotected
144  {
145  return "default";
146  }

◆ getFederatedIdentity()

BrokeredIdentityContext org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.getFederatedIdentity ( String  response)
inlineinherited
281  {
282  String accessToken = extractTokenFromResponse(response, getAccessTokenResponseParameter());
283 
284  if (accessToken == null) {
285  throw new IdentityBrokerException("No access token available in OAuth server response: " + response);
286  }
287 
288  BrokeredIdentityContext context = doGetFederatedIdentity(accessToken);
289  context.getContextData().put(FEDERATED_ACCESS_TOKEN, accessToken);
290  return context;
291  }
String extractTokenFromResponse(String response, String tokenName)
Definition: AbstractOAuth2IdentityProvider.java:130
BrokeredIdentityContext doGetFederatedIdentity(String accessToken)
Definition: AbstractOAuth2IdentityProvider.java:298
String getAccessTokenResponseParameter()
Definition: AbstractOAuth2IdentityProvider.java:293

◆ getJsonProperty()

String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.getJsonProperty ( JsonNode  jsonNode,
String  name 
)
inlineinherited

Get JSON property as text. JSON numbers and booleans are converted to text. Empty string is converted to null.

引数
jsonNodeto get property from
nameof property to get
戻り値
string value of the property or null.
358  {
359  if (jsonNode.has(name) && !jsonNode.get(name).isNull()) {
360  String s = jsonNode.get(name).asText();
361  if(s != null && !s.isEmpty())
362  return s;
363  else
364  return null;
365  }
366 
367  return null;
368  }

◆ getProfileEndpointForValidation()

String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.getProfileEndpointForValidation ( EventBuilder  event)
inlineprotectedinherited
456  {
457  event.detail(Details.REASON, "exchange unsupported");
458  event.error(Errors.INVALID_TOKEN);
459  throw new ErrorResponseException(OAuthErrorException.INVALID_TOKEN, "invalid token", Response.Status.BAD_REQUEST);
460  }

◆ hasExternalExchangeToken()

Response org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.hasExternalExchangeToken ( EventBuilder  event,
UserSessionModel  tokenUserSession,
MultivaluedMap< String, String >  params 
)
inlineprotectedinherited

check to see if we have a token exchange in session in other words check to see if this session was created by an external exchange

引数
tokenUserSession
params
戻り値
195  {
196  if (getConfig().getAlias().equals(tokenUserSession.getNote(OIDCIdentityProvider.EXCHANGE_PROVIDER))) {
197 
198  String requestedType = params.getFirst(OAuth2Constants.REQUESTED_TOKEN_TYPE);
199  if ((requestedType == null || requestedType.equals(OAuth2Constants.ACCESS_TOKEN_TYPE))) {
200  String accessToken = tokenUserSession.getNote(FEDERATED_ACCESS_TOKEN);
201  if (accessToken != null) {
202  AccessTokenResponse tokenResponse = new AccessTokenResponse();
203  tokenResponse.setToken(accessToken);
204  tokenResponse.setIdToken(null);
205  tokenResponse.setRefreshToken(null);
206  tokenResponse.setRefreshExpiresIn(0);
207  tokenResponse.setExpiresIn(0);
208  tokenResponse.getOtherClaims().clear();
209  tokenResponse.getOtherClaims().put(OAuth2Constants.ISSUED_TOKEN_TYPE, OAuth2Constants.ACCESS_TOKEN_TYPE);
210  event.success();
211  return Response.ok(tokenResponse).type(MediaType.APPLICATION_JSON_TYPE).build();
212  }
213  } else if (OAuth2Constants.ID_TOKEN_TYPE.equals(requestedType)) {
214  String idToken = tokenUserSession.getNote(OIDCIdentityProvider.FEDERATED_ID_TOKEN);
215  if (idToken != null) {
216  AccessTokenResponse tokenResponse = new AccessTokenResponse();
217  tokenResponse.setToken(null);
218  tokenResponse.setIdToken(idToken);
219  tokenResponse.setRefreshToken(null);
220  tokenResponse.setRefreshExpiresIn(0);
221  tokenResponse.setExpiresIn(0);
222  tokenResponse.getOtherClaims().clear();
223  tokenResponse.getOtherClaims().put(OAuth2Constants.ISSUED_TOKEN_TYPE, OAuth2Constants.ID_TOKEN_TYPE);
224  event.success();
225  return Response.ok(tokenResponse).type(MediaType.APPLICATION_JSON_TYPE).build();
226  }
227 
228  }
229 
230  }
231  return null;
232  }
C getConfig()
Definition: AbstractOAuth2IdentityProvider.java:126

◆ isIssuer()

boolean org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.isIssuer ( String  issuer,
MultivaluedMap< String, String >  params 
)
inlineinherited
511  {
512  if (!supportsExternalExchange()) return false;
513  String requestedIssuer = params.getFirst(OAuth2Constants.SUBJECT_ISSUER);
514  if (requestedIssuer == null) requestedIssuer = issuer;
515  return requestedIssuer.equals(getConfig().getAlias());
516  }
C getConfig()
Definition: AbstractOAuth2IdentityProvider.java:126
boolean supportsExternalExchange()
Definition: AbstractOAuth2IdentityProvider.java:506

◆ performLogin()

Response org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.performLogin ( AuthenticationRequest  request)
inlineinherited
110  {
111  try {
112  URI authorizationUrl = createAuthorizationUrl(request).build();
113 
114  return Response.seeOther(authorizationUrl).build();
115  } catch (Exception e) {
116  throw new IdentityBrokerException("Could not create authentication request.", e);
117  }
118  }
UriBuilder createAuthorizationUrl(AuthenticationRequest request)
Definition: AbstractOAuth2IdentityProvider.java:303

◆ retrieveToken()

Response org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.retrieveToken ( KeycloakSession  session,
FederatedIdentityModel  identity 
)
inlineinherited
121  {
122  return Response.ok(identity.getToken()).build();
123  }

◆ supportsExternalExchange()

boolean org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.supportsExternalExchange ( )
inlineprotectedinherited
506  {
507  return false;
508  }

◆ validateExternalTokenThroughUserInfo()

BrokeredIdentityContext org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.validateExternalTokenThroughUserInfo ( EventBuilder  event,
String  subjectToken,
String  subjectTokenType 
)
inlineprotectedinherited
466  {
467  event.detail("validation_method", "user info");
468  SimpleHttp.Response response = null;
469  int status = 0;
470  try {
471  String userInfoUrl = getProfileEndpointForValidation(event);
472  response = buildUserInfoRequest(subjectToken, userInfoUrl).asResponse();
473  status = response.getStatus();
474  } catch (IOException e) {
475  logger.debug("Failed to invoke user info for external exchange", e);
476  }
477  if (status != 200) {
478  logger.debug("Failed to invoke user info status: " + status);
479  event.detail(Details.REASON, "user info call failure");
480  event.error(Errors.INVALID_TOKEN);
481  throw new ErrorResponseException(OAuthErrorException.INVALID_TOKEN, "invalid token", Response.Status.BAD_REQUEST);
482  }
483  JsonNode profile = null;
484  try {
485  profile = response.asJson();
486  } catch (IOException e) {
487  event.detail(Details.REASON, "user info call failure");
488  event.error(Errors.INVALID_TOKEN);
489  throw new ErrorResponseException(OAuthErrorException.INVALID_TOKEN, "invalid token", Response.Status.BAD_REQUEST);
490  }
491  BrokeredIdentityContext context = extractIdentityFromProfile(event, profile);
492  if (context.getId() == null) {
493  event.detail(Details.REASON, "user info call failure");
494  event.error(Errors.INVALID_TOKEN);
495  throw new ErrorResponseException(OAuthErrorException.INVALID_TOKEN, "invalid token", Response.Status.BAD_REQUEST);
496  }
497  return context;
498  }
String getProfileEndpointForValidation(EventBuilder event)
Definition: AbstractOAuth2IdentityProvider.java:456
static final Logger logger
Definition: AbstractOAuth2IdentityProvider.java:75
BrokeredIdentityContext extractIdentityFromProfile(EventBuilder event, JsonNode node)
Definition: AbstractOAuth2IdentityProvider.java:462
SimpleHttp buildUserInfoRequest(String subjectToken, String userInfoUrl)
Definition: AbstractOAuth2IdentityProvider.java:500

メンバ詳解

◆ ACCESS_DENIED

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.ACCESS_DENIED = "access_denied"
staticinherited

◆ FEDERATED_REFRESH_TOKEN

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.FEDERATED_REFRESH_TOKEN = "FEDERATED_REFRESH_TOKEN"
staticinherited

◆ FEDERATED_TOKEN_EXPIRATION

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.FEDERATED_TOKEN_EXPIRATION = "FEDERATED_TOKEN_EXPIRATION"
staticinherited

◆ logger

final Logger org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.logger = Logger.getLogger(AbstractOAuth2IdentityProvider.class)
staticprotectedinherited

◆ mapper

ObjectMapper org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.mapper = new ObjectMapper()
staticprotectedinherited

◆ OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE = "authorization_code"
staticinherited

◆ OAUTH2_GRANT_TYPE_REFRESH_TOKEN

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_GRANT_TYPE_REFRESH_TOKEN = "refresh_token"
staticinherited

◆ OAUTH2_PARAMETER_ACCESS_TOKEN

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_PARAMETER_ACCESS_TOKEN = "access_token"
staticinherited

◆ OAUTH2_PARAMETER_CLIENT_ID

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_PARAMETER_CLIENT_ID = "client_id"
staticinherited

◆ OAUTH2_PARAMETER_CLIENT_SECRET

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_PARAMETER_CLIENT_SECRET = "client_secret"
staticinherited

◆ OAUTH2_PARAMETER_CODE

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_PARAMETER_CODE = "code"
staticinherited

◆ OAUTH2_PARAMETER_GRANT_TYPE

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_PARAMETER_GRANT_TYPE = "grant_type"
staticinherited

◆ OAUTH2_PARAMETER_REDIRECT_URI

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_PARAMETER_REDIRECT_URI = "redirect_uri"
staticinherited

◆ OAUTH2_PARAMETER_RESPONSE_TYPE

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_PARAMETER_RESPONSE_TYPE = "response_type"
staticinherited

◆ OAUTH2_PARAMETER_SCOPE

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_PARAMETER_SCOPE = "scope"
staticinherited

◆ OAUTH2_PARAMETER_STATE

final String org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider< C extends OAuth2IdentityProviderConfig >.OAUTH2_PARAMETER_STATE = "state"
staticinherited

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