You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by pa...@apache.org on 2019/01/25 18:19:46 UTC

svn commit: r1852158 - in /turbine/fulcrum/trunk/crypto/src: java/org/apache/fulcrum/crypto/ java/org/apache/fulcrum/crypto/provider/ test/org/apache/fulcrum/crypto/

Author: painter
Date: Fri Jan 25 18:19:46 2019
New Revision: 1852158

URL: http://svn.apache.org/viewvc?rev=1852158&view=rev
Log:
JavaDoc cleanup, enforce Turbine coding standards

Modified:
    turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoAlgorithm.java
    turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoService.java
    turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.java
    turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/ClearCrypt.java
    turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/JavaCrypt.java
    turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/OldJavaCrypt.java
    turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/UnixCrypt.java
    turbine/fulcrum/trunk/crypto/src/test/org/apache/fulcrum/crypto/CryptoServiceTest.java

Modified: turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoAlgorithm.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoAlgorithm.java?rev=1852158&r1=1852157&r2=1852158&view=diff
==============================================================================
--- turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoAlgorithm.java (original)
+++ turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoAlgorithm.java Fri Jan 25 18:19:46 2019
@@ -28,7 +28,6 @@ package org.apache.fulcrum.crypto;
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id$
  */
-
 public interface CryptoAlgorithm
 {
     /**

Modified: turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoService.java?rev=1852158&r1=1852157&r2=1852158&view=diff
==============================================================================
--- turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoService.java (original)
+++ turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/CryptoService.java Fri Jan 25 18:19:46 2019
@@ -1,6 +1,5 @@
 package org.apache.fulcrum.crypto;
 
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -20,7 +19,6 @@ package org.apache.fulcrum.crypto;
  * under the License.
  */
 
-
 import java.security.NoSuchAlgorithmException;
 
 /**
@@ -30,6 +28,7 @@ import java.security.NoSuchAlgorithmExce
  *
  * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
  * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
+ * @version $Id$ 
  */
 public interface CryptoService
 {
@@ -39,10 +38,8 @@ public interface CryptoService
    * Returns a CryptoAlgorithm Object which represents the requested
    * crypto algorithm.
    *
-   * @param algo      Name of the requested algorithm
-   *
+   * @param algo Name of the requested algorithm
    * @return An Object representing the algorithm
-   *
    * @throws NoSuchAlgorithmException  Requested algorithm is not available
    *
    */

Modified: turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.java?rev=1852158&r1=1852157&r2=1852158&view=diff
==============================================================================
--- turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.java (original)
+++ turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.java Fri Jan 25 18:19:46 2019
@@ -40,8 +40,7 @@ import org.apache.avalon.framework.threa
  *
  * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
- * @version $Id: DefaultCryptoService.java 581797 2007-10-04 08:26:18Z sgoeschl
- *          $
+ * @version $Id$
  */
 public class DefaultCryptoService extends AbstractLogEnabled
 		implements CryptoService, Configurable, Initializable, ThreadSafe {
@@ -63,6 +62,8 @@ public class DefaultCryptoService extend
 	 * Returns a CryptoAlgorithm Object which represents the requested crypto
 	 * algorithm.
 	 *
+	 * @see org.apache.fulcrum.crypto.CryptoService#getCryptoAlgorithm(java.lang.String)
+	 *
 	 * @param algo Name of the requested algorithm
 	 *
 	 * @return An Object representing the algorithm
@@ -117,9 +118,11 @@ public class DefaultCryptoService extend
 	}
 	
 	/**
-	 * {@link org.apache.avalon.framework.activity.Initializable#initialize()}
+	 * Initialize the service
+	 * 
+	 * @see org.apache.avalon.framework.activity.Initializable#initialize()
 	 * 
-	 * @throws Exception generic exception
+	 * @throws Exception if initialization fails
 	 */
 	public void initialize() throws Exception 
 	{

Modified: turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/ClearCrypt.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/ClearCrypt.java?rev=1852158&r1=1852157&r2=1852158&view=diff
==============================================================================
--- turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/ClearCrypt.java (original)
+++ turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/ClearCrypt.java Fri Jan 25 18:19:46 2019
@@ -31,7 +31,6 @@ import org.apache.fulcrum.crypto.CryptoA
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id$
  */
-
 public class ClearCrypt implements CryptoAlgorithm {
 	
 	/**
@@ -48,7 +47,6 @@ public class ClearCrypt implements Crypt
 	 */
 	public void setCipher(String cipher) 
 	{
-		/* dummy */
 	}
 
 	/**
@@ -58,22 +56,18 @@ public class ClearCrypt implements Crypt
 	 */
 	public void setSeed(String seed) 
 	{
-		/* dummy */
 	}
 
 	/**
-	 * encrypt the supplied string with the requested cipher
+	 * This method performs no encryption and will simply
+	 * return the value passed
 	 *
 	 * @param value The value to be encrypted
-	 * @return The encrypted value
+	 * @return The original value
 	 * @throws Exception An Exception of the underlying implementation.
 	 */
 	public String encrypt(String value) throws Exception 
 	{
-		/*
-		 * Ultra-clever implementation. ;-)
-		 */
-
 		return value;
 	}
 }

Modified: turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/JavaCrypt.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/JavaCrypt.java?rev=1852158&r1=1852157&r2=1852158&view=diff
==============================================================================
--- turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/JavaCrypt.java (original)
+++ turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/JavaCrypt.java Fri Jan 25 18:19:46 2019
@@ -41,8 +41,8 @@ import org.apache.fulcrum.crypto.CryptoA
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id$
  */
-
-public class JavaCrypt implements CryptoAlgorithm {
+public class JavaCrypt implements CryptoAlgorithm 
+{
 
 	/** The default cipher */
 	public static final String DEFAULT_CIPHER = "SHA";
@@ -51,7 +51,7 @@ public class JavaCrypt implements Crypto
 	private String cipher = null;
 
 	/**
-	 * Constructo
+	 * Constructor
 	 *
 	 */
 	public JavaCrypt() 
@@ -66,6 +66,8 @@ public class JavaCrypt implements Crypto
 	 * This will never throw an error even if there is no provider for this cipher.
 	 * The error will be thrown by encrypt() (Fixme?)
 	 *
+	 * @see org.apache.fulcrum.crypto.CryptoAlgorithm#setCipher(java.lang.String)
+	 *
 	 * @param cipher The cipher to use.
 	 *
 	 */
@@ -77,6 +79,8 @@ public class JavaCrypt implements Crypto
 	/**
 	 * This class never uses a seed, so this is just a dummy.
 	 *
+	 * @see org.apache.fulcrum.crypto.CryptoAlgorithm#setSeed(java.lang.String)
+	 * 
 	 * @param seed Seed (ignored)
 	 *
 	 */
@@ -86,7 +90,9 @@ public class JavaCrypt implements Crypto
 	}
 
 	/**
-	 * encrypt the supplied string with the requested cipher
+	 * Encrypt the supplied string with the requested cipher
+	 *
+	 * @see org.apache.fulcrum.crypto.CryptoAlgorithm#encrypt(java.lang.String)
 	 *
 	 * @param value The value to be encrypted
 	 * @return The encrypted value

Modified: turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/OldJavaCrypt.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/OldJavaCrypt.java?rev=1852158&r1=1852157&r2=1852158&view=diff
==============================================================================
--- turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/OldJavaCrypt.java (original)
+++ turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/OldJavaCrypt.java Fri Jan 25 18:19:46 2019
@@ -41,9 +41,8 @@ import org.apache.fulcrum.crypto.CryptoA
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id$
  */
-
-public class OldJavaCrypt implements CryptoAlgorithm {
-
+public class OldJavaCrypt implements CryptoAlgorithm 
+{
 	/** The default cipher */
 	public static final String DEFAULT_CIPHER = "SHA";
 
@@ -85,7 +84,7 @@ public class OldJavaCrypt implements Cry
 	}
 
 	/**
-	 * encrypt the supplied string with the requested cipher
+	 * Encrypt the supplied string with the requested cipher
 	 *
 	 * @param value The value to be encrypted
 	 * @return The encrypted value
@@ -96,10 +95,12 @@ public class OldJavaCrypt implements Cry
 		MessageDigest md = MessageDigest.getInstance(cipher);
 		byte[] digest = md.digest(value.getBytes("UTF-8"));
 		byte[] base64 = Base64.encodeBase64(digest);
+		
 		// from MD5 the digest has 16 bytes but for SHA1 it contains 20 bytes
-		// depending on the digest lenght the result is truncated
+		// depending on the digest length the result is truncated
 		int len = (digest.length == 16 ? 20 : 24);
 		byte[] result = new byte[len];
+		
 		System.arraycopy(base64, 0, result, 0, result.length);
 		return new String(result, "UTF-8");
 	}

Modified: turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/UnixCrypt.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/UnixCrypt.java?rev=1852158&r1=1852157&r2=1852158&view=diff
==============================================================================
--- turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/UnixCrypt.java (original)
+++ turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/provider/UnixCrypt.java Fri Jan 25 18:19:46 2019
@@ -19,17 +19,18 @@ package org.apache.fulcrum.crypto.provid
  * under the License.
  */
 
-import org.apache.fulcrum.crypto.CryptoAlgorithm;
 import java.util.Random;
 
+import org.apache.fulcrum.crypto.CryptoAlgorithm;
+
 /**
  * Implements Standard Unix crypt(3) for use with the Crypto Service.
  *
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id$
  */
-
-public class UnixCrypt implements CryptoAlgorithm {
+public class UnixCrypt implements CryptoAlgorithm 
+{
 
 	/** The seed to use */
 	private String seed = null;
@@ -68,7 +69,7 @@ public class UnixCrypt implements Crypto
 	}
 
 	/**
-	 * encrypt the supplied string with the requested cipher
+	 * Encrypt the supplied string with the requested cipher
 	 *
 	 * @param value The value to be encrypted
 	 * @return The encrypted value
@@ -76,7 +77,8 @@ public class UnixCrypt implements Crypto
 	 */
 	public String encrypt(String value) throws Exception 
 	{
-		if (seed == null) {
+		if (seed == null) 
+		{
 			Random randomGenerator = new Random();
 			int numSaltChars = SALT_CHARS.length;
 			StringBuilder sb = new StringBuilder();

Modified: turbine/fulcrum/trunk/crypto/src/test/org/apache/fulcrum/crypto/CryptoServiceTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/crypto/src/test/org/apache/fulcrum/crypto/CryptoServiceTest.java?rev=1852158&r1=1852157&r2=1852158&view=diff
==============================================================================
--- turbine/fulcrum/trunk/crypto/src/test/org/apache/fulcrum/crypto/CryptoServiceTest.java (original)
+++ turbine/fulcrum/trunk/crypto/src/test/org/apache/fulcrum/crypto/CryptoServiceTest.java Fri Jan 25 18:19:46 2019
@@ -69,12 +69,14 @@ public class CryptoServiceTest extends B
         String preDefinedResult = "z5EQaXpuu059c";
 
         CryptoAlgorithm ca = sc.getCryptoAlgorithm("unix");
+        
         /*
          * Test predefined Seed
          */
         ca.setSeed(preDefinedSeed);
         String output = ca.encrypt(preDefinedInput);
         assertEquals( preDefinedResult, output, "Encryption failed ");
+        
         /*
          * Test random Seed
          *
@@ -87,6 +89,10 @@ public class CryptoServiceTest extends B
 
     }
     
+    /**
+     * Test no encryption 
+     * @throws Exception exception
+     */
     @Test
     public void testClearCrypt() throws Exception
     {
@@ -98,6 +104,9 @@ public class CryptoServiceTest extends B
 
     }
     
+    /**
+     * @throws Exception exception
+     */
     @Test
     @DisplayName("OldJavaCrypt: Truncated base64 from MD5 (Turbine 2.1) Test")
     public void testOldJavaCryptMd5() throws Exception
@@ -111,6 +120,9 @@ public class CryptoServiceTest extends B
 
     }
     
+    /**
+     * @throws Exception exception
+     */
     @Test
     public void testOldJavaCryptSha1() throws Exception
     {
@@ -123,6 +135,9 @@ public class CryptoServiceTest extends B
 
     }
     
+    /**
+     * @throws Exception exception
+     */
     @Test
     public void testJavaCryptMd5() throws Exception
     {
@@ -133,6 +148,9 @@ public class CryptoServiceTest extends B
         assertEquals( preDefinedResult, output, "MD5 Encryption failed ");
     }
     
+    /**
+     * @throws Exception exception
+     */
     @Test
     public void testJavaCryptSha1() throws Exception
     {
@@ -144,6 +162,9 @@ public class CryptoServiceTest extends B
 
     }
     
+    /**
+     * @throws Exception exception
+     */
     @Test
     public void testJavaCryptSha256() throws Exception
     {
@@ -154,6 +175,9 @@ public class CryptoServiceTest extends B
         assertEquals( preDefinedResult, output, "SHA256 Encryption failed ");
     }
     
+    /**
+     * @throws Exception exception
+     */
     @Test
     public void testJavaCryptSha512() throws Exception
     {