incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From enor...@apache.org
Subject svn commit: r1208229 - in /sling/trunk/bundles/jcr: contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/
Date Wed, 30 Nov 2011 03:05:54 GMT
Author: enorman
Date: Wed Nov 30 03:05:52 2011
New Revision: 1208229

URL: http://svn.apache.org/viewvc?rev=1208229&view=rev
Log:
SLING-2308 Remove user password digesting from sling

Modified:
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentImporter.java
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/JcrContentHelper.java
    sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractUserPostServlet.java
    sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java
    sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java?rev=1208229&r1=1208228&r2=1208229&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
(original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
Wed Nov 30 03:05:52 2011
@@ -18,10 +18,7 @@
  */
 package org.apache.sling.jcr.contentloader.internal;
 
-import java.io.UnsupportedEncodingException;
-import java.security.NoSuchAlgorithmException;
 import java.util.Calendar;
-import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -69,16 +66,6 @@ public class ContentLoaderService implem
 
     public static final String BUNDLE_CONTENT_NODE = "/var/sling/bundle-content";
 
-    /**
-     * To be used for the encryption. E.g. for passwords in
-     * {@link javax.jcr.SimpleCredentials#getPassword()} SimpleCredentials}
-     *
-     * @scr.property valueRef="DEFAULT_PASSWORD_DIGEST_ALGORITHM"
-     */
-    private static final String PROP_PASSWORD_DIGEST_ALGORITHM = "password.digest.algorithm";
-    private static final String DEFAULT_PASSWORD_DIGEST_ALGORITHM = "sha1";
-    private String passwordDigestAlgoritm = null;
-
     /** default log */
     final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -215,27 +202,6 @@ public class ContentLoaderService implem
         }
     }
 
-    /**
-     * Digest the given password using the configured digest algorithm
-     *
-     * @param pwd the value to digest
-     * @return the digested value
-     * @throws IllegalArgumentException
-     */
-    public String digestPassword(String pwd) throws IllegalArgumentException {
-        try {
-            StringBuffer password = new StringBuffer();
-            password.append("{").append(passwordDigestAlgoritm).append("}");
-            password.append(DefaultContentCreator.digest(passwordDigestAlgoritm,
-                pwd.getBytes("UTF-8")));
-            return password.toString();
-        } catch (NoSuchAlgorithmException e) {
-            throw new IllegalArgumentException(e.toString());
-        } catch (UnsupportedEncodingException e) {
-            throw new IllegalArgumentException(e.toString());
-        }
-    }
-
     // ---------- SCR Integration ---------------------------------------------
 
     /** Activates this component, called by SCR before registering as a service */
@@ -245,14 +211,6 @@ public class ContentLoaderService implem
 
         componentContext.getBundleContext().addBundleListener(this);
 
-        Dictionary<?, ?> props = componentContext.getProperties();
-        Object propValue = props.get(PROP_PASSWORD_DIGEST_ALGORITHM);
-        if (propValue instanceof String) {
-            passwordDigestAlgoritm = (String) propValue;
-        } else {
-            passwordDigestAlgoritm = DEFAULT_PASSWORD_DIGEST_ALGORITHM;
-        }
-
         Session session = null;
         try {
             session = this.getSession();
@@ -307,7 +265,6 @@ public class ContentLoaderService implem
             this.initialContentLoader.dispose();
             this.initialContentLoader = null;
         }
-        passwordDigestAlgoritm = null;
     }
 
     // ---------- internal helper ----------------------------------------------

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java?rev=1208229&r1=1208228&r2=1208229&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
(original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
Wed Nov 30 03:05:52 2011
@@ -842,9 +842,8 @@ public class DefaultContentCreator imple
         Authorizable authorizable = userManager.getAuthorizable(name);
         if (authorizable == null) {
             //principal does not exist yet, so create it
-        	String digestedPassword = jcrContentHelper.digestPassword(password);
         	User user = userManager.createUser(name,
-        			digestedPassword,
+        			password,
         			new Principal() {
 						public String getName() {
 							return name;

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentImporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentImporter.java?rev=1208229&r1=1208228&r2=1208229&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentImporter.java
(original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentImporter.java
Wed Nov 30 03:05:52 2011
@@ -22,10 +22,7 @@ import static javax.jcr.ImportUUIDBehavi
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
-import java.util.Dictionary;
 import java.util.List;
 
 import javax.jcr.InvalidSerializedDataException;
@@ -37,7 +34,6 @@ import org.apache.sling.commons.mime.Mim
 import org.apache.sling.jcr.contentloader.ContentImportListener;
 import org.apache.sling.jcr.contentloader.ContentImporter;
 import org.apache.sling.jcr.contentloader.ImportOptions;
-import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -68,17 +64,6 @@ public class DefaultContentImporter exte
      */
     private MimeTypeService mimeTypeService;
 
-    /**
-     * To be used for the encryption. E.g. for passwords in
-     * {@link javax.jcr.SimpleCredentials#getPassword()} SimpleCredentials}
-     *
-     * @scr.property valueRef="DEFAULT_PASSWORD_DIGEST_ALGORITHM"
-     */
-    private static final String PROP_PASSWORD_DIGEST_ALGORITHM = "password.digest.algorithm";
-    private static final String DEFAULT_PASSWORD_DIGEST_ALGORITHM = "sha1";
-    private String passwordDigestAlgoritm = null;
-
-
     /* (non-Javadoc)
 	 * @see org.apache.sling.jcr.contentloader.ContentImporter#importContent(javax.jcr.Node,
java.lang.String, java.io.InputStream, org.apache.sling.jcr.contentloader.ImportOptions, org.apache.sling.jcr.contentloader.ContentImportListener)
 	 */
@@ -215,23 +200,6 @@ public class DefaultContentImporter exte
     // ---------- JcrContentHelper implementation ---------------------------------------------
 
 	/* (non-Javadoc)
-	 * @see org.apache.sling.jcr.contentloader.internal.JcrContentHelper#digestPassword(java.lang.String)
-	 */
-	public String digestPassword(String pwd) throws IllegalArgumentException {
-        try {
-            StringBuffer password = new StringBuffer();
-            password.append("{").append(passwordDigestAlgoritm).append("}");
-            password.append(DefaultContentCreator.digest(passwordDigestAlgoritm,
-                pwd.getBytes("UTF-8")));
-            return password.toString();
-        } catch (NoSuchAlgorithmException e) {
-            throw new IllegalArgumentException(e.toString());
-        } catch (UnsupportedEncodingException e) {
-            throw new IllegalArgumentException(e.toString());
-        }
-	}
-
-	/* (non-Javadoc)
 	 * @see org.apache.sling.jcr.contentloader.internal.JcrContentHelper#getMimeType(java.lang.String)
 	 */
 	public String getMimeType(String name) {
@@ -241,23 +209,4 @@ public class DefaultContentImporter exte
         return (mts != null) ? mts.getMimeType(name) : null;
 	}
 
-
-    // ---------- SCR Integration ---------------------------------------------
-
-    /** Activates this component, called by SCR before registering as a service */
-    protected void activate(ComponentContext componentContext) {
-        Dictionary<?, ?> props = componentContext.getProperties();
-        Object propValue = props.get(PROP_PASSWORD_DIGEST_ALGORITHM);
-        if (propValue instanceof String) {
-            passwordDigestAlgoritm = (String) propValue;
-        } else {
-            passwordDigestAlgoritm = DEFAULT_PASSWORD_DIGEST_ALGORITHM;
-        }
-    }
-
-    /** Deativates this component, called by SCR to take out of service */
-    protected void deactivate(ComponentContext componentContext) {
-        passwordDigestAlgoritm = null;
-    }
-
 }

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/JcrContentHelper.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/JcrContentHelper.java?rev=1208229&r1=1208228&r2=1208229&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/JcrContentHelper.java
(original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/JcrContentHelper.java
Wed Nov 30 03:05:52 2011
@@ -31,13 +31,4 @@ public interface JcrContentHelper {
 	 */
 	String getMimeType(String name);
 
-	/**
-	 * Digest the given password using the configured digest algorithm
-	 * 
-	 * @param pwd the password to digest
-	 * @return digested password
-	 * @throws IllegalArgumentException
-	 */
-    String digestPassword(String pwd) throws IllegalArgumentException;
-
 }

Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractUserPostServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractUserPostServlet.java?rev=1208229&r1=1208228&r2=1208229&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractUserPostServlet.java
(original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractUserPostServlet.java
Wed Nov 30 03:05:52 2011
@@ -16,12 +16,7 @@
  */
 package org.apache.sling.jackrabbit.usermanager.impl.post;
 
-import java.io.UnsupportedEncodingException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Dictionary;
-
 import org.apache.felix.scr.annotations.Component;
-import org.apache.jackrabbit.util.Text;
 import org.osgi.service.component.ComponentContext;
 
 /**
@@ -30,70 +25,16 @@ import org.osgi.service.component.Compon
 @Component (componentAbstract=true)
 public abstract class AbstractUserPostServlet extends
         AbstractAuthorizablePostServlet {
-    private static final long serialVersionUID = -8401210711297654453L;
-
-    /**
-     * To be used for the encryption. E.g. for passwords in
-     * {@link javax.jcr.SimpleCredentials#getPassword()} SimpleCredentials}
-     *
-     * @scr.property valueRef="DEFAULT_PASSWORD_DIGEST_ALGORITHM"
-     */
-    private static final String PROP_PASSWORD_DIGEST_ALGORITHM = "password.digest.algorithm";
-
-    private static final String DEFAULT_PASSWORD_DIGEST_ALGORITHM = "sha1";
 
-    private String passwordDigestAlgoritm = null;
+	private static final long serialVersionUID = 8292047684552692610L;
 
-    // ---------- SCR Integration ----------------------------------------------
+	// ---------- SCR Integration ----------------------------------------------
 
-    protected void activate(ComponentContext context) {
+	protected void activate(ComponentContext context) {
         super.activate(context);
-
-        Dictionary<?, ?> props = context.getProperties();
-
-        Object propValue = props.get(PROP_PASSWORD_DIGEST_ALGORITHM);
-        if (propValue instanceof String) {
-            passwordDigestAlgoritm = (String) propValue;
-        } else {
-            passwordDigestAlgoritm = DEFAULT_PASSWORD_DIGEST_ALGORITHM;
-        }
     }
 
     protected void deactivate(ComponentContext context) {
         super.deactivate(context);
-        passwordDigestAlgoritm = null;
     }
-
-    /**
-     * Digest the given password using the configured digest algorithm
-     *
-     * @param pwd the value to digest
-     * @return the digested value
-     * @throws IllegalArgumentException
-     */
-    protected String digestPassword(String pwd) throws IllegalArgumentException {
-        return digestPassword(pwd, passwordDigestAlgoritm);
-    }
-
-    /**
-     * Digest the given password using the given digest algorithm
-     *
-     * @param pwd the value to digest
-     * @param digest the digest algorithm to use for digesting
-     * @return the digested value
-     * @throws IllegalArgumentException
-     */
-    protected String digestPassword(String pwd, String digest) throws IllegalArgumentException
{
-        try {
-            StringBuffer password = new StringBuffer();
-            password.append("{").append(digest).append("}");
-            password.append(Text.digest(digest, pwd.getBytes("UTF-8")));
-            return password.toString();
-        } catch (NoSuchAlgorithmException e) {
-            throw new IllegalArgumentException(e.toString());
-        } catch (UnsupportedEncodingException e) {
-            throw new IllegalArgumentException(e.toString());
-        }
-    }
-
 }

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=1208229&r1=1208228&r2=1208229&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
Wed Nov 30 03:05:52 2011
@@ -233,7 +233,7 @@ public class ChangeUserPasswordServlet e
         }
 
         try {
-            ((User) authorizable).changePassword(digestPassword(newPassword));
+            ((User) authorizable).changePassword(newPassword);
 
             String userPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX
                 + user.getID();

Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java?rev=1208229&r1=1208228&r2=1208229&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java
(original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java
Wed Nov 30 03:05:52 2011
@@ -293,7 +293,7 @@ public class CreateUserServlet extends A
                     "A principal already exists with the requested name: "
                         + name);
             } else {
-                user = userManager.createUser(name, digestPassword(password));
+                user = userManager.createUser(name, password);
                 String userPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_USER_PREFIX
                     + user.getID();
                 



Mime
View raw message