Author: indika
Date: Thu Jul  3 23:24:21 2008
New Revision: 673915

URL: http://svn.apache.org/viewvc?rev=673915&view=rev
Log:
add more logs

Modified:
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/CipherInformation.java
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/KeyStoreInformation.java
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/repository/FileBaseSecretRepository.java
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/CipherWrapper.java
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/IdentityKeyStoreWrapper.java

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/CipherInformation.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/CipherInformation.java?rev=673915&r1=673914&r2=673915&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/CipherInformation.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/CipherInformation.java
 Thu Jul  3 23:24:21 2008
@@ -18,11 +18,18 @@
 */
 package org.apache.synapse.security.bean;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.security.tool.CipherTool;
+
 /**
  * Encapsulates the cipher related information
  */
 public class CipherInformation {
 
+    private static final Log log = LogFactory.getLog(CipherInformation.class);
+
     private static String DEFAULT_ALGORITHM = "RSA";
     private String algorithm = DEFAULT_ALGORITHM;
     private String operationMode;
@@ -36,9 +43,12 @@
     }
 
     public void setAlgorithm(String algorithm) {
-        if (this.algorithm != null) {
-            this.algorithm = algorithm;
+        if (algorithm == null || "".equals(algorithm)) {
+            if (log.isDebugEnabled()) {
+                log.debug("Given algorithm is null, using a defaut one : RSA");
+            }
         }
+        this.algorithm = algorithm;
     }
 
     public String getOperationMode() {
@@ -46,6 +56,13 @@
     }
 
     public void setOperationMode(String operationMode) {
+        if (operationMode == null || "".equals(operationMode)) {
+            handleException("Operation mode can not be null");
+        }
+        if (!CipherTool.ENCRYPT.equals(operationMode)
+                && !CipherTool.DECRYPT.equals(operationMode)) {
+            handleException("Invalid operation mode ' " + operationMode + " ' 
for cipher ");
+        }
         this.operationMode = operationMode;
     }
 
@@ -80,4 +97,9 @@
     public void setOutType(String outType) {
         this.outType = outType;
     }
+
+    private void handleException(String msg) {
+        log.error(msg);
+        throw new SynapseException(msg);
+    }
 }

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/KeyStoreInformation.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/KeyStoreInformation.java?rev=673915&r1=673914&r2=673915&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/KeyStoreInformation.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/bean/KeyStoreInformation.java
 Thu Jul  3 23:24:21 2008
@@ -18,12 +18,18 @@
 */
 package org.apache.synapse.security.bean;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseException;
+
 /**
  * Encapsulates the keyStore related information
  */
 public class KeyStoreInformation {
 
-    private String storeType;
+    private static final Log log = 
LogFactory.getLog(KeyStoreInformation.class);
+
+    private String storeType = "JKS";
     private String alias;
     private String location;
 
@@ -33,6 +39,11 @@
     }
 
     public void setStoreType(String storeType) {
+        if (storeType == null || "".equals(storeType)) {
+            if (log.isDebugEnabled()) {
+                log.debug("Given store type is null , using default type : 
JKS");
+            }
+        }
         this.storeType = storeType;
     }
 
@@ -41,6 +52,9 @@
     }
 
     public void setAlias(String alias) {
+        if (alias == null || "".equals(alias)) {
+            handleException("Alias for a key entry or a certificate cannot be 
null");
+        }
         this.alias = alias;
     }
 
@@ -49,7 +63,15 @@
     }
 
     public void setLocation(String location) {
+        if (location != null && "".equals(location)) {
+            handleException("KeyStore location can not be null");
+        }
         this.location = location;
     }
 
+    private void handleException(String msg) {
+        log.error(msg);
+        throw new SynapseException(msg);
+    }
+
 }

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java?rev=673915&r1=673914&r2=673915&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java
 Thu Jul  3 23:24:21 2008
@@ -23,20 +23,35 @@
 
     private static SecretManager ourInstance = new SecretManager();
 
+    /* Default configuration file path for secret manager*/
     private final static String DEFAULT_CONF_LOCATION = 
"secret-manager.properties";
-    private final static String SECRET_MANAGER_CONF = "secret-manage-conf";
+    /* If the location of the secret manager configuration is provided as a 
property- it's name */
+    private final static String SECRET_MANAGER_CONF = "secret.manager.conf";
+    /* Property key for secretRepositories*/
     private final static String SECRET_REPOSITORIES = "secretRepositories";
+    /* Type of the secret repository */
     private final static String TYPE = "type";
+    /* Private key entry KeyStore password */
     private final static String IDENTITY_KEY_STORE = 
"keystore.identity.location";
+    /* Private key entry KeyStore type  */
     private final static String IDENTITY_KEY_STORE_TYPE = 
"keystore.identity.type";
+    /*Alias for private key entry KeyStore  */
     private final static String IDENTITY_KEY_STORE_ALIAS = 
"keystore.identity.alias";
+    /* Trusted certificate KeyStore password */
     private final static String TRUST_KEY_STORE = "keystore.trust.location";
+    /* Trusted certificate KeyStore type*/
     private final static String TRUST_KEY_STORE_TYPE = "keystore.trust.type";
+    /* Alias for certificate KeyStore */
     private final static String TRUST_KEY_STORE_ALIAS = "keystore.trust.alias";
+
     private final static String DOT = ".";
+    /* Secret Repository type - file */
     private final static String REPO_TYPE_FILE = "file";
 
+    /*Root Secret Repository */
     private SecretRepository parentRepository;
+    /* True , if secret manage has been started up properly- need to have a at
+    least one Secret Repository*/
     private boolean initialize = false;
 
     public static SecretManager getInstance() {
@@ -86,23 +101,29 @@
             return;
         }
 
+        //Create a KeyStore Information  for private key entry KeyStore
         KeyStoreInformation keyStoreInformation = new KeyStoreInformation();
 
         keyStoreInformation.setAlias(
-                MiscellaneousUtil.getProperty(configurationProperties, 
IDENTITY_KEY_STORE_ALIAS, null));
+                MiscellaneousUtil.getProperty(configurationProperties,
+                        IDENTITY_KEY_STORE_ALIAS, null));
         keyStoreInformation.setLocation(
                 MiscellaneousUtil.getProperty(configurationProperties, 
IDENTITY_KEY_STORE, null));
         keyStoreInformation.setStoreType(
-                MiscellaneousUtil.getProperty(configurationProperties, 
IDENTITY_KEY_STORE_TYPE, null));
+                MiscellaneousUtil.getProperty(configurationProperties,
+                        IDENTITY_KEY_STORE_TYPE, null));
 
+        // Create a KeyStore Information for trusted certificate KeyStore
         KeyStoreInformation trustInformation = new KeyStoreInformation();
 
         trustInformation.setAlias(
                 MiscellaneousUtil.getProperty(configurationProperties, 
TRUST_KEY_STORE, null));
         trustInformation.setLocation(
-                MiscellaneousUtil.getProperty(configurationProperties, 
TRUST_KEY_STORE_ALIAS, null));
+                MiscellaneousUtil.getProperty(configurationProperties,
+                        TRUST_KEY_STORE_ALIAS, null));
         trustInformation.setStoreType(
-                MiscellaneousUtil.getProperty(configurationProperties, 
TRUST_KEY_STORE_TYPE, null));
+                MiscellaneousUtil.getProperty(configurationProperties,
+                        TRUST_KEY_STORE_TYPE, null));
 
         IdentityKeyStoreWrapper identityKeyStoreWrapper = new 
IdentityKeyStoreWrapper();
         identityKeyStoreWrapper.init(keyStoreInformation, identityStorePass, 
identityKeyPass);
@@ -128,6 +149,11 @@
             }
 
             if (REPO_TYPE_FILE.equals(type)) {
+
+                if (log.isDebugEnabled()) {
+                    log.debug("Initiating a File Based Secret Repository");
+                }
+
                 SecretRepository secretRepository = new 
FileBaseSecretRepository(
                         identityKeyStoreWrapper, trustStoreWrapper);
                 secretRepository.init(configurationProperties, id);
@@ -137,6 +163,10 @@
                 secretRepository.setParent(currentParent);
                 currentParent = secretRepository;
                 initialize = true;
+
+                if (log.isDebugEnabled()) {
+                    log.debug("Successfully Initiate a File Based Secret 
Repository");
+                }
             } else {
                 log.warn("Unsupported secret repository type : " + type);
             }

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/repository/FileBaseSecretRepository.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/repository/FileBaseSecretRepository.java?rev=673915&r1=673914&r2=673915&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/repository/FileBaseSecretRepository.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/repository/FileBaseSecretRepository.java
 Thu Jul  3 23:24:21 2008
@@ -51,11 +51,15 @@
     private final static String TRUSTED = "trusted";
     private final static String DEFAULT_CONF_LOCATION = 
"cipher-text.properties";
 
+    /* Parent secret repository */
     private SecretRepository parentRepository;
-
+    /*Map of secrets keyed by alias for property name */
     private final Map secrets = new HashMap();
+    /*Wrapper for Identity KeyStore */
     private IdentityKeyStoreWrapper identity;
+    /* Wrapper for trusted KeyStore */
     private TrustKeyStoreWrapper trust;
+    /* Whether this secrte repository has been initiated successfully*/
     private boolean initialize = false;
 
     public FileBaseSecretRepository(IdentityKeyStoreWrapper wrapper, 
TrustKeyStoreWrapper trust) {
@@ -122,7 +126,8 @@
             String keyStorePropertyKey = buffer.toString();
 
             //Load keyStore
-            String keyStore = MiscellaneousUtil.getProperty(cipherProperties, 
keyStorePropertyKey, null);
+            String keyStore = MiscellaneousUtil.getProperty(cipherProperties,
+                    keyStorePropertyKey, null);
 
             StringBuffer sbTwo = new StringBuffer();
             sbTwo.append(propKey);
@@ -171,6 +176,11 @@
         }
     }
 
+    /**
+     * @param alias Alias name for look up a secret
+     * @return Secret if there is any , otherwise ,alias itself
+     * @see org.apache.synapse.security.secret.SecretRepository
+     */
     public String getSecret(String alias) {
 
         if (alias == null || "".equals(alias)) {

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/CipherWrapper.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/CipherWrapper.java?rev=673915&r1=673914&r2=673915&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/CipherWrapper.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/CipherWrapper.java
 Thu Jul  3 23:24:21 2008
@@ -54,7 +54,7 @@
      * providing those
      *
      * @param information Encapsulated object contains all information 
required to cipher
-     * @param key         The key that will be used by the cipher either for 
encryption and secryption
+     * @param key       The key that will be used by the cipher either for 
encryption and encryption
      */
     public CipherWrapper(CipherInformation information, Key key) {
         this.information = information;

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/IdentityKeyStoreWrapper.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/IdentityKeyStoreWrapper.java?rev=673915&r1=673914&r2=673915&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/IdentityKeyStoreWrapper.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/wrappers/IdentityKeyStoreWrapper.java
 Thu Jul  3 23:24:21 2008
@@ -26,7 +26,8 @@
 
 /**
  * Represents the private keyStore entry
- * To provide that abstraction , this class exposes both getter methods to 
public, private and secret keys
+ * To provide that abstraction , this class exposes both getter methods to 
public,
+ * private and secret keys
  */
 public class IdentityKeyStoreWrapper extends KeyStoreWrapper {
 


Reply via email to