svn commit: r1817751 - /ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1817751 - /ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java

mbrohl
Author: mbrohl
Date: Mon Dec 11 08:10:16 2017
New Revision: 1817751

URL: http://svn.apache.org/viewvc?rev=1817751&view=rev
Log:
Improved: General refactoring and code improvements, package
org.apache.ofbiz.common.authentication.
(OFBIZ-9875)

Thanks Julian Leichert for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java

Modified: ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java?rev=1817751&r1=1817750&r2=1817751&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthHelper.java Mon Dec 11 08:10:16 2017
@@ -38,13 +38,18 @@ import org.apache.ofbiz.service.LocalDis
 public final class AuthHelper {
 
     private static final String module = AuthHelper.class.getName();
-    private static List<Authenticator> authenticators = new ArrayList<Authenticator>();
+    private static List<Authenticator> authenticators = new ArrayList<>();
     private static boolean authenticatorsLoaded = false;
 
-    private AuthHelper() {}
+    private AuthHelper() {
+    }
 
-    public static boolean authenticate(String username, String password, boolean isServiceAuth) throws AuthenticatorException {
-        if (!authenticatorsLoaded) throw new AuthenticatorException("Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
+    public static boolean authenticate(String username, String password, boolean isServiceAuth)
+            throws AuthenticatorException {
+        if (!authenticatorsLoaded) {
+            throw new AuthenticatorException(
+                    "Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
+        }
         for (Authenticator auth : authenticators) {
             boolean pass = auth.authenticate(username, password, isServiceAuth);
             if (pass) {
@@ -57,14 +62,20 @@ public final class AuthHelper {
     }
 
     public static void logout(String username) throws AuthenticatorException {
-        if (!authenticatorsLoaded) throw new AuthenticatorException("Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
+        if (!authenticatorsLoaded) {
+            throw new AuthenticatorException(
+                    "Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
+        }
         for (Authenticator auth : authenticators) {
             auth.logout(username);
         }
     }
 
     public static void syncUser(String username) throws AuthenticatorException {
-        if (!authenticatorsLoaded) throw new AuthenticatorException("Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
+        if (!authenticatorsLoaded) {
+            throw new AuthenticatorException(
+                    "Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
+        }
         for (Authenticator auth : authenticators) {
             if (auth.isUserSynchronized()) {
                 auth.syncUser(username);
@@ -72,8 +83,12 @@ public final class AuthHelper {
         }
     }
 
-    public static void updatePassword(String username, String password, String newPassword) throws AuthenticatorException {
-        if (!authenticatorsLoaded) throw new AuthenticatorException("Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
+    public static void updatePassword(String username, String password, String newPassword)
+            throws AuthenticatorException {
+        if (!authenticatorsLoaded) {
+            throw new AuthenticatorException(
+                    "Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
+        }
         for (Authenticator auth : authenticators) {
             auth.updatePassword(username, password, newPassword);
         }
@@ -109,9 +124,10 @@ public final class AuthHelper {
         }
     }
 
-    /* Do not move this into a shared global util class; doing so
-     * would mean the method would have to be public, and then it
-     * could be called by any other non-secure source.
+    /*
+     * Do not move this into a shared global util class; doing so would mean the
+     * method would have to be public, and then it could be called by any other
+     * non-secure source.
      */
     private static ClassLoader getContextClassLoader() {
         return AccessController.doPrivileged(