You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/11/05 20:57:27 UTC
svn commit: r592134 - in /incubator/cxf/trunk:
rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/
systests/src/test/java/org/apache/cxf/systest/http/
systests/src/test/java/org/apache/cxf/systest/http/resources/
tools/common/src...
Author: dkulp
Date: Mon Nov 5 11:57:22 2007
New Revision: 592134
URL: http://svn.apache.org/viewvc?rev=592134&view=rev
Log:
[CXF-1096] Patch for tls keystore loading applied (Thanks Fred)
For command line tools, try to split on whitespace
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec.xml (with props)
Modified:
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSParameterJaxBUtils.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/jaxws-publish.xml
incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java
Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSParameterJaxBUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSParameterJaxBUtils.java?rev=592134&r1=592133&r2=592134&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSParameterJaxBUtils.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSParameterJaxBUtils.java Mon Nov 5 11:57:22 2007
@@ -31,12 +31,15 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Collection;
+import java.util.logging.Logger;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.configuration.security.CertStoreType;
import org.apache.cxf.configuration.security.KeyManagersType;
import org.apache.cxf.configuration.security.KeyStoreType;
@@ -50,6 +53,9 @@
* with TLSClientParameters and TLSServerParameters respectively.
*/
public final class TLSParameterJaxBUtils {
+
+ private static final Logger LOG =
+ LogUtils.getL7dLogger(TLSParameterJaxBUtils.class);
private TLSParameterJaxBUtils() {
// empty
@@ -92,7 +98,6 @@
if (kst == null) {
return null;
}
-
String type = kst.isSetType()
? kst.getType()
: KeyStore.getDefaultType();
@@ -109,7 +114,15 @@
keyStore.load(new FileInputStream(kst.getFile()), password);
}
if (kst.isSetResource()) {
- keyStore.load(kst.getClass().getClassLoader().getResourceAsStream(kst.getResource()), password);
+ final java.io.InputStream is =
+ ClassLoaderUtils.getResourceAsStream(kst.getResource(), kst.getClass());
+ if (is == null) {
+ final String msg =
+ "Could not load keystore resource " + kst.getResource();
+ LOG.severe(msg);
+ throw new java.io.IOException(msg);
+ }
+ keyStore.load(is, password);
}
if (kst.isSetUrl()) {
keyStore.load(new URL(kst.getUrl()).openStream(), password);
@@ -131,11 +144,15 @@
return createTrustStore(new FileInputStream(pst.getFile()));
}
if (pst.isSetResource()) {
- return createTrustStore(
- pst.getClass().getClassLoader().getResourceAsStream(
- pst.getResource()
- )
- );
+ final java.io.InputStream is =
+ ClassLoaderUtils.getResourceAsStream(pst.getResource(), pst.getClass());
+ if (is == null) {
+ final String msg =
+ "Could not load truststore resource " + pst.getResource();
+ LOG.severe(msg);
+ throw new java.io.IOException(msg);
+ }
+ return createTrustStore(is);
}
if (pst.isSetUrl()) {
return createTrustStore(new URL(pst.getUrl()).openStream());
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java?rev=592134&r1=592133&r2=592134&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java Mon Nov 5 11:57:22 2007
@@ -112,4 +112,10 @@
testSuccessfulCall("resources/pkcs12.xml",
"https://localhost:9003/SoapContext/HttpsPort");
}
+
+ @Test
+ public final void testResourceKeySpecEndpoint() throws Exception {
+ testSuccessfulCall("resources/resource-key-spec.xml",
+ "https://localhost:9004/SoapContext/HttpsPort");
+ }
}
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/jaxws-publish.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/jaxws-publish.xml?rev=592134&r1=592133&r2=592134&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/jaxws-publish.xml (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/jaxws-publish.xml Mon Nov 5 11:57:22 2007
@@ -62,13 +62,13 @@
<httpj:engine port="9001">
<httpj:tlsServerParameters>
<sec:keyManagers keyPassword="password">
- <sec:keyStore type="JKS" password="password"
- file="src/test/java/org/apache/cxf/systest/http/resources/Bethal.jks"/>
- </sec:keyManagers>
- <sec:trustManagers>
- <sec:keyStore type="JKS" password="password"
- file="src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks"/>
- </sec:trustManagers>
+ <sec:keyStore type="JKS" password="password"
+ file="src/test/java/org/apache/cxf/systest/http/resources/Bethal.jks"/>
+ </sec:keyManagers>
+ <sec:trustManagers>
+ <sec:keyStore type="JKS" password="password"
+ file="src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks"/>
+ </sec:trustManagers>
</httpj:tlsServerParameters>
</httpj:engine>
</httpj:engine-factory>
@@ -79,13 +79,13 @@
<http:conduit name="{http://apache.org/hello_world/services}HttpsPort.http-conduit">
<http:tlsClientParameters>
<sec:keyManagers keyPassword="password">
- <sec:keyStore type="JKS" password="password"
- file="src/test/java/org/apache/cxf/systest/http/resources/Morpit.jks"/>
- </sec:keyManagers>
- <sec:trustManagers>
- <sec:keyStore type="JKS" password="password"
- file="src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks"/>
- </sec:trustManagers>
+ <sec:keyStore type="JKS" password="password"
+ file="src/test/java/org/apache/cxf/systest/http/resources/Morpit.jks"/>
+ </sec:keyManagers>
+ <sec:trustManagers>
+ <sec:keyStore type="JKS" password="password"
+ file="src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks"/>
+ </sec:trustManagers>
</http:tlsClientParameters>
</http:conduit>
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec.xml?rev=592134&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec.xml Mon Nov 5 11:57:22 2007
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:sec="http://cxf.apache.org/configuration/security"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+ http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+ http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+ ">
+
+ <!-- -->
+ <!-- This Spring config file is designed to represent a minimal -->
+ <!-- configuration for spring-loading a CXF servant, where the -->
+ <!-- servant listens using HTTP/S as the transport protocol. -->
+ <!-- -->
+ <!-- Note that the service endpoint is spring-loaded. In the -->
+ <!-- scenario in which this config is designed to run, the -->
+ <!-- server application merely instantiates a Bus, and does not -->
+ <!-- publish any services programmatically -->
+ <!-- -->
+
+ <!-- -->
+ <!-- Spring-load an HTTPS servant -->
+ <!-- -->
+ <jaxws:endpoint
+ id="JaxwsHttpsEndpoint"
+ implementor="org.apache.cxf.systest.http.GreeterImpl"
+ address="https://localhost:9004/SoapContext/HttpsPort"
+ serviceName="s:SOAPService"
+ endpointName="e:HttpsPort"
+ xmlns:e="http://apache.org/hello_world/services"
+ xmlns:s="http://apache.org/hello_world/services"
+ depends-on="port-9004-tls-config"/>
+
+ <!-- -->
+ <!-- TLS Port configuration parameters for port 9004 -->
+ <!-- -->
+ <!-- This test exercises the resource attribute in a keyStore element -->
+ <!-- -->
+ <httpj:engine-factory id="port-9004-tls-config">
+ <httpj:engine port="9004">
+ <httpj:tlsServerParameters>
+ <sec:keyManagers keyPassword="password">
+ <sec:keyStore type="JKS" password="password"
+ resource="org/apache/cxf/systest/http/resources/Bethal.jks"/>
+ </sec:keyManagers>
+ <sec:trustManagers>
+ <sec:keyStore type="JKS" password="password"
+ resource="org/apache/cxf/systest/http/resources/Truststore.jks"/>
+ </sec:trustManagers>
+ </httpj:tlsServerParameters>
+ </httpj:engine>
+ </httpj:engine-factory>
+
+ <!-- -->
+ <!-- HTTP/S configuration for clients -->
+ <!-- -->
+ <!-- This test exercises the resource attribute in a keyStore and certStore element -->
+ <!-- -->
+ <http:conduit name="{http://apache.org/hello_world/services}HttpsPort.http-conduit">
+ <http:tlsClientParameters>
+ <sec:keyManagers keyPassword="password">
+ <sec:keyStore type="pkcs12" password="password"
+ resource="org/apache/cxf/systest/http/resources/Morpit.p12"/>
+ </sec:keyManagers>
+ <sec:trustManagers>
+ <sec:certStore
+ resource="org/apache/cxf/systest/http/resources/Truststore.pem"/>
+ </sec:trustManagers>
+ </http:tlsClientParameters>
+ </http:conduit>
+
+</beans>
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java?rev=592134&r1=592133&r2=592134&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java (original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java Mon Nov 5 11:57:22 2007
@@ -254,7 +254,9 @@
for (i = 0; i < tmpStr.length(); i = i + (totalLen - beforeDesSpan)) {
if (i + totalLen - beforeDesSpan < tmpStr.length()) {
addWhiteNamespace(strbuffer, beforeDesSpan);
- strbuffer.append(tmpStr.substring(i, i + totalLen - beforeDesSpan));
+ int lastIdx = i + totalLen - beforeDesSpan;
+ int lastIdx2 = splitAndAppendText(strbuffer, tmpStr, i, lastIdx);
+ i += lastIdx2 - lastIdx;
strbuffer.append(lineSeparator);
} else {
addWhiteNamespace(strbuffer, beforeDesSpan);
@@ -267,6 +269,21 @@
}
return strbuffer.toString();
+ }
+ private int splitAndAppendText(StringBuffer buffer, String tmpStr, int idx, int lastIdx) {
+ int origLast = lastIdx;
+ while (lastIdx > idx && !Character.isWhitespace(tmpStr.charAt(lastIdx))) {
+ --lastIdx;
+ }
+ if (lastIdx == idx) {
+ lastIdx = origLast;
+ }
+ buffer.append(tmpStr.substring(idx, lastIdx));
+
+ if (Character.isWhitespace(tmpStr.charAt(lastIdx))) {
+ lastIdx++;
+ }
+ return lastIdx;
}
private void addWhiteNamespace(StringBuffer strbuffer, int count) {
Modified: incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java?rev=592134&r1=592133&r2=592134&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java (original)
+++ incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java Mon Nov 5 11:57:22 2007
@@ -311,6 +311,15 @@
assertNotNull(usage);
StringTokenizer st1 = new StringTokenizer(usage, System.getProperty("line.separator"));
assertEquals(13, st1.countTokens());
+
+ while (st1.hasMoreTokens()) {
+ String s = st1.nextToken();
+ if (s.indexOf("java package") != -1) {
+ s = s.trim();
+ assertTrue(s.charAt(s.length() - 1) != 'o');
+ }
+ }
+
}
}