http://git-wip-us.apache.org/repos/asf/juddi/blob/5994cd06/juddiv3-war-repl/README.txt ---------------------------------------------------------------------- diff --git a/juddiv3-war-repl/README.txt b/juddiv3-war-repl/README.txt new file mode 100644 index 0000000..d3bc088 --- /dev/null +++ b/juddiv3-war-repl/README.txt @@ -0,0 +1,93 @@ +To support our users with different platform configurations we have the following profiles: + + +1. Target platform Tomcat and Derby using OpenJPA and CXF. + +Both OpenJPA and CXF are packaged up in the juddiv3.war. + +mvn clean package -P openjpa + + +2. Target platform Tomcat and Derby using Hibernate and CXF + +Both Hibernate and CXF are packaged up in the juddiv3.war. + +mvn clean package -P hibernate + + +3. Target platform JBoss-6.x and HSQL using Hibernate and JBossWS-native + +The juddiv3.war relies on Hibernate and JBossWS-native in the appserver. + +mvn clean package -P hibernate-jbossws-native + + +4. Target platform JBoss-6.x and HSQL using Hibernate and JBossWS-cxf + +The juddiv3.war relies on Hibernate and JBossWS-cxf in the appserver. + +mvn clean package -P hibernate-jbossws-cxf + + +5. Target platform Tomcat and Derby using OpenJPA and Apache Axis2 + +Both OpenJPA and Apache Axis2 are packaged up in the juddiv3.war. + +mvn clean package -P hibernate-jbossws-cxf + +6. Target platform JBoss 5 or 6 using OpenJPA and JbossWS-cxf + +mvn clean package -P openjpa-jbossws-cxf + + +KNOWN ISSUES + +I. 15:14:37,275 SEVERE [RegistryServlet] jUDDI registry could not be started. +org.apache.commons.configuration.ConfigurationException: java.util.zip.ZipException: +error in opening zip file: org.apache.commons.configuration.ConfigurationException: +org.apache.commons.configuration.ConfigurationException: java.util.zip.ZipException: +error in opening zip file + +Workaround: deploy juddiv3.war as a directory (not a zip file). + + +II. JBoss-5.x +Note that configuration 3 and 4 will also run on JBoss-5.x, but you may run into the following: +ERROR [org.jboss.ws.metadata.wsdl.xmlschema.JBossXSErrorHandler] (main) +[domain:http://www.w3.org/TR/xml-schema-1]::[key=src-resolve]::Message=src-resolve: +Cannot resolve the name 'ns1:Signature' to a 'element declaration' component. + +for which there is the following workaround: + + 1. unzip the deployers/jbossws.deployer/jbossws-native-core.jar + and add the xmldsig-core-schema.xsd in the schema directory, + + 10293 Fri May 27 14:40:40 EDT 2011 schema/xmldsig-core-schema.xsd + + 2. and edit the + + META-INF/jbossws-entities.properties + + by adding a line at the bottom saying: + + http\://www.w3.org/2000/09/xmldsig#=schema/xmldsig-core-schema.xsd + +6. Target platform Wildfy/EAP-6.x running Hibernate and CXF + +This deployment uses the hibernate and cxf modules of the appserver. Simply run + +mvn clean package -Pjboss7up + +and deploy the juddiv3.war to standalone/deployments. + +Note that by default jUDDI is configured to use the 'ExampleDS' H2 datasource, +as configured in the web.xml and persistence.xml. Update these files and add your + database driver for your database of choice. + + + + + + + +
http://git-wip-us.apache.org/repos/asf/juddi/blob/5994cd06/juddiv3-war-repl/context.xml ---------------------------------------------------------------------- diff --git a/juddiv3-war-repl/context.xml b/juddiv3-war-repl/context.xml new file mode 100644 index 0000000..6bfc484 --- /dev/null +++ b/juddiv3-war-repl/context.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/* + * Copyright 2001-2008 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + --> +<Context> + <WatchedResource>WEB-INF/web.xml</WatchedResource> + <!-- --> + <Resource name="jdbc/JuddiDS" auth="Container" + type="javax.sql.DataSource" username="" password="" + driverClassName="org.apache.derby.jdbc.EmbeddedDriver" + url="jdbc:derby:target/juddi-derby-test-db;create=true" + maxActive="8" + /> + + <!-- mysql + <Resource name="jdbc/JuddiDS" auth="Container" + type="javax.sql.DataSource" username="root" password="" + driverClassName="com.mysql.jdbc.Driver" + url="jdbc:mysql://localhost:3306/juddiv3" + maxActive="8" + /> + --> + <!-- postgresql + <Resource name="jdbc/JuddiDS" auth="Container" + type="javax.sql.DataSource" username="juddi" password="juddi" + driverClassName="org.postgresql.Driver" + url="jdbc:postgresql://localhost:5432/juddi" + maxActive="8" + /> + --> +</Context> + http://git-wip-us.apache.org/repos/asf/juddi/blob/5994cd06/juddiv3-war-repl/pom.xml ---------------------------------------------------------------------- diff --git a/juddiv3-war-repl/pom.xml b/juddiv3-war-repl/pom.xml new file mode 100644 index 0000000..17234ac --- /dev/null +++ b/juddiv3-war-repl/pom.xml @@ -0,0 +1,527 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- * Copyright 2001-2009 The Apache Software Foundation. * * Licensed under + the Apache License, Version 2.0 (the "License"); * you may not use this file + except in compliance with the License. * You may obtain a copy of the License + at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by + applicable law or agreed to in writing, software * distributed under the + License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. * See the License for the specific + language governing permissions and * limitations under the License. * */ --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.juddi</groupId> + <artifactId>juddi-parent</artifactId> + <version>3.3.0-SNAPSHOT</version> + </parent> + <artifactId>juddiv3-war-repl</artifactId> + <packaging>war</packaging> + <name>jUDDI Replication Services WAR</name> + <url>http://juddi.apache.org</url> + + <dependencies> + <dependency> + <artifactId>uddi-ws</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.parent.version}</version> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.1.3</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>commons-configuration</groupId> + <artifactId>commons-configuration</artifactId> + <version>1.10</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.2.1</version> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20090211</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + </dependency> + </dependencies> + <build> + <finalName>juddiv3replication</finalName> + </build> + <profiles> + <!-- the hibernate-jbossws-native profile builds a war for jboss, where + hibernate and jbossws are provided by the appserver --> + <profile> + <id>hibernate-jbossws-native</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <configuration> + <webResources> + <resource> + <directory>JPA/Hibernate-JBoss</directory> + </resource> + <resource> + <directory>JAX-WS/JBossWS-Native</directory> + </resource> + </webResources> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <artifactId>juddi-core</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax.persistence</groupId> + <artifactId>persistence-api</artifactId> + <version>1.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate</artifactId> + <version>3.2.5.ga</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-entitymanager</artifactId> + <version>3.3.1.ga</version> + <scope>provided</scope> + </dependency> + + </dependencies> + </profile> + <profile> + <id>hibernate-jbossws-cxf</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <configuration> + <webResources> + <resource> + <directory>JPA/Hibernate-JBoss</directory> + </resource> + <resource> + <directory>JAX-WS/JBossWS-CXF</directory> + </resource> + </webResources> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <artifactId>juddi-core</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + </dependency> + <dependency> + <artifactId>juddi-rest-cxf</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax.persistence</groupId> + <artifactId>persistence-api</artifactId> + <version>1.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate</artifactId> + <version>3.2.5.ga</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-entitymanager</artifactId> + <version>3.3.1.ga</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>2.1_3</version> + <scope>provided</scope> + </dependency> + </dependencies> + </profile> + <profile> + <!-- the hibernate profile builds a war for tomcat, with hibernate and + cxf in the war --> + <id>hibernate</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <configuration> + <webResources> + <resource> + <directory>JPA/Hibernate</directory> + </resource> + <resource> + <directory>JAX-WS/CXF</directory> + </resource> + </webResources> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <artifactId>juddi-core</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + </dependency> + <dependency> + <artifactId>juddi-rest-cxf</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <version>${cxf.version}</version> + <exclusions> + <exclusion> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${springframework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${springframework.version}</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.javamail</groupId> + <artifactId>geronimo-javamail_1.4_mail</artifactId> + <version>1.8.3</version> + </dependency> + </dependencies> + </profile> + <profile> + <!-- the openjpa profile builds a war for tomcat, with openjpa and cxf + in the war --> + <id>openjpa</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <configuration> + <webResources> + <resource> + <directory>JPA/OpenJPA</directory> + </resource> + <resource> + <directory>JAX-WS/CXF</directory> + </resource> + </webResources> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <artifactId>juddi-core-openjpa</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <artifactId>juddi-rest-cxf</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <version>${cxf.version}</version> + </dependency> + <!--added AO 6/8/2013 support for JSON encoding on REST endpoints --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-extension-providers</artifactId> + <version>2.7.5</version> + </dependency> + + <dependency> + <groupId>org.codehaus.jettison</groupId> + <artifactId>jettison</artifactId> + <version>1.3.4</version> + </dependency> + <!--END added AO 6/8/2013 support for JSON encoding on REST endpoints --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <version>${cxf.version}</version> + <exclusions> + <exclusion> + <groupId>cglib</groupId> + <artifactId>cglib</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${springframework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${springframework.version}</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.javamail</groupId> + <artifactId>geronimo-javamail_1.4_mail</artifactId> + <version>1.8.3</version> + </dependency> + </dependencies> + </profile> + <profile> + <!-- the openjpa-axis2 profile builds a war for tomcat, with openjpa and + axis2 in the war --> + <id>axis2</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <configuration> + <webResources> + <resource> + <directory>JPA/OpenJPA</directory> + </resource> + <resource> + <directory>JAX-WS/Axis2</directory> + </resource> + </webResources> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.6</version> + <executions> + <execution> + <id>default-cli</id> + <configuration> + <target name="axis2-servicejars"> + <dependencyfilesets prefix="mydeps." /> + <mkdir dir="${basedir}/target/juddiv3/WEB-INF/servicejars" /> + <copy todir="${basedir}/target/juddiv3/WEB-INF/servicejars"> + <fileset refid="mydeps.org.apache.juddi:juddi-core-openjpa:jar" /> + </copy> + </target> + </configuration> + <phase>compile</phase> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + <dependencies> + <!-- providing this through ant in the servicejars directory --> + <dependency> + <artifactId>juddi-core-openjpa</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- and then add the axis2 jars --> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2</artifactId> + <version>1.6.2</version> + </dependency> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-jaxws</artifactId> + <version>1.6.2</version> + </dependency> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-transport-http</artifactId> + <version>1.6.2</version> + </dependency> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-transport-local</artifactId> + <version>1.6.2</version> + </dependency> + <dependency> + <groupId>org.apache.xmlbeans</groupId> + <artifactId>xmlbeans</artifactId> + <version>2.4.0</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.javamail</groupId> + <artifactId>geronimo-javamail_1.4_mail</artifactId> + <version>1.8.3</version> + </dependency> + </dependencies> + </profile> + <profile> + <id>jboss7up</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <packagingExcludes> + WEB-INF/lib/hibernate*.jar, + WEB-INF/lib/cglib*.jar, + WEB-INF/lib/log4j*.jar, + WEB-INF/lib/stax*.jar, + WEB-INF/lib/commons-log*.jar, + WEB-INF/classes/commons*, + WEB-INF/classes/log* + </packagingExcludes> + <webResources> + <resource> + <directory>JPA/Hibernate-JBossAS7Up</directory> + </resource> + <resource> + <directory>JAX-WS/CXF-JBossAS7Up</directory> + </resource> + </webResources> + + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <artifactId>juddi-core</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + <exclusion> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-entitymanager</artifactId> + </exclusion> + <exclusion> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-jpa</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <artifactId>juddi-rest-cxf</artifactId> + <groupId>org.apache.juddi</groupId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-extension-providers</artifactId> + </exclusion> + <exclusion> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + </exclusion> + <exclusion> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-entitymanager</artifactId> + </exclusion> + <exclusion> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-jpa</artifactId> + </exclusion> + </exclusions> + </dependency> + + </dependencies> + </profile> + </profiles> +</project> http://git-wip-us.apache.org/repos/asf/juddi/blob/5994cd06/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/AES.java ---------------------------------------------------------------------- diff --git a/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/AES.java b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/AES.java new file mode 100644 index 0000000..d6c4493 --- /dev/null +++ b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/AES.java @@ -0,0 +1,164 @@ +/* + * Copyright 2001-2013 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.juddi.adminconsole; + +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:[email protected]">Alex O'Ree</a> + */ +public class AES { + + public static final String logname = "org.apache.juddi.gui"; + public static final Log log = LogFactory.getLog(logname); + + /** + * 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); + } + return null; + } + + /** + * Generate a new AES 256 bit encryption key. Once generated, this key + * can be used to replace the default key. + * + * @return a base64 encoded key, 256 bit + */ + 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 true if the key is valid + */ + 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.getMessage()); + log.debug("Key validation failed! "+ ex.getMessage(), ex); + return false; + } + } + + /** + * encrypts a password using AES Requires the Unlimited Strength Crypto + * Extensions + * + * @param clear + * @param key + * @return a base64 encoded cipher of the clear text using the key + */ + 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 ""; + } + + /** + * 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 the decrypted string + */ + 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; + + } +} http://git-wip-us.apache.org/repos/asf/juddi/blob/5994cd06/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/CrossSiteRequestForgeryException.java ---------------------------------------------------------------------- diff --git a/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/CrossSiteRequestForgeryException.java b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/CrossSiteRequestForgeryException.java new file mode 100644 index 0000000..ea9d2f2 --- /dev/null +++ b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/CrossSiteRequestForgeryException.java @@ -0,0 +1,67 @@ +/* + * Copyright 2001-2013 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.juddi.adminconsole; + +/** + * Provides a very basic, no stack trace exception, useful for throwing at a browser without revealing any details + * @author <a href="mailto:[email protected]">Alex O'Ree</a> + */ +public class CrossSiteRequestForgeryException extends Exception { + //Parameterless Constructor +/** + * CrossSiteRequestForgeryException + */ + public CrossSiteRequestForgeryException() { + super(msg, null); + } + + /** + * Constructor that accepts a message + */ + public CrossSiteRequestForgeryException(String message) { + super(msg, null); + } +/** + * CrossSiteRequestForgeryException + * @param message + * @param cause + */ + public CrossSiteRequestForgeryException(String message, Throwable cause) { + super(msg, null); + } + private static final String msg = "Cross Site Request Forgery"; + + @Override + public String toString() { + return msg; + } + + @Override + public String getMessage() { + return msg; + } + + @Override + public String getLocalizedMessage() { + return msg; + } + + @Override + public Throwable getCause() { + return null; + } +} http://git-wip-us.apache.org/repos/asf/juddi/blob/5994cd06/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/PostBackConstants.java ---------------------------------------------------------------------- diff --git a/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/PostBackConstants.java b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/PostBackConstants.java new file mode 100644 index 0000000..0db3c2c --- /dev/null +++ b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/PostBackConstants.java @@ -0,0 +1,62 @@ +/* + * Copyright 2001-2008 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.juddi.adminconsole; + +/** + * A collection of constants to use for form postbacks and parsing data from the + * browser All fields MUST not contain any characters that could interfer with + * the rendering of a webpage or javascript and should thus be escaped sequences + * of characters + * + * @author <a href="mailto:[email protected]">Alex O'Ree</a> + */ +public class PostBackConstants { + + public static final String INSTANCE = "instance"; + public static final String ACCESSPOINT_TYPE = "accessPointType"; + public static final String ACCESSPOINT_VALUE = "accessPointValue"; + @Deprecated + public static final String HOSTINGREDIRECTOR = "hostingRedirector"; + public static final String OVERVIEW = "overviewDoc"; + public static final String TMODELINSTANCE = "tmodelInstance"; + public static final String BINDINGTEMPLATE = "bindingTemplate"; + public static final String BINDINGKEY = "bindingKey"; + public static final String BUSINESSKEY = "businessKey"; + public static final String SERVICEKEY = "serviceKey"; + //public static final String CLICK_TO_EDIT = "Click to edit"; + public static final String DESCRIPTION = "Description"; + public static final String DISCOVERYURL = "disco"; + public static final String PHONE = "Phone"; + public static final String ADDRESS = "Address"; + public static final String ADDRESSLINE = "addressLine"; + public static final String CONTACT_PREFIX = "contact"; + public static final String NAME = "Name"; + public static final String LANG = "Lang"; + public static final String VALUE = "Value"; + public static final String TYPE = "Type"; + public static final String EMAIL = "Email"; + public static final String SORTCODE = "Sortcode"; + public static final String KEYNAME = "KeyName"; + public static final String KEYVALUE = "KeyValue"; + public static final String CATBAG_KEY_REF = "catbagkeyref"; + public static final String IDENT_KEY_REF = "identbagkeyref"; + public static final String CATBAG_KEY_REF_GRP = "catbaggrpkeyref"; + public static final String KEY_REF = "keyref"; + public static final String TMODEL_DELETED = "isDeleted"; + + +} http://git-wip-us.apache.org/repos/asf/juddi/blob/5994cd06/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/StartupServlet.java ---------------------------------------------------------------------- diff --git a/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/StartupServlet.java b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/StartupServlet.java new file mode 100644 index 0000000..c600522 --- /dev/null +++ b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/StartupServlet.java @@ -0,0 +1,131 @@ +/* + * Copyright 2001-2008 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.juddi.adminconsole; + +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 + * + * @author <a href="mailto:[email protected]">Alex O'Ree</a> + */ +public class StartupServlet implements javax.servlet.ServletContextListener { + + 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.warning("256 bit key validation failed. To use higher key sizes, try installing the Java Cryptographic Extensions (JCE) Unlimited Strength"); + } + } + 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) { + } + } + } + + /** + * 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); + } + + } +} http://git-wip-us.apache.org/repos/asf/juddi/blob/5994cd06/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/hub/JUDDIRequestsAsXML.java ---------------------------------------------------------------------- diff --git a/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/hub/JUDDIRequestsAsXML.java b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/hub/JUDDIRequestsAsXML.java new file mode 100644 index 0000000..acfa03c --- /dev/null +++ b/juddiv3-war-repl/src/main/java/org/apache/juddi/adminconsole/hub/JUDDIRequestsAsXML.java @@ -0,0 +1,209 @@ +/* + * Copyright 2013 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.juddi.adminconsole.hub; + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.GregorianCalendar; +import java.util.logging.Level; +import java.util.logging.Logger; +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; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.juddi.api_v3.AdminSaveBusiness; +import org.apache.juddi.api_v3.AdminSaveBusinessWrapper; +import org.apache.juddi.api_v3.AdminSaveSubscriptionRequest; +import org.apache.juddi.api_v3.AdminSaveTModel; +import org.apache.juddi.api_v3.AdminSaveTModelWrapper; +import org.apache.juddi.api_v3.Clerk; +import org.apache.juddi.api_v3.ClientSubscriptionInfo; +import org.apache.juddi.api_v3.SaveClientSubscriptionInfo; +import org.apache.juddi.api_v3.SyncSubscription; +import org.apache.juddi.config.AppConfig; +import org.apache.juddi.config.Property; +import org.apache.juddi.v3.client.UDDIConstants; +import org.uddi.api_v3.BusinessEntity; +import org.uddi.api_v3.Contact; +import org.uddi.api_v3.FindBusiness; +import org.uddi.api_v3.FindQualifiers; +import org.uddi.api_v3.Name; +import org.uddi.api_v3.PersonName; +import org.uddi.api_v3.TModel; +import org.uddi.repl_v3.CommunicationGraph; +import org.uddi.repl_v3.Operator; +import org.uddi.repl_v3.OperatorStatusType; +import org.uddi.repl_v3.ReplicationConfiguration; +import org.uddi.sub_v3.CoveragePeriod; +import org.uddi.sub_v3.GetSubscriptionResults; +import org.uddi.sub_v3.Subscription; +import org.uddi.sub_v3.SubscriptionFilter; + +/** + * This class generates XML as String objects for UDDI requests. This is used + * from the "advanced" web pages + * + * @author <a href="mailto:[email protected]">Alex O'Ree</a> + */ +public class JUDDIRequestsAsXML { + + private static String PrettyPrintXML(String input) { + if (input == null || input.length() == 0) { + return ""; + } + try { + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + //initialize StreamResult with File object to save to file + StreamResult result = new StreamResult(new StringWriter()); + StreamSource source = new StreamSource(new StringReader(input.trim())); + transformer.transform(source, result); + String xmlString = result.getWriter().toString(); + return (xmlString); + } catch (Exception ex) { + } + return null; + } + + public static String getSampleXML(String method) { + StringWriter sw = new StringWriter(); + + if (method.equalsIgnoreCase("save_ClientSubscriptionInfo")) { + SaveClientSubscriptionInfo obj = new SaveClientSubscriptionInfo(); + obj.getClientSubscriptionInfo().add(new ClientSubscriptionInfo()); + obj.getClientSubscriptionInfo().get(0).setFromClerk(new Clerk()); + obj.getClientSubscriptionInfo().get(0).setToClerk(new Clerk()); + obj.getClientSubscriptionInfo().get(0).setSubscriptionKey("key"); + + JAXB.marshal(obj, sw); + } + if (method.equalsIgnoreCase("invoke_SyncSubscription")) { + SyncSubscription obj = new SyncSubscription(); + obj.getGetSubscriptionResultsList().add(new GetSubscriptionResults()); + obj.getGetSubscriptionResultsList().get(0).setSubscriptionKey("key"); + obj.getGetSubscriptionResultsList().get(0).setCoveragePeriod(new CoveragePeriod()); + DatatypeFactory newInstance; + try { + newInstance = DatatypeFactory.newInstance(); + obj.getGetSubscriptionResultsList().get(0).getCoveragePeriod().setEndPoint(newInstance.newXMLGregorianCalendar(new GregorianCalendar())); + obj.getGetSubscriptionResultsList().get(0).getCoveragePeriod().setStartPoint(newInstance.newXMLGregorianCalendar(new GregorianCalendar())); + + } catch (DatatypeConfigurationException ex) { + Logger.getLogger(JUDDIRequestsAsXML.class.getName()).log(Level.SEVERE, null, ex); + } + JAXB.marshal(obj, sw); + } + if (method.equalsIgnoreCase("admin_SaveBusiness")) { + AdminSaveBusiness obj = new AdminSaveBusiness(); + obj.getValues().add(new AdminSaveBusinessWrapper()); + obj.getValues().get(0).setPublisherID("username"); + obj.getValues().get(0).getBusinessEntity().add(new BusinessEntity()); + obj.getValues().get(0).getBusinessEntity().get(0).getName().add(new Name("Business Name", "en")); + JAXB.marshal(obj, sw); + } + if (method.equalsIgnoreCase("admin_SaveTModel")) { + AdminSaveTModel obj = new AdminSaveTModel(); + obj.getValues().add(new AdminSaveTModelWrapper()); + obj.getValues().get(0).setPublisherID("username"); + obj.getValues().get(0).getTModel().add(new TModel()); + obj.getValues().get(0).getTModel().get(0).setName(new Name("TModel Name", "en")); + JAXB.marshal(obj, sw); + } + + if (method.equalsIgnoreCase("admin_SaveSubscription")) { + AdminSaveSubscriptionRequest obj = new AdminSaveSubscriptionRequest(); + obj.setPublisherOrUsername("username"); + obj.getSubscriptions().add(new Subscription()); + obj.getSubscriptions().get(0).setSubscriptionFilter(new SubscriptionFilter()); + obj.getSubscriptions().get(0).setBrief(Boolean.TRUE); + obj.getSubscriptions().get(0).getSubscriptionFilter().setFindBusiness(new FindBusiness()); + obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness().getName().add(new Name(UDDIConstants.WILDCARD, null)); + obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers()); + obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH); + obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier().add(UDDIConstants.CASE_INSENSITIVE_MATCH); + //obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness() + JAXB.marshal(obj, sw); + } + + if (method.equalsIgnoreCase("set_ReplicationNodes")) { + ReplicationConfiguration replicationConfiguration = new ReplicationConfiguration(); + replicationConfiguration.setCommunicationGraph(new CommunicationGraph()); + String thisnode = "NODEID"; + try { + thisnode = AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID); + } catch (ConfigurationException ex) { + Logger.getLogger(JUDDIRequestsAsXML.class.getName()).log(Level.SEVERE, null, ex); + } + + replicationConfiguration.getCommunicationGraph().getNode().add(thisnode); + Operator op = new Operator(); + op.setOperatorNodeID(thisnode); + + op.setOperatorStatus(OperatorStatusType.NORMAL); + String url = "http://localhost:8080/juddiv3/services/replication"; + try { + url = AppConfig.getConfiguration().getString(Property.DEFAULT_BASE_URL_SECURE) + "/services/replication"; + } catch (ConfigurationException ex) { + Logger.getLogger(JUDDIRequestsAsXML.class.getName()).log(Level.SEVERE, null, ex); + } + op.setSoapReplicationURL(url); + + replicationConfiguration.getOperator().add(op); + replicationConfiguration.setRegistryContact(new ReplicationConfiguration.RegistryContact()); + replicationConfiguration.getRegistryContact().setContact(new Contact()); + replicationConfiguration.getRegistryContact().getContact().getPersonName().add(new PersonName("UNKNOWN", "en")); + + JAXB.marshal(replicationConfiguration, sw); + } + + return PrettyPrintXML(sw.toString()); + } + + public static Object getObjectJuddi(String method, String content) { + StringReader sr = new StringReader(content); + + if (method.equalsIgnoreCase("save_ClientSubscriptionInfo")) { + return JAXB.unmarshal(sr, SaveClientSubscriptionInfo.class); + } + if (method.equalsIgnoreCase("invoke_SyncSubscription")) { + return JAXB.unmarshal(sr, SyncSubscription.class); + } + if (method.equalsIgnoreCase("admin_SaveBusiness")) { + return JAXB.unmarshal(sr, AdminSaveBusiness.class); + } + if (method.equalsIgnoreCase("admin_SaveTModel")) { + //System.out.println(content); + return JAXB.unmarshal(sr, AdminSaveTModel.class); + } + + if (method.equalsIgnoreCase("admin_SaveSubscription")) { + return JAXB.unmarshal(sr, AdminSaveSubscriptionRequest.class); + } + + if (method.equalsIgnoreCase("set_ReplicationNodes")) { + return JAXB.unmarshal(sr, ReplicationConfiguration.class); + } + + return null; + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
