You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2016/04/22 16:43:43 UTC
[1/3] cxf git commit: Added some OIDC systests
Repository: cxf
Updated Branches:
refs/heads/master f95f6649f -> 2ed0f4352
Added some OIDC systests
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f41dca89
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f41dca89
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f41dca89
Branch: refs/heads/master
Commit: f41dca8950e850f4068a1b5e569f866495269d78
Parents: 07c1a12
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Fri Apr 22 14:38:06 2016 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Fri Apr 22 14:38:28 2016 +0100
----------------------------------------------------------------------
systests/rs-security/pom.xml | 5 +
.../security/oauth2/common/OAuth2TestUtils.java | 3 +
.../oauth2/common/OAuthDataProviderImpl.java | 6 +
.../security/oidc/IdTokenProviderImpl.java | 50 +++
.../jaxrs/security/oidc/OIDCFlowTest.java | 330 +++++++++++++++++++
.../systest/jaxrs/security/oidc/OIDCServer.java | 48 +++
.../src/test/resources/logging.properties | 4 +-
.../cxf/systest/jaxrs/security/oidc/client.xml | 35 ++
.../systest/jaxrs/security/oidc/oidc-server.xml | 128 +++++++
9 files changed, 607 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/f41dca89/systests/rs-security/pom.xml
----------------------------------------------------------------------
diff --git a/systests/rs-security/pom.xml b/systests/rs-security/pom.xml
index 104df2f..19a03ed 100644
--- a/systests/rs-security/pom.xml
+++ b/systests/rs-security/pom.xml
@@ -79,6 +79,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-security-sso-oidc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk15on</artifactId>
<version>${cxf.bcprov.version}</version>
http://git-wip-us.apache.org/repos/asf/cxf/blob/f41dca89/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java
index aac8b5b..ea7afa0 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuth2TestUtils.java
@@ -97,6 +97,9 @@ public final class OAuth2TestUtils {
form.param("session_authenticity_token", authzData.getAuthenticityToken());
form.param("client_id", authzData.getClientId());
form.param("redirect_uri", authzData.getRedirectUri());
+ if (authzData.getNonce() != null) {
+ form.param("nonce", authzData.getNonce());
+ }
if (authzData.getProposedScope() != null) {
form.param("scope", authzData.getProposedScope());
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f41dca89/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuthDataProviderImpl.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuthDataProviderImpl.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuthDataProviderImpl.java
index 20e952a..0fed0d4 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuthDataProviderImpl.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/common/OAuthDataProviderImpl.java
@@ -56,6 +56,7 @@ public class OAuthDataProviderImpl extends DefaultEHCacheCodeDataProvider {
client.getRegisteredScopes().add("read_book");
client.getRegisteredScopes().add("create_book");
client.getRegisteredScopes().add("create_image");
+ client.getRegisteredScopes().add("openid");
this.setClient(client);
@@ -69,6 +70,7 @@ public class OAuthDataProviderImpl extends DefaultEHCacheCodeDataProvider {
client.getRegisteredAudiences().add("https://localhost:" + servicePort
+ "/secured/bookstore/books");
client.getRegisteredAudiences().add("https://127.0.0.1/test");
+ client.getRegisteredScopes().add("openid");
this.setClient(client);
@@ -81,6 +83,7 @@ public class OAuthDataProviderImpl extends DefaultEHCacheCodeDataProvider {
client.getRegisteredAudiences().add("https://localhost:" + servicePort
+ "/securedxyz/bookstore/books");
+ client.getRegisteredScopes().add("openid");
this.setClient(client);
@@ -176,6 +179,9 @@ public class OAuthDataProviderImpl extends DefaultEHCacheCodeDataProvider {
permission.setUris(uris);
permissions.add(permission);
+ } else if ("openid".equals(requestedScope)) {
+ OAuthPermission permission = new OAuthPermission("openid", "Authenticate user");
+ permissions.add(permission);
} else {
throw new OAuthServiceException("invalid_scope");
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f41dca89/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/IdTokenProviderImpl.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/IdTokenProviderImpl.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/IdTokenProviderImpl.java
new file mode 100644
index 0000000..bd7a4d9
--- /dev/null
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/IdTokenProviderImpl.java
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.systest.jaxrs.security.oidc;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.cxf.rs.security.oauth2.common.UserSubject;
+import org.apache.cxf.rs.security.oidc.common.IdToken;
+import org.apache.cxf.rs.security.oidc.idp.IdTokenProvider;
+
+public class IdTokenProviderImpl implements IdTokenProvider {
+
+ public IdTokenProviderImpl() {
+
+ }
+
+ @Override
+ public IdToken getIdToken(String clientId, UserSubject authenticatedUser, List<String> scopes) {
+ IdToken token = new IdToken();
+
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.SECOND, 60);
+ token.setExpiryTime(cal.getTimeInMillis() / 1000L);
+ token.setIssuedAt(new Date().getTime() / 1000L);
+ token.setAudience(clientId);
+ token.setSubject(authenticatedUser.getLogin());
+ token.setIssuer("OIDC IdP");
+
+ return token;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f41dca89/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java
new file mode 100644
index 0000000..bba05a4
--- /dev/null
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java
@@ -0,0 +1,330 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.systest.jaxrs.security.oidc;
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm;
+import org.apache.cxf.rs.security.jose.jws.JwsJwtCompactConsumer;
+import org.apache.cxf.rs.security.jose.jwt.JwtConstants;
+import org.apache.cxf.rs.security.jose.jwt.JwtToken;
+import org.apache.cxf.rs.security.oauth2.common.ClientAccessToken;
+import org.apache.cxf.rs.security.oidc.common.IdToken;
+import org.apache.cxf.systest.jaxrs.security.oauth2.common.OAuth2TestUtils;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.TestUtil;
+import org.apache.wss4j.common.util.Loader;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+/**
+ * Some unit tests to test the various flows in OpenID Connect.
+ */
+public class OIDCFlowTest extends AbstractBusClientServerTestBase {
+
+ static final String PORT = TestUtil.getPortNumber("jaxrs-oidc");
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(OIDCServer.class, true)
+ );
+ }
+
+ @org.junit.Test
+ public void testAuthorizationCodeFlow() throws Exception {
+ URL busFile = OIDCFlowTest.class.getResource("client.xml");
+
+ String address = "https://localhost:" + PORT + "/services/";
+ WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "alice", "security", busFile.toString());
+
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ // Get Authorization Code
+ String code = OAuth2TestUtils.getAuthorizationCode(client, "openid");
+ assertNotNull(code);
+
+ // Now get the access token
+ client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "consumer-id", "this-is-a-secret", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ ClientAccessToken accessToken =
+ OAuth2TestUtils.getAccessTokenWithAuthorizationCode(client, code);
+ assertNotNull(accessToken.getTokenKey());
+ assertTrue(accessToken.getApprovedScope().contains("openid"));
+
+ String idToken = accessToken.getParameters().get("id_token");
+ assertNotNull(idToken);
+ validateIdToken(idToken, null);
+ }
+
+ // Just a normal OAuth invocation, check it all works ok
+ @org.junit.Test
+ public void testAuthorizationCodeOAuth() throws Exception {
+ URL busFile = OIDCFlowTest.class.getResource("client.xml");
+
+ String address = "https://localhost:" + PORT + "/services/";
+ WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "alice", "security", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ // Get Authorization Code
+ String code = OAuth2TestUtils.getAuthorizationCode(client, "read_balance");
+ assertNotNull(code);
+
+ // Now get the access token
+ client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "consumer-id", "this-is-a-secret", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ ClientAccessToken accessToken =
+ OAuth2TestUtils.getAccessTokenWithAuthorizationCode(client, code);
+ assertNotNull(accessToken.getTokenKey());
+ // We should not have an IdToken here
+ String idToken = accessToken.getParameters().get("id_token");
+ assertNull(idToken);
+ assertFalse(accessToken.getApprovedScope().contains("openid"));
+ }
+
+ @org.junit.Test
+ public void testAuthorizationCodeFlowWithNonce() throws Exception {
+ URL busFile = OIDCFlowTest.class.getResource("client.xml");
+
+ String address = "https://localhost:" + PORT + "/services/";
+ WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "alice", "security", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ // Get Authorization Code
+ String code = OAuth2TestUtils.getAuthorizationCode(client, "openid", "consumer-id",
+ "123456789", null);
+ assertNotNull(code);
+
+ // Now get the access token
+ client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "consumer-id", "this-is-a-secret", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ ClientAccessToken accessToken =
+ OAuth2TestUtils.getAccessTokenWithAuthorizationCode(client, code);
+ assertNotNull(accessToken.getTokenKey());
+ assertTrue(accessToken.getApprovedScope().contains("openid"));
+
+ String idToken = accessToken.getParameters().get("id_token");
+ assertNotNull(idToken);
+ validateIdToken(idToken, "123456789");
+ }
+
+ @org.junit.Test
+ public void testAuthorizationCodeFlowWithScope() throws Exception {
+ URL busFile = OIDCFlowTest.class.getResource("client.xml");
+
+ String address = "https://localhost:" + PORT + "/services/";
+ WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "alice", "security", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ // Get Authorization Code
+ String code = OAuth2TestUtils.getAuthorizationCode(client, "openid read_balance");
+ assertNotNull(code);
+
+ // Now get the access token
+ client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "consumer-id", "this-is-a-secret", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ ClientAccessToken accessToken =
+ OAuth2TestUtils.getAccessTokenWithAuthorizationCode(client, code);
+ assertNotNull(accessToken.getTokenKey());
+ assertTrue(accessToken.getApprovedScope().contains("openid"));
+ assertTrue(accessToken.getApprovedScope().contains("read_balance"));
+
+ String idToken = accessToken.getParameters().get("id_token");
+ assertNotNull(idToken);
+ validateIdToken(idToken, null);
+ }
+
+ @org.junit.Test
+ public void testAuthorizationCodeFlowWithRefresh() throws Exception {
+ URL busFile = OIDCFlowTest.class.getResource("client.xml");
+
+ String address = "https://localhost:" + PORT + "/services/";
+ WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "alice", "security", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ // Get Authorization Code
+ String code = OAuth2TestUtils.getAuthorizationCode(client, "openid");
+ assertNotNull(code);
+
+ // Now get the access token
+ client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "consumer-id", "this-is-a-secret", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ ClientAccessToken accessToken =
+ OAuth2TestUtils.getAccessTokenWithAuthorizationCode(client, code);
+ assertNotNull(accessToken.getTokenKey());
+ assertTrue(accessToken.getApprovedScope().contains("openid"));
+ assertNotNull(accessToken.getRefreshToken());
+
+ String idToken = accessToken.getParameters().get("id_token");
+ assertNotNull(idToken);
+ validateIdToken(idToken, null);
+
+ // Refresh the access token
+ client.type("application/x-www-form-urlencoded").accept("application/json");
+
+ Form form = new Form();
+ form.param("grant_type", "refresh_token");
+ form.param("refresh_token", accessToken.getRefreshToken());
+ form.param("client_id", "consumer-id");
+ form.param("scope", "openid");
+ Response response = client.post(form);
+
+ accessToken = response.readEntity(ClientAccessToken.class);
+ assertNotNull(accessToken.getTokenKey());
+ assertNotNull(accessToken.getRefreshToken());
+ accessToken.getParameters().get("id_token");
+ assertNotNull(idToken);
+ }
+
+ @org.junit.Test
+ public void testAuthorizationCodeFlowWithState() throws Exception {
+ URL busFile = OIDCFlowTest.class.getResource("client.xml");
+
+ String address = "https://localhost:" + PORT + "/services/";
+ WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "alice", "security", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ // Get Authorization Code
+ String code = OAuth2TestUtils.getAuthorizationCode(client, "openid", "consumer-id",
+ null, "123456789");
+ assertNotNull(code);
+
+ // Now get the access token
+ client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "consumer-id", "this-is-a-secret", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ ClientAccessToken accessToken =
+ OAuth2TestUtils.getAccessTokenWithAuthorizationCode(client, code);
+ assertNotNull(accessToken.getTokenKey());
+ assertTrue(accessToken.getApprovedScope().contains("openid"));
+
+ String idToken = accessToken.getParameters().get("id_token");
+ assertNotNull(idToken);
+ validateIdToken(idToken, null);
+ }
+
+ @org.junit.Test
+ public void testAuthorizationCodeFlowWithAudience() throws Exception {
+ URL busFile = OIDCFlowTest.class.getResource("client.xml");
+
+ String address = "https://localhost:" + PORT + "/services/";
+ WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "alice", "security", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ // Get Authorization Code
+ String code = OAuth2TestUtils.getAuthorizationCode(client, "openid", "consumer-id-aud",
+ null, null);
+ assertNotNull(code);
+
+ // Now get the access token
+ client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
+ "consumer-id-aud", "this-is-a-secret", busFile.toString());
+ // Save the Cookie for the second request...
+ WebClient.getConfig(client).getRequestContext().put(
+ org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
+
+ String audience = "https://localhost:" + PORT + "/secured/bookstore/books";
+ ClientAccessToken accessToken =
+ OAuth2TestUtils.getAccessTokenWithAuthorizationCode(client, code, "consumer-id-aud", audience);
+ assertNotNull(accessToken.getTokenKey());
+ }
+
+ private void validateIdToken(String idToken, String nonce)
+ throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
+ JwsJwtCompactConsumer jwtConsumer = new JwsJwtCompactConsumer(idToken);
+ JwtToken jwt = jwtConsumer.getJwtToken();
+
+ // Validate claims
+ Assert.assertEquals("alice", jwt.getClaim(JwtConstants.CLAIM_SUBJECT));
+ Assert.assertEquals("OIDC IdP", jwt.getClaim(JwtConstants.CLAIM_ISSUER));
+ Assert.assertEquals("consumer-id", jwt.getClaim(JwtConstants.CLAIM_AUDIENCE));
+ Assert.assertNotNull(jwt.getClaim(JwtConstants.CLAIM_EXPIRY));
+ Assert.assertNotNull(jwt.getClaim(JwtConstants.CLAIM_ISSUED_AT));
+ if (nonce != null) {
+ Assert.assertEquals(nonce, jwt.getClaim(IdToken.NONCE_CLAIM));
+ }
+
+ KeyStore keystore = KeyStore.getInstance("JKS");
+ keystore.load(Loader.getResource("org/apache/cxf/systest/jaxrs/security/certs/alice.jks").openStream(),
+ "password".toCharArray());
+ Certificate cert = keystore.getCertificate("alice");
+ Assert.assertNotNull(cert);
+
+ Assert.assertTrue(jwtConsumer.verifySignatureWith((X509Certificate)cert,
+ SignatureAlgorithm.RS256));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f41dca89/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCServer.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCServer.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCServer.java
new file mode 100644
index 0000000..1b697f5
--- /dev/null
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCServer.java
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.jaxrs.security.oidc;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
+
+public class OIDCServer extends AbstractBusTestServerBase {
+ public static final String PORT = TestUtil.getPortNumber("jaxrs-oidc");
+ private static final URL SERVER_CONFIG_FILE =
+ OIDCServer.class.getResource("oidc-server.xml");
+
+ protected void run() {
+ SpringBusFactory bf = new SpringBusFactory();
+ Bus springBus = bf.createBus(SERVER_CONFIG_FILE);
+ BusFactory.setDefaultBus(springBus);
+ setBus(springBus);
+
+ try {
+ new OIDCServer();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f41dca89/systests/rs-security/src/test/resources/logging.properties
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/resources/logging.properties b/systests/rs-security/src/test/resources/logging.properties
index b796128..b2e5a79 100644
--- a/systests/rs-security/src/test/resources/logging.properties
+++ b/systests/rs-security/src/test/resources/logging.properties
@@ -46,7 +46,7 @@
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
-.level= WARNING
+.level= INFO
############################################################
# Handler specific properties.
@@ -60,7 +60,7 @@ java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
# Limit the message that are printed on the console to INFO and above.
-java.util.logging.ConsoleHandler.level = SEVERE
+java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
http://git-wip-us.apache.org/repos/asf/cxf/blob/f41dca89/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/oidc/client.xml
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/oidc/client.xml b/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/oidc/client.xml
new file mode 100644
index 0000000..f5ede61
--- /dev/null
+++ b/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/oidc/client.xml
@@ -0,0 +1,35 @@
+<?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:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core" xmlns:p="http://cxf.apache.org/policy" xmlns:sec="http://cxf.apache.org/configuration/security" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/policy http://cxf.apache.org/schemas/poli
cy.xsd">
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+ <cxf:bus>
+ <cxf:features>
+ <cxf:logging/>
+ </cxf:features>
+ </cxf:bus>
+ <http:conduit name="https://localhost.*">
+ <http:client ConnectionTimeout="3000000" ReceiveTimeout="3000000"/>
+ <http:tlsClientParameters disableCNCheck="true">
+ <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>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/f41dca89/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/oidc/oidc-server.xml
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/oidc/oidc-server.xml b/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/oidc/oidc-server.xml
new file mode 100644
index 0000000..ad95bec
--- /dev/null
+++ b/systests/rs-security/src/test/resources/org/apache/cxf/systest/jaxrs/security/oidc/oidc-server.xml
@@ -0,0 +1,128 @@
+<?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:sec="http://cxf.apache.org/configuration/security"
+ xmlns:cxf="http://cxf.apache.org/core"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
+ http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.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">
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+ <cxf:bus>
+ <cxf:features>
+ <cxf:logging/>
+ </cxf:features>
+ <cxf:properties>
+ <entry key="org.apache.cxf.jaxrs.bus.providers" value-ref="busProviders"/>
+ </cxf:properties>
+ </cxf:bus>
+ <!-- providers -->
+ <util:list id="busProviders">
+ <ref bean="oauthJson"/>
+ </util:list>
+ <bean id="oauthJson" class="org.apache.cxf.rs.security.oauth2.provider.OAuthJSONProvider"/>
+
+ <httpj:engine-factory id="tls-config">
+ <httpj:engine port="${testutil.ports.jaxrs-oidc}">
+ <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:clientAuthentication want="false" required="false"/>
+ </httpj:tlsServerParameters>
+ <httpj:sessionSupport>true</httpj:sessionSupport>
+ </httpj:engine>
+ </httpj:engine-factory>
+
+ <bean id="oauthProvider" class="org.apache.cxf.systest.jaxrs.security.oauth2.common.OAuthDataProviderImpl">
+ <constructor-arg><value>${testutil.ports.jaxrs-oidc}</value></constructor-arg>
+ </bean>
+
+ <bean id="authorizationService" class="org.apache.cxf.rs.security.oauth2.services.AuthorizationCodeGrantService">
+ <property name="dataProvider" ref="oauthProvider"/>
+ </bean>
+
+ <bean id="implicitService" class="org.apache.cxf.rs.security.oauth2.services.ImplicitGrantService">
+ <property name="dataProvider" ref="oauthProvider"/>
+ </bean>
+
+ <bean id="refreshGrantHandler" class="org.apache.cxf.rs.security.oauth2.grants.refresh.RefreshTokenGrantHandler">
+ <property name="dataProvider" ref="oauthProvider"/>
+ </bean>
+
+ <bean id="idTokenProviderImpl" class="org.apache.cxf.systest.jaxrs.security.oidc.IdTokenProviderImpl"/>
+
+ <bean id="idTokenFilter" class="org.apache.cxf.rs.security.oidc.idp.IdTokenResponseFilter">
+ <property name="idTokenProvider" ref="idTokenProviderImpl"/>
+ </bean>
+
+ <bean id="tokenService" class="org.apache.cxf.rs.security.oauth2.services.AccessTokenService">
+ <property name="dataProvider" ref="oauthProvider"/>
+ <property name="grantHandlers">
+ <list>
+ <ref bean="refreshGrantHandler"/>
+ </list>
+ </property>
+ <property name="responseFilter" ref="idTokenFilter"/>
+ </bean>
+
+ <bean id="callbackHandler" class="org.apache.cxf.systest.jaxrs.security.oauth2.common.CallbackHandlerImpl"/>
+ <bean id="basicAuthFilter" class="org.apache.cxf.systest.jaxrs.security.oauth2.common.WSS4JBasicAuthFilter">
+ <property name="callbackHandler" ref="callbackHandler"/>
+ </bean>
+
+ <bean id="oidcKeysService" class="org.apache.cxf.rs.security.oidc.idp.OidcKeysService"/>
+
+ <jaxrs:server
+ depends-on="tls-config"
+ address="https://localhost:${testutil.ports.jaxrs-oidc}/services">
+ <jaxrs:serviceBeans>
+ <ref bean="authorizationService"/>
+ <ref bean="implicitService"/>
+ <ref bean="tokenService"/>
+ <ref bean="oidcKeysService"/>
+ </jaxrs:serviceBeans>
+ <jaxrs:providers>
+ <ref bean="basicAuthFilter"/>
+ </jaxrs:providers>
+ <jaxrs:properties>
+ <entry key="rs.security.keystore.type" value="jks" />
+ <entry key="rs.security.keystore.alias" value="alice"/>
+ <entry key="rs.security.keystore.password" value="password"/>
+ <entry key="rs.security.key.password" value="password"/>
+ <entry key="rs.security.keystore.file"
+ value="org/apache/cxf/systest/jaxrs/security/certs/alice.jks" />
+ <entry key="rs.security.signature.algorithm" value="RS256" />
+ </jaxrs:properties>
+ </jaxrs:server>
+
+
+</beans>
[3/3] cxf git commit: Renaming "Hybrid" grant type
Posted by co...@apache.org.
Renaming "Hybrid" grant type
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/2ed0f435
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/2ed0f435
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/2ed0f435
Branch: refs/heads/master
Commit: 2ed0f4352b1586ea728a7498cebf4c9f4ae1c113
Parents: f41dca8
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Fri Apr 22 15:43:03 2016 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Fri Apr 22 15:43:03 2016 +0100
----------------------------------------------------------------------
.../org/apache/cxf/rs/security/oidc/idp/OidcHybridService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/2ed0f435/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/OidcHybridService.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/OidcHybridService.java b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/OidcHybridService.java
index edade5b..2d93a5c 100644
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/OidcHybridService.java
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/idp/OidcHybridService.java
@@ -41,7 +41,7 @@ public class OidcHybridService extends OidcImplicitService {
this(false);
}
public OidcHybridService(boolean hybridOnly) {
- super(getResponseTypes(hybridOnly), "Hybrid");
+ super(getResponseTypes(hybridOnly), "hybrid");
}
private static Set<String> getResponseTypes(boolean hybridOnly) {
[2/3] cxf git commit: More stream closing
Posted by co...@apache.org.
More stream closing
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/07c1a12a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/07c1a12a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/07c1a12a
Branch: refs/heads/master
Commit: 07c1a12a4d3ce2c49d2eb2c8373ef89db08b520b
Parents: f95f664
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Fri Apr 22 12:13:10 2016 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Fri Apr 22 14:38:28 2016 +0100
----------------------------------------------------------------------
.../org/apache/cxf/javascript/JsHttpRequestTest.java | 10 ++--------
.../apache/cxf/rs/security/jose/common/JoseUtils.java | 5 +++--
.../transport/http_jetty/JettyHTTPServerEngineTest.java | 7 ++++---
.../cxf/xkms/x509/repo/ldap/LDAPCertificateRepoTest.java | 11 +++++++----
.../org/apache/cxf/systest/servlet/JaxRsServletTest.java | 9 ++-------
5 files changed, 18 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/07c1a12a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java
----------------------------------------------------------------------
diff --git a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java
index b2055a0..5e8b983 100644
--- a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java
+++ b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java
@@ -21,7 +21,6 @@ package org.apache.cxf.javascript;
import java.io.File;
import java.io.Reader;
-import java.io.StringWriter;
import java.net.URL;
import java.util.Properties;
@@ -31,6 +30,7 @@ import javax.xml.xpath.XPathConstants;
import org.w3c.dom.Document;
import org.apache.cxf.Bus;
+import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.test.AbstractCXFSpringTest;
@@ -114,13 +114,7 @@ public class JsHttpRequestTest extends AbstractCXFSpringTest {
// check for 'Shalom' in Hebrew as a charset check.
assertTrue(httpResponse.contains("\u05e9\u05dc\u05d5\u05dd"));
Reader r = getResourceAsReader("/org/apache/cxf/javascript/XML_GreetMeDocLiteralReq.xml");
- StringWriter writer = new StringWriter();
- char[] buffer = new char[1024];
- int readCount;
- while ((readCount = r.read(buffer, 0, 1024)) > 0) {
- writer.write(buffer, 0, readCount);
- }
- String xml = writer.toString();
+ String xml = IOUtils.toString(r);
EndpointImpl endpoint = this.getBean(EndpointImpl.class, "greeter-service-endpoint");
JsSimpleDomNode xmlResponse =
testUtilities.rhinoCallConvert("testSyncXml",
http://git-wip-us.apache.org/repos/asf/cxf/blob/07c1a12a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/JoseUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/JoseUtils.java b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/JoseUtils.java
index 225540e..12741c8 100644
--- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/JoseUtils.java
+++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/JoseUtils.java
@@ -195,8 +195,9 @@ public final class JoseUtils {
public static Properties loadProperties(String propertiesLocation, Bus bus) throws Exception {
Properties props = new Properties();
- InputStream is = getResourceStream(propertiesLocation, bus);
- props.load(is);
+ try (InputStream is = getResourceStream(propertiesLocation, bus)) {
+ props.load(is);
+ }
return props;
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/07c1a12a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java b/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
index 704a149..778c77b 100644
--- a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
+++ b/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
@@ -416,8 +416,9 @@ public class JettyHTTPServerEngineTest extends Assert {
assertTrue(connection instanceof HttpURLConnection);
connection.connect();
InputStream in = connection.getInputStream();
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- IOUtils.copy(in, buffer);
- return buffer.toString();
+ try (ByteArrayOutputStream buffer = new ByteArrayOutputStream()) {
+ IOUtils.copy(in, buffer);
+ return buffer.toString();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/07c1a12a/services/xkms/xkms-x509-repo-ldap/src/test/java/org/apache/cxf/xkms/x509/repo/ldap/LDAPCertificateRepoTest.java
----------------------------------------------------------------------
diff --git a/services/xkms/xkms-x509-repo-ldap/src/test/java/org/apache/cxf/xkms/x509/repo/ldap/LDAPCertificateRepoTest.java b/services/xkms/xkms-x509-repo-ldap/src/test/java/org/apache/cxf/xkms/x509/repo/ldap/LDAPCertificateRepoTest.java
index 167eb0c..17dc53f 100644
--- a/services/xkms/xkms-x509-repo-ldap/src/test/java/org/apache/cxf/xkms/x509/repo/ldap/LDAPCertificateRepoTest.java
+++ b/services/xkms/xkms-x509-repo-ldap/src/test/java/org/apache/cxf/xkms/x509/repo/ldap/LDAPCertificateRepoTest.java
@@ -21,6 +21,7 @@ package org.apache.cxf.xkms.x509.repo.ldap;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
@@ -83,6 +84,7 @@ public class LDAPCertificateRepoTest {
FileInputStream fis = new FileInputStream(certFile);
CertificateFactory factory = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) factory.generateCertificate(fis);
+ fis.close();
UseKeyWithType key = new UseKeyWithType();
key.setApplication(Applications.PKIX.getUri());
@@ -136,11 +138,12 @@ public class LDAPCertificateRepoTest {
c.verify();
}
- private X509Certificate getTestCert() throws FileNotFoundException, CertificateException {
+ private X509Certificate getTestCert() throws FileNotFoundException, CertificateException, IOException {
File certFile = new File("src/test/resources/cert1.cer");
Assert.assertTrue(certFile.exists());
- FileInputStream fis = new FileInputStream(certFile);
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
- return (X509Certificate) factory.generateCertificate(fis);
+ try (FileInputStream fis = new FileInputStream(certFile)) {
+ CertificateFactory factory = CertificateFactory.getInstance("X.509");
+ return (X509Certificate) factory.generateCertificate(fis);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/07c1a12a/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java
----------------------------------------------------------------------
diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java
index e4a3b7e..a3dbd8a 100644
--- a/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/servlet/JaxRsServletTest.java
@@ -27,7 +27,6 @@ import com.meterware.servletunit.ServletUnitClient;
import org.apache.cxf.Bus;
import org.apache.cxf.BusException;
import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.io.CachedOutputStream;
import org.junit.Test;
@@ -71,11 +70,7 @@ public class JaxRsServletTest extends AbstractServletTest {
}
- private String getStringFromInputStream(InputStream in) throws Exception {
- CachedOutputStream bos = new CachedOutputStream();
- IOUtils.copy(in, bos);
- in.close();
- bos.close();
- return bos.getOut().toString();
+ private String getStringFromInputStream(InputStream in) throws Exception {
+ return IOUtils.toString(in);
}
}