]> git.mxchange.org Git - jjobs-war.git/blobdiff - src/java/org/mxchange/jjobs/validator/password/JobsUserPasswordValidator.java
Please cherry-pick:
[jjobs-war.git] / src / java / org / mxchange / jjobs / validator / password / JobsUserPasswordValidator.java
index 2a901e8f5aaef538b3ea11a436714b381f5bab87..8430d9c600dba75d7330161f536880d2a1de8613 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Roland Häder
+ * Copyright (C) 2016 - 2018 Free Software Foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
 package org.mxchange.jjobs.validator.password;
 
 import java.text.MessageFormat;
-import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.validator.FacesValidator;
-import javax.faces.validator.Validator;
 import javax.faces.validator.ValidatorException;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcoreee.validator.string.BaseStringValidator;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController;
-import org.mxchange.jusercore.container.login.LoginContainer;
-import org.mxchange.jusercore.container.login.UserLoginContainer;
-import org.mxchange.jusercore.model.user.UserUtils;
 
 /**
  * A validator for validating passwords (if they match with stored)
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesValidator (value = "UserPasswordValidator")
-public class JobsUserPasswordValidator extends BaseStringValidator implements Validator {
+@FacesValidator ("UserPasswordValidator")
+public class JobsUserPasswordValidator extends BaseStringValidator {
 
        /**
         * Serial number
         */
        private static final long serialVersionUID = 48_581_795_687_317L;
 
-       /**
-        * Logger instance
-        */
-       @Log
-       private LoggerBeanLocal loggerBeanLocal;
-
-       /**
-        * User login controller
-        */
-       private JobsUserLoginWebSessionController userLoginController;
-
        /**
         * Default constructor
         */
@@ -66,9 +47,6 @@ public class JobsUserPasswordValidator extends BaseStringValidator implements Va
                try {
                        // Get initial context
                        Context context = new InitialContext();
-
-                       // Lookup logger
-                       this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
                } catch (final NamingException ex) {
                        // Continue to throw it
                        throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
@@ -77,26 +55,23 @@ public class JobsUserPasswordValidator extends BaseStringValidator implements Va
 
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
-               // Trace message
-               this.loggerBeanLocal.logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
-
                // The required field
-               String[] requiredFields = {"currentPassword"}; //NOI18N
+               final String[] requiredFields = {"currentPassword"}; //NOI18N
 
                // Pre-validation (example: not null, not a string, empty string ...)
                super.preValidate(context, component, value, requiredFields, false);
 
+               /*
+                * @TODO injection is not working in converters. No, JavaEE is not so super-flexible.
                // value is known to be an entered password, so instance login container
                LoginContainer container = new UserLoginContainer(this.userLoginController.getLoggedInUser(), (String) value);
 
                // Test it here
                if (!UserUtils.ifPasswordMatches(container, this.userLoginController.getLoggedInUser())) {
                        // Password mismatches
-                       throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password mismatching.", "The password the user has entered does not match the stored password.")); //NOI18N
+                       throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, "Password mismatching.", "The password the user has entered does not match the stored password.")); //NOI18N
                }
-
-               // Trace message
-               this.loggerBeanLocal.logTrace("validate: EXIT!"); //NOI18N
+                */
        }
 
 }