Author: painter
Date: Mon Nov  5 15:59:18 2018
New Revision: 1845820

URL: http://svn.apache.org/viewvc?rev=1845820&view=rev
Log:
Fix/update javadoc for fulcrum-crypto

Modified:
    
turbine/fulcrum/trunk/crypto/src/java/org/apache/fulcrum/crypto/DefaultCryptoService.java

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=1845820&r1=1845819&r2=1845820&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
 Mon Nov  5 15:59:18 2018
@@ -20,6 +20,7 @@ package org.apache.fulcrum.crypto;
  */
 
 import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
 import java.util.Hashtable;
 
 import org.apache.avalon.framework.activity.Initializable;
@@ -31,117 +32,111 @@ import org.apache.avalon.framework.threa
 
 /**
  * An implementation of CryptoService that uses either supplied crypto
- * Algorithms (provided in the component config xml file) or tries to get them 
via
- * the normal java mechanisms if this fails.
+ * Algorithms (provided in the component config xml file) or tries to get them
+ * via the normal java mechanisms if this fails.
+ *
+ * avalon.component name="crypto" lifestyle="singleton" avalon.service
+ * type="org.apache.fulcrum.crypto.CryptoService"
+ *
  *
  * @author <a href="mailto:ep...@upstate.com";>Eric Pugh</a>
  * @author <a href="mailto:h...@intermeta.de";>Henning P. Schmiedehausen</a>
- * @version $Id$
- *
- * @avalon.component name="crypto" lifestyle="singleton"
- * @avalon.service type="org.apache.fulcrum.crypto.CryptoService"
+ * @version $Id: DefaultCryptoService.java 581797 2007-10-04 08:26:18Z sgoeschl
+ *          $
  */
-public class DefaultCryptoService
-    extends AbstractLogEnabled
-    implements CryptoService, Configurable, Initializable, ThreadSafe
-{
-    //
-    // SJM: removed Component and Contextualizable, Startable
-    //
-
-    /** Key Prefix for our algorithms */
-    private static final String ALGORITHM = "algorithm";
-    /** Default Key */
-    private static final String DEFAULT_KEY = "default";
-    /** Default Encryption Class */
-    private static final String DEFAULT_CLASS =
-      "org.apache.fulcrum.crypto.provider.JavaCrypt";
-    /** Names of the registered algorithms and the wanted classes */
-    private Hashtable algos = null;
-
-    /**
-     * Returns a CryptoAlgorithm Object which represents the requested
-     * crypto algorithm.
-     *
-     * @param algo      Name of the requested algorithm
-     *
-     * @return An Object representing the algorithm
-     *
-     * @throws NoSuchAlgorithmException  Requested algorithm is not available
-     *
-     */
-    public CryptoAlgorithm getCryptoAlgorithm( String algo )
-      throws NoSuchAlgorithmException
-    {
-        String cryptoClass = (String) algos.get(algo);
-        CryptoAlgorithm ca = null;
-        if (cryptoClass == null)
-        {
-            cryptoClass = (String) algos.get(DEFAULT_KEY);
-        }
-        if (cryptoClass == null || cryptoClass.equalsIgnoreCase("none"))
-        {
-            throw new NoSuchAlgorithmException(
-              "TurbineCryptoService: No Algorithm for " + algo + " found");
-        }
-        try
-        {
-            //@todo should be created via factory service.
-            //Just trying to get something to work.
-            //ca = (CryptoAlgorithm) factoryService.getInstance(cryptoClass);
-            ca = (CryptoAlgorithm) Class.forName(cryptoClass).newInstance();
-        }
-        catch (Exception e)
-        {
-            throw new NoSuchAlgorithmException(
-              "TurbineCryptoService: Error instantiating "
-              + cryptoClass + " for " + algo);
-        }
-        ca.setCipher(algo);
-        return ca;
-    }
-
-    // ---------------- Avalon Lifecycle Methods ---------------------
-
-    /**
-     * Avalon component lifecycle method
-     */
-    public void configure(Configuration conf) throws ConfigurationException
-    {
-        this.algos = new Hashtable();
-        // Set up default (Can be overridden by default key
-        // from the properties
-        algos.put(DEFAULT_KEY, DEFAULT_CLASS);
-        final Configuration algorithms = conf.getChild(ALGORITHM, false);
-        if (algorithms != null)
-        {
-            Configuration[] nameVal = algorithms.getChildren();
-            for (int i = 0; i < nameVal.length; i++)
-            {
-                String key = nameVal[i].getName();
-                String val = nameVal[i].getValue();
-                // getLogger.debug("Registered " + val
-                //            + " for Crypto Algorithm " + key);
-                algos.put(key, val);
-            }
-        }
-    }
-
-   /**
-    * @see org.apache.avalon.framework.activity.Initializable#initialize()
-    */
-    public void initialize()
-      throws Exception
-    {
-        getLogger().debug("initialize()");
-    }
-
-    /**
-     * Avalon component lifecycle method
-     */
-    public void dispose()
-    {
-        algos = null;
-    }
+public class DefaultCryptoService extends AbstractLogEnabled
+               implements CryptoService, Configurable, Initializable, 
ThreadSafe {
+       //
+       // SJM: removed Component and Contextualizable, Startable
+       //
+
+       /** Key Prefix for our algorithms */
+       private static final String ALGORITHM = "algorithm";
+
+       /** Default Key */
+       private static final String DEFAULT_KEY = "default";
+
+       /** Default Encryption Class */
+       private static final String DEFAULT_CLASS = 
"org.apache.fulcrum.crypto.provider.JavaCrypt";
+
+       /** Names of the registered algorithms and the wanted classes */
+       private HashMap<String, String> algos = null;
+
+       /**
+        * Returns a CryptoAlgorithm Object which represents the requested 
crypto
+        * algorithm.
+        *
+        * @param algo Name of the requested algorithm
+        *
+        * @return An Object representing the algorithm
+        *
+        * @throws NoSuchAlgorithmException Requested algorithm is not available
+        *
+        */
+       public CryptoAlgorithm getCryptoAlgorithm(String algo) throws 
NoSuchAlgorithmException {
+               String cryptoClass = (String) algos.get(algo);
+               CryptoAlgorithm ca = null;
+               if (cryptoClass == null) {
+                       cryptoClass = (String) algos.get(DEFAULT_KEY);
+               }
+               if (cryptoClass == null || 
cryptoClass.equalsIgnoreCase("none")) {
+                       throw new 
NoSuchAlgorithmException("TurbineCryptoService: No Algorithm for " + algo + " 
found");
+               }
+               try {
+                       // @todo should be created via factory service.
+                       // Just trying to get something to work.
+                       // ca = (CryptoAlgorithm) 
factoryService.getInstance(cryptoClass);
+                       ca = (CryptoAlgorithm) 
Class.forName(cryptoClass).newInstance();
+               } catch (Exception e) {
+                       throw new NoSuchAlgorithmException(
+                                       "TurbineCryptoService: Error 
instantiating " + cryptoClass + " for " + algo);
+               }
+               ca.setCipher(algo);
+               return ca;
+       }
+
+       // ---------------- Avalon Lifecycle Methods ---------------------
+
+       /**
+        * Avalon component lifecycle method
+        * 
+        * @param conf the configuration
+        * @throws ConfigurationException if not found
+        */
+       public void configure(Configuration conf) throws ConfigurationException 
{
+               
+               // Initialize the hash and setup default
+               // Can be overriden by default key from properties
+               this.algos = new HashMap<>();
+               this.algos.put(DEFAULT_KEY, DEFAULT_CLASS);
+               
+               final Configuration algorithms = conf.getChild(ALGORITHM, 
false);
+               if (algorithms != null) {
+                       Configuration[] nameVal = algorithms.getChildren();
+                       for (int i = 0; i < nameVal.length; i++) {
+                               String key = nameVal[i].getName();
+                               String val = nameVal[i].getValue();
+                               // getLogger.debug("Registered " + val
+                               // + " for Crypto Algorithm " + key);
+                               algos.put(key, val);
+                       }
+               }
+       }
+
+       /**
+        * {@link 
org.apache.avalon.framework.activity.Initializable#initialize()}
+        * 
+        * @throws Exception generic exception
+        */
+       public void initialize() throws Exception {
+               getLogger().debug("initialize()");
+       }
+
+       /**
+        * Avalon component lifecycle method
+        */
+       public void dispose() {
+               algos = null;
+       }
 
 }


Reply via email to