Search in sources :

Example 1 with SecretQuestionCredentialModel

use of org.keycloak.examples.authenticator.credential.SecretQuestionCredentialModel in project keycloak by keycloak.

the class SecretQuestionCredentialProvider method isValid.

@Override
public boolean isValid(RealmModel realm, UserModel user, CredentialInput input) {
    if (!(input instanceof UserCredentialModel)) {
        logger.debug("Expected instance of UserCredentialModel for CredentialInput");
        return false;
    }
    if (!input.getType().equals(getType())) {
        return false;
    }
    String challengeResponse = input.getChallengeResponse();
    if (challengeResponse == null) {
        return false;
    }
    CredentialModel credentialModel = getCredentialStore().getStoredCredentialById(realm, user, input.getCredentialId());
    SecretQuestionCredentialModel sqcm = getCredentialFromModel(credentialModel);
    return sqcm.getSecretQuestionSecretData().getAnswer().equals(challengeResponse);
}
Also used : UserCredentialModel(org.keycloak.models.UserCredentialModel) CredentialModel(org.keycloak.credential.CredentialModel) SecretQuestionCredentialModel(org.keycloak.examples.authenticator.credential.SecretQuestionCredentialModel) UserCredentialModel(org.keycloak.models.UserCredentialModel) SecretQuestionCredentialModel(org.keycloak.examples.authenticator.credential.SecretQuestionCredentialModel)

Aggregations

CredentialModel (org.keycloak.credential.CredentialModel)1 SecretQuestionCredentialModel (org.keycloak.examples.authenticator.credential.SecretQuestionCredentialModel)1 UserCredentialModel (org.keycloak.models.UserCredentialModel)1