directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szoer...@apache.org
Subject svn commit: r907300 - in /directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash: HashTools.java Main.java PasswordHashInterceptor.java
Date Sat, 06 Feb 2010 20:38:46 GMT
Author: szoerner
Date: Sat Feb  6 20:38:45 2010
New Revision: 907300

URL: http://svn.apache.org/viewvc?rev=907300&view=rev
Log:
javadoc, formatting etc

Modified:
    directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/HashTools.java
    directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java
    directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/PasswordHashInterceptor.java

Modified: directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/HashTools.java
URL: http://svn.apache.org/viewvc/directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/HashTools.java?rev=907300&r1=907299&r2=907300&view=diff
==============================================================================
--- directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/HashTools.java
(original)
+++ directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/HashTools.java
Sat Feb  6 20:38:45 2010
@@ -34,15 +34,12 @@
             "SMD5" };
 
     /**
-     * Applys a hash algorithm to a sequence of bytes.
+     * Detects whether a value has already been hashed with a known message
+     * digest algorithm.
      * 
-     * @param algorithm
-     *            algorithm to use
      * @param value
-     *            value to be hashed
-     * @return hashed value preceeded by algorithm in curly brackets
-     * 
-     * @throws NoSuchAlgorithmException
+     *            value to analyse
+     * @return true, if already hashed
      */
     public static boolean isAlreadyHashed(byte[] value) {
         String sValue = new String(value);
@@ -55,12 +52,15 @@
     }
 
     /**
-     * Detects wether a value has already been hashed with a known message
-     * digest algorithm
+     * Applies a hash algorithm to a sequence of bytes.
      * 
+     * @param algorithm
+     *            algorithm to use
      * @param value
-     *            value to analyse
-     * @return true, if already hashed
+     *            value to be hashed
+     * @return hashed value preceeded by algorithm in curly brackets
+     * 
+     * @throws NoSuchAlgorithmException
      */
     public static byte[] applyHashAlgorithm(String algorithm, byte[] value)
             throws NoSuchAlgorithmException {

Modified: directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java
URL: http://svn.apache.org/viewvc/directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java?rev=907300&r1=907299&r2=907300&view=diff
==============================================================================
--- directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java
(original)
+++ directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java
Sat Feb  6 20:38:45 2010
@@ -27,6 +27,10 @@
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 
+/**
+ * Main class which starts an embedded server with the interceptor added to the
+ * chain.
+ */
 public class Main {
 
     public static void main(String[] args) throws Exception {
@@ -39,7 +43,7 @@
         ldapServer.setAllowAnonymousAccess(true);
 
         List<Interceptor> is = directoryService.getInterceptors();
-        is.add(0, new PasswordHashInterceptor());
+        is.add(new PasswordHashInterceptor());
         directoryService.setInterceptors(is);
 
         TcpTransport ldapTransport = new TcpTransport(10389);
@@ -48,5 +52,4 @@
         directoryService.startup();
         ldapServer.start();
     }
-
 }

Modified: directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/PasswordHashInterceptor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/PasswordHashInterceptor.java?rev=907300&r1=907299&r2=907300&view=diff
==============================================================================
--- directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/PasswordHashInterceptor.java
(original)
+++ directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/PasswordHashInterceptor.java
Sat Feb  6 20:38:45 2010
@@ -70,6 +70,10 @@
         super.modify(next, opContext);
     }
 
+    /**
+     * Intercepts the add operation in order to replace plain password values
+     * with hashed ones.
+     */
     @Override
     public void add(NextInterceptor next, AddOperationContext opContext)
             throws Exception {
@@ -91,7 +95,6 @@
             byte[] password = attribute.getBytes();
             if (!isAlreadyHashed(password)) {
                 byte[] hashed = applyHashAlgorithm(hashAlgorithm, password);
-                System.out.println("Hashed value:" + new String(hashed));
                 attribute.clear();
                 attribute.add(hashed);
             }



Mime
View raw message