diff --git a/keycloak/sms-provider/src/main/java/org/sunbird/keycloak/login/phone/AbstractPhoneFormAuthenticator.java b/keycloak/sms-provider/src/main/java/org/sunbird/keycloak/login/phone/AbstractPhoneFormAuthenticator.java
index 5e91e2c4..56739e68 100755
--- a/keycloak/sms-provider/src/main/java/org/sunbird/keycloak/login/phone/AbstractPhoneFormAuthenticator.java
+++ b/keycloak/sms-provider/src/main/java/org/sunbird/keycloak/login/phone/AbstractPhoneFormAuthenticator.java
@@ -18,18 +18,15 @@
package org.sunbird.keycloak.login.phone;
import org.jboss.logging.Logger;
-import org.keycloak.authentication.AbstractFormAuthenticator;
import org.keycloak.authentication.AuthenticationFlowContext;
import org.keycloak.authentication.AuthenticationFlowError;
-import org.keycloak.credential.CredentialInput;
+import org.keycloak.authentication.authenticators.browser.AbstractUsernameFormAuthenticator;
import org.keycloak.events.Details;
import org.keycloak.events.Errors;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.ModelDuplicateException;
-import org.keycloak.models.UserCredentialModel;
import org.keycloak.models.UserModel;
import org.keycloak.models.utils.KeycloakModelUtils;
-import org.keycloak.representations.idm.CredentialRepresentation;
import org.keycloak.services.ServicesLogger;
import org.keycloak.services.managers.AuthenticationManager;
import org.keycloak.services.messages.Messages;
@@ -37,84 +34,12 @@
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-import java.util.LinkedList;
import java.util.List;
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-public abstract class AbstractPhoneFormAuthenticator extends AbstractFormAuthenticator {
+public abstract class AbstractPhoneFormAuthenticator extends AbstractUsernameFormAuthenticator {
private static final Logger logger = Logger.getLogger(AbstractPhoneFormAuthenticator.class);
- public static final String REGISTRATION_FORM_ACTION = "registration_form";
- public static final String ATTEMPTED_USERNAME = "ATTEMPTED_USERNAME";
-
- @Override
- public void action(AuthenticationFlowContext context) {
-
- }
-
- protected Response invalidUser(AuthenticationFlowContext context) {
- return context.form()
- .setError(Messages.INVALID_USER)
- .createLogin();
- }
-
- protected Response disabledUser(AuthenticationFlowContext context) {
- return context.form()
- .setError(Messages.ACCOUNT_DISABLED).createLogin();
- }
-
- protected Response temporarilyDisabledUser(AuthenticationFlowContext context) {
- return context.form()
- .setError(Messages.INVALID_USER).createLogin();
- }
-
- protected Response invalidCredentials(AuthenticationFlowContext context) {
- return context.form()
- .setError(Messages.INVALID_USER).createLogin();
- }
-
- protected Response setDuplicateUserChallenge(AuthenticationFlowContext context, String eventError, String loginFormError, AuthenticationFlowError authenticatorError) {
- context.getEvent().error(eventError);
- Response challengeResponse = context.form()
- .setError(loginFormError).createLogin();
- context.failureChallenge(authenticatorError, challengeResponse);
- return challengeResponse;
- }
-
- public boolean invalidUser(AuthenticationFlowContext context, UserModel user) {
- if (user == null) {
- context.getEvent().error(Errors.USER_NOT_FOUND);
- Response challengeResponse = invalidUser(context);
- context.failureChallenge(AuthenticationFlowError.INVALID_USER, challengeResponse);
- return true;
- }
- return false;
- }
-
- public boolean enabledUser(AuthenticationFlowContext context, UserModel user) {
- if (!user.isEnabled()) {
- context.getEvent().user(user);
- context.getEvent().error(Errors.USER_DISABLED);
- Response challengeResponse = disabledUser(context);
- context.failureChallenge(AuthenticationFlowError.USER_DISABLED, challengeResponse);
- return false;
- }
- if (context.getRealm().isBruteForceProtected()) {
- if (context.getProtector().isTemporarilyDisabled(context.getSession(), context.getRealm(), user)) {
- context.getEvent().user(user);
- context.getEvent().error(Errors.USER_TEMPORARILY_DISABLED);
- Response challengeResponse = temporarilyDisabledUser(context);
- context.failureChallenge(AuthenticationFlowError.USER_TEMPORARILY_DISABLED, challengeResponse);
- return false;
- }
- }
- return true;
- }
-
public boolean validateUserAndPassword(AuthenticationFlowContext context, MultivaluedMap inputData) {
String username = inputData.getFirst(AuthenticationManager.FORM_USERNAME);
logger.error("AbstractPhoneFormAuthenticator@validateUserAndPassword - Username -" + username);
@@ -191,20 +116,4 @@ private UserModel getUser(AuthenticationFlowContext context, String username) {
}
}
- public boolean validatePassword(AuthenticationFlowContext context, UserModel user, MultivaluedMap inputData) {
- List credentials = new LinkedList<>();
- String password = inputData.getFirst(CredentialRepresentation.PASSWORD);
- credentials.add(UserCredentialModel.password(password));
- if (password != null && !password.isEmpty() && context.getSession().userCredentialManager().isValid(context.getRealm(), user, credentials)) {
- return true;
- } else {
- context.getEvent().user(user);
- context.getEvent().error(Errors.INVALID_USER_CREDENTIALS);
- Response challengeResponse = invalidCredentials(context);
- context.failureChallenge(AuthenticationFlowError.INVALID_CREDENTIALS, challengeResponse);
- context.clearUser();
- return false;
- }
- }
-
}