sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1649766 - in /sling/trunk/bundles/jcr/jackrabbit-usermanager: pom.xml src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java
Date Tue, 06 Jan 2015 10:17:17 GMT
Author: chetanm
Date: Tue Jan  6 10:17:17 2015
New Revision: 1649766

URL: http://svn.apache.org/r1649766
Log:
SLING-3230 - UpdateUserTest integration test fails with Oak

Avoid using reflection instead change the password using newer api

Modified:
    sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml
    sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java

Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml?rev=1649766&r1=1649765&r2=1649766&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/pom.xml Tue Jan  6 10:17:17 2015
@@ -110,7 +110,7 @@
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-api</artifactId>
-            <version>2.2.0</version>
+            <version>2.3.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -160,4 +160,4 @@
         </dependency>
 
     </dependencies>
-</project>
\ No newline at end of file
+</project>

Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java?rev=1649766&r1=1649765&r2=1649766&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java
(original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java
Tue Jan  6 10:17:17 2015
@@ -242,13 +242,13 @@ public class ChangeUserPasswordServlet e
                 "New Password does not match the confirmation password");
         }
 
-        if (oldPassword != null && oldPassword.length() > 0) {
-            // verify old password
-            checkPassword(authorizable, oldPassword);
-        }
-
         try {
-            user.changePassword(newPassword);
+            if (oldPassword != null && oldPassword.length() > 0) {
+                // verify old password
+                user.changePassword(newPassword, oldPassword);
+            } else {
+                user.changePassword(newPassword);
+            }
 
             final String passwordPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_USER_PREFIX
+ user.getID() + "/rep:password";
 
@@ -259,34 +259,4 @@ public class ChangeUserPasswordServlet e
 
         return user;
     }
-
-
-    private void checkPassword(Authorizable authorizable, String oldPassword)
-            throws RepositoryException {
-        Credentials oldCreds = ((User) authorizable).getCredentials();
-        if (oldCreds instanceof SimpleCredentials) {
-            char[] oldCredsPwd = ((SimpleCredentials) oldCreds).getPassword();
-            if (oldPassword.equals(String.valueOf(oldCredsPwd))) {
-                return;
-            }
-        } else {
-            try {
-                // CryptSimpleCredentials.matches(SimpleCredentials credentials)
-                Class<?> oldCredsClass = oldCreds.getClass();
-                Method matcher = oldCredsClass.getMethod("matches",
-                    SimpleCredentials.class);
-                SimpleCredentials newCreds = new SimpleCredentials(
-                    authorizable.getPrincipal().getName(),
-                    oldPassword.toCharArray());
-                boolean match = (Boolean) matcher.invoke(oldCreds, newCreds);
-                if (match) {
-                    return;
-                }
-            } catch (Throwable t) {
-                // failure here, fall back to password check failure below
-            }
-        }
-
-        throw new RepositoryException("Old Password does not match");
-    }
 }



Mime
View raw message