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

公開メンバ関数

 IdpVerifyAccountLinkActionTokenHandler ()
 
Predicate<? super IdpVerifyAccountLinkActionToken > [] getVerifiers (ActionTokenContext< IdpVerifyAccountLinkActionToken > tokenContext)
 
Response handleToken (IdpVerifyAccountLinkActionToken token, ActionTokenContext< IdpVerifyAccountLinkActionToken > tokenContext)
 
ActionTokenHandler< T > create (KeycloakSession session)
 
void init (Scope config)
 
void postInit (KeycloakSessionFactory factory)
 
String getId ()
 
void close ()
 
Class< T > getTokenClass ()
 
EventType eventType ()
 
String getDefaultErrorMessage ()
 
String getDefaultEventError ()
 
String getAuthenticationSessionIdFromToken (T token, ActionTokenContext< T > tokenContext, AuthenticationSessionModel currentAuthSession)
 
AuthenticationSessionModel startFreshAuthenticationSession (T token, ActionTokenContext< T > tokenContext)
 
boolean canUseTokenRepeatedly (T token, ActionTokenContext< T > tokenContext)
 
Response handleToken (T token, ActionTokenContext< T > tokenContext)
 
default Predicate<? super T > [] getVerifiers (ActionTokenContext< T > tokenContext)
 

詳解

Action token handler for verification of e-mail address.

著者
hmlnarik

構築子と解体子

◆ IdpVerifyAccountLinkActionTokenHandler()

org.keycloak.authentication.actiontoken.idpverifyemail.IdpVerifyAccountLinkActionTokenHandler.IdpVerifyAccountLinkActionTokenHandler ( )
inline
48  {
49  super(
50  IdpVerifyAccountLinkActionToken.TOKEN_TYPE,
51  IdpVerifyAccountLinkActionToken.class,
52  Messages.STALE_CODE,
55  );
56  }
String INVALID_TOKEN
Definition: Errors.java:48
IDENTITY_PROVIDER_LINK_ACCOUNT
Definition: EventType.java:95
Definition: Errors.java:23
Definition: EventType.java:23

関数詳解

◆ canUseTokenRepeatedly()

boolean org.keycloak.authentication.actiontoken.AbstractActionTokenHander< T extends JsonWebToken >.canUseTokenRepeatedly ( token,
ActionTokenContext< T >  tokenContext 
)
inlineinherited
102  {
103  return true;
104  }

◆ close()

66  {
67  }

◆ create()

48  {
49  return this;
50  }

◆ eventType()

75  {
76  return this.defaultEventType;
77  }
final EventType defaultEventType
Definition: AbstractActionTokenHander.java:36

◆ getAuthenticationSessionIdFromToken()

String org.keycloak.authentication.actiontoken.AbstractActionTokenHander< T extends JsonWebToken >.getAuthenticationSessionIdFromToken ( token,
ActionTokenContext< T >  tokenContext,
AuthenticationSessionModel  currentAuthSession 
)
inlineinherited
90  {
91  return token instanceof DefaultActionToken ? ((DefaultActionToken) token).getCompoundAuthenticationSessionId() : null;
92  }

◆ getDefaultErrorMessage()

String org.keycloak.authentication.actiontoken.AbstractActionTokenHander< T extends JsonWebToken >.getDefaultErrorMessage ( )
inlineinherited
80  {
81  return this.defaultErrorMessage;
82  }
final String defaultErrorMessage
Definition: AbstractActionTokenHander.java:35

◆ getDefaultEventError()

String org.keycloak.authentication.actiontoken.AbstractActionTokenHander< T extends JsonWebToken >.getDefaultEventError ( )
inlineinherited
85  {
86  return this.defaultEventError;
87  }
final String defaultEventError
Definition: AbstractActionTokenHander.java:37

◆ getId()

61  {
62  return this.id;
63  }
final String id
Definition: AbstractActionTokenHander.java:33

◆ getTokenClass()

Class<T> org.keycloak.authentication.actiontoken.AbstractActionTokenHander< T extends JsonWebToken >.getTokenClass ( )
inlineinherited
70  {
71  return this.tokenClass;
72  }
final Class< T > tokenClass
Definition: AbstractActionTokenHander.java:34

◆ getVerifiers() [1/2]

Predicate<? super IdpVerifyAccountLinkActionToken> [] org.keycloak.authentication.actiontoken.idpverifyemail.IdpVerifyAccountLinkActionTokenHandler.getVerifiers ( ActionTokenContext< IdpVerifyAccountLinkActionToken tokenContext)
inline
59  {
60  return TokenUtils.predicates(
61  );
62  }
static< T extends JsonWebToken > Predicate<? super T > [] predicates(Predicate<? super T >... predicate)
Definition: TokenUtils.java:82

◆ getVerifiers() [2/2]

default Predicate<? super T> [] org.keycloak.authentication.actiontoken.ActionTokenHandler< T extends JsonWebToken >.getVerifiers ( ActionTokenContext< T >  tokenContext)
inlineinherited

Returns an array of verifiers that are tested prior to handling the token. All verifiers have to pass successfully for token to be handled. The returned array must not be

null

.

引数
tokenContext
戻り値
Verifiers or an empty array. The returned array must not be
null
.
60  {
61  return new Predicate[] {};
62  }

◆ handleToken() [1/2]

Response org.keycloak.authentication.actiontoken.ActionTokenHandler< T extends JsonWebToken >.handleToken ( token,
ActionTokenContext< T >  tokenContext 
)
inherited

Performs the action as per the token details. This method is only called if all verifiers returned in handleToken succeed.

引数
token
tokenContext
戻り値

◆ handleToken() [2/2]

Response org.keycloak.authentication.actiontoken.idpverifyemail.IdpVerifyAccountLinkActionTokenHandler.handleToken ( IdpVerifyAccountLinkActionToken  token,
ActionTokenContext< IdpVerifyAccountLinkActionToken tokenContext 
)
inline
65  {
67  EventBuilder event = tokenContext.getEvent();
68  final UriInfo uriInfo = tokenContext.getUriInfo();
69  final RealmModel realm = tokenContext.getRealm();
70  final KeycloakSession session = tokenContext.getSession();
71 
73  .detail(Details.EMAIL, user.getEmail())
74  .detail(Details.IDENTITY_PROVIDER, token.getIdentityProviderAlias())
75  .detail(Details.IDENTITY_PROVIDER_USERNAME, token.getIdentityProviderUsername())
76  .success();
77 
78  AuthenticationSessionModel authSession = tokenContext.getAuthenticationSession();
79  if (tokenContext.isAuthenticationSessionFresh()) {
80  token.setOriginalCompoundAuthenticationSessionId(token.getCompoundAuthenticationSessionId());
81 
82  String authSessionEncodedId = AuthenticationSessionCompoundId.fromAuthSession(authSession).getEncodedId();
83  token.setCompoundAuthenticationSessionId(authSessionEncodedId);
84  UriBuilder builder = Urls.actionTokenBuilder(uriInfo.getBaseUri(), token.serialize(session, realm, uriInfo),
85  authSession.getClient().getClientId(), authSession.getTabId());
86  String confirmUri = builder.build(realm.getName()).toString();
87 
88  return session.getProvider(LoginFormsProvider.class)
89  .setAuthenticationSession(authSession)
90  .setSuccess(Messages.CONFIRM_ACCOUNT_LINKING, token.getIdentityProviderUsername(), token.getIdentityProviderAlias())
91  .setAttribute(Constants.TEMPLATE_ATTR_ACTION_URI, confirmUri)
92  .createInfoPage();
93  }
94 
95  // verify user email as we know it is valid as this entry point would never have gotten here.
96  user.setEmailVerified(true);
97 
98  if (token.getOriginalCompoundAuthenticationSessionId() != null) {
100  asm.removeAuthenticationSession(realm, authSession, true);
101 
102  AuthenticationSessionCompoundId compoundId = AuthenticationSessionCompoundId.encoded(token.getOriginalCompoundAuthenticationSessionId());
103  ClientModel originalClient = realm.getClientById(compoundId.getClientUUID());
104  authSession = asm.getAuthenticationSessionByIdAndClient(realm, compoundId.getRootSessionId(), originalClient, compoundId.getTabId());
105 
106  if (authSession != null) {
107  authSession.setAuthNote(IdpEmailVerificationAuthenticator.VERIFY_ACCOUNT_IDP_USERNAME, token.getIdentityProviderUsername());
108  } else {
109 
111  compoundId,
112  Collections.singletonMap(IdpEmailVerificationAuthenticator.VERIFY_ACCOUNT_IDP_USERNAME, token.getIdentityProviderUsername())
113  );
114  }
115 
116  return session.getProvider(LoginFormsProvider.class)
117  .setAuthenticationSession(authSession)
118  .setSuccess(Messages.IDENTITY_PROVIDER_LINK_SUCCESS, token.getIdentityProviderAlias(), token.getIdentityProviderUsername())
119  .setAttribute(Constants.SKIP_LINK, true)
120  .createInfoPage();
121  }
122 
123  authSession.setAuthNote(IdpEmailVerificationAuthenticator.VERIFY_ACCOUNT_IDP_USERNAME, token.getIdentityProviderUsername());
124 
125  return tokenContext.brokerFlow(null, null, authSession.getAuthNote(AuthenticationProcessor.CURRENT_FLOW_PATH));
126  }
Definition: UserModel.java:30
Definition: AuthenticationSessionCompoundId.java:27
String IDENTITY_PROVIDER_USERNAME
Definition: Details.java:37
String getTabId()
Definition: AuthenticationSessionCompoundId.java:68
AuthenticationSessionProvider authenticationSessions()
static AuthenticationSessionCompoundId fromAuthSession(AuthenticationSessionModel authSession)
Definition: AuthenticationSessionCompoundId.java:31
String getClientUUID()
Definition: AuthenticationSessionCompoundId.java:72
String IDENTITY_PROVIDER
Definition: Details.java:36
static UriBuilder actionTokenBuilder(URI baseUri, String tokenString, String clientId, String tabId)
Definition: Urls.java:190
void updateNonlocalSessionAuthNotes(AuthenticationSessionCompoundId compoundId, Map< String, String > authNotesFragment)
void setAuthNote(String name, String value)
Definition: AuthenticationProcessor.java:72
Definition: AuthenticationSessionManager.java:42
IDENTITY_PROVIDER_LINK_ACCOUNT
Definition: EventType.java:95
String getRootSessionId()
Definition: AuthenticationSessionCompoundId.java:64
ClientModel getClientById(String id)
UriInfo getUriInfo()
Definition: ActionTokenContext.java:97
static final String CURRENT_FLOW_PATH
Definition: AuthenticationProcessor.java:75
EventBuilder getEvent()
Definition: ActionTokenContext.java:81
< T extends Provider > T getProvider(Class< T > clazz)
void setEmailVerified(boolean verified)
Definition: Urls.java:36
String EMAIL
Definition: Details.java:25
Definition: ClientModel.java:27
AuthenticationSessionModel getAuthenticationSession()
Definition: ActionTokenContext.java:134
KeycloakSession getSession()
Definition: ActionTokenContext.java:89
Definition: AuthenticationSessionModel.java:33
Definition: EventBuilder.java:37
Response brokerFlow(String authSessionId, String code, String flowPath)
Definition: ActionTokenContext.java:163
Definition: Details.java:23
static AuthenticationSessionCompoundId encoded(String encodedId)
Definition: AuthenticationSessionCompoundId.java:40
String getEncodedId()
Definition: AuthenticationSessionCompoundId.java:76
RealmModel getRealm()
Definition: ActionTokenContext.java:93
boolean isAuthenticationSessionFresh()
Definition: ActionTokenContext.java:130
Definition: EventType.java:23
Definition: KeycloakSession.java:32
Definition: RealmModel.java:34

◆ init()

void org.keycloak.authentication.actiontoken.AbstractActionTokenHander< T extends JsonWebToken >.init ( Scope  config)
inlineinherited
53  {
54  }

◆ postInit()

57  {
58  }

◆ startFreshAuthenticationSession()

AuthenticationSessionModel org.keycloak.authentication.actiontoken.AbstractActionTokenHander< T extends JsonWebToken >.startFreshAuthenticationSession ( token,
ActionTokenContext< T >  tokenContext 
)
inlineinherited
95  {
96  AuthenticationSessionModel authSession = tokenContext.createAuthenticationSessionForClient(token.getIssuedFor());
97  authSession.setAuthNote(AuthenticationManager.END_AFTER_REQUIRED_ACTIONS, "true");
98  return authSession;
99  }

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