cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject git commit: Fixing SAML SSO utils
Date Tue, 16 Sep 2014 16:12:37 GMT
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 <coheigea@apache.org>
Authored: Tue Sep 16 17:12:26 2014 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
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)


Mime
View raw message