cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject git commit: [FEDIZ-86] - Adding metadata support for spring + tests
Date Thu, 04 Sep 2014 15:53:01 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/master a4b86cc6b -> cdfe522f2


[FEDIZ-86] - Adding metadata support for spring + tests


Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/cdfe522f
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/cdfe522f
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/cdfe522f

Branch: refs/heads/master
Commit: cdfe522f2c21fc2df6f0a3ae4313af8d3df9128f
Parents: a4b86cc
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Thu Sep 4 16:52:31 2014 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Thu Sep 4 16:52:31 2014 +0100

----------------------------------------------------------------------
 .../web/FederationAuthenticationEntryPoint.java | 44 ++++++++++++-
 .../web/FederationAuthenticationEntryPoint.java | 68 +++++++++++++++++++-
 .../idp/kerberos/KerberosTokenValidator.java    | 12 +++-
 .../federation/FederationTest.java              |  7 ++
 .../cxf/fediz/integrationtests/JettyTest.java   | 68 --------------------
 .../WEB-INF/applicationContext-security.xml     |  1 +
 .../WEB-INF/applicationContext-security.xml     |  1 +
 .../fediz/integrationtests/AbstractTests.java   | 68 ++++++++++++++++++++
 .../cxf/fediz/integrationtests/TomcatTest.java  | 66 -------------------
 9 files changed, 197 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cdfe522f/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
----------------------------------------------------------------------
diff --git a/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
b/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
index 8033930..e777ab8 100644
--- a/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
+++ b/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
@@ -20,18 +20,27 @@
 package org.apache.cxf.fediz.spring.web;
 
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.util.Map;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.w3c.dom.Document;
+
+import org.apache.cxf.fediz.core.FederationConstants;
+import org.apache.cxf.fediz.core.SAMLSSOConstants;
+import org.apache.cxf.fediz.core.config.FederationProtocol;
 import org.apache.cxf.fediz.core.config.FedizContext;
+import org.apache.cxf.fediz.core.config.SAMLProtocol;
 import org.apache.cxf.fediz.core.exception.ProcessingException;
 import org.apache.cxf.fediz.core.processor.FedizProcessor;
 import org.apache.cxf.fediz.core.processor.FedizProcessorFactory;
 import org.apache.cxf.fediz.core.processor.RedirectionResponse;
 import org.apache.cxf.fediz.spring.FederationConfig;
+import org.apache.wss4j.common.util.DOM2Writer;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeansException;
@@ -74,9 +83,31 @@ public class FederationAuthenticationEntryPoint implements AuthenticationEntryPo
     public final void commence(final HttpServletRequest servletRequest, final HttpServletResponse
response,
             final AuthenticationException authenticationException) throws IOException, ServletException
{
 
-        String redirectUrl = null;
         FedizContext fedContext = federationConfig.getFedizContext();
         LOG.debug("Federation context: {}", fedContext);
+        
+        if (servletRequest.getRequestURL().indexOf(FederationConstants.METADATA_PATH_URI)
!= -1
+            || servletRequest.getRequestURL().indexOf(getMetadataURI(fedContext)) != -1)
{
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Metadata document requested");
+            }
+            response.setContentType("text/xml");
+            PrintWriter out = response.getWriter();
+            
+            FedizProcessor wfProc = 
+                FedizProcessorFactory.newFedizProcessor(fedContext.getProtocol());
+            try {
+                Document metadata = wfProc.getMetaData(fedContext);
+                out.write(DOM2Writer.nodeToString(metadata));
+                return;
+            } catch (Exception ex) {
+                LOG.warn("Failed to get metadata document: " + ex.getMessage());
+                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+                return;
+            }            
+        }
+        
+        String redirectUrl = null;
         try {
             FedizProcessor wfProc = 
                 FedizProcessorFactory.newFedizProcessor(fedContext.getProtocol());
@@ -108,6 +139,17 @@ public class FederationAuthenticationEntryPoint implements AuthenticationEntryPo
         response.sendRedirect(redirectUrl);
     }
 
+    private String getMetadataURI(FedizContext fedConfig) {
+        if (fedConfig.getProtocol().getMetadataURI() != null) {
+            return fedConfig.getProtocol().getMetadataURI();
+        } else if (fedConfig.getProtocol() instanceof FederationProtocol) {
+            return FederationConstants.METADATA_PATH_URI;
+        } else if (fedConfig.getProtocol() instanceof SAMLProtocol) {
+            return SAMLSSOConstants.FEDIZ_SAML_METADATA_PATH_URI;
+        }
+        
+        return FederationConstants.METADATA_PATH_URI;
+    }
 
     /**
      * Template method for you to do your own pre-processing before the redirect occurs.

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cdfe522f/plugins/spring2/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
----------------------------------------------------------------------
diff --git a/plugins/spring2/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
b/plugins/spring2/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
index a2e762f..ffc4fe6 100644
--- a/plugins/spring2/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
+++ b/plugins/spring2/src/main/java/org/apache/cxf/fediz/spring/web/FederationAuthenticationEntryPoint.java
@@ -20,6 +20,7 @@
 package org.apache.cxf.fediz.spring.web;
 
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.util.Map;
 
 import javax.servlet.ServletException;
@@ -28,12 +29,20 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.w3c.dom.Document;
+
+import org.apache.cxf.fediz.core.FederationConstants;
+import org.apache.cxf.fediz.core.SAMLSSOConstants;
+import org.apache.cxf.fediz.core.config.FederationProtocol;
 import org.apache.cxf.fediz.core.config.FedizContext;
+import org.apache.cxf.fediz.core.config.SAMLProtocol;
 import org.apache.cxf.fediz.core.exception.ProcessingException;
 import org.apache.cxf.fediz.core.processor.FedizProcessor;
 import org.apache.cxf.fediz.core.processor.FedizProcessorFactory;
 import org.apache.cxf.fediz.core.processor.RedirectionResponse;
 import org.apache.cxf.fediz.spring.FederationConfig;
+import org.apache.wss4j.common.util.DOM2Writer;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeansException;
@@ -77,9 +86,31 @@ public class FederationAuthenticationEntryPoint implements AuthenticationEntryPo
     public final void commence(final HttpServletRequest servletRequest, final HttpServletResponse
response,
             final AuthenticationException authenticationException) throws IOException, ServletException
{
 
-        String redirectUrl = null;
         FedizContext fedContext = federationConfig.getFedizContext();
         LOG.debug("Federation context: {}", fedContext);
+        
+        if (servletRequest.getRequestURL().indexOf(FederationConstants.METADATA_PATH_URI)
!= -1
+            || servletRequest.getRequestURL().indexOf(getMetadataURI(fedContext)) != -1)
{
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Metadata document requested");
+            }
+            response.setContentType("text/xml");
+            PrintWriter out = response.getWriter();
+            
+            FedizProcessor wfProc = 
+                FedizProcessorFactory.newFedizProcessor(fedContext.getProtocol());
+            try {
+                Document metadata = wfProc.getMetaData(fedContext);
+                out.write(DOM2Writer.nodeToString(metadata));
+                return;
+            } catch (Exception ex) {
+                LOG.warn("Failed to get metadata document: " + ex.getMessage());
+                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+                return;
+            }            
+        }
+        
+        String redirectUrl = null;
         try {
             FedizProcessor wfProc = 
                 FedizProcessorFactory.newFedizProcessor(fedContext.getProtocol());
@@ -111,6 +142,17 @@ public class FederationAuthenticationEntryPoint implements AuthenticationEntryPo
         response.sendRedirect(redirectUrl);
     }
 
+    private String getMetadataURI(FedizContext fedConfig) {
+        if (fedConfig.getProtocol().getMetadataURI() != null) {
+            return fedConfig.getProtocol().getMetadataURI();
+        } else if (fedConfig.getProtocol() instanceof FederationProtocol) {
+            return FederationConstants.METADATA_PATH_URI;
+        } else if (fedConfig.getProtocol() instanceof SAMLProtocol) {
+            return SAMLSSOConstants.FEDIZ_SAML_METADATA_PATH_URI;
+        }
+        
+        return FederationConstants.METADATA_PATH_URI;
+    }
 
     /**
      * Template method for you to do your own pre-processing before the redirect occurs.
@@ -133,9 +175,31 @@ public class FederationAuthenticationEntryPoint implements AuthenticationEntryPo
         
         HttpServletRequest hrequest = (HttpServletRequest)request;
         HttpServletResponse hresponse = (HttpServletResponse)response;
-        String redirectUrl = null;
         FedizContext fedContext = federationConfig.getFedizContext();
         LOG.debug("Federation context: {}", fedContext);
+        
+        if (hrequest.getRequestURL().indexOf(FederationConstants.METADATA_PATH_URI) != -1
+            || hrequest.getRequestURL().indexOf(getMetadataURI(fedContext)) != -1) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Metadata document requested");
+            }
+            response.setContentType("text/xml");
+            PrintWriter out = response.getWriter();
+            
+            FedizProcessor wfProc = 
+                FedizProcessorFactory.newFedizProcessor(fedContext.getProtocol());
+            try {
+                Document metadata = wfProc.getMetaData(fedContext);
+                out.write(DOM2Writer.nodeToString(metadata));
+                return;
+            } catch (Exception ex) {
+                LOG.warn("Failed to get metadata document: " + ex.getMessage());
+                hresponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+                return;
+            }            
+        }
+        
+        String redirectUrl = null;
         try {
             FedizProcessor wfProc = 
                 FedizProcessorFactory.newFedizProcessor(fedContext.getProtocol());

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cdfe522f/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosTokenValidator.java
----------------------------------------------------------------------
diff --git a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosTokenValidator.java
b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosTokenValidator.java
index d3e65fe..c9b0cd7 100644
--- a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosTokenValidator.java
+++ b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosTokenValidator.java
@@ -43,6 +43,7 @@ public class KerberosTokenValidator {
     private CallbackHandler callbackHandler;
     private String contextName;
     private boolean usernameServiceNameForm;
+    private boolean spnego;
 
     /**
      * Get the JAAS Login context name to use.
@@ -133,7 +134,8 @@ public class KerberosTokenValidator {
 
         // Validate the ticket
         KerberosServiceExceptionAction action = 
-            new KerberosServiceExceptionAction(token.getToken(), service, isUsernameServiceNameForm());
+            new KerberosServiceExceptionAction(token.getToken(), service, 
+                                               isUsernameServiceNameForm(), spnego);
         KerberosServiceContext krbServiceCtx = Subject.doAs(subject, action);
 
         if (LOG.isDebugEnabled()) {
@@ -172,4 +174,12 @@ public class KerberosTokenValidator {
     public void setUsernameServiceNameForm(boolean isUsernameServiceNameForm) {
         this.usernameServiceNameForm = isUsernameServiceNameForm;
     }
+
+    public boolean isSpnego() {
+        return spnego;
+    }
+
+    public void setSpnego(boolean spnego) {
+        this.spnego = spnego;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cdfe522f/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
----------------------------------------------------------------------
diff --git a/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
b/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
index f763340..fd2d5e4 100644
--- a/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
+++ b/systests/cxf/src/test/java/org/apache/cxf/fediz/integrationtests/federation/FederationTest.java
@@ -195,6 +195,13 @@ public class FederationTest extends AbstractTests {
 
     }
 
+    @org.junit.Test
+    @org.junit.Ignore
+    @Override
+    public void testMetadata() throws Exception {
+    }
+
+
     public String getServletContextName() {
         return "fedizhelloworld";
     }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cdfe522f/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
----------------------------------------------------------------------
diff --git a/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
b/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
index 0646e17..eb99243 100644
--- a/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
+++ b/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
@@ -19,22 +19,6 @@
 
 package org.apache.cxf.fediz.integrationtests;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.security.KeyStore;
-
-import javax.net.ssl.SSLContext;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLContextBuilder;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.LaxRedirectStrategy;
-import org.apache.http.util.EntityUtils;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -89,56 +73,4 @@ public class JettyTest extends AbstractTests {
         return "fedizhelloworld";
     }
     
-    @org.junit.Test
-    public void testMetadata() throws Exception {
-        String url = "https://localhost:" + getRpHttpsPort() 
-            + "/fedizhelloworld/FederationMetadata/2007-06/FederationMetadata.xml";
-
-        CloseableHttpClient httpClient = null;
-        try {
-            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.setSSLSocketFactory(sslSocketFactory);
-            httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
-
-            httpClient = httpClientBuilder.build();
-
-            HttpGet httpget = new HttpGet(url);
-
-            HttpResponse response = httpClient.execute(httpget);
-            HttpEntity entity = response.getEntity();
-
-            Assert.assertEquals(200, response.getStatusLine().getStatusCode());
-
-            String metadata = EntityUtils.toString(entity);
-            Assert.assertTrue(metadata.startsWith("<EntityDescriptor"));
-        } 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();
-            }
-        }
-    }
-    
 }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cdfe522f/systests/spring2Webapp/src/main/webapp/WEB-INF/applicationContext-security.xml
----------------------------------------------------------------------
diff --git a/systests/spring2Webapp/src/main/webapp/WEB-INF/applicationContext-security.xml
b/systests/spring2Webapp/src/main/webapp/WEB-INF/applicationContext-security.xml
index 21cf5eb..3974a96 100644
--- a/systests/spring2Webapp/src/main/webapp/WEB-INF/applicationContext-security.xml
+++ b/systests/spring2Webapp/src/main/webapp/WEB-INF/applicationContext-security.xml
@@ -15,6 +15,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
         <sec:intercept-url pattern="/index.html" access="permitAll"/>
         <sec:intercept-url pattern="/secure/fedservlet" access="isAuthenticated()"/>
 -->
+        <sec:intercept-url pattern="/FederationMetadata/**" access="IS_AUTHENTICATED_FULLY"/>
         <sec:intercept-url pattern="/secure/fedservlet" access="IS_AUTHENTICATED_FULLY"/>
         <sec:intercept-url pattern="/secure/manager/**" access="ROLE_MANAGER"/>
         <sec:intercept-url pattern="/secure/admin/**" access="ROLE_ADMIN"/>

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cdfe522f/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml
----------------------------------------------------------------------
diff --git a/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml
b/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml
index 27d9f42..b2c1a08 100644
--- a/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml
+++ b/systests/springWebapp/src/main/webapp/WEB-INF/applicationContext-security.xml
@@ -18,6 +18,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/sch
         <sec:intercept-url pattern="/" access="permitAll"/>
         <sec:intercept-url pattern="/fediz" access="permitAll"/>
         <sec:intercept-url pattern="/index.html" access="permitAll"/>
+        <sec:intercept-url pattern="/FederationMetadata/**" access="isAuthenticated()"/>
         <sec:intercept-url pattern="/secure/fedservlet" access="isAuthenticated()"/>
         <sec:intercept-url pattern="/secure/manager/**" access="hasRole('ROLE_MANAGER')"/>
         <sec:intercept-url pattern="/secure/admin/**" access="hasRole('ROLE_ADMIN')"/>

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cdfe522f/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java
----------------------------------------------------------------------
diff --git a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java
b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java
index 478ce91..9962f11 100644
--- a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java
+++ b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java
@@ -19,7 +19,23 @@
 
 package org.apache.cxf.fediz.integrationtests;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.security.KeyStore;
+
+import javax.net.ssl.SSLContext;
+
 import org.apache.cxf.fediz.core.ClaimTypes;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContextBuilder;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.LaxRedirectStrategy;
+import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
 
 public abstract class AbstractTests {
@@ -213,4 +229,56 @@ public abstract class AbstractTests {
         HTTPTestUtils.sendHttpGet(url, user, password, 200, 403, Integer.parseInt(getIdpHttpsPort()));
       
     }
 
+    @org.junit.Test
+    public void testMetadata() throws Exception {
+        String url = "https://localhost:" + getRpHttpsPort() 
+            + "/fedizhelloworld/FederationMetadata/2007-06/FederationMetadata.xml";
+
+        CloseableHttpClient httpClient = null;
+        try {
+            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.setSSLSocketFactory(sslSocketFactory);
+            httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
+
+            httpClient = httpClientBuilder.build();
+
+            HttpGet httpget = new HttpGet(url);
+
+            HttpResponse response = httpClient.execute(httpget);
+            HttpEntity entity = response.getEntity();
+
+            Assert.assertEquals(200, response.getStatusLine().getStatusCode());
+
+            String metadata = EntityUtils.toString(entity);
+            Assert.assertTrue(metadata.startsWith("<EntityDescriptor"));
+        } 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();
+            }
+        }
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cdfe522f/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
index b35bfd1..163c97b 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
@@ -21,10 +21,6 @@ package org.apache.cxf.fediz.integrationtests;
 
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.security.KeyStore;
-
-import javax.net.ssl.SSLContext;
 
 import org.apache.catalina.Context;
 import org.apache.catalina.LifecycleState;
@@ -32,16 +28,6 @@ import org.apache.catalina.connector.Connector;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.cxf.fediz.core.ClaimTypes;
 import org.apache.cxf.fediz.tomcat.FederationAuthenticator;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLContextBuilder;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.LaxRedirectStrategy;
-import org.apache.http.util.EntityUtils;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -219,56 +205,4 @@ public class TomcatTest extends AbstractTests {
 
     }
     
-    @org.junit.Test
-    public void testMetadata() throws Exception {
-        String url = "https://localhost:" + getRpHttpsPort() 
-            + "/fedizhelloworld/FederationMetadata/2007-06/FederationMetadata.xml";
-
-        CloseableHttpClient httpClient = null;
-        try {
-            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.setSSLSocketFactory(sslSocketFactory);
-            httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
-
-            httpClient = httpClientBuilder.build();
-
-            HttpGet httpget = new HttpGet(url);
-
-            HttpResponse response = httpClient.execute(httpget);
-            HttpEntity entity = response.getEntity();
-
-            Assert.assertEquals(200, response.getStatusLine().getStatusCode());
-
-            String metadata = EntityUtils.toString(entity);
-            Assert.assertTrue(metadata.startsWith("<EntityDescriptor"));
-        } 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();
-            }
-        }
-    }
-    
 }


Mime
View raw message