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 6496F11432 for ; Tue, 16 Sep 2014 16:12:38 +0000 (UTC) Received: (qmail 14788 invoked by uid 500); 16 Sep 2014 16:12:38 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 14730 invoked by uid 500); 16 Sep 2014 16:12:38 -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 14721 invoked by uid 99); 16 Sep 2014 16:12:38 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2014 16:12:38 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id EF165A162BC; Tue, 16 Sep 2014 16:12:37 +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 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: Fixing SAML SSO utils Date: Tue, 16 Sep 2014 16:12:37 +0000 (UTC) Repository: cxf-fediz Updated Branches: refs/heads/master eec6e390c -> bf2cbeaf3 Fixing SAML SSO utils Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/bf2cbeaf Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/bf2cbeaf Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/bf2cbeaf Branch: refs/heads/master Commit: bf2cbeaf333918bf52903056445243930ed6176f Parents: eec6e39 Author: Colm O hEigeartaigh Authored: Tue Sep 16 17:12:26 2014 +0100 Committer: Colm O hEigeartaigh Committed: Tue Sep 16 17:12:26 2014 +0100 ---------------------------------------------------------------------- .../fediz/integrationtests/HTTPTestUtils.java | 75 +++----------------- 1 file changed, 10 insertions(+), 65 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/bf2cbeaf/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java ---------------------------------------------------------------------- diff --git a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java index 82e6272..586d1db 100644 --- a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java +++ b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/HTTPTestUtils.java @@ -59,75 +59,20 @@ public final class HTTPTestUtils { return rpPage.getBody().getTextContent(); } - -/* - public static String sendHttpGetForSAMLSSO(String url, String user, - String password, int idpPort) throws Exception { - return sendHttpGetForSAMLSSO(url, user, password, 200, 200, idpPort); - } - public static String sendHttpGetForSAMLSSO(String url, String user, String password, - int returnCodeIDP, int returnCodeRP, int idpPort) - throws Exception { - - CloseableHttpClient httpClient = null; - try { - CredentialsProvider credsProvider = new BasicCredentialsProvider(); - credsProvider.setCredentials( - new AuthScope("localhost", idpPort), - new UsernamePasswordCredentials(user, password)); - - KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); - FileInputStream instream = new FileInputStream(new File("./target/test-classes/client.jks")); - try { - trustStore.load(instream, "clientpass".toCharArray()); - } finally { - try { - instream.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - SSLContextBuilder sslContextBuilder = new SSLContextBuilder(); - sslContextBuilder.loadTrustMaterial(trustStore, new TrustSelfSignedStrategy()); - sslContextBuilder.loadKeyMaterial(trustStore, "clientpass".toCharArray()); - - SSLContext sslContext = sslContextBuilder.build(); - SSLConnectionSocketFactory sslSocketFactory = - new SSLConnectionSocketFactory(sslContext); - - HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); - httpClientBuilder.setDefaultCredentialsProvider(credsProvider); - httpClientBuilder.setSSLSocketFactory(sslSocketFactory); - httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy()); - - httpClient = httpClientBuilder.build(); - - HttpGet httpget = new HttpGet(url); - - HttpResponse response = httpClient.execute(httpget); - HttpEntity entity = response.getEntity(); + public static String loginForSAMLSSO(String url, String user, String password, String idpPort) throws IOException { + final WebClient webClient = new WebClient(); + webClient.getOptions().setUseInsecureSSL(true); + webClient.getCredentialsProvider().setCredentials( + new AuthScope("localhost", Integer.parseInt(idpPort)), + new UsernamePasswordCredentials(user, password)); - System.out.println(response.getStatusLine()); - if (entity != null) { - System.out.println("Response content length: " + entity.getContentLength()); - } - Assert.assertTrue("RP HTTP Response code: " + response.getStatusLine().getStatusCode() - + " [Expected: " + returnCodeRP + "]", - returnCodeRP == response.getStatusLine().getStatusCode()); + webClient.getOptions().setJavaScriptEnabled(false); + final HtmlPage rpPage = webClient.getPage(url); - return EntityUtils.toString(entity); - } finally { - // When HttpClient instance is no longer needed, - // shut down the connection manager to ensure - // immediate deallocation of all system resources - if (httpClient != null) { - httpClient.close(); - } - } + return rpPage.getBody().getTextContent(); } - + /** * Same as sendHttpGet above, except that we return the HttpClient so that it can * subsequently be re-used (for e.g. logout)