Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 108F0199A4 for ; Fri, 22 Apr 2016 14:43:44 +0000 (UTC) Received: (qmail 11152 invoked by uid 500); 22 Apr 2016 14:43:43 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 11073 invoked by uid 500); 22 Apr 2016 14:43:43 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 11063 invoked by uid 99); 22 Apr 2016 14:43:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Apr 2016 14:43:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9EC51DFF46; Fri, 22 Apr 2016 14:43:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: coheigea@apache.org To: commits@cxf.apache.org Date: Fri, 22 Apr 2016 14:43:43 -0000 Message-Id: <2941dc44c2454ba7ba32fb22511c6253@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [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 Authored: Fri Apr 22 14:38:06 2016 +0100 Committer: Colm O hEigeartaigh 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 @@ ${project.version} + org.apache.cxf + cxf-rt-rs-security-sso-oidc + ${project.version} + + org.bouncycastle bcprov-ext-jdk15on ${cxf.bcprov.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 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 @@ + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + ${testutil.ports.jaxrs-oidc} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +