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 2017/02/13 11:36:18 UTC
[02/18] cxf-fediz git commit: Whitespace cleanup
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java
----------------------------------------------------------------------
diff --git a/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java b/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java
index cd68992..f358924 100644
--- a/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java
+++ b/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/Spring2Test.java
@@ -50,10 +50,10 @@ public class Spring2Test extends AbstractTests {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -72,13 +72,13 @@ public class Spring2Test extends AbstractTests {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -92,8 +92,8 @@ public class Spring2Test extends AbstractTests {
e.printStackTrace();
}
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -128,11 +128,11 @@ public class Spring2Test extends AbstractTests {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
- File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(),
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(),
"fediz-systests-webapps-spring2");
server.addWebapp("/fedizhelloworld_spring2", rpWebapp.getAbsolutePath());
}
@@ -151,54 +151,54 @@ public class Spring2Test extends AbstractTests {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
@Override
public String getServletContextName() {
return "fedizhelloworld_spring2";
}
-
+
@Ignore("This tests is currently failing on Spring")
@Override
public void testConcurrentRequests() throws Exception {
// super.testConcurrentRequests();
}
-
+
@Test
@Ignore("Logout not supported with Spring2")
@Override
public void testIdPLogout() throws Exception {
-
+
}
-
+
@Test
@Ignore("Logout not supported with Spring2")
@Override
public void testIdPLogoutCleanup() throws Exception {
-
+
}
-
+
@Test
@Ignore("Logout not supported with Spring2")
@Override
public void testRPLogout() throws Exception {
-
+
}
-
+
@Test
@Ignore("Logout not supported with Spring2")
@Override
public void testRPLogoutViaAction() throws Exception {
-
+
}
-
+
@Override
@Test
public void testAliceModifiedSignature() throws Exception {
- String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName()
+ String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName()
+ "/secure/fedservlet";
String user = "alice";
String password = "ecila";
-
+
// Get the initial token
CookieManager cookieManager = new CookieManager();
final WebClient webClient = new WebClient();
@@ -224,9 +224,9 @@ public class Spring2Test extends AbstractTests {
result.setAttributeNS(null, "value", value);
}
}
-
+
// Invoke back on the RP
-
+
final HtmlForm form = idpPage.getFormByName("signinresponseform");
final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
@@ -242,20 +242,20 @@ public class Spring2Test extends AbstractTests {
webClient.close();
}
-
+
@Override
@Test
@Ignore
public void testEntityExpansionAttack() throws Exception {
}
-
+
@Override
@org.junit.Test
public void testCSRFAttack() throws Exception {
- String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName()
+ String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName()
+ "/j_spring_fediz_security_check";
csrfAttackTest(url);
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java
----------------------------------------------------------------------
diff --git a/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java b/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java
index 93b4201..db09cde 100644
--- a/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java
+++ b/systests/spring/src/test/java/org/apache/cxf/fediz/integrationtests/SpringTest.java
@@ -37,10 +37,10 @@ public class SpringTest extends AbstractTests {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -59,13 +59,13 @@ public class SpringTest extends AbstractTests {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -79,8 +79,8 @@ public class SpringTest extends AbstractTests {
e.printStackTrace();
}
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -115,11 +115,11 @@ public class SpringTest extends AbstractTests {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
- File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(),
+ File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(),
"fediz-systests-webapps-spring");
server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
}
@@ -138,22 +138,22 @@ public class SpringTest extends AbstractTests {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
@Override
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
@Ignore("This tests is currently failing on Spring")
@Override
public void testConcurrentRequests() throws Exception {
// super.testConcurrentRequests();
}
-
+
@Override
@org.junit.Test
public void testCSRFAttack() throws Exception {
- String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName()
+ String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName()
+ "/j_spring_fediz_security_check";
csrfAttackTest(url);
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractClientCertTests.java
----------------------------------------------------------------------
diff --git a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractClientCertTests.java b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractClientCertTests.java
index e8edc88..0282356 100644
--- a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractClientCertTests.java
+++ b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractClientCertTests.java
@@ -39,7 +39,7 @@ import org.apache.wss4j.dom.engine.WSSConfig;
import org.junit.Assert;
public abstract class AbstractClientCertTests {
-
+
static {
WSSConfig.init();
}
@@ -49,7 +49,7 @@ public abstract class AbstractClientCertTests {
}
public abstract String getServletContextName();
-
+
public abstract String getIdpHttpsPort();
public abstract String getRpHttpsPort();
@@ -57,7 +57,7 @@ public abstract class AbstractClientCertTests {
@org.junit.Test
public void testClientAuthentication() throws Exception {
String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName() + "/secure/fedservlet";
-
+
final WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
webClient.getOptions().setSSLClientCertificate(
@@ -70,7 +70,7 @@ public abstract class AbstractClientCertTests {
final HtmlForm form = idpPage.getFormByName("signinresponseform");
final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
-
+
// Test the Subject Confirmation method here
DomNodeList<DomElement> results = idpPage.getElementsByTagName("input");
@@ -81,7 +81,7 @@ public abstract class AbstractClientCertTests {
break;
}
}
- Assert.assertTrue(wresult != null
+ Assert.assertTrue(wresult != null
&& wresult.contains("urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"));
final HtmlPage rpPage = button.click();
@@ -98,7 +98,7 @@ public abstract class AbstractClientCertTests {
bodyTextContent.contains("role:Manager=false"));
Assert.assertTrue("User " + user + " must have role User",
bodyTextContent.contains("role:User=true"));
-
+
String claim = ClaimTypes.FIRSTNAME.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not 'Alice'",
bodyTextContent.contains(claim + "=Alice"));
@@ -108,15 +108,15 @@ public abstract class AbstractClientCertTests {
claim = ClaimTypes.EMAILADDRESS.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not 'alice@realma.org'",
bodyTextContent.contains(claim + "=alice@realma.org"));
-
+
// webClient.close();
}
-
+
@org.junit.Test
public void testDifferentClientCertificate() throws Exception {
// Get the initial wresult from the IdP
String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName() + "/secure/fedservlet";
-
+
CookieManager cookieManager = new CookieManager();
final WebClient webClient = new WebClient();
webClient.setCookieManager(cookieManager);
@@ -146,17 +146,17 @@ public abstract class AbstractClientCertTests {
}
}
Assert.assertTrue(wctx != null && wtrealm != null);
- Assert.assertTrue(wresult != null
+ Assert.assertTrue(wresult != null
&& wresult.contains("urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"));
// webClient.close();
-
+
// Now invoke on the RP using the saved parameters above, but a different client cert!
final WebClient webClient2 = new WebClient();
webClient2.setCookieManager(cookieManager);
webClient2.getOptions().setUseInsecureSSL(true);
webClient2.getOptions().setSSLClientCertificate(
this.getClass().getClassLoader().getResource("server.jks"), "tompass", "jks");
-
+
WebRequest request = new WebRequest(new URL(url), HttpMethod.POST);
request.setRequestParameters(new ArrayList<NameValuePair>());
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/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 d33e212..07c5958 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
@@ -404,7 +404,7 @@ public abstract class AbstractTests {
// webClient.close();
}
-
+
@Test
public void testRPLogoutViaAction() throws Exception {
@@ -447,7 +447,7 @@ public abstract class AbstractTests {
// webClient.close();
}
-
+
@Test
public void testIdPLogout() throws Exception {
@@ -677,13 +677,13 @@ public abstract class AbstractTests {
}
// webClient2.close();
}
-
+
@Test
public void testEntityExpansionAttack() throws Exception {
String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName() + "/secure/fedservlet";
String user = "alice";
String password = "ecila";
-
+
// Get the initial token
CookieManager cookieManager = new CookieManager();
final WebClient webClient = new WebClient();
@@ -703,7 +703,7 @@ public abstract class AbstractTests {
String entity = IOUtils.toString(this.getClass().getClassLoader().getResource("entity.xml").openStream());
String reference = "&m;";
-
+
for (DomElement result : results) {
if ("wresult".equals(result.getAttributeNS(null, "name"))) {
// Now modify the Signature
@@ -713,9 +713,9 @@ public abstract class AbstractTests {
result.setAttributeNS(null, "value", value);
}
}
-
+
// Invoke back on the RP
-
+
final HtmlForm form = idpPage.getFormByName("signinresponseform");
final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
@@ -737,12 +737,12 @@ public abstract class AbstractTests {
String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName() + "/secure/fedservlet";
csrfAttackTest(url);
}
-
+
protected void csrfAttackTest(String rpURL) throws Exception {
String url = "https://localhost:" + getRpHttpsPort() + "/" + getServletContextName() + "/secure/fedservlet";
String user = "alice";
String password = "ecila";
-
+
// 1. Log in as "alice"
WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
@@ -757,12 +757,12 @@ public abstract class AbstractTests {
final HtmlForm form = idpPage.getFormByName("signinresponseform");
final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
-
+
final HtmlPage rpPage = button.click();
Assert.assertTrue("WS Federation Systests Examples".equals(rpPage.getTitleText())
|| "WS Federation Systests Spring Examples".equals(rpPage.getTitleText()));
-
-
+
+
// 2. Log in as "bob" using another WebClient
WebClient webClient2 = new WebClient();
webClient2.getOptions().setUseInsecureSSL(true);
@@ -776,11 +776,11 @@ public abstract class AbstractTests {
Assert.assertEquals("IDP SignIn Response Form", idpPage2.getTitleText());
// 3. Now instead of clicking on the form, send the form via alice's WebClient instead
-
+
// Send with context...
WebRequest request = new WebRequest(new URL(rpURL), HttpMethod.POST);
request.setRequestParameters(new ArrayList<NameValuePair>());
-
+
DomNodeList<DomElement> results = idpPage2.getElementsByTagName("input");
for (DomElement result : results) {
@@ -791,16 +791,16 @@ public abstract class AbstractTests {
request.getRequestParameters().add(new NameValuePair(result.getAttributeNS(null, "name"), value));
}
}
-
+
try {
webClient.getPage(request);
Assert.fail("Failure expected on a CSRF attack");
} catch (FailingHttpStatusCodeException ex) {
// expected
}
-
+
// webClient.close();
-
+
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/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 921e97f..f5a530d 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
@@ -41,7 +41,7 @@ public final class HTTPTestUtils {
private HTTPTestUtils() {
// complete
}
-
+
public static String login(String url, String user, String password, String idpPort) throws IOException {
final WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
@@ -64,7 +64,7 @@ public final class HTTPTestUtils {
// webClient.close();
return rpPage.getBody().getTextContent();
}
-
+
public static String loginForSAMLSSO(String url, String user, String password, String idpPort) throws IOException {
final WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
@@ -78,8 +78,8 @@ public final class HTTPTestUtils {
// webClient.close();
return rpPage.getBody().getTextContent();
}
-
- public static String loginWithCookieManager(String url, String user, String password,
+
+ public static String loginWithCookieManager(String url, String user, String password,
String idpPort, CookieManager cookieManager) throws IOException {
final WebClient webClient = new WebClient();
webClient.setCookieManager(cookieManager);
@@ -103,7 +103,7 @@ public final class HTTPTestUtils {
// webClient.close();
return rpPage.getBody().getTextContent();
}
-
+
public static void logout(String url, CookieManager cookieManager) throws IOException {
final WebClient webClient = new WebClient();
webClient.setCookieManager(cookieManager);
@@ -125,10 +125,10 @@ public final class HTTPTestUtils {
//we should get a fault if the image isn't available.
webClient.getPage(imgSrc);
}
-
+
// webClient.close();
}
-
+
public static void logoutCleanup(String url, CookieManager cookieManager) throws IOException {
final WebClient webClient = new WebClient();
webClient.setCookieManager(cookieManager);
@@ -138,7 +138,7 @@ public final class HTTPTestUtils {
Assert.assertEquals("IDP SignOut Response Page", idpPage.getTitleText());
Assert.assertTrue(idpPage.asText().contains("CXF Fediz IDP successful logout"));
-
+
DomNodeList<DomElement> images = idpPage.getElementsByTagName("img");
Assert.assertEquals(1, images.getLength());
for (int i = 0; i < images.size(); i++) {
@@ -148,7 +148,7 @@ public final class HTTPTestUtils {
//we should get a fault if the image isn't available.
webClient.getPage(imgSrc);
}
-
+
// webClient.close();
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java
index d9822cb..929e6f6 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java
@@ -53,10 +53,10 @@ public class AudienceRestrictionTest {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -66,8 +66,8 @@ public class AudienceRestrictionTest {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -76,8 +76,8 @@ public class AudienceRestrictionTest {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -112,13 +112,13 @@ public class AudienceRestrictionTest {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config_aud_restr.xml");
@@ -127,13 +127,13 @@ public class AudienceRestrictionTest {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config_aud_restr.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_aud_restr.xml");
@@ -144,13 +144,13 @@ public class AudienceRestrictionTest {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -172,17 +172,17 @@ public class AudienceRestrictionTest {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
@org.junit.Test
public void testSAMLTokenWithNonMatchingAudienceRestriction() throws Exception {
String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet";
String user = "alice";
String password = "ecila";
-
+
final WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
webClient.getCredentialsProvider().setCredentials(
@@ -193,7 +193,7 @@ public class AudienceRestrictionTest {
final HtmlPage idpPage = webClient.getPage(url);
webClient.getOptions().setJavaScriptEnabled(true);
Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText());
-
+
final HtmlForm form = idpPage.getFormByName("signinresponseform");
final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
@@ -206,5 +206,5 @@ public class AudienceRestrictionTest {
webClient.close();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
index 547d03a..4ecacf0 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
@@ -45,10 +45,10 @@ public class ClientCertificateTest extends AbstractClientCertTests {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -58,8 +58,8 @@ public class ClientCertificateTest extends AbstractClientCertTests {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -68,8 +68,8 @@ public class ClientCertificateTest extends AbstractClientCertTests {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -104,13 +104,13 @@ public class ClientCertificateTest extends AbstractClientCertTests {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config_client_cert.xml");
@@ -119,13 +119,13 @@ public class ClientCertificateTest extends AbstractClientCertTests {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config_client_cert.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_client_cert.xml");
@@ -136,13 +136,13 @@ public class ClientCertificateTest extends AbstractClientCertTests {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -164,9 +164,9 @@ public class ClientCertificateTest extends AbstractClientCertTests {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java
index e2f402c..a323696 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java
@@ -29,11 +29,11 @@ import org.apache.cxf.fediz.core.spi.WReqCallback;
public class HOKCallbackHandler implements CallbackHandler {
- static final String HOK_WREQ =
+ static final String HOK_WREQ =
"<RequestSecurityToken xmlns=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\">"
+ "<KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/PublicKey</KeyType>"
+ "</RequestSecurityToken>";
-
+
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WReqCallback) {
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
index cd86f28..c67ba64 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
@@ -55,10 +55,10 @@ public class HolderOfKeyTest {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -68,8 +68,8 @@ public class HolderOfKeyTest {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -78,8 +78,8 @@ public class HolderOfKeyTest {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -114,13 +114,13 @@ public class HolderOfKeyTest {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config_hok.xml");
@@ -129,13 +129,13 @@ public class HolderOfKeyTest {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config_hok.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_hok.xml");
@@ -146,13 +146,13 @@ public class HolderOfKeyTest {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -166,7 +166,7 @@ public class HolderOfKeyTest {
e.printStackTrace();
}
}
-
+
public String getIdpHttpsPort() {
return idpHttpsPort;
}
@@ -174,17 +174,17 @@ public class HolderOfKeyTest {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
@org.junit.Test
public void testHolderOfKey() throws Exception {
String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet";
String user = "alice";
String password = "ecila";
-
+
final WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
webClient.getOptions().setSSLClientCertificate(
@@ -200,7 +200,7 @@ public class HolderOfKeyTest {
final HtmlForm form = idpPage.getFormByName("signinresponseform");
final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
-
+
// Test the Subject Confirmation method here
DomNodeList<DomElement> results = idpPage.getElementsByTagName("input");
@@ -211,9 +211,9 @@ public class HolderOfKeyTest {
break;
}
}
- Assert.assertTrue(wresult != null
+ Assert.assertTrue(wresult != null
&& wresult.contains("urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"));
-
+
final HtmlPage rpPage = button.click();
Assert.assertEquals("WS Federation Systests Examples", rpPage.getTitleText());
@@ -227,7 +227,7 @@ public class HolderOfKeyTest {
bodyTextContent.contains("role:Manager=false"));
Assert.assertTrue("User " + user + " must have role User",
bodyTextContent.contains("role:User=true"));
-
+
String claim = ClaimTypes.FIRSTNAME.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not 'Alice'",
bodyTextContent.contains(claim + "=Alice"));
@@ -237,8 +237,8 @@ public class HolderOfKeyTest {
claim = ClaimTypes.EMAILADDRESS.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not 'alice@realma.org'",
bodyTextContent.contains(claim + "=alice@realma.org"));
-
+
webClient.close();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java
index eca3695..776b458 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java
@@ -29,11 +29,11 @@ import org.apache.cxf.fediz.core.spi.WReqCallback;
public class TestCallbackHandler implements CallbackHandler {
- static final String TEST_WREQ =
+ static final String TEST_WREQ =
"<RequestSecurityToken xmlns=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\">"
+ "<TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</TokenType>"
+ "</RequestSecurityToken>";
-
+
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WReqCallback) {
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/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 2dcd8ec..b5e10c9 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
@@ -42,10 +42,10 @@ public class TomcatTest extends AbstractTests {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -55,8 +55,8 @@ public class TomcatTest extends AbstractTests {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -65,8 +65,8 @@ public class TomcatTest extends AbstractTests {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -101,13 +101,13 @@ public class TomcatTest extends AbstractTests {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config.xml");
@@ -116,13 +116,13 @@ public class TomcatTest extends AbstractTests {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config.xml");
@@ -133,13 +133,13 @@ public class TomcatTest extends AbstractTests {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -163,10 +163,10 @@ public class TomcatTest extends AbstractTests {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
@Override
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
index 2afb162..95bd271 100644
--- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
+++ b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
@@ -55,10 +55,10 @@ public class WReqTest {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -68,8 +68,8 @@ public class WReqTest {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -78,8 +78,8 @@ public class WReqTest {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -114,13 +114,13 @@ public class WReqTest {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config_wreq.xml");
@@ -129,13 +129,13 @@ public class WReqTest {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config_wreq.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_wreq.xml");
@@ -146,13 +146,13 @@ public class WReqTest {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -174,19 +174,19 @@ public class WReqTest {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
@org.junit.Test
public void testSAML1TokenViaWReq() throws Exception {
String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet";
String user = "alice";
String password = "ecila";
-
+
final String bodyTextContent = login(url, user, password, getIdpHttpsPort());
-
+
Assert.assertTrue("Principal not " + user,
bodyTextContent.contains("userPrincipal=" + user));
Assert.assertTrue("User " + user + " does not have role Admin",
@@ -207,7 +207,7 @@ public class WReqTest {
bodyTextContent.contains(claim + "=alice@realma.org"));
}
-
+
private static String login(String url, String user, String password, String idpPort) throws IOException {
final WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
@@ -219,7 +219,7 @@ public class WReqTest {
final HtmlPage idpPage = webClient.getPage(url);
webClient.getOptions().setJavaScriptEnabled(true);
Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText());
-
+
// Test the SAML Version here
DomNodeList<DomElement> results = idpPage.getElementsByTagName("input");
@@ -230,7 +230,7 @@ public class WReqTest {
break;
}
}
- Assert.assertTrue(wresult != null
+ Assert.assertTrue(wresult != null
&& wresult.contains("urn:oasis:names:tc:SAML:1.0:cm:bearer"));
final HtmlForm form = idpPage.getFormByName("signinresponseform");
@@ -242,5 +242,5 @@ public class WReqTest {
webClient.close();
return rpPage.getBody().getTextContent();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java
index 673b868..efcecbf 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/AudienceRestrictionTest.java
@@ -53,10 +53,10 @@ public class AudienceRestrictionTest {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -66,8 +66,8 @@ public class AudienceRestrictionTest {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -76,8 +76,8 @@ public class AudienceRestrictionTest {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -112,13 +112,13 @@ public class AudienceRestrictionTest {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config_aud_restr.xml");
@@ -127,13 +127,13 @@ public class AudienceRestrictionTest {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config_aud_restr.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_aud_restr.xml");
@@ -144,13 +144,13 @@ public class AudienceRestrictionTest {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -172,17 +172,17 @@ public class AudienceRestrictionTest {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
@org.junit.Test
public void testSAMLTokenWithNonMatchingAudienceRestriction() throws Exception {
String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet";
String user = "alice";
String password = "ecila";
-
+
final WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
webClient.getCredentialsProvider().setCredentials(
@@ -193,7 +193,7 @@ public class AudienceRestrictionTest {
final HtmlPage idpPage = webClient.getPage(url);
webClient.getOptions().setJavaScriptEnabled(true);
Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText());
-
+
final HtmlForm form = idpPage.getFormByName("signinresponseform");
final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
@@ -206,5 +206,5 @@ public class AudienceRestrictionTest {
webClient.close();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
index 9faf41d..a2c5a6b 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/ClientCertificateTest.java
@@ -45,10 +45,10 @@ public class ClientCertificateTest extends AbstractClientCertTests {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -58,8 +58,8 @@ public class ClientCertificateTest extends AbstractClientCertTests {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -68,8 +68,8 @@ public class ClientCertificateTest extends AbstractClientCertTests {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -104,13 +104,13 @@ public class ClientCertificateTest extends AbstractClientCertTests {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config_client_cert.xml");
@@ -119,13 +119,13 @@ public class ClientCertificateTest extends AbstractClientCertTests {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config_client_cert.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_client_cert.xml");
@@ -136,13 +136,13 @@ public class ClientCertificateTest extends AbstractClientCertTests {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -164,9 +164,9 @@ public class ClientCertificateTest extends AbstractClientCertTests {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java
index e2f402c..a323696 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HOKCallbackHandler.java
@@ -29,11 +29,11 @@ import org.apache.cxf.fediz.core.spi.WReqCallback;
public class HOKCallbackHandler implements CallbackHandler {
- static final String HOK_WREQ =
+ static final String HOK_WREQ =
"<RequestSecurityToken xmlns=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\">"
+ "<KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/PublicKey</KeyType>"
+ "</RequestSecurityToken>";
-
+
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WReqCallback) {
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
index b82ed9d..2abb4b4 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/HolderOfKeyTest.java
@@ -55,10 +55,10 @@ public class HolderOfKeyTest {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -68,8 +68,8 @@ public class HolderOfKeyTest {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -78,8 +78,8 @@ public class HolderOfKeyTest {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -114,13 +114,13 @@ public class HolderOfKeyTest {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config_hok.xml");
@@ -129,13 +129,13 @@ public class HolderOfKeyTest {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config_hok.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_hok.xml");
@@ -146,13 +146,13 @@ public class HolderOfKeyTest {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -174,17 +174,17 @@ public class HolderOfKeyTest {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
@org.junit.Test
public void testHolderOfKey() throws Exception {
String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet";
String user = "alice";
String password = "ecila";
-
+
final WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
webClient.getOptions().setSSLClientCertificate(
@@ -200,7 +200,7 @@ public class HolderOfKeyTest {
final HtmlForm form = idpPage.getFormByName("signinresponseform");
final HtmlSubmitInput button = form.getInputByName("_eventId_submit");
-
+
// Test the Subject Confirmation method here
DomNodeList<DomElement> results = idpPage.getElementsByTagName("input");
@@ -211,9 +211,9 @@ public class HolderOfKeyTest {
break;
}
}
- Assert.assertTrue(wresult != null
+ Assert.assertTrue(wresult != null
&& wresult.contains("urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"));
-
+
final HtmlPage rpPage = button.click();
Assert.assertEquals("WS Federation Systests Examples", rpPage.getTitleText());
@@ -227,7 +227,7 @@ public class HolderOfKeyTest {
bodyTextContent.contains("role:Manager=false"));
Assert.assertTrue("User " + user + " must have role User",
bodyTextContent.contains("role:User=true"));
-
+
String claim = ClaimTypes.FIRSTNAME.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not 'Alice'",
bodyTextContent.contains(claim + "=Alice"));
@@ -237,8 +237,8 @@ public class HolderOfKeyTest {
claim = ClaimTypes.EMAILADDRESS.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not 'alice@realma.org'",
bodyTextContent.contains(claim + "=alice@realma.org"));
-
+
webClient.close();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java
index eca3695..776b458 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TestCallbackHandler.java
@@ -29,11 +29,11 @@ import org.apache.cxf.fediz.core.spi.WReqCallback;
public class TestCallbackHandler implements CallbackHandler {
- static final String TEST_WREQ =
+ static final String TEST_WREQ =
"<RequestSecurityToken xmlns=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\">"
+ "<TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</TokenType>"
+ "</RequestSecurityToken>";
-
+
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WReqCallback) {
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
index 9fce8e6..66acdc0 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
@@ -42,10 +42,10 @@ public class TomcatTest extends AbstractTests {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -55,8 +55,8 @@ public class TomcatTest extends AbstractTests {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -65,8 +65,8 @@ public class TomcatTest extends AbstractTests {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -101,13 +101,13 @@ public class TomcatTest extends AbstractTests {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config.xml");
@@ -116,13 +116,13 @@ public class TomcatTest extends AbstractTests {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config.xml");
@@ -133,13 +133,13 @@ public class TomcatTest extends AbstractTests {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -163,10 +163,10 @@ public class TomcatTest extends AbstractTests {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
@Override
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
----------------------------------------------------------------------
diff --git a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
index 3b90b82..7bea676 100644
--- a/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
+++ b/systests/tomcat8/src/test/java/org/apache/cxf/fediz/integrationtests/WReqTest.java
@@ -55,10 +55,10 @@ public class WReqTest {
static String idpHttpsPort;
static String rpHttpsPort;
-
+
private static Tomcat idpServer;
private static Tomcat rpServer;
-
+
@BeforeClass
public static void init() throws Exception {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
@@ -68,8 +68,8 @@ public class WReqTest {
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
- System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
-
+ System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
+
idpHttpsPort = System.getProperty("idp.https.port");
Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
rpHttpsPort = System.getProperty("rp.https.port");
@@ -78,8 +78,8 @@ public class WReqTest {
idpServer = startServer(true, idpHttpsPort);
rpServer = startServer(false, rpHttpsPort);
}
-
- private static Tomcat startServer(boolean idp, String port)
+
+ private static Tomcat startServer(boolean idp, String port)
throws ServletException, LifecycleException, IOException {
Tomcat server = new Tomcat();
server.setPort(0);
@@ -114,13 +114,13 @@ public class WReqTest {
if (idp) {
File stsWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp-sts");
server.addWebapp("/fediz-idp-sts", stsWebapp.getAbsolutePath());
-
+
File idpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "fediz-idp");
server.addWebapp("/fediz-idp", idpWebapp.getAbsolutePath());
} else {
File rpWebapp = new File(baseDir + File.separator + server.getHost().getAppBase(), "simpleWebapp");
Context cxt = server.addWebapp("/fedizhelloworld", rpWebapp.getAbsolutePath());
-
+
// Substitute the IDP port. Necessary if running the test in eclipse where port filtering doesn't seem
// to work
File f = new File(currentDir + "/src/test/resources/fediz_config_wreq.xml");
@@ -129,13 +129,13 @@ public class WReqTest {
inputStream.close();
if (content.contains("idp.https.port")) {
content = content.replaceAll("\\$\\{idp.https.port\\}", "" + idpHttpsPort);
-
+
File f2 = new File(baseDir + "/test-classes/fediz_config_wreq.xml");
try (FileOutputStream outputStream = new FileOutputStream(f2)) {
IOUtils.write(content, outputStream, "UTF-8");
}
}
-
+
FederationAuthenticator fa = new FederationAuthenticator();
fa.setConfigFile(currentDir + File.separator + "target" + File.separator
+ "test-classes" + File.separator + "fediz_config_wreq.xml");
@@ -146,13 +146,13 @@ public class WReqTest {
return server;
}
-
+
@AfterClass
public static void cleanup() {
shutdownServer(idpServer);
shutdownServer(rpServer);
}
-
+
private static void shutdownServer(Tomcat server) {
try {
if (server != null && server.getServer() != null
@@ -166,7 +166,7 @@ public class WReqTest {
e.printStackTrace();
}
}
-
+
public String getIdpHttpsPort() {
return idpHttpsPort;
}
@@ -174,19 +174,19 @@ public class WReqTest {
public String getRpHttpsPort() {
return rpHttpsPort;
}
-
+
public String getServletContextName() {
return "fedizhelloworld";
}
-
+
@org.junit.Test
public void testSAML1TokenViaWReq() throws Exception {
String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet";
String user = "alice";
String password = "ecila";
-
+
final String bodyTextContent = login(url, user, password, getIdpHttpsPort());
-
+
Assert.assertTrue("Principal not " + user,
bodyTextContent.contains("userPrincipal=" + user));
Assert.assertTrue("User " + user + " does not have role Admin",
@@ -207,7 +207,7 @@ public class WReqTest {
bodyTextContent.contains(claim + "=alice@realma.org"));
}
-
+
private static String login(String url, String user, String password, String idpPort) throws IOException {
final WebClient webClient = new WebClient();
webClient.getOptions().setUseInsecureSSL(true);
@@ -219,7 +219,7 @@ public class WReqTest {
final HtmlPage idpPage = webClient.getPage(url);
webClient.getOptions().setJavaScriptEnabled(true);
Assert.assertEquals("IDP SignIn Response Form", idpPage.getTitleText());
-
+
// Test the SAML Version here
DomNodeList<DomElement> results = idpPage.getElementsByTagName("input");
@@ -230,7 +230,7 @@ public class WReqTest {
break;
}
}
- Assert.assertTrue(wresult != null
+ Assert.assertTrue(wresult != null
&& wresult.contains("urn:oasis:names:tc:SAML:1.0:cm:bearer"));
final HtmlForm form = idpPage.getFormByName("signinresponseform");
@@ -242,5 +242,5 @@ public class WReqTest {
webClient.close();
return rpPage.getBody().getTextContent();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/webapps/cxfWebapp/src/main/java/org/apache/cxf/fediz/example/Service.java
----------------------------------------------------------------------
diff --git a/systests/webapps/cxfWebapp/src/main/java/org/apache/cxf/fediz/example/Service.java b/systests/webapps/cxfWebapp/src/main/java/org/apache/cxf/fediz/example/Service.java
index 21c88d5..b50511d 100644
--- a/systests/webapps/cxfWebapp/src/main/java/org/apache/cxf/fediz/example/Service.java
+++ b/systests/webapps/cxfWebapp/src/main/java/org/apache/cxf/fediz/example/Service.java
@@ -48,21 +48,21 @@ public class Service {
public String doGetAdmin(@Context UriInfo uriInfo) throws Exception {
return doGet(uriInfo);
}
-
+
@Path("/manager/fedservlet")
@RolesAllowed("Manager")
@GET
public String doGetManager(@Context UriInfo uriInfo) throws Exception {
return doGet(uriInfo);
}
-
+
@Path("/user/fedservlet")
@RolesAllowed({ "User", "Admin", "Manager" })
@GET
public String doGetUser(@Context UriInfo uriInfo) throws Exception {
return doGet(uriInfo);
}
-
+
@Path("/fedservlet")
@RolesAllowed({ "User", "Admin", "Manager", "Authenticated", "Secretary" })
@GET
@@ -70,7 +70,7 @@ public class Service {
public String doGetSecure(@Context UriInfo uriInfo) throws Exception {
return doGet(uriInfo);
}
-
+
// Just used for testing purposes...
@Path("/test.html")
@RolesAllowed({ "User", "Admin", "Manager", "Authenticated" })
@@ -83,12 +83,12 @@ public class Service {
out.append("<body>\n");
out.append("<P><H3>Secure Test</H3><P></P>");
out.append("</body>\n");
-
+
return out.toString();
}
-
+
private String doGet(@Context UriInfo uriInfo) throws Exception {
-
+
StringBuilder out = new StringBuilder();
out.append("<html>\n");
out.append("<head><title>WS Federation Systests Examples</title></head>\n");
@@ -101,36 +101,36 @@ public class Service {
out.append(p.getName());
}
out.append("</p>\n");
-
+
List<String> roleListToCheck = Arrays.asList("Admin", "Manager", "User", "Authenticated");
for (String item: roleListToCheck) {
- out.append("<p>role:" + item + "="
- + ((messageContext.getSecurityContext().isUserInRole(item)) ? "true" : "false")
+ out.append("<p>role:" + item + "="
+ + ((messageContext.getSecurityContext().isUserInRole(item)) ? "true" : "false")
+ "</p>\n");
}
if (p instanceof FedizPrincipal) {
FedizPrincipal fp = (FedizPrincipal)p;
-
+
ClaimCollection claims = fp.getClaims();
for (Claim c: claims) {
out.append("<p>" + c.getClaimType().toString() + "=" + c.getValue() + "</p>\n");
}
-
+
Element el = fp.getLoginToken();
if (el != null) {
out.append("loginToken=FOUND{FedizPrincipal}<p>\n");
}
-
+
el = SecurityTokenThreadLocal.getToken();
if (el != null) {
out.append("loginToken=FOUND{SecurityTokenThreadLocal}<p>\n");
}
-
+
}
-
+
out.append("</body>\n");
-
+
return out.toString();
}
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/systests/webapps/simpleWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
----------------------------------------------------------------------
diff --git a/systests/webapps/simpleWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java b/systests/webapps/simpleWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
index 873e0da..3b6f56b 100644
--- a/systests/webapps/simpleWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
+++ b/systests/webapps/simpleWebapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
@@ -48,7 +48,7 @@ import org.apache.cxf.fediz.core.SecurityTokenThreadLocal;
public class FederationServlet extends HttpServlet {
/**
- *
+ *
*/
private static final long serialVersionUID = -9019993850246851112L;
@@ -69,7 +69,7 @@ public class FederationServlet extends HttpServlet {
out.print(p.getName());
}
out.println("</p>");
-
+
List<String> roleListToCheck = Arrays.asList("Admin", "Manager", "User", "Authenticated");
for (String item: roleListToCheck) {
out.println("<p>role:" + item + "=" + ((request.isUserInRole(item)) ? "true" : "false") + "</p>");
@@ -77,17 +77,17 @@ public class FederationServlet extends HttpServlet {
if (p instanceof FedizPrincipal) {
FedizPrincipal fp = (FedizPrincipal)p;
-
+
ClaimCollection claims = fp.getClaims();
for (Claim c: claims) {
out.println("<p>" + c.getClaimType().toString() + "=" + c.getValue() + "</p>");
}
-
+
Element el = fp.getLoginToken();
if (el != null) {
out.println("loginToken=FOUND{FedizPrincipal}<p>");
}
-
+
el = SecurityTokenThreadLocal.getToken();
if (el != null) {
out.println("loginToken=FOUND{SecurityTokenThreadLocal}<p>");
@@ -109,7 +109,7 @@ public class FederationServlet extends HttpServlet {
}
}
-
+
out.println("</body>");
}