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

公開メンバ関数

void authenticate (AuthenticationFlowContext context)
 
boolean requiresUser ()
 
boolean configuredFor (KeycloakSession session, RealmModel realm, UserModel user)
 
void setRequiredActions (KeycloakSession session, RealmModel realm, UserModel user)
 
boolean isUserSetupAllowed ()
 
String getDisplayType ()
 
String getReferenceCategory ()
 
boolean isConfigurable ()
 
AuthenticationExecutionModel.Requirement [] getRequirementChoices ()
 
String getHelpText ()
 
List< ProviderConfigProperty > getConfigProperties ()
 
String getId ()
 
Response errorResponse (int status, String error, String errorDescription)
 
void action (AuthenticationFlowContext context)
 
void close ()
 
Authenticator create (KeycloakSession session)
 
void init (Config.Scope config)
 
void postInit (KeycloakSessionFactory factory)
 

静的公開変数類

static final String PROVIDER_ID = "direct-grant-validate-otp"
 
static final AuthenticationExecutionModel.Requirement [] REQUIREMENT_CHOICES
 

限定公開メンバ関数

String retrieveOTP (AuthenticationFlowContext context)
 

非公開メンバ関数

boolean isConfigured (KeycloakSession session, RealmModel realm, UserModel user)
 

詳解

著者
Bill Burke
バージョン
Revision
1

関数詳解

◆ action()

void org.keycloak.authentication.authenticators.directgrant.AbstractDirectGrantAuthenticator.action ( AuthenticationFlowContext  context)
inlineinherited
42  {
43 
44  }

◆ authenticate()

void org.keycloak.authentication.authenticators.directgrant.ValidateOTP.authenticate ( AuthenticationFlowContext  context)
inline
45  {
46  if (!isConfigured(context.getSession(), context.getRealm(), context.getUser())) {
47  if (context.getExecution().isOptional()) {
48  context.attempted();
49  } else if (context.getExecution().isRequired()) {
50  context.getEvent().error(Errors.INVALID_USER_CREDENTIALS);
51  Response challengeResponse = errorResponse(Response.Status.UNAUTHORIZED.getStatusCode(), "invalid_grant", "Invalid user credentials");
52  context.failure(AuthenticationFlowError.INVALID_USER, challengeResponse);
53  }
54  return;
55  }
56  String otp = retrieveOTP(context);
57  if (otp == null) {
58  if (context.getUser() != null) {
59  context.getEvent().user(context.getUser());
60  }
61  context.getEvent().error(Errors.INVALID_USER_CREDENTIALS);
62  Response challengeResponse = errorResponse(Response.Status.UNAUTHORIZED.getStatusCode(), "invalid_grant", "Invalid user credentials");
63  context.failure(AuthenticationFlowError.INVALID_USER, challengeResponse);
64  return;
65  }
66  boolean valid = context.getSession().userCredentialManager().isValid(context.getRealm(), context.getUser(), UserCredentialModel.otp(context.getRealm().getOTPPolicy().getType(), otp));
67  if (!valid) {
68  context.getEvent().user(context.getUser());
69  context.getEvent().error(Errors.INVALID_USER_CREDENTIALS);
70  Response challengeResponse = errorResponse(Response.Status.UNAUTHORIZED.getStatusCode(), "invalid_grant", "Invalid user credentials");
71  context.failure(AuthenticationFlowError.INVALID_USER, challengeResponse);
72  return;
73  }
74 
75  context.success();
76  }
String retrieveOTP(AuthenticationFlowContext context)
Definition: ValidateOTP.java:144
Response errorResponse(int status, String error, String errorDescription)
Definition: AbstractDirectGrantAuthenticator.java:36
boolean isConfigured(KeycloakSession session, RealmModel realm, UserModel user)
Definition: ValidateOTP.java:88

◆ close()

void org.keycloak.authentication.authenticators.directgrant.AbstractDirectGrantAuthenticator.close ( )
inlineinherited
47  {
48 
49  }

◆ configuredFor()

boolean org.keycloak.authentication.authenticators.directgrant.ValidateOTP.configuredFor ( KeycloakSession  session,
RealmModel  realm,
UserModel  user 
)
inline
84  {
85  return true;
86  }

◆ create()

Authenticator org.keycloak.authentication.authenticators.directgrant.AbstractDirectGrantAuthenticator.create ( KeycloakSession  session)
inlineinherited
52  {
53  return this;
54  }

◆ errorResponse()

Response org.keycloak.authentication.authenticators.directgrant.AbstractDirectGrantAuthenticator.errorResponse ( int  status,
String  error,
String  errorDescription 
)
inlineinherited
36  {
37  OAuth2ErrorRepresentation errorRep = new OAuth2ErrorRepresentation(error, errorDescription);
38  return Response.status(status).entity(errorRep).type(MediaType.APPLICATION_JSON_TYPE).build();
39  }

◆ getConfigProperties()

List<ProviderConfigProperty> org.keycloak.authentication.authenticators.directgrant.ValidateOTP.getConfigProperties ( )
inline
135  {
136  return new LinkedList<>();
137  }

◆ getDisplayType()

String org.keycloak.authentication.authenticators.directgrant.ValidateOTP.getDisplayType ( )
inline
104  {
105  return "OTP";
106  }

◆ getHelpText()

String org.keycloak.authentication.authenticators.directgrant.ValidateOTP.getHelpText ( )
inline
130  {
131  return "Validates the one time password supplied as a 'totp' form parameter in direct grant request";
132  }

◆ getId()

String org.keycloak.authentication.authenticators.directgrant.ValidateOTP.getId ( )
inline
140  {
141  return PROVIDER_ID;
142  }
static final String PROVIDER_ID
Definition: ValidateOTP.java:42

◆ getReferenceCategory()

String org.keycloak.authentication.authenticators.directgrant.ValidateOTP.getReferenceCategory ( )
inline
109  {
110  return null;
111  }

◆ getRequirementChoices()

AuthenticationExecutionModel.Requirement [] org.keycloak.authentication.authenticators.directgrant.ValidateOTP.getRequirementChoices ( )
inline
125  {
126  return REQUIREMENT_CHOICES;
127  }
static final AuthenticationExecutionModel.Requirement [] REQUIREMENT_CHOICES
Definition: ValidateOTP.java:118

◆ init()

void org.keycloak.authentication.authenticators.directgrant.AbstractDirectGrantAuthenticator.init ( Config.Scope  config)
inlineinherited
57  {
58 
59  }

◆ isConfigurable()

boolean org.keycloak.authentication.authenticators.directgrant.ValidateOTP.isConfigurable ( )
inline
114  {
115  return false;
116  }

◆ isConfigured()

boolean org.keycloak.authentication.authenticators.directgrant.ValidateOTP.isConfigured ( KeycloakSession  session,
RealmModel  realm,
UserModel  user 
)
inlineprivate
88  {
89  return session.userCredentialManager().isConfiguredFor(realm, user, realm.getOTPPolicy().getType());
90  }

◆ isUserSetupAllowed()

boolean org.keycloak.authentication.authenticators.directgrant.ValidateOTP.isUserSetupAllowed ( )
inline
98  {
99  return false;
100  }

◆ postInit()

void org.keycloak.authentication.authenticators.directgrant.AbstractDirectGrantAuthenticator.postInit ( KeycloakSessionFactory  factory)
inlineinherited
62  {
63 
64  }

◆ requiresUser()

boolean org.keycloak.authentication.authenticators.directgrant.ValidateOTP.requiresUser ( )
inline
79  {
80  return true;
81  }

◆ retrieveOTP()

String org.keycloak.authentication.authenticators.directgrant.ValidateOTP.retrieveOTP ( AuthenticationFlowContext  context)
inlineprotected
144  {
145  MultivaluedMap<String, String> inputData = context.getHttpRequest().getDecodedFormParameters();
146  return inputData.getFirst(CredentialRepresentation.TOTP);
147  }

◆ setRequiredActions()

void org.keycloak.authentication.authenticators.directgrant.ValidateOTP.setRequiredActions ( KeycloakSession  session,
RealmModel  realm,
UserModel  user 
)
inline
93  {
94 
95  }

メンバ詳解

◆ PROVIDER_ID

final String org.keycloak.authentication.authenticators.directgrant.ValidateOTP.PROVIDER_ID = "direct-grant-validate-otp"
static

◆ REQUIREMENT_CHOICES

final AuthenticationExecutionModel.Requirement [] org.keycloak.authentication.authenticators.directgrant.ValidateOTP.REQUIREMENT_CHOICES
static
初期値:
= {
AuthenticationExecutionModel.Requirement.REQUIRED,
AuthenticationExecutionModel.Requirement.OPTIONAL,
AuthenticationExecutionModel.Requirement.DISABLED
}

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