You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2014/01/18 02:18:22 UTC

svn commit: r1559301 - in /juddi/trunk: juddi-client/src/main/java/org/apache/juddi/v3/client/config/ juddi-core/src/main/java/org/apache/juddi/v3/auth/ juddi-gui/ juddi-gui/src/main/java/org/apache/juddi/webconsole/ juddi-gui/src/main/java/org/apache/...

Author: alexoree
Date: Sat Jan 18 01:18:21 2014
New Revision: 1559301

URL: http://svn.apache.org/r1559301
Log:
JUDDI-791 hopefully fixed for juddi-gui and admin console
JUDDI-246 revising javadoc

Modified:
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClient.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/LdapExpandedAuthenticator.java
    juddi/trunk/juddi-gui/pom.xml
    juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/AES.java
    juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/StartupServlet.java
    juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java
    juddi/trunk/juddiv3-war/pom.xml
    juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/AES.java
    juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/StartupServlet.java
    juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/hub/UddiAdminHub.java
    juddi/trunk/juddiv3-war/src/main/webapp/admin/ajax/loginpost.jsp
    juddi/trunk/juddiv3-war/src/main/webapp/admin/js/main.js
    juddi/trunk/juddiv3-war/src/main/webapp/admin/login.jsp
    juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_160_RESTIntergrationTest.java

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClient.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClient.java?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClient.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClient.java Sat Jan 18 01:18:21 2014
@@ -135,7 +135,8 @@ public class UDDIClient {
     }
 
     /**
-     * Stops the clerks.
+     * Stops the clerks. If transport is InVM, all database resources are released.
+     * If anything was auto registered, it will be removed prior to shutdown
      *
      * @throws ConfigurationException
      */
@@ -162,7 +163,8 @@ public class UDDIClient {
     }
 
     /**
-     * Initializes the UDDI Clerk.
+     * Initializes the UDDI Clerk. If transport is set to InVM, this will initialize 
+     * all database connections, other it will trigger all background registration threads
      *
      * @throws ConfigurationException
      */
@@ -206,6 +208,10 @@ public class UDDIClient {
         }
     }
 
+    /**
+     * calls stop and start again
+     * @throws ConfigurationException 
+     */
     public void restart() throws ConfigurationException {
         stop();
         start();
@@ -345,10 +351,18 @@ public class UDDIClient {
 
     }
 
+    /**
+     * Returns a live instance of the raw configuration file
+     * @return 
+     */
     public ClientConfig getClientConfig() {
         return clientConfig;
     }
     
+    /**
+     * returns getClientConfig().getClientName()
+     * @return 
+     */
     public String getName() {
         return clientConfig.getClientName();
     }

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/LdapExpandedAuthenticator.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/LdapExpandedAuthenticator.java?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/LdapExpandedAuthenticator.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/auth/LdapExpandedAuthenticator.java Sat Jan 18 01:18:21 2014
@@ -49,15 +49,15 @@ import org.apache.commons.configuration.
  * Usage:
  * 
  * To use this class you must add the following properties to the
- * juddiv3.properties file:
+ * juddiv3.xml file:
  * 
  * # The LDAP Authenticator
- * juddi.authenticator=org.apache.juddi.v3.auth.LdapSimpleAuthenticator
+ * juddi/auth/class=org.apache.juddi.v3.auth.LdapSimpleAuthenticator
  * 
  * # LDAP authentication URL
- * juddi.authenticator.url=ldap://localhost:389
+ * juddi/auth/url=ldap://localhost:389
  *
- * juddi.authenticator.ldapexp=CN=%s, OU=Users,DC=Domain, etc
+ * juddi/auth/ldapexp=CN=%s, OU=Users,DC=Domain, etc
  * 
  * This authenticator assumes that the publisher username can be reformatted to a LDAP 
  * common name. This is common for Microsoft based LDAPs. The configuration item juddi.authenticator.ldapexp

Modified: juddi/trunk/juddi-gui/pom.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-gui/pom.xml?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddi-gui/pom.xml (original)
+++ juddi/trunk/juddi-gui/pom.xml Sat Jan 18 01:18:21 2014
@@ -54,8 +54,8 @@ language governing permissions and * lim
         </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.1</version>
+			  <artifactId>commons-lang3</artifactId>
+			  <version>3.2.1</version>
         </dependency>
         <dependency>
             <groupId>commons-collections</groupId>

Modified: juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/AES.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/AES.java?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/AES.java (original)
+++ juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/AES.java Sat Jan 18 01:18:21 2014
@@ -18,6 +18,7 @@ package org.apache.juddi.webconsole;
 
 import javax.crypto.*;
 import javax.crypto.spec.*;
+import org.apache.commons.codec.binary.Base64;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -36,49 +37,6 @@ public class AES {
         public static final Log log = LogFactory.getLog(logname);
 
         /**
-         * Turns array of bytes into string
-         *
-         * @param buf	Array of bytes to convert to hex string
-         * @return	Generated hex string
-         */
-        private static String asHex(byte buf[]) {
-                //return new String(buf);
-                StringBuilder strbuf = new StringBuilder(buf.length * 2);
-                int i;
-
-                for (i = 0; i < buf.length; i++) {
-                        if (((int) buf[i] & 0xff) < 0x10) {
-                                strbuf.append("0");
-                        }
-                        strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
-                }
-
-                return strbuf.toString();
-        }
-
-        private static byte[] hexToBytes(String s) {
-                //return s.getBytes();
-                return hexToBytes(s.toCharArray());
-        }
-        private static final char[] kDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a',
-                'b', 'c', 'd', 'e', 'f'};
-
-        private static byte[] hexToBytes(char[] hex) {
-                int length = hex.length / 2;
-                byte[] raw = new byte[length];
-                for (int i = 0; i < length; i++) {
-                        int high = Character.digit(hex[i * 2], 16);
-                        int low = Character.digit(hex[i * 2 + 1], 16);
-                        int value = (high << 4) | low;
-                        if (value > 127) {
-                                value -= 256;
-                        }
-                        raw[i] = (byte) value;
-                }
-                return raw;
-        }
-
-        /**
          * generates an AES based off of the selected key size
          *
          * @param keysize
@@ -92,7 +50,7 @@ public class AES {
                         kgen.init(keysize);
                         SecretKey skey = kgen.generateKey();
                         byte[] raw = skey.getEncoded();
-                        return asHex(raw);
+                        return Base64.encodeBase64String(raw);
                 } catch (Exception ex) {
                         log.fatal("error generating key", ex);
                 }
@@ -111,22 +69,22 @@ public class AES {
 
         static String EN(String cleartext, String key) throws Exception {
                 byte[] raw =//skey.getEncoded();
-                        hexToBytes(key); //
+                        Base64.decodeBase64(key); //
                 SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
                 // Instantiate the cipher
                 Cipher cipher = Cipher.getInstance("AES");
                 cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
                 byte[] encrypted = cipher.doFinal(cleartext.getBytes());
-                return asHex(encrypted);
+                return Base64.encodeBase64String(encrypted);
         }
 
         static String DE(String ciphertext, String key) throws Exception {
                 byte[] raw =//skey.getEncoded();
-                        hexToBytes(key); //
+                        Base64.decodeBase64(key); //
                 SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
                 Cipher cipher = Cipher.getInstance("AES");
                 cipher.init(Cipher.DECRYPT_MODE, skeySpec);
-                byte[] original = cipher.doFinal(hexToBytes(ciphertext));
+                byte[] original = cipher.doFinal(Base64.decodeBase64(ciphertext));
                 return new String(original);
         }
 

Modified: juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/StartupServlet.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/StartupServlet.java?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/StartupServlet.java (original)
+++ juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/StartupServlet.java Sat Jan 18 01:18:21 2014
@@ -44,24 +44,39 @@ public class StartupServlet implements j
                 try {
                         //URL resource = sce.getServletContext().getResource("/META-INF/config.properties");
                         Properties p = new Properties();
-                        InputStream is = sce.getServletContext().getResourceAsStream("/META-INF/config.properties");
-                        p.load(is);
-                        is.close();
-                        p.remove("key");
+
                         log.info("Attempting to generate 256 bit AES key");
+                        boolean ok = false;
                         String key = AES.GEN(256);
                         if (key == null) {
-                                log.info("FAILED. Now attempting to generate 128 bit AES key");
-                                key = AES.GEN(128);
+                                ok = false;
                         } else {
-                                log.info("Generatation of 256 bit AES key successful");
+                                if (AES.ValidateKey(key)) {
+                                        log.info("Generation of 256 bit AES key successful");
+                                        ok = true;
+                                } else {
+                                        log.info("256 bit key validation failed.");
+                                }
                         }
-                        if (key == null) {
-                                log.log(Level.SEVERE, "128 bit key generation failed! user credentials may not be encrypted");
+                        if (!ok) {
+                                log.info("Attempting to generate 128 bit AES key");
+                                key = AES.GEN(128);
+                                if (key == null) {
+                                        log.log(Level.SEVERE, "128 bit key generation failed! user's won't be able to login!");
+                                        return;
+                                } else if (AES.ValidateKey(key)) {
+                                        log.info("Generation of 128 bit AES key successful");
+                                } else {
+                                        log.severe("128 bit key validation failed! giving up, user's won't be able to login! ");
+                                        return;
+
+                                }
                         }
+
                         p.put("key", key);
                         fos = new FileOutputStream(sce.getServletContext().getRealPath("/META-INF/config.properties"));
 
+                        log.log(Level.INFO, "Storing key to " + sce.getServletContext().getRealPath("/META-INF/config.properties"));
                         p.store(fos, "No comments");
                         fos.flush();
                         fos.close();

Modified: juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java (original)
+++ juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java Sat Jan 18 01:18:21 2014
@@ -22,6 +22,7 @@ import java.io.Serializable;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.rmi.RemoteException;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
@@ -844,35 +845,7 @@ public class UddiHub implements Serializ
                 return null;
         }
 
-        /**
-         * Calls Publisher Save Service API
-         *
-         * @param be
-         * @return
-         */
-        public String SaveService(BusinessService be) {
-                try {
-                        SaveService sb = new SaveService();
-                        sb.setAuthInfo(GetToken());
-                        sb.getBusinessService().add(be);
-                        try {
-                                publish.saveService(sb);
-                        } catch (Exception ex) {
-                                if (isExceptionExpiration(ex)) {
-                                        token = null;
-                                        sb.setAuthInfo(GetToken());
-                                        publish.saveService(sb);
-                                } else {
-                                        throw ex;
-                                }
-                        }
-
-                        return ResourceLoader.GetResource(session, "actions.saved");
-                } catch (Exception ex) {
-                        return HandleException(ex);
-                }
-        }
-
+        
         /**
          * don't think this is used yet
          *
@@ -953,20 +926,23 @@ public class UddiHub implements Serializ
                 try {
                         SaveService sb = new SaveService();
                         sb.setAuthInfo(GetToken());
+                         ServiceDetail saveService =null;
                         sb.getBusinessService().add(be);
                         try {
-                                publish.saveService(sb);
+                                 saveService = publish.saveService(sb);
                         } catch (Exception ex) {
                                 if (isExceptionExpiration(ex)) {
                                         token = null;
                                         sb.setAuthInfo(GetToken());
-                                        publish.saveService(sb);
+                                        saveService =   publish.saveService(sb);
 
                                 } else {
                                         throw ex;
                                 }
                         }
-                        return ResourceLoader.GetResource(session, "actions.save.service");
+                        return ResourceLoader.GetResource(session, "actions.saved") + " " +
+                                "<a href=\"businessEditor2.jsp?id=" + URLEncoder.encode(saveService.getBusinessService().get(0).getServiceKey(),"UTF8") +
+                                "\">" + StringEscapeUtils.escapeHtml(saveService.getBusinessService().get(0).getServiceKey()) + "</a>";        
                 } catch (Exception ex) {
                         return HandleException(ex);
                 }
@@ -983,20 +959,23 @@ public class UddiHub implements Serializ
                         SaveBusiness sb = new SaveBusiness();
                         sb.setAuthInfo(GetToken());
                         sb.getBusinessEntity().add(be);
+                        BusinessDetail saveBusiness=null;
                         try {
-                                publish.saveBusiness(sb);
+                                 saveBusiness = publish.saveBusiness(sb);
                         } catch (Exception ex) {
                                 if (isExceptionExpiration(ex)) {
                                         token = null;
                                         sb.setAuthInfo(GetToken());
-                                        publish.saveBusiness(sb);
+                                      saveBusiness=  publish.saveBusiness(sb);
 
                                 } else {
                                         throw ex;
                                 }
                         }
 
-                        return ResourceLoader.GetResource(session, "actions.saved");
+                        return ResourceLoader.GetResource(session, "actions.saved") + " " +
+                                "<a href=\"businessEditor2.jsp?id=" + URLEncoder.encode(saveBusiness.getBusinessEntity().get(0).getBusinessKey(),"UTF8") +
+                                "\">" + StringEscapeUtils.escapeHtml(saveBusiness.getBusinessEntity().get(0).getBusinessKey()) + "</a>";        
                 } catch (Exception ex) {
                         return HandleException(ex);
                 }
@@ -2070,22 +2049,25 @@ public class UddiHub implements Serializ
                 try {
                         SaveTModel sb = new SaveTModel();
                         sb.setAuthInfo(GetToken());
-
+                        TModelDetail saveTModel=null;
                         sb.getTModel().add(be);
                         //JAXB.marshal(be, System.out);
                         try {
-                                publish.saveTModel(sb);
+                                 saveTModel = publish.saveTModel(sb);
                         } catch (Exception ex) {
                                 if (isExceptionExpiration(ex)) {
                                         token = null;
                                         sb.setAuthInfo(GetToken());
-                                        publish.saveTModel(sb);
+                                         saveTModel = publish.saveTModel(sb);
 
                                 } else {
                                         throw ex;
                                 }
                         }
-                        return ResourceLoader.GetResource(session, "actions.saved");
+                        //return ResourceLoader.GetResource(session, "actions.saved");
+                        return ResourceLoader.GetResource(session, "actions.saved") + " " +
+                                "<a href=\"tmodelEditor.jsp?id=" + URLEncoder.encode(saveTModel.getTModel().get(0).getTModelKey(),"UTF8") +
+                                "\">" + StringEscapeUtils.escapeHtml(saveTModel.getTModel().get(0).getTModelKey()) + "</a>";
                 } catch (Exception ex) {
                         return HandleException(ex);
                 }

Modified: juddi/trunk/juddiv3-war/pom.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/juddiv3-war/pom.xml?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddiv3-war/pom.xml (original)
+++ juddi/trunk/juddiv3-war/pom.xml Sat Jan 18 01:18:21 2014
@@ -40,12 +40,12 @@
 		<dependency>
 			<groupId>commons-configuration</groupId>
 			<artifactId>commons-configuration</artifactId>
-			<version>1.9</version>
+			<version>1.10</version>
 		</dependency>
 		    <dependency>
-	           <groupId>org.apache.commons</groupId>
-			   <artifactId>commons-lang3</artifactId>
-			    <version>3.1</version>
+	         <groupId>org.apache.commons</groupId>
+  <artifactId>commons-lang3</artifactId>
+  <version>3.2.1</version>
 			</dependency>
 			<dependency>
 		<groupId>org.json</groupId>

Modified: juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/AES.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/AES.java?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/AES.java (original)
+++ juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/AES.java Sat Jan 18 01:18:21 2014
@@ -14,297 +14,150 @@
  * limitations under the License.
  *
  */
-package  org.apache.juddi.webconsole;
+package org.apache.juddi.webconsole;
 
-import java.io.*;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
+import java.nio.charset.Charset;
 import javax.crypto.*;
 import javax.crypto.spec.*;
+import org.apache.commons.codec.binary.Base64;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-
 /**
  * <summary> This program uses a AES key, retrieves its raw bytes, and then
  * reinstantiates a AES key from the key bytes.</summary> The reinstantiated key
  * is used to initialize a AES cipher for encryption and decryption. source :
  * http://java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html
- *@author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
+ *
+ * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
  */
 public class AES {
 
-    public static final String logname = "org.apache.juddi.gui";
-    public static final Log log = LogFactory.getLog(logname);
-
-    /**
-     * Turns array of bytes into string
-     *
-     * @param buf	Array of bytes to convert to hex string
-     * @return	Generated hex string
-     */
-    private static String asHex(byte buf[]) {
-        //return new String(buf);
-        StringBuilder strbuf = new StringBuilder(buf.length * 2);
-        int i;
-
-        for (i = 0; i < buf.length; i++) {
-            if (((int) buf[i] & 0xff) < 0x10) {
-                strbuf.append("0");
-            }
-            strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
-        }
-
-        return strbuf.toString();
-    }
-
-    private static byte[] hexToBytes(String s) {
-        //return s.getBytes();
-        return hexToBytes(s.toCharArray());
-    }
-    private static final char[] kDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a',
-        'b', 'c', 'd', 'e', 'f'};
-
-    private static byte[] hexToBytes(char[] hex) {
-        int length = hex.length / 2;
-        byte[] raw = new byte[length];
-        for (int i = 0; i < length; i++) {
-            int high = Character.digit(hex[i * 2], 16);
-            int low = Character.digit(hex[i * 2 + 1], 16);
-            int value = (high << 4) | low;
-            if (value > 127) {
-                value -= 256;
-            }
-            raw[i] = (byte) value;
-        }
-        return raw;
-    }
-    //default key
-    private final static String something2 = "dde284c781d60ca0b56c4b23eec85217951dc99869402abd42c7dcc9080d60aa";
-
-    /**
-     * generates an AES based off of the selected key size
-     * @param keysize
-     * @return may return null if the key is not of a supported size by the current jdk
-     */
-    public static String GEN(int keysize) {
-        KeyGenerator kgen;
-        try {
-            kgen = KeyGenerator.getInstance("AES");
-            kgen.init(keysize);
-            SecretKey skey = kgen.generateKey();
-            byte[] raw = skey.getEncoded();
-            return asHex(raw);
-        } catch (Exception ex) {
-            log.fatal("error generating key", ex);
-        }
-        return null;
-    }
-
-    /**
-     * Generate a new AES 256 bit encryption key. Once generated, this key can
-     * be used to replace the default key.
-     *
-     * @return
-     */
-    public static String GEN() {
-        return GEN(256);
-    }
-
-    /**
-     * uses a variety of mechanisms to load a resource, should be jdk and os independent
-     * @param FileName
-     * @return 
-     */
-    URI getUrl(String FileName) {
-        URL url = null;
-        if (url == null) {
-            try {
-                url = Thread.currentThread().getContextClassLoader().getResource(FileName);
-                log.debug( "8 file loaded  from " + url.toString());
-            } catch (Exception ex) {
-                log.debug( "not found", ex);
-            }
-        }
-        if (url == null) {
-            try {
-                url = Thread.currentThread().getContextClassLoader().getResource("/" + FileName);
-                log.debug( "7 file loaded  from " + url.toString());
-            } catch (Exception ex) {
-                log.debug( "not found", ex);
-            }
-        }
-
-        if (url == null) {
-            try {
-                url = new URL(FileName);
-                log.debug( "1 file loaded  from " + url.toString());
-            } catch (Exception ex) {
-                log.debug( "not found", ex);
-            }
-        }
-
-        if (url == null) {
-            try {
-                url = this.getClass().getClassLoader().getResource(FileName);
-                log.debug( "3 file loaded  from " + url.toString());
-            } catch (Exception ex) {
-                log.debug( "not found", ex);
-            }
-        }
-        if (url == null) {
-            try {
-                url = this.getClass().getClassLoader().getResource("/" + FileName);
-                log.debug( "3 file loaded  from " + url.toString());
-            } catch (Exception ex) {
-                log.debug( "not found", ex);
-            }
-        }
-        try {
-            return url.toURI();
-        } catch (URISyntaxException ex) {
-            log.debug( null, ex);
-        }
-        return null;
-    }
-
-    /**
-     * used to read our key file
-     * @param file
-     * @return 
-     */
-    private static String ReadAllText(File file) {
-        try {
-            FileInputStream stream = new FileInputStream(file);
-            int size = 1024;
-            byte chars[] = new byte[size];
-            int k = stream.read(chars);
-            StringBuilder str = new StringBuilder();
-            while (k > 0) {
+        public static final String logname = "org.apache.juddi.gui";
+        public static final Log log = LogFactory.getLog(logname);
 
-                for (int i = 0; i < k; i++) {
-                    str.append((char) chars[i]);
+        /**
+         * generates an AES based off of the selected key size
+         *
+         * @param keysize
+         * @return may return null if the key is not of a supported size by the
+         * current jdk
+         */
+        public static String GEN(int keysize) {
+                KeyGenerator kgen;
+                try {
+                        kgen = KeyGenerator.getInstance("AES");
+                        kgen.init(keysize);
+                        SecretKey skey = kgen.generateKey();
+                        byte[] raw = skey.getEncoded();
+                        return new String(Base64.encodeBase64(raw), Charset.defaultCharset());
+                } catch (Exception ex) {
+                        log.fatal("error generating key", ex);
                 }
-                k = stream.read(chars);
-            }
-            stream.close();
-            return str.toString();
-        } catch (Exception e) {
-            return "";
+                return null;
         }
 
-    }
-
-    private static String LoadKey() {
-        String key = null;
-        try {
-            File f = new File(new AES().getUrl("/META-INF/aes.key"));
-            key = ReadAllText(f);
-        } catch (Exception e) {
-        }
-        if (key != null) {
-            log.debug( "key loaded from file");
-            return key;
-        } else {
-            log.debug( "default encryption key loaded.");
-            return something2;
+        /**
+         * Generate a new AES 256 bit encryption key. Once generated, this key
+         * can be used to replace the default key.
+         *
+         * @return
+         */
+        public static String GEN() {
+                return GEN(256);
+        }
+
+        static String EN(String cleartext, String key) throws Exception {
+                byte[] raw =//skey.getEncoded();
+                        Base64.decodeBase64(key.getBytes(Charset.defaultCharset())); //
+                SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+                // Instantiate the cipher
+                Cipher cipher = Cipher.getInstance("AES");
+                cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
+                byte[] encrypted = cipher.doFinal(cleartext.getBytes());
+                return  new String(Base64.encodeBase64(encrypted), Charset.defaultCharset());
+        }
+
+        static String DE(String ciphertext, String key) throws Exception {
+                byte[] raw =//skey.getEncoded();
+                        Base64.decodeBase64(key.getBytes(Charset.defaultCharset())); //
+                SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+                Cipher cipher = Cipher.getInstance("AES");
+                cipher.init(Cipher.DECRYPT_MODE, skeySpec);
+                byte[] original = cipher.doFinal(Base64.decodeBase64(ciphertext.getBytes(Charset.defaultCharset())));
+                return new String(original);
+        }
+
+        /**
+         * return true is the supplied key is a valid aes key
+         *
+         * @param key
+         * @return
+         */
+        public static boolean ValidateKey(String key) {
+                try {
+                        String src = "abcdefghijklmopqrstuvwxyz123567890!@#$%^&*()_+{}|:\">?<,";
+                        String x = EN(src, key);
+                        String y = DE(x, key);
+                        //if the sample text is encryptable and decryptable, and it was actually encrypted
+                        if (y.equals(src) && !x.equals(y)) {
+                                return true;
+                        }
+                        return false;
+                } catch (Exception ex) {
+                        log.info("Key validation failed!", ex);
+                        return false;
+                }
         }
-    }
 
-    public static String EN(String cleartext) throws Exception {
-        return EN(cleartext, LoadKey());
-    }
-
-    static String EN(String cleartext, String key) throws Exception {
-        byte[] raw =//skey.getEncoded();
-                hexToBytes(key); //
-        SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
-        // Instantiate the cipher
-        Cipher cipher = Cipher.getInstance("AES");
-        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
-        byte[] encrypted = cipher.doFinal(cleartext.getBytes());
-        return asHex(encrypted);
-    }
-
-    static String DE(String ciphertext) throws Exception {
-        return DE(ciphertext, LoadKey());
-    }
-
-    static String DE(String ciphertext, String key) throws Exception {
-        byte[] raw =//skey.getEncoded();
-                hexToBytes(key); //
-        SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
-        Cipher cipher = Cipher.getInstance("AES");
-        cipher.init(Cipher.DECRYPT_MODE, skeySpec);
-        byte[] original = cipher.doFinal(hexToBytes(ciphertext));
-        return new String(original);
-    }
-
-    /**
-     * return true is the supplied key is a valid aes key
-     *
-     * @param key
-     * @return
-     */
-    public static boolean ValidateKey(String key) {
-        try {
-            String src = "abcdefghijklmopqrstuvwxyz123567890!@#$%^&*()_+{}|:\">?<,";
-            String x = EN(src, key);
-            String y = DE(x, key);
-            //if the sample text is encryptable and decryptable, and it was actually encrypted
-            if (x.equals(src) && !x.equals(y)) {
-                return true;
-            }
-            return false;
-        } catch (Exception ex) {
-            log.warn( null, ex);
-            return false;
+        /**
+         * encrypts a password using AES Requires the Unlimited Strength Crypto
+         * Extensions
+         *
+         * @param clear
+         * @param key
+         * @return
+         */
+        public static String Encrypt(String clear, String key) throws Exception {
+                if ((clear == null || clear.length() == 0)) {
+                        return "";
+                }
+                if (key == null || key.length() == 0) {
+                        log.fatal("The generated encryption key was null or emtpy!");
+                }
+                try {
+                        return AES.EN(clear, key);
+                } catch (Exception ex) {
+                        log.fatal("Cannot encrypt sensitive information! Check to make sure the unlimited strength JCE is installed " + ex.getMessage(), ex);
+                        throw new Exception("Internal Configuration Error, See Log for details. ");
+                }
+                // return "";
         }
-    }
 
-    /**
-     * encrypts a password using AES  Requires the Unlimited Strength Crypto
-     * Extensions
-     *
-     * @param clear
-     * @return
-     */
-    public static String Encrypt(String clear, String key) {
-        if ((clear==null || clear.length()==0)) {
-            return "";
-        }
-        try {
-            return AES.EN(clear, key);
-        } catch (Exception ex) {
-            log.fatal("Cannot encrypt sensitive information! Check to make sure the unlimited strength JCE is installed " + ex.getMessage());
-        }
-        return "";
-    }
+        /**
+         * Decrypts a password or other sensitive data If the parameter is null
+         * or empty, an empty string is returned. If the parameter is not
+         * encrypted or was encrypted using a different key or it fails to
+         * decrypt, the original text is returned.
+         *
+         * @param cipher encrypted text
+         * @param key
+         * @return
+         */
+        public static String Decrypt(String cipher, String key) {
+                if ((cipher == null || cipher.length() == 0)) {
+                        return "";
+                }
+                if (key == null || key.length() == 0) {
+                        log.fatal("The generated encryption key was null or emtpy!");
+                }
+                try {
+                        return AES.DE(cipher, key);
+                } catch (Exception ex) {
+                        log.fatal("trouble decrypting data, check to make sure the unlimited strength JCE is installed. If this error occured during deployment, I'll automatically try a smaller key size. " + ex.getMessage(), ex);
+                }
+                return cipher;
 
-    /**
-     * Decrypts a password or other sensitive data If the parameter is null or
-     * empty, an empty string is returned. If the parameter is not encrypted or
-     * was encrypted using a different key or it fails to decrypt, the original
-     * text is returned.
-     *
-     * @param cipher
-     * @return
-     */
-    public static String Decrypt(String cipher, String key) {
-        if ((cipher==null || cipher.length()==0)) {
-            return "";
-        }
-        try {
-            return AES.DE(cipher, key);
-        } catch (Exception ex) {
-            log.fatal("trouble decrypting data, check to make sure the unlimited strength JCE is installed. If this error occured during deployment, I'll automatically try a smaller key size. " + ex.getMessage());
         }
-        return cipher;
-
-    }
-
- 
- 
 }

Modified: juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/StartupServlet.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/StartupServlet.java?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/StartupServlet.java (original)
+++ juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/StartupServlet.java Sat Jan 18 01:18:21 2014
@@ -7,52 +7,113 @@ package org.apache.juddi.webconsole;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.servlet.ServletContextEvent;
 
 /**
- * This startup servlet's job is to generate an encryption key which will be used for encrypting
- * cached user credentials in the http session object
+ * This startup servlet's job is to generate an encryption key which will be
+ * used for encrypting cached user credentials in the http session object
+ *
  * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
  */
 public class StartupServlet implements javax.servlet.ServletContextListener {
 
-    /**
-     * creates a new AES key and stores it to the properties files
-     * @param sce 
-     */
-    public void contextInitialized(ServletContextEvent sce) {
-        FileOutputStream fos = null;
-        try {
-            //URL resource = sce.getServletContext().getResource("/META-INF/config.properties");
-            Properties p = new Properties();
-            InputStream is = sce.getServletContext().getResourceAsStream("/WEB-INF/config.properties");
-            p.load(is);
-            p.remove("key");
-            String key = AES.GEN(256);
-            if (key == null) {
-                key = AES.GEN(128);
-            }
-            p.put("key", key);
-            fos = new FileOutputStream(sce.getServletContext().getRealPath("/WEB-INF/config.properties"));
-
-            p.store(fos, "No comments");
-            fos.flush();
-            fos.close();
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            try {
-                if (fos != null) {
-                    fos.close();
+        static final Logger log = Logger.getLogger(StartupServlet.class.getCanonicalName());
+
+        /**
+         * creates a new AES key and stores it to the properties files
+         *
+         * @param sce
+         */
+        public void contextInitialized(ServletContextEvent sce) {
+                log.info("juddi-admin gui startup");
+                FileOutputStream fos = null;
+                try {
+                        //URL resource = sce.getServletContext().getResource("/META-INF/config.properties");
+                        Properties p = new Properties();
+
+                        log.info("Attempting to generate 256 bit AES key");
+                        boolean ok = false;
+                        String key = AES.GEN(256);
+                        if (key == null) {
+                                ok = false;
+                        } else {
+                                if (AES.ValidateKey(key)) {
+                                        log.info("Generation of 256 bit AES key successful");
+                                        ok = true;
+                                } else {
+                                        log.info("256 bit key validation failed.");
+                                }
+                        }
+                        if (!ok) {
+                                log.info("Attempting to generate 128 bit AES key");
+                                key = AES.GEN(128);
+                                if (key == null) {
+                                        log.log(Level.SEVERE, "128 bit key generation failed! user's won't be able to login!");
+                                        return;
+                                } else if (AES.ValidateKey(key)) {
+                                        log.info("Generation of 128 bit AES key successful");
+                                } else {
+                                        log.severe("128 bit key validation failed! giving up, user's won't be able to login! ");
+                                        return;
+
+                                }
+                        }
+
+                        p.put("key", key);
+                        fos = new FileOutputStream(sce.getServletContext().getRealPath("/WEB-INF/config.properties"));
+
+                        log.log(Level.INFO, "Storing key to " + sce.getServletContext().getRealPath("/WEB-INF/config.properties"));
+                        p.store(fos, "No comments");
+                        fos.flush();
+                        fos.close();
+                } catch (Exception ex) {
+                        log.log(Level.WARNING, null, ex);
+                        try {
+                                if (fos != null) {
+                                        fos.close();
+                                }
+                        } catch (Exception e) {
+                        }
                 }
-            } catch (Exception e) {
-            }
         }
-    }
 
-    /**
-     * does nothing
-     * @param sce 
-     */
-    public void contextDestroyed(ServletContextEvent sce) {
-    }
+        /**
+         * does nothing
+         *
+         * @param sce
+         */
+        public void contextDestroyed(ServletContextEvent sce) {
+                FileOutputStream fos = null;
+                try {
+                        log.info("Cleaning up juddi-admin");
+                        Properties p = new Properties();
+                        InputStream is = sce.getServletContext().getResourceAsStream("/WEB-INF/config.properties");
+                        p.load(is);
+                        p.remove("key");
+                        is.close();
+                        fos = new FileOutputStream(sce.getServletContext().getRealPath("/WEB-INF/config.properties"));
+                        p.store(fos, "No comments");
+                        fos.flush();
+                        fos.close();
+                } catch (Exception ex) {
+                        log.log(Level.WARNING, null, ex);
+                        try {
+                                if (fos != null) {
+                                        fos.close();
+                                }
+                        } catch (Exception e) {
+                        }
+                }
+                try {
+                        sce.getServletContext().removeAttribute("username");
+                        sce.getServletContext().removeAttribute("password");
+                        sce.getServletContext().removeAttribute("locale");
+                        sce.getServletContext().removeAttribute("hub");
+                } catch (Exception ex) {
+                        log.log(Level.WARNING, null, ex);
+                }
+
+        }
 }

Modified: juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/hub/UddiAdminHub.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/hub/UddiAdminHub.java?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/hub/UddiAdminHub.java (original)
+++ juddi/trunk/juddiv3-war/src/main/java/org/apache/juddi/webconsole/hub/UddiAdminHub.java Sat Jan 18 01:18:21 2014
@@ -28,7 +28,6 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpSession;
 import javax.xml.bind.JAXB;
 import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
@@ -50,10 +49,9 @@ import org.apache.juddi.api_v3.SaveClien
 import org.apache.juddi.api_v3.SavePublisher;
 import org.apache.juddi.api_v3.SyncSubscription;
 import org.apache.juddi.api_v3.SyncSubscriptionDetail;
-import org.apache.juddi.v3.client.ClassUtil;
+import org.apache.juddi.v3.client.UDDIConstants;
 import org.apache.juddi.v3.client.config.ClientConfig;
 import org.apache.juddi.v3.client.config.UDDIClient;
-import org.apache.juddi.v3.client.config.UDDIClientContainer;
 import org.apache.juddi.v3.client.config.UDDINode;
 import org.apache.juddi.v3.client.transport.Transport;
 import org.apache.juddi.v3_service.JUDDIApiPortType;
@@ -63,7 +61,10 @@ import org.uddi.api_v3.AuthToken;
 import org.uddi.api_v3.DeleteTModel;
 import org.uddi.api_v3.DiscardAuthToken;
 import org.uddi.api_v3.DispositionReport;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.FindQualifiers;
 import org.uddi.api_v3.GetAuthToken;
+import org.uddi.api_v3.Name;
 
 import org.uddi.v3_service.DispositionReportFaultMessage;
 import org.uddi.v3_service.UDDISecurityPortType;
@@ -184,6 +185,9 @@ public class UddiAdminHub {
         private UddiAdminHub(ServletContext application, HttpSession _session) throws Exception {
                 URL prop = application.getResource("/WEB-INF/config.properties");
                 if (prop == null) {
+                        application.getResource("WEB-INF/config.properties");
+                }
+                if (prop == null) {
                         throw new Exception("Cannot locate the configuration file.");
                 }
                 session = _session;
@@ -350,11 +354,13 @@ public class UddiAdminHub {
                 EnsureConfig();
                 if (style != AuthStyle.UDDI_AUTH) {
                         BindingProvider bp = null;
-                        Map<String, Object> context = null;
-                        bp = (BindingProvider) juddi;
-                        context = bp.getRequestContext();
-                        context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
-                        context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
+                        if (WS_Transport) {
+                                Map<String, Object> context = null;
+                                bp = (BindingProvider) juddi;
+                                context = bp.getRequestContext();
+                                context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
+                                context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
+                        }
                         return null;
                 } else {
                         if (token != null) {
@@ -484,7 +490,7 @@ public class UddiAdminHub {
                         }
                 }
                 if (d != null) {
-                        ret.append("<table class=\"table table-hover\"><tr>th>Name</th><th>Info</th></tr>");
+                        ret.append("<table class=\"table table-hover\"><tr><th>Name</th><th>Info</th></tr>");
                         for (int i = 0; i < d.getPublisher().size(); i++) {
                                 ret.append("<tr><td>").append(StringEscapeUtils.escapeHtml(d.getPublisher().get(i).getPublisherName()))
                                         .append("</td><td>");
@@ -635,14 +641,16 @@ public class UddiAdminHub {
                         p.setIsAdmin(Boolean.parseBoolean(parameters.getParameter("savePublisherIsAdmin")));
                 } catch (Exception ex) {
                 }
-                if ("on".equalsIgnoreCase(parameters.getParameter("savePublisherIsAdmin")))
+                if ("on".equalsIgnoreCase(parameters.getParameter("savePublisherIsAdmin"))) {
                         p.setIsAdmin(true);
+                }
                 try {
                         p.setIsEnabled(Boolean.parseBoolean(parameters.getParameter("savePublisherIsEnabled")));
                 } catch (Exception ex) {
                 }
-                if ("on".equalsIgnoreCase(parameters.getParameter("savePublisherIsEnabled")))
+                if ("on".equalsIgnoreCase(parameters.getParameter("savePublisherIsEnabled"))) {
                         p.setIsEnabled(true);
+                }
 
                 PublisherDetail d = null;
                 sb.setAuthInfo(GetToken());
@@ -746,4 +754,75 @@ public class UddiAdminHub {
         public boolean isAdminLocalhostOnly() {
                 return clientConfig.getConfiguration().getBoolean(PROP_ADMIN_LOCALHOST_ONLY, true);
         }
+
+        public String verifyLogin() {
+                EnsureConfig();
+                if (style != AuthStyle.UDDI_AUTH) {
+                        if (WS_Transport) {
+                                BindingProvider bp = null;
+                                Map<String, Object> context = null;
+
+                                bp = (BindingProvider) juddi;
+                                context = bp.getRequestContext();
+                                context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
+                                context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
+                        }
+                        FindBusiness fb = new FindBusiness();
+                        fb.setListHead(0);
+                        fb.setMaxRows(1);
+                        fb.setFindQualifiers(new FindQualifiers());
+                        fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+                        fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
+                        try {
+                                GetPublisherDetail publisherDetail = new GetPublisherDetail();
+                                publisherDetail.getPublisherId().add((String) session.getAttribute("username"));
+                                juddi.getPublisherDetail(publisherDetail);
+
+                        } catch (Exception ex) {
+                                return HandleException(ex);
+                        }
+                        /*
+                         bp = (BindingProvider) juddi;
+                         context = bp.getRequestContext();
+                         context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
+                         context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));*/
+                        return null;
+                } else {
+                        if (token != null) {
+                                return token;
+                        }
+                        if (WS_Transport) {
+                                BindingProvider bp = null;
+                                Map<String, Object> context = null;
+
+                                bp = (BindingProvider) juddi;
+                                context = bp.getRequestContext();
+                                context.remove(BindingProvider.USERNAME_PROPERTY);
+                                context.remove(BindingProvider.PASSWORD_PROPERTY);
+                        }
+                        GetAuthToken req = new GetAuthToken();
+                        try {
+                                if (security == null) {
+                                        security = transport.getUDDISecurityService();
+                                }
+                        } catch (Exception ex) {
+                                return HandleException(ex);
+                        }
+                        if (session.getAttribute("username") != null
+                                && session.getAttribute("password") != null) {
+                                req.setUserID((String) session.getAttribute("username"));
+                                req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key")));
+                                log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is " + ((security == null) ? "HTTP" : "AUTH_TOKEN"));
+                                try {
+                                        AuthToken authToken = security.getAuthToken(req);
+                                        token = authToken.getAuthInfo();
+                                        return null;
+                                } catch (Exception ex) {
+                                        return HandleException(ex);
+                                }
+                        }
+                }
+                return "Unexpected error";
+        }
+
 }

Modified: juddi/trunk/juddiv3-war/src/main/webapp/admin/ajax/loginpost.jsp
URL: http://svn.apache.org/viewvc/juddi/trunk/juddiv3-war/src/main/webapp/admin/ajax/loginpost.jsp?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddiv3-war/src/main/webapp/admin/ajax/loginpost.jsp (original)
+++ juddi/trunk/juddiv3-war/src/main/webapp/admin/ajax/loginpost.jsp Sat Jan 18 01:18:21 2014
@@ -4,37 +4,69 @@
     Author     : Alex O'Ree
 --%>
 
+<%@page import="java.io.FileInputStream"%>
+<%@page import="java.io.File"%>
+<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
 <%@page import="java.util.Properties"%>
 <%@page import="java.io.InputStream"%>
 <%@page import="java.net.URL"%>
 <%@page import="org.apache.juddi.webconsole.AES"%>
 <%@page import="org.apache.juddi.webconsole.hub.UddiAdminHub"%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<!DOCTYPE html>
 <%@include  file="../csrf.jsp" %>
-<%
-
-    URL prop = application.getResource("/WEB-INF/config.properties");
-    if (prop == null) {
-        prop = application.getResource("WEB-INF/config.properties");
-
-    }
-    if (prop == null) {
-        throw new Exception("Cannot locate the configuration file.");
-    }
-    
-    InputStream in = prop.openStream();
-    Properties p = new Properties();
-    p.load(in);
-    in.close();
-    session.setAttribute("username", request.getParameter("username"));
-    session.setAttribute("password", AES.Encrypt(request.getParameter("password"), (String) p.get("key")));
-
-
-
-    UddiAdminHub.reset(request.getSession());
-    UddiAdminHub x = UddiAdminHub.getInstance(application, request.getSession());
-
+<%        boolean ok = true;
+        FileInputStream fis = null;
+        Properties p = new Properties();
+        try {
+                File f = new File(application.getRealPath("/WEB-INF/config.properties"));
+                fis = new FileInputStream(f);
+
+                p.load(fis);
+                fis.close();
+        } catch (Exception ex) {
+                ex.printStackTrace();
+                out.write("Internal configuration error");
+                response.setStatus(406);
+                ok = false;
+        } finally {
+                if (fis != null) {
+                        try {
+                                fis.close();
+                        } catch (Exception x) {
+                        }
+                }
+        }
+        session.setAttribute("username", request.getParameter("username"));
+        if (request.getParameter("password") == null || request.getParameter("password").length() == 0) {
+                response.setStatus(406);
+                out.write("Please enter a password");
+                ok = false;
+                //TODO i18n
+        }
+        if (request.getParameter("username") == null || request.getParameter("username").length() == 0) {
+                response.setStatus(406);
+                out.write("Please enter a username");
+                ok = false;
+                //TODO i18n
+        }
+
+        if (ok) {
+                try {
+                        session.setAttribute("password", AES.Encrypt(request.getParameter("password"), (String) p.get("key")));
+                } catch (Exception ex) {
+                        response.setStatus(406);
+                        out.write(StringEscapeUtils.escapeHtml(ex.getMessage()));
+
+                        UddiAdminHub.reset(request.getSession());
+                        UddiAdminHub x = UddiAdminHub.getInstance(application, request.getSession());
+
+                        String msg = x.verifyLogin();
+                        if (msg != null) {
+                                response.setStatus(406);
+                                out.write(msg);
+                        }
+                }
+        }
 
 
 %>
\ No newline at end of file

Modified: juddi/trunk/juddiv3-war/src/main/webapp/admin/js/main.js
URL: http://svn.apache.org/viewvc/juddi/trunk/juddiv3-war/src/main/webapp/admin/js/main.js?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddiv3-war/src/main/webapp/admin/js/main.js (original)
+++ juddi/trunk/juddiv3-war/src/main/webapp/admin/js/main.js Sat Jan 18 01:18:21 2014
@@ -87,6 +87,8 @@ function Login()
         //TODO handle expired nonce values?
         RefreshLoginPage();
         $("#loginbutton").text(i18n_login);
+        $("#loginfailuredetails").text("Login failed: " + textStatus + " " + jqXHR.responseText);
+        $("#loginfailure").modal();
     });
 }
 

Modified: juddi/trunk/juddiv3-war/src/main/webapp/admin/login.jsp
URL: http://svn.apache.org/viewvc/juddi/trunk/juddiv3-war/src/main/webapp/admin/login.jsp?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/juddiv3-war/src/main/webapp/admin/login.jsp (original)
+++ juddi/trunk/juddiv3-war/src/main/webapp/admin/login.jsp Sat Jan 18 01:18:21 2014
@@ -4,6 +4,7 @@
     Author     : Alex O'Ree
 --%>
 
+<%@page import="org.apache.juddi.webconsole.hub.UddiAdminHub"%>
 <%@page import="org.apache.juddi.webconsole.resources.ResourceLoader"%>
 <%@page import="org.apache.commons.lang.StringEscapeUtils"%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
@@ -43,7 +44,7 @@
         <input class="span2" type="password" placeholder="<%=ResourceLoader.GetResource(session, "navbar.login.password")%>" name="password" id="password">
         <button type="button" onclick="javascript:Login();" class="btn" id="loginbutton">
             <%
-                if (!request.isSecure()) {
+                if (!request.isSecure() ||  !UddiAdminHub.getInstance(application, session).isSecure()) {
             %>
             <i class="icon-warning-sign" title="<%=ResourceLoader.GetResource(session, "warning.ssl")%>"></i>
             <%
@@ -57,3 +58,19 @@
 
 
 </div>
+
+        
+            
+<div class="modal hide fade container" id="loginfailure">
+    <div class="modal-header">
+        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+        <h3><%=ResourceLoader.GetResource(session, "errors.generic")%></h3>
+    </div>
+    <div class="modal-body">
+            <i class="icon-4x icon-thumbs-down"></i><br>
+            <div id="loginfailuredetails"></div>
+    </div>
+    <div class="modal-footer">
+            <button type="button" class="btn" data-dismiss="modal" ><%=ResourceLoader.GetResource(session, "modal.close")%></button>
+    </div>
+</div>
\ No newline at end of file

Modified: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_160_RESTIntergrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_160_RESTIntergrationTest.java?rev=1559301&r1=1559300&r2=1559301&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_160_RESTIntergrationTest.java (original)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_160_RESTIntergrationTest.java Sat Jan 18 01:18:21 2014
@@ -115,6 +115,7 @@ public class UDDI_160_RESTIntergrationTe
                 HttpGet httpGet = new HttpGet(url + "?businessKey=" + findBusiness.getBusinessInfos().getBusinessInfo().get(0).getBusinessKey());
                 logger.info("Fetching " + httpGet.getURI());
                 HttpResponse response = client.execute(httpGet);
+                client.getConnectionManager().shutdown();
                 Assert.assertTrue(response.getStatusLine().getStatusCode() == 200);
                 logger.info("Response content: " + response.getEntity().getContent());
                 BusinessEntity unmarshal = JAXB.unmarshal(response.getEntity().getContent(), BusinessEntity.class);
@@ -146,6 +147,7 @@ public class UDDI_160_RESTIntergrationTe
                 HttpGet httpGet = new HttpGet(url + "?tModelKey=" + findTModel.getTModelInfos().getTModelInfo().get(0).getTModelKey());
                 logger.info("Fetching " + httpGet.getURI());
                 HttpResponse response = client.execute(httpGet);
+                client.getConnectionManager().shutdown();
                 Assert.assertTrue(response.getStatusLine().getStatusCode() == 200);
                 logger.info("Response content: " + response.getEntity().getContent());
                 TModel unmarshal = JAXB.unmarshal(response.getEntity().getContent(), TModel.class);
@@ -178,6 +180,7 @@ public class UDDI_160_RESTIntergrationTe
                 HttpGet httpGet = new HttpGet(url + "?serviceKey=" + findService.getServiceInfos().getServiceInfo().get(0).getServiceKey());
                 logger.info("Fetching " + httpGet.getURI());
                 HttpResponse response = client.execute(httpGet);
+                client.getConnectionManager().shutdown();
                 Assert.assertTrue(response.getStatusLine().getStatusCode() == 200);
                 logger.info("Response content: " + response.getEntity().getContent());
                 BusinessService unmarshal = JAXB.unmarshal(response.getEntity().getContent(), BusinessService.class);
@@ -244,6 +247,7 @@ public class UDDI_160_RESTIntergrationTe
                 HttpGet httpGet = new HttpGet(url + "?bindingKey=" + bt.getBindingKey());
                 logger.info("Fetching " + httpGet.getURI());
                 HttpResponse response = client.execute(httpGet);
+                client.getConnectionManager().shutdown();
                 Assert.assertTrue(response.getStatusLine().getStatusCode() == 200);
                 logger.info("Response content: " + response.getEntity().getContent());
                 BindingTemplate unmarshal = JAXB.unmarshal(response.getEntity().getContent(), BindingTemplate.class);



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