46         if (!
isConfigured(context.getSession(), context.getRealm(), context.getUser())) {
    47             if (context.getExecution().isOptional()) {
    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);
    58             if (context.getUser() != null) {
    59                 context.getEvent().user(context.getUser());
    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);
    66         boolean valid = context.getSession().userCredentialManager().isValid(context.getRealm(), context.getUser(), UserCredentialModel.otp(context.getRealm().getOTPPolicy().getType(), otp));
    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);
 Response errorResponse(int status, String error, String errorDescription)
Definition: AbstractDirectGrantAuthenticator.java:36
boolean isConfigured(KeycloakSession session, RealmModel realm, UserModel user)
Definition: ValidateOTP.java:88
String retrieveOTP(AuthenticationFlowContext context)
Definition: ValidateOTP.java:144