Author: ilgrosso
Date: Mon Jul  7 08:40:23 2014
New Revision: 1608365

URL: http://svn.apache.org/r1608365
Log:
[SYNCOPE-531] Changes are fine - provided small optimizations

Modified:
    
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java

Modified: 
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java?rev=1608365&r1=1608364&r2=1608365&view=diff
==============================================================================
--- 
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java
 (original)
+++ 
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java
 Mon Jul  7 08:40:23 2014
@@ -120,13 +120,12 @@ public class SyncopeAuthenticationProvid
                         authentication.getCredentials().toString(),
                         user.getCipherAlgorithm(),
                         user.getPassword());
+
+                updateLoginAttributes(user, authenticated);
             }
         }
 
-        updateLoginAttributes(user, authenticated);
-        
         UsernamePasswordAuthenticationToken token;
-
         if (authenticated) {
             token = new UsernamePasswordAuthenticationToken(
                     authentication.getPrincipal(),
@@ -148,7 +147,6 @@ public class SyncopeAuthenticationProvid
 
             LOG.debug("User {} successfully authenticated, with roles {}",
                     authentication.getPrincipal(), token.getAuthorities());
-
         } else {
             auditManager.audit(
                     AuditElements.EventCategoryType.REST,
@@ -168,31 +166,28 @@ public class SyncopeAuthenticationProvid
 
         return token;
     }
-    
+
     private void updateLoginAttributes(SyncopeUser user, boolean 
authenticated) {
-       
-       if (user != null) {
-               boolean userModified = false;
-               
-               if (authenticated) {
-                       if (Boolean.valueOf(confDAO.find("log.lastlogindate", 
Boolean.toString(true)).getValue())) {
-                               user.setLastLoginDate(new Date());
-                               userModified = true;
-                       }
-                       
-                       if (user.getFailedLogins() != 0) {
-                               user.setFailedLogins(0);
-                               userModified = true;
-                       }
-               } else {
-                       user.setFailedLogins(user.getFailedLogins() + 1);
-                       userModified = true;
-               }
-               
-               if (userModified) {
-                       userDAO.save(user);
-               }
-       }
+        boolean userModified = false;
+
+        if (authenticated) {
+            if (Boolean.valueOf(confDAO.find("log.lastlogindate", 
Boolean.toString(true)).getValue())) {
+                user.setLastLoginDate(new Date());
+                userModified = true;
+            }
+
+            if (user.getFailedLogins() != 0) {
+                user.setFailedLogins(0);
+                userModified = true;
+            }
+        } else {
+            user.setFailedLogins(user.getFailedLogins() + 1);
+            userModified = true;
+        }
+
+        if (userModified) {
+            userDAO.save(user);
+        }
     }
 
     protected boolean authenticate(final String password, final 
CipherAlgorithm cipherAlgorithm,


Reply via email to