juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexo...@apache.org
Subject svn commit: r1515260 - in /juddi/trunk: juddi-client/src/main/java/org/apache/juddi/v3/client/config/ juddi-client/src/main/java/org/apache/juddi/v3/client/crypto/ juddi-client/src/test/java/org/apache/juddi/v3/client/ juddi-client/src/test/java/org/ap...
Date Mon, 19 Aug 2013 02:00:07 GMT
Author: alexoree
Date: Mon Aug 19 02:00:06 2013
New Revision: 1515260

URL: http://svn.apache.org/r1515260
Log:
JUDDI-614 fixing the build, the test case was incorrect after changing the clientconfig api
to automatically decrypt passwords
JUDDI-578 fixing an incorrect test by adding a trust store file and altering the test case

Added:
    juddi/trunk/juddi-client/src/test/resources/truststore.jks   (with props)
Modified:
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/crypto/DigSigUtil.java
    juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/DigSigUtilTest.java
    juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/config/CryptoConfigTest.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/CrytorUtil.java

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java?rev=1515260&r1=1515259&r2=1515260&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
(original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
Mon Aug 19 02:00:06 2013
@@ -828,6 +828,15 @@ public class UDDIClerk implements Serial
         }
         return password;
     }
+    
+    /**
+     * If the password is encrypted, it cipher text is returned, otherwise
+     * the clear text will be returned.
+     * @return 
+     */
+    public String getRawPassword() {
+        return password;
+    }
 
     /**
      * Use with caution, don't forget to set the IsEncrypted and Crypto provider

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/crypto/DigSigUtil.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/crypto/DigSigUtil.java?rev=1515260&r1=1515259&r2=1515260&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/crypto/DigSigUtil.java
(original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/crypto/DigSigUtil.java
Mon Aug 19 02:00:06 2013
@@ -583,7 +583,13 @@ public class DigSigUtil {
     }
 
     private KeyStore GetTrustStore() throws Exception {
-        KeyStore ks = KeyStore.getInstance(map.getProperty(TRUSTSTORE_FILETYPE));
+        String type=map.getProperty(TRUSTSTORE_FILETYPE);
+        if (type==null)
+            type="JKS";
+        KeyStore ks = KeyStore.getInstance(type);
+        String filename=map.getProperty(TRUSTSTORE_FILE);
+        if (filename==null)
+            return null;
         URL url = Thread.currentThread().getContextClassLoader().getResource(map.getProperty(TRUSTSTORE_FILE));
         if (url == null) {
             try {
@@ -824,6 +830,7 @@ public class DigSigUtil {
 
     private X509Certificate FindCertByDN(X500Principal name) throws Exception {
         KeyStore ks = GetTrustStore();
+        if (ks==null) return null;
         Enumeration<String> aliases = ks.aliases();
         while (aliases.hasMoreElements()) {
             String nextElement = aliases.nextElement();
@@ -856,6 +863,7 @@ public class DigSigUtil {
 
     private X509Certificate FindCertByIssuer(String X509IssuerName, String X509SerialNumber)
throws Exception {
         KeyStore ks = GetTrustStore();
+         if (ks==null) return null;
         Enumeration<String> aliases = ks.aliases();
         while (aliases.hasMoreElements()) {
             String nextElement = aliases.nextElement();

Modified: juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/DigSigUtilTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/DigSigUtilTest.java?rev=1515260&r1=1515259&r2=1515260&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/DigSigUtilTest.java
(original)
+++ juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/DigSigUtilTest.java
Mon Aug 19 02:00:06 2013
@@ -56,6 +56,12 @@ public class DigSigUtilTest {
         ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILETYPE, "JKS");
         ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILE_PASSWORD, "Test");
         ds.put(DigSigUtil.SIGNATURE_KEYSTORE_KEY_ALIAS, "Test");
+        
+        ds.put(DigSigUtil.TRUSTSTORE_FILE, "./src/test/resources/truststore.jks");
+        ds.put(DigSigUtil.TRUSTSTORE_FILETYPE, "JKS");
+        ds.put(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, "Test");
+        
+        
     }
 
     void SubjectDNOnly() throws CertificateException {
@@ -72,8 +78,9 @@ public class DigSigUtilTest {
 
     @Test
     public void testSignBusinessSubjectDNOnly() throws CertificateException {
+        
         SubjectDNOnly();
-        System.out.println("signing");
+        System.out.println("testSignBusinessSubjectDNOnly signing");
         BusinessEntity be = new BusinessEntity();
         be.setBusinessKey("uddi:juddi.apache.org:testkey");
         be.setDiscoveryURLs(new DiscoveryURLs());
@@ -98,8 +105,9 @@ public class DigSigUtilTest {
 
     @Test
     public void testSignBusinessSerialAndIssuerOnly() throws CertificateException {
+        System.out.println("testSignBusinessSerialAndIssuerOnly signing");
         SerialAndIssuerOnly();
-        System.out.println("signing");
+        
         BusinessEntity be = new BusinessEntity();
         be.setBusinessKey("uddi:juddi.apache.org:testkey");
         be.setDiscoveryURLs(new DiscoveryURLs());
@@ -127,7 +135,7 @@ public class DigSigUtilTest {
         Default();
 
 
-        System.out.println("signing");
+        System.out.println("testSignBusiness signing");
         BusinessEntity be = new BusinessEntity();
         be.setBusinessKey("uddi:juddi.apache.org:testkey");
         be.setDiscoveryURLs(new DiscoveryURLs());
@@ -152,7 +160,7 @@ public class DigSigUtilTest {
     @Test
     public void testSignService() throws CertificateException {
         Default();
-        System.out.println("signing");
+        System.out.println("testSignService signing");
         BusinessService be = new BusinessService();
         be.setBusinessKey("uddi:juddi.apache.org:testkey");
 
@@ -176,7 +184,7 @@ public class DigSigUtilTest {
     @Test
     public void testSignTmodel() throws CertificateException {
         Default();
-        System.out.println("signing");
+        System.out.println("testSignTmodel signing");
         TModel be = new TModel();
         be.setTModelKey("uddi:juddi.apache.org:testkey");
 
@@ -200,7 +208,7 @@ public class DigSigUtilTest {
     @Test
     public void testSignBinding() throws CertificateException {
         Default();
-        System.out.println("signing");
+        System.out.println("testSignBinding signing");
         BindingTemplate be = new BindingTemplate();
         be.setBindingKey("uddi:juddi.apache.org:testkey");
 
@@ -224,7 +232,7 @@ public class DigSigUtilTest {
     @Test
     public void testSignPublisherAssertion() throws CertificateException {
         Default();
-        System.out.println("signing");
+        System.out.println("testSignPublisherAssertion signing");
         PublisherAssertion be = new PublisherAssertion();
         be.setFromKey("uddi:juddi.apache.org:testkey");
         be.setToKey("uddi:juddi.apache.org:testkey");

Modified: juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/config/CryptoConfigTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/config/CryptoConfigTest.java?rev=1515260&r1=1515259&r2=1515260&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/config/CryptoConfigTest.java
(original)
+++ juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/config/CryptoConfigTest.java
Mon Aug 19 02:00:06 2013
@@ -39,11 +39,11 @@ public class CryptoConfigTest {
         UDDIClerk c = clerkManager.getClerk("default");
         UDDIClerk c2 = clerkManager.getClerk("medroot");
         Assert.assertNotSame(c.getPassword(), c2.getPassword());
-        Assert.assertEquals("7d3e79ca453f4ebfd36e22afe029c3a2", c.getPassword());
-        Assert.assertEquals("root", CryptorFactory.getCryptor(c.getCryptoProvider()).decrypt(c.getPassword()));
+        Assert.assertEquals("root", CryptorFactory.getCryptor(c.getCryptoProvider()).decrypt(c.getRawPassword()));
+        Assert.assertEquals("root", c.getPassword());
 
-        Assert.assertEquals("18604180541d172f9827e08c998db568", c2.getPassword());
-        Assert.assertEquals("password", CryptorFactory.getCryptor(c2.getCryptoProvider()).decrypt(c2.getPassword()));
+        Assert.assertEquals("password", CryptorFactory.getCryptor(c2.getCryptoProvider()).decrypt(c2.getRawPassword()));
+        Assert.assertEquals("password", c2.getPassword());
 
 
     }

Added: juddi/trunk/juddi-client/src/test/resources/truststore.jks
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/resources/truststore.jks?rev=1515260&view=auto
==============================================================================
Binary file - no diff available.

Propchange: juddi/trunk/juddi-client/src/test/resources/truststore.jks
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/CrytorUtil.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/CrytorUtil.java?rev=1515260&r1=1515259&r2=1515260&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/CrytorUtil.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/CrytorUtil.java Mon Aug
19 02:00:06 2013
@@ -17,7 +17,7 @@ package org.apache.juddi.v3.auth;
 
 import org.apache.juddi.cryptor.Cryptor;
 import org.apache.juddi.cryptor.CryptorFactory;
- 
+
 /**
  *
  * @author Alex O'Ree
@@ -25,21 +25,30 @@ import org.apache.juddi.cryptor.CryptorF
  */
 public class CrytorUtil {
 
-    public static void main(String[] args) throws Exception{
+    public static void main(String[] args) throws Exception {
         if (args.length == 0) {
             PrintUsage();
             return;
         }
-        Cryptor cryptor = CryptorFactory.getCryptor(args[0]);
-        System.out.print("Password: ");
-        char[] readPassword = System.console().readPassword();
-        System.out.println("Cipher: " +  cryptor.encrypt(new String(readPassword)));
+        String impl = args[0];
+        if (args[0].equalsIgnoreCase("decrypt")) {
+            impl = args[1];
+            Cryptor cryptor = CryptorFactory.getCryptor(impl);
+            System.out.print("Cipher: ");
+            char[] readPassword = System.console().readPassword();
+            System.out.println("Clear: " + cryptor.decrypt(new String(readPassword)));
+        } else {
+            Cryptor cryptor = CryptorFactory.getCryptor(impl);
+            System.out.print("Password: ");
+            char[] readPassword = System.console().readPassword();
+            System.out.println("Cipher: " + cryptor.encrypt(new String(readPassword)));
+        }
     }
 
     private static void PrintUsage() {
         System.out.println("Encrypts a password using the specified crypto provider");
         System.out.println("Usage: java -cp (classpath) org.apache.juddi.v3.auth.CrytorUtil
(CryptoProvider)");
-        
+
         System.out.println("Provided crypto providers:");
         System.out.println("\torg.apache.juddi.cryptor.DefaultCryptor - uses PBEWithMD5AndDES");
         System.out.println("\torg.apache.juddi.cryptor.TripleDESCrytor - uses TripleDES");



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org


Mime
View raw message