Author: anil.saldhana(a)jboss.com
Date: 2011-06-24 14:10:38 -0400 (Fri, 24 Jun 2011)
New Revision: 1032
Modified:
federation/trunk/picketlink-bindings/src/test/java/org/picketlink/test/identity/federation/bindings/workflow/SAML2LogoutTomcatWorkflowUnitTestCase.java
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/saml/v2/SignatureValidationUnitTestCase.java
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/config/PBEUtilsUnitTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/DOMTransformerTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloRequestParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustBatchValidateParsingTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueSymmetricKeyTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/X500AttributeUnitTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataParsingUnitTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/stax/DomElementToStaxWritingTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLTimeUtilUnitTestCase.java
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/saml/handlers/SAML2AuthenticationHandlerUnitTestCase.java
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/saml2/SAML2LogoutWorkflowUnitTestCase.java
Log:
unneeded system.out
Modified:
federation/trunk/picketlink-bindings/src/test/java/org/picketlink/test/identity/federation/bindings/workflow/SAML2LogoutTomcatWorkflowUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-bindings/src/test/java/org/picketlink/test/identity/federation/bindings/workflow/SAML2LogoutTomcatWorkflowUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-bindings/src/test/java/org/picketlink/test/identity/federation/bindings/workflow/SAML2LogoutTomcatWorkflowUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -21,7 +21,9 @@
*/
package org.picketlink.test.identity.federation.bindings.workflow;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -35,8 +37,6 @@
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
-import junit.framework.TestCase;
-
import org.apache.catalina.deploy.LoginConfig;
import org.apache.catalina.realm.GenericPrincipal;
import org.junit.Test;
@@ -65,18 +65,22 @@
@SuppressWarnings("unused")
public class SAML2LogoutTomcatWorkflowUnitTestCase
{
- private String profile = "saml2/logout";
+ private final String profile = "saml2/logout";
+
private ClassLoader tcl;
- private String IDP = "http://localhost:8080/idp/";
- private String employee = "http://localhost:8080/employee/";
- private String sales = "http://localhost:8080/sales/";
-
+ private final String IDP = "http://localhost:8080/idp/";
- private String RELAY_STATE_KEY = "RelayState=";
- private String SAML_REQUEST_KEY = "SAMLRequest=";
- private String SAML_RESPONSE_KEY = "SAMLResponse=";
-
+ private final String employee = "http://localhost:8080/employee/";
+
+ private final String sales = "http://localhost:8080/sales/";
+
+ private final String RELAY_STATE_KEY = "RelayState=";
+
+ private final String SAML_REQUEST_KEY = "SAMLRequest=";
+
+ private final String SAML_RESPONSE_KEY = "SAMLResponse=";
+
/**
* Test that the SP Redirect Authenticator generates the logout request
* to the IDP when there is a parameter "GLO" set to true
@@ -85,7 +89,7 @@
*/
@Test
public void testSPLogOutRequestGeneration() throws Exception
- {
+ {
MockCatalinaSession session = new MockCatalinaSession();
session.setAttribute(GeneralConstants.PRINCIPAL_ID, new Principal()
{
@@ -93,205 +97,182 @@
{
return "anil";
}
- });
+ });
List<String> rolesList = new ArrayList<String>();
rolesList.add("manager");
session.setAttribute(GeneralConstants.ROLES_ID, rolesList);
-
MockCatalinaContext context = new MockCatalinaContext();
session.setServletContext(context);
-
+
//Let us feed the LogOutRequest to the SPFilter
MockCatalinaContextClassLoader mclSPEmp = setupTCL(profile +
"/sp/employee");
Thread.currentThread().setContextClassLoader(mclSPEmp);
-
+
SPRedirectFormAuthenticator sp = new SPRedirectFormAuthenticator();
sp.setContainer(context);
sp.testStart();
-
- MockCatalinaRequest catalinaRequest = new MockCatalinaRequest();
+
+ MockCatalinaRequest catalinaRequest = new MockCatalinaRequest();
MockCatalinaResponse response = new MockCatalinaResponse();
MockCatalinaLoginConfig loginConfig = new MockCatalinaLoginConfig();
-
+
ByteArrayOutputStream filterbaos = new ByteArrayOutputStream();
response.setWriter(new PrintWriter(filterbaos));
catalinaRequest.setParameter(GeneralConstants.GLOBAL_LOGOUT, "true");
sp.authenticate(catalinaRequest, response, loginConfig);
-
+
String redirectStr = response.redirectString;
- String logoutRequest = redirectStr.substring(redirectStr.indexOf(SAML_REQUEST_KEY)
+
- SAML_REQUEST_KEY.length()) ;
-
-
- InputStream stream = RedirectBindingUtil.urlBase64DeflateDecode(logoutRequest);
-
+ String logoutRequest = redirectStr.substring(redirectStr.indexOf(SAML_REQUEST_KEY)
+ SAML_REQUEST_KEY.length());
+
+ InputStream stream = RedirectBindingUtil.urlBase64DeflateDecode(logoutRequest);
+
SAML2Request saml2Request = new SAML2Request();
- LogoutRequestType lor =
- (LogoutRequestType) saml2Request.getRequestType(stream);
+ LogoutRequestType lor = (LogoutRequestType) saml2Request.getRequestType(stream);
assertEquals("Match Employee URL", employee,
lor.getIssuer().getValue());
}
-
@Test
public void testSAML2LogOutFromIDP() throws Exception
- {
+ {
MockCatalinaSession session = new MockCatalinaSession();
-
+
MockCatalinaContextClassLoader mclIDP = setupTCL(profile + "/idp");
Thread.currentThread().setContextClassLoader(mclIDP);
-
+
MockCatalinaContext catalinaContext = new MockCatalinaContext();
session.setServletContext(catalinaContext);
-
+
IdentityServer server = this.getIdentityServer(session);
catalinaContext.setAttribute("IDENTITY_SERVER", server);
-
- IDPWebBrowserSSOValve idp = new IDPWebBrowserSSOValve();
-
+
+ IDPWebBrowserSSOValve idp = new IDPWebBrowserSSOValve();
+
idp.setContainer(catalinaContext);
idp.setSignOutgoingMessages(false);
idp.setIgnoreIncomingSignatures(true);
- idp.start();
-
+ idp.start();
+
//Assume that we already have the principal and roles set in the session
MockCatalinaRealm realm = new MockCatalinaRealm("anil", "test",
new Principal()
- {
+ {
public String getName()
- {
+ {
return "anil";
}
});
List<String> roles = new ArrayList<String>();
roles.add("manager");
roles.add("employee");
-
+
List<String> rolesList = new ArrayList<String>();
rolesList.add("manager");
-
+
MockCatalinaRequest request = new MockCatalinaRequest();
session.clear();
- request.setSession(session);
-
+ request.setSession(session);
+
request.addHeader("Referer", sales);
- GenericPrincipal genericPrincipal =new GenericPrincipal(realm, "anil",
"test", roles) ;
+ GenericPrincipal genericPrincipal = new GenericPrincipal(realm, "anil",
"test", roles);
request.setUserPrincipal(genericPrincipal);
-
- String samlMessage =
RedirectBindingUtil.deflateBase64Encode(createLogOutRequest(sales).getBytes());
+
+ String samlMessage =
RedirectBindingUtil.deflateBase64Encode(createLogOutRequest(sales).getBytes());
request.setParameter("SAMLRequest", samlMessage);
-
-
MockCatalinaResponse response = new MockCatalinaResponse();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.setWriter(new PrintWriter(baos));
-
+
// The IDP is preloaded with 2 participants :
"http://localhost:8080/sales/"
// and "http://localhost:8080/employee"
-
+
//Lets start the workflow with get
request.setMethod("GET");
- idp.invoke(request, response);
-
+ idp.invoke(request, response);
+
String redirectStr = response.redirectString;
-
- System.out.println("RedirectStr from IDP=" + redirectStr);
- String destination = redirectStr.substring(0,redirectStr.indexOf(SAML_REQUEST_KEY)
-1);
- String relayState = redirectStr.substring(redirectStr.indexOf(RELAY_STATE_KEY) +
- RELAY_STATE_KEY.length()) ;
- String logoutRequest = redirectStr.substring(redirectStr.indexOf(SAML_REQUEST_KEY)
+
- SAML_REQUEST_KEY.length(),redirectStr.indexOf(RELAY_STATE_KEY) - 1 ) ;
-
-
- System.out.println("LogO=" + logoutRequest);
- InputStream stream = RedirectBindingUtil.urlBase64DeflateDecode(logoutRequest);
-
+ String destination = redirectStr.substring(0, redirectStr.indexOf(SAML_REQUEST_KEY)
- 1);
+ String relayState = redirectStr.substring(redirectStr.indexOf(RELAY_STATE_KEY) +
RELAY_STATE_KEY.length());
+ String logoutRequest = redirectStr.substring(redirectStr.indexOf(SAML_REQUEST_KEY)
+ SAML_REQUEST_KEY.length(),
+ redirectStr.indexOf(RELAY_STATE_KEY) - 1);
+
+ InputStream stream = RedirectBindingUtil.urlBase64DeflateDecode(logoutRequest);
+
SAML2Request saml2Request = new SAML2Request();
- LogoutRequestType lor =
- (LogoutRequestType) saml2Request.getRequestType(stream);
+ LogoutRequestType lor = (LogoutRequestType) saml2Request.getRequestType(stream);
assertEquals("Match Employee URL", employee, destination);
assertEquals("Destination exists", employee,
lor.getDestination().toString());
-
+
//Let us feed the LogOutRequest to the SPFilter
MockCatalinaContextClassLoader mclSPEmp = setupTCL(profile +
"/sp/employee");
- Thread.currentThread().setContextClassLoader(mclSPEmp);
+ Thread.currentThread().setContextClassLoader(mclSPEmp);
MockCatalinaContext context = new MockCatalinaContext();
context.setRealm(realm);
session.setServletContext(context);
-
+
SPRedirectFormAuthenticator sp = new SPRedirectFormAuthenticator();
sp.setContainer(context);
- sp.testStart();
-
+ sp.testStart();
+
request = new MockCatalinaRequest();
request.setSession(session);
request.setParameter("SAMLRequest",
RedirectBindingUtil.urlDecode(logoutRequest));
request.setParameter("RelayState", relayState);
-
+
MockCatalinaResponse filterResponse = new MockCatalinaResponse();
ByteArrayOutputStream filterbaos = new ByteArrayOutputStream();
filterResponse.setWriter(new PrintWriter(filterbaos));
-
- sp.authenticate(request, response, new LoginConfig());
-
+ sp.authenticate(request, response, new LoginConfig());
+
redirectStr = response.redirectString;
-
- System.out.println("Redirect String from SP=" + redirectStr);
-
- destination = redirectStr.substring(0,redirectStr.indexOf(SAML_RESPONSE_KEY) -1);
- relayState = redirectStr.substring(redirectStr.indexOf(RELAY_STATE_KEY) +
- RELAY_STATE_KEY.length()) ;
- assertNotNull("RelayState exists",relayState);
- String logoutResponse =
redirectStr.substring(redirectStr.indexOf(SAML_RESPONSE_KEY) +
- SAML_RESPONSE_KEY.length(),redirectStr.indexOf(RELAY_STATE_KEY) - 1 ) ;
-
- System.out.println("Logout Response from SP=" + logoutResponse);
-
- stream = RedirectBindingUtil.urlBase64DeflateDecode(logoutResponse);
- StatusResponseType statusResponse =
- (StatusResponseType) saml2Request.getSAML2ObjectFromStream(stream);
+
+ destination = redirectStr.substring(0, redirectStr.indexOf(SAML_RESPONSE_KEY) -
1);
+ relayState = redirectStr.substring(redirectStr.indexOf(RELAY_STATE_KEY) +
RELAY_STATE_KEY.length());
+ assertNotNull("RelayState exists", relayState);
+ String logoutResponse = redirectStr.substring(
+ redirectStr.indexOf(SAML_RESPONSE_KEY) + SAML_RESPONSE_KEY.length(),
+ redirectStr.indexOf(RELAY_STATE_KEY) - 1);
+
+ stream = RedirectBindingUtil.urlBase64DeflateDecode(logoutResponse);
+ StatusResponseType statusResponse = (StatusResponseType)
saml2Request.getSAML2ObjectFromStream(stream);
assertEquals("Match IDP URL", IDP, destination);
-
+
//Now the SP (employee app) has logged out and sending a status response to IDP
Thread.currentThread().setContextClassLoader(mclIDP);
session.clear();
request.clear();
-
+
request.setMethod("GET");
request.setSession(session);
request.setUserPrincipal(genericPrincipal);
request.setParameter("SAMLResponse",
RedirectBindingUtil.urlDecode(logoutResponse));
request.setParameter("RelayState", relayState);
-
- idp.invoke(request, response);
- destination = redirectStr.substring(0,redirectStr.indexOf(SAML_RESPONSE_KEY) -1);
- relayState = redirectStr.substring(redirectStr.indexOf(RELAY_STATE_KEY) +
- RELAY_STATE_KEY.length()) ;
- logoutResponse = redirectStr.substring(redirectStr.indexOf(SAML_RESPONSE_KEY) +
- SAML_RESPONSE_KEY.length(),redirectStr.indexOf(RELAY_STATE_KEY) - 1 ) ;
-
-
- System.out.println("LogO=" + logoutResponse);
- stream = RedirectBindingUtil.urlBase64DeflateDecode(logoutResponse);
-
+ idp.invoke(request, response);
+
+ destination = redirectStr.substring(0, redirectStr.indexOf(SAML_RESPONSE_KEY) -
1);
+ relayState = redirectStr.substring(redirectStr.indexOf(RELAY_STATE_KEY) +
RELAY_STATE_KEY.length());
+ logoutResponse = redirectStr.substring(redirectStr.indexOf(SAML_RESPONSE_KEY) +
SAML_RESPONSE_KEY.length(),
+ redirectStr.indexOf(RELAY_STATE_KEY) - 1);
+
+ stream = RedirectBindingUtil.urlBase64DeflateDecode(logoutResponse);
+
SAML2Response saml2Response = new SAML2Response();
- statusResponse =
- (StatusResponseType) saml2Request.getSAML2ObjectFromStream(stream);
+ statusResponse = (StatusResponseType)
saml2Request.getSAML2ObjectFromStream(stream);
assertEquals("Match IDP URL", IDP, destination);
-
+
//Now we should have got a full success report from IDP
MockCatalinaContextClassLoader mclSPSales = setupTCL(profile +
"/sp/employee");
Thread.currentThread().setContextClassLoader(mclSPSales);
sp = new SPRedirectFormAuthenticator();
sp.setContainer(context);
- sp.testStart();
-
+ sp.testStart();
+
session.clear();
request.clear();
request.setSession(session);
@@ -299,12 +280,12 @@
request.setParameter("SAMLResponse",
RedirectBindingUtil.urlDecode(logoutResponse));
request.setParameter("RelayState", relayState);
request.setContext(context);
-
- sp.authenticate(request, response, new LoginConfig());
-
+
+ sp.authenticate(request, response, new LoginConfig());
+
assertEquals(0, server.stack().getParticipants(session.getId()));
assertEquals(0, server.stack().getNumOfParticipantsInTransit(session.getId()));
-
+
//Finally the session should be invalidated
assertTrue(session.isInvalidated());
}
@@ -312,32 +293,32 @@
private MockCatalinaContextClassLoader setupTCL(String resource)
{
tcl = Thread.currentThread().getContextClassLoader();
- URL[] urls = new URL[] {tcl.getResource(resource)};
-
+ URL[] urls = new URL[]
+ {tcl.getResource(resource)};
+
MockCatalinaContextClassLoader mcl = new MockCatalinaContextClassLoader(urls);
mcl.setDelegate(tcl);
mcl.setProfile(resource);
return mcl;
}
-
+
private String createLogOutRequest(String url) throws Exception
{
SAML2Request samlRequest = new SAML2Request();
- LogoutRequestType lot =
- samlRequest.createLogoutRequest(url);
+ LogoutRequestType lot = samlRequest.createLogoutRequest(url);
StringWriter sw = new StringWriter();
samlRequest.marshall(lot, sw);
return sw.toString();
}
-
+
//Get the Identity server with 2 participants
private IdentityServer getIdentityServer(HttpSession session)
{
IdentityServer server = new IdentityServer();
server.sessionCreated(new HttpSessionEvent(session));
-
+
server.stack().register(session.getId(), sales, false);
server.stack().register(session.getId(), employee, false);
return server;
- }
+ }
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
===================================================================
---
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -403,7 +403,6 @@
writer.write(responseType, new QName(PROTOCOL_NSURI.get(),
LOGOUT_RESPONSE.get(), "samlp"));
}
- //System.out.println( new String( bos.toByteArray() ) );
return DocumentUtil.getDocument(new ByteArrayInputStream(bos.toByteArray()));
}
Modified:
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/saml/v2/SignatureValidationUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/saml/v2/SignatureValidationUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/saml/v2/SignatureValidationUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -80,8 +80,6 @@
ss.setSignatureMethod(SignatureMethod.DSA_SHA1);
Document signedDoc = ss.sign(authnRequest, kp);
- // System.out.println(DocumentUtil.getDocumentAsString(signedDoc));
-
// Validate the signature
boolean isValid = XMLSignatureUtil.validate(signedDoc, kp.getPublic());
assertTrue(isValid);
@@ -102,12 +100,12 @@
String authnContextDeclRef =
JBossSAMLURIConstants.AC_PASSWORD_PROTECTED_TRANSPORT.get();
- AuthnStatementType authnStatement =
response.createAuthnStatement(authnContextDeclRef, XMLTimeUtil
- .getIssueInstant());
+ AuthnStatementType authnStatement =
response.createAuthnStatement(authnContextDeclRef,
+ XMLTimeUtil.getIssueInstant());
// Create an assertion
AssertionType assertion = response.createAssertion(id, issuerInfo.getIssuer());
- assertion.addStatement( authnStatement );
+ assertion.addStatement(authnStatement);
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA");
KeyPair kp = kpg.genKeyPair();
@@ -154,8 +152,6 @@
SAML2Signature ss = new SAML2Signature();
Document signedDoc = ss.sign(responseType, id, kp, referenceURI);
- // System.out.println(DocumentUtil.getDocumentAsString(signedDoc));
-
Node signedNode = DocumentUtil.getNodeWithAttribute(signedDoc,
"urn:oasis:names:tc:SAML:2.0:assertion",
"Assertion", "ID", id);
@@ -167,8 +163,7 @@
// Validate the signature
boolean isValid = XMLSignatureUtil.validate(validatingDoc, kp.getPublic());
assertTrue("Signature is valid:", isValid);
-
-
+
/**
* Now the signed document is marshalled across the wire using dom
* write
@@ -176,10 +171,10 @@
//Binder<Node> binder = response.getBinder();
//We have to parse the dom coming from the stream and feed to binder
Document readDoc =
DocumentUtil.getDocument(DocumentUtil.getNodeAsStream(signedDoc));
-
- signedNode = DocumentUtil.getNodeWithAttribute(readDoc,
"urn:oasis:names:tc:SAML:2.0:assertion",
- "Assertion", "ID", id);
-
+
+ signedNode = DocumentUtil.getNodeWithAttribute(readDoc,
"urn:oasis:names:tc:SAML:2.0:assertion", "Assertion",
+ "ID", id);
+
// The client creates a validating document, importing the signed assertion.
validatingDoc = DocumentUtil.createDocument();
importedSignedNode = validatingDoc.importNode(signedNode, true);
@@ -187,7 +182,7 @@
// The client re-validates the signature.
assertTrue("Signature is valid:",
XMLSignatureUtil.validate(validatingDoc, kp.getPublic()));
-
+
/*JAXBElement<ResponseType> jaxbresponseType =
(JAXBElement<ResponseType>) binder.unmarshal(readDoc);
responseType = jaxbresponseType.getValue();
assertNotNull(responseType); */
@@ -210,5 +205,5 @@
boolean valid = SignatureUtil.validate(arbitContent.getBytes(), sigVal,
kp.getPublic());
assertTrue(valid);
- }
+ }
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -55,127 +55,119 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-
/**
* Unit Test the XML Encryption Utility
* @author Anil.Saldhana(a)redhat.com
* @since Feb 5, 2009
- */
+ */
public class XMLEncryptionUnitTestCase extends TestCase
{
SAML2Response sr = new SAML2Response();
-
+
public void testEncryptAssertion() throws Exception
{
PicketLinkCoreSTS sts = PicketLinkCoreSTS.instance();
sts.installDefaultConfiguration();
-
+
KeyPair kp = this.getKeyPair("RSA");
SecretKey sk = this.getSecretKey();
-
+
ResponseType rt = createResponse();
- Document responseDoc = sr.convert(rt);
-
+ Document responseDoc = sr.convert(rt);
+
String assertionNS = JBossSAMLURIConstants.ASSERTION_NSURI.get();
-
+
QName assertionQName = new QName(assertionNS, "EncryptedAssertion",
"saml");
-
- Element docElement =
XMLEncryptionUtil.encryptElementInDocument(responseDoc,kp.getPublic(), sk,
- 128, assertionQName, true);
-
- System.out.println( DocumentUtil.getDOMElementAsString(docElement));
-
- // System.out.println( DocumentUtil.getNodeAsString(docElement));
- InputStream is = DocumentUtil.getNodeAsStream( docElement );
- EncryptedAssertionType eet = sr.getEncryptedAssertion( is );
- rt.addAssertion( new RTChoiceType( eet ) );
-
+ Element docElement = XMLEncryptionUtil.encryptElementInDocument(responseDoc,
kp.getPublic(), sk, 128,
+ assertionQName, true);
+
+ InputStream is = DocumentUtil.getNodeAsStream(docElement);
+ EncryptedAssertionType eet = sr.getEncryptedAssertion(is);
+ rt.addAssertion(new RTChoiceType(eet));
+
RTChoiceType choiceType = rt.getAssertions().get(1);
EncryptedAssertionType encryptedAssertionType =
choiceType.getEncryptedAssertion();
-
- Document eetDoc = sr.convert( encryptedAssertionType );
-
- Element decryptedDocumentElement =
XMLEncryptionUtil.decryptElementInDocument(eetDoc,kp.getPrivate());
-
+
+ Document eetDoc = sr.convert(encryptedAssertionType);
+
+ Element decryptedDocumentElement =
XMLEncryptionUtil.decryptElementInDocument(eetDoc, kp.getPrivate());
+
//Let us use the encrypted doc element to decrypt it
-
+
ResponseType newRT =
sr.getResponseType(DocumentUtil.getNodeAsStream(decryptedDocumentElement));
- AssertionType assertion = (AssertionType)
newRT.getAssertions().get(0).getAssertion();
+ AssertionType assertion = newRT.getAssertions().get(0).getAssertion();
assertEquals("testPrincipal", assertion.getIssuer().getValue());
-
- }
-
+
+ }
+
public void testArbitraryXML() throws Exception
{
String myXML =
"<somexml><a><b></b></a></somexml>";
-
+
KeyPair kp = this.getKeyPair("RSA");
SecretKey sk = this.getSecretKey();
-
+
PublicKey publicKey = kp.getPublic();
-
+
Document doc = DocumentUtil.getDocument(myXML);
QName qname = new QName("urn:test", "encryptedA",
"someprefix");
-
+
QName elementAQname = new QName("a");
-
- XMLEncryptionUtil.encryptElement(elementAQname, doc,
- publicKey, sk, 256, qname, true);
-
+
+ XMLEncryptionUtil.encryptElement(elementAQname, doc, publicKey, sk, 256, qname,
true);
+
//Let us verify the document: The original document that has been passed has been
updated
- NodeList nl = doc.getElementsByTagNameNS(XMLEncryptionUtil.XMLENC_NS,
- XMLEncryptionUtil.ENCRYPTED_KEY_LOCALNAME);
- assertTrue(nl != null && nl.getLength() == 1);
-
+ NodeList nl = doc.getElementsByTagNameNS(XMLEncryptionUtil.XMLENC_NS,
XMLEncryptionUtil.ENCRYPTED_KEY_LOCALNAME);
+ assertTrue(nl != null && nl.getLength() == 1);
+
Node wrappedNode = doc.getDocumentElement().getFirstChild();
- assertEquals(wrappedNode.getLocalName(),qname.getLocalPart());
+ assertEquals(wrappedNode.getLocalName(), qname.getLocalPart());
assertEquals(wrappedNode.getNamespaceURI(), qname.getNamespaceURI());
- assertEquals(wrappedNode.getPrefix(), qname.getPrefix());
-
+ assertEquals(wrappedNode.getPrefix(), qname.getPrefix());
+
//Let us decrypt the document
PrivateKey privateKey = kp.getPrivate();
Element decryptedElement = XMLEncryptionUtil.decryptElementInDocument(doc,
privateKey);
assertEquals("a", decryptedElement.getLocalName());
}
-
+
public void testArbitraryXMLWithOuterKeyInfo() throws Exception
{
String myXML =
"<somexml><a><b></b></a></somexml>";
-
+
KeyPair kp = this.getKeyPair("RSA");
SecretKey sk = this.getSecretKey();
-
+
PublicKey publicKey = kp.getPublic();
-
+
Document doc = DocumentUtil.getDocument(myXML);
QName qname = new QName("urn:test", "encryptedA",
"someprefix");
-
+
QName elementAQname = new QName("a");
-
- XMLEncryptionUtil.encryptElement(elementAQname, doc,
- publicKey, sk, 256, qname, false);
-
+
+ XMLEncryptionUtil.encryptElement(elementAQname, doc, publicKey, sk, 256, qname,
false);
+
//Let us verify the document: The original document that has been passed has been
updated
- NodeList nl = doc.getElementsByTagNameNS(XMLEncryptionUtil.XMLENC_NS,
- XMLEncryptionUtil.ENCRYPTED_KEY_LOCALNAME);
+ NodeList nl = doc.getElementsByTagNameNS(XMLEncryptionUtil.XMLENC_NS,
XMLEncryptionUtil.ENCRYPTED_KEY_LOCALNAME);
assertTrue(nl != null && nl.getLength() == 1);
}
+
private ResponseType createResponse() throws Exception
{
List<String> roles = new ArrayList<String>();
roles.add("roleA");
roles.add("roleB");
-
+
ResponseType responseType = null;
-
+
SAML2Response saml2Response = new SAML2Response();
-
+
//Create a response type
String id = IDGenerator.create("ID_");
- IssuerInfoHolder issuerHolder = new
IssuerInfoHolder("http://identityurl");
+ IssuerInfoHolder issuerHolder = new
IssuerInfoHolder("http://identityurl");
issuerHolder.setStatusCode(JBossSAMLURIConstants.STATUS_SUCCESS.get());
IDPInfoHolder idp = new IDPInfoHolder();
@@ -185,28 +177,27 @@
SPInfoHolder sp = new SPInfoHolder();
sp.setResponseDestinationURI("http://service");
responseType = saml2Response.createResponseType(id, sp, idp, issuerHolder);
- AssertionType assertion = (AssertionType)
responseType.getAssertions().get(0).getAssertion();
+ AssertionType assertion = responseType.getAssertions().get(0).getAssertion();
AttributeStatementType attrStatement =
StatementUtil.createAttributeStatement(roles);
- assertion.addStatement( attrStatement );
-
+ assertion.addStatement(attrStatement);
+
//Add timed conditions
saml2Response.createTimedConditions(assertion, 5000L);
-
- return responseType;
+
+ return responseType;
}
-
+
private KeyPair getKeyPair(String algo) throws Exception
{
KeyPairGenerator kpg = KeyPairGenerator.getInstance(algo);
- return kpg.genKeyPair();
- }
-
+ return kpg.genKeyPair();
+ }
+
private SecretKey getSecretKey() throws Exception
- {
- KeyGenerator keyGenerator =
- KeyGenerator.getInstance("AES");
+ {
+ KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
keyGenerator.init(128);
return keyGenerator.generateKey();
- }
+ }
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/config/PBEUtilsUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/config/PBEUtilsUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/config/PBEUtilsUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -43,27 +43,24 @@
public void testPBE() throws Exception
{
String pass = "testpass";
-
+
String salt = "18273645";
int iterationCount = 56;
-
String pbeAlgo = PicketLinkFederationConstants.PBE_ALGORITHM;
- SecretKeyFactory factory = SecretKeyFactory.getInstance( pbeAlgo );
+ SecretKeyFactory factory = SecretKeyFactory.getInstance(pbeAlgo);
char[] password =
"somearbitrarycrazystringthatdoesnotmatter".toCharArray();
- PBEParameterSpec cipherSpec = new PBEParameterSpec( salt.getBytes(), iterationCount
);
+ PBEParameterSpec cipherSpec = new PBEParameterSpec(salt.getBytes(),
iterationCount);
PBEKeySpec keySpec = new PBEKeySpec(password);
SecretKey cipherKey = factory.generateSecret(keySpec);
-
- String encodedPass = PBEUtils.encode64(pass.getBytes(), pbeAlgo , cipherKey,
cipherSpec);
-
- System.out.println( getClass().getCanonicalName() + ":encoded=" +
encodedPass );
-
+
+ String encodedPass = PBEUtils.encode64(pass.getBytes(), pbeAlgo, cipherKey,
cipherSpec);
+
//Decode the stuff
cipherKey = factory.generateSecret(keySpec);
String decodedPass = PBEUtils.decode64(encodedPass, pbeAlgo, cipherKey,
cipherSpec);
-
- assertEquals( "Passwords match", pass, decodedPass );
+
+ assertEquals("Passwords match", pass, decodedPass);
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/DOMTransformerTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/DOMTransformerTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/DOMTransformerTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -51,33 +51,31 @@
public class DOMTransformerTestCase
{
String xml = "<a
xmlns=\'urn:a\'><b><c><d>SomeD</d></c></b></a>";
-
+
@Test
public void testDOMTransformer() throws Exception
- {
- ByteArrayInputStream bis = new ByteArrayInputStream( xml.getBytes() );
- XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader( bis );
-
- StartElement a = StaxParserUtil.getNextStartElement( xmlEventReader );
- StaxParserUtil.validate(a, "a" );
-
+ {
+ ByteArrayInputStream bis = new ByteArrayInputStream(xml.getBytes());
+ XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(bis);
+
+ StartElement a = StaxParserUtil.getNextStartElement(xmlEventReader);
+ StaxParserUtil.validate(a, "a");
+
Document resultDocument = DocumentUtil.createDocument();
- DOMResult domResult = new DOMResult( resultDocument );
-
+ DOMResult domResult = new DOMResult(resultDocument);
+
//Let us parse <b><c><d> using transformer
StAXSource source = new StAXSource(xmlEventReader);
-
+
Transformer transformer = TransformerUtil.getStaxSourceToDomResultTransformer();
- transformer.transform( source, domResult );
-
+ transformer.transform(source, domResult);
+
Document doc = (Document) domResult.getNode();
Element elem = doc.getDocumentElement();
- assertEquals( "b", elem.getLocalName() );
-
+ assertEquals("b", elem.getLocalName());
+
XMLEvent xmlEvent = xmlEventReader.nextEvent();
- assertTrue( xmlEvent instanceof EndElement );
- StaxParserUtil.validate( (EndElement) xmlEvent, "a" );
-
- System.out.println( DocumentUtil.asString( (Document) domResult.getNode() ));
- }
+ assertTrue(xmlEvent instanceof EndElement);
+ StaxParserUtil.validate((EndElement) xmlEvent, "a");
+ }
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -224,55 +224,10 @@
assertEquals(1, audienceRestrictionType.getAudience().size());
assertEquals("https://sp.example.com/SAML2",
audienceRestrictionType.getAudience().get(0).toString());
- /*List<JAXBElement<?>> content = subject.getContent();
-
- int size = content.size();
- assertEquals( 2, size );
-
- for( int i = 0 ; i < size; i++ )
- {
- JAXBElement<?> node = content.get(i);
- Class<?> clazz = node.getDeclaredType();
- if( clazz.equals( NameIDType.class ))
- {
- NameIDType subjectNameID = (NameIDType) node.getValue();
-
- assertEquals( "3f7b3dcf-1674-4ecd-92c8-1544f346baf8",
subjectNameID.getValue() );
- assertEquals(
"urn:oasis:names:tc:SAML:2.0:nameid-format:transient", subjectNameID.getFormat()
);
- }
-
- if( clazz.equals( ConditionsType.class ))
- {
- //Conditions
- ConditionsType conditions = (ConditionsType) node.getValue();
- assertEquals( XMLTimeUtil.parse( "2004-12-05T09:17:05Z" ) ,
conditions.getNotBefore() );
- assertEquals( XMLTimeUtil.parse( "2004-12-05T09:27:05Z" ) ,
conditions.getNotOnOrAfter() );
-
- //Audience Restriction
- AudienceRestrictionType audienceRestrictionType =
- (AudienceRestrictionType)
conditions.getConditionOrAudienceRestrictionOrOneTimeUse();
- assertEquals( 1, audienceRestrictionType.getAudience().size() );
- assertEquals( "https://sp.example.com/SAML2",
audienceRestrictionType.getAudience().get( 0 ));
- }
-
- else if( clazz.equals( SubjectConfirmationType.class ))
- {
- SubjectConfirmationType subjectConfirmation = (SubjectConfirmationType)
node.getValue();
- assertEquals( "urn:oasis:names:tc:SAML:2.0:cm:bearer",
subjectConfirmation.getMethod() );
-
- SubjectConfirmationDataType subjectConfirmationData =
subjectConfirmation.getSubjectConfirmationData();
- assertEquals( "ID_aaf23196-1773-2113-474a-fe114412ab72",
subjectConfirmationData.getInResponseTo() );
- assertEquals( XMLTimeUtil.parse( "2004-12-05T09:27:05Z" ),
subjectConfirmationData.getNotOnOrAfter() );
- assertEquals( "https://sp.example.com/SAML2/SSO/POST",
subjectConfirmationData.getRecipient());
- }
- } */
-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SAMLAssertionWriter writer = new
SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(assertion);
- System.out.println(new String(baos.toByteArray()));
-
ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
DocumentUtil.getDocument(bis); //throws exceptions
}
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAuthnRequestParserTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -33,7 +33,7 @@
import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLRequestWriter;
-import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.core.util.StaxUtil;
import org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType;
import org.picketlink.identity.federation.saml.v2.protocol.NameIDPolicyType;
@@ -48,36 +48,36 @@
public void testSAMLAuthnRequestParse() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream configStream = tcl.getResourceAsStream(
"parser/saml2/saml2-authnrequest.xml" );
-
+ InputStream configStream =
tcl.getResourceAsStream("parser/saml2/saml2-authnrequest.xml");
+
SAMLParser parser = new SAMLParser();
- AuthnRequestType authnRequest = ( AuthnRequestType ) parser.parse(configStream);
- assertNotNull( "AuthnRequestType is not null", authnRequest );
-
- assertEquals(
"http://localhost/org.eclipse.higgins.saml2idp.test/SAMLEndpoint",
authnRequest.getAssertionConsumerServiceURL().toString() );
- assertEquals(
"http://localhost/org.eclipse.higgins.saml2idp.server/SAMLEndpoint",
authnRequest.getDestination().toString() );
- assertEquals( "a2sffdlgdhgfg32fdldsdghdsgdgfdglgx", authnRequest.getID()
);
- assertEquals( XMLTimeUtil.parse( "2007-12-17T18:40:52.203Z" ),
authnRequest.getIssueInstant() );
- assertEquals( "urn:oasis:names.tc:SAML:2.0:bindings:HTTP-Redirect",
authnRequest.getProtocolBinding().toString() );
- assertEquals( "Test SAML2 SP", authnRequest.getProviderName() );
- assertEquals( "2.0", authnRequest.getVersion() );
-
+ AuthnRequestType authnRequest = (AuthnRequestType) parser.parse(configStream);
+ assertNotNull("AuthnRequestType is not null", authnRequest);
+
+
assertEquals("http://localhost/org.eclipse.higgins.saml2idp.test/SAMLEndpoint",
authnRequest
+ .getAssertionConsumerServiceURL().toString());
+
assertEquals("http://localhost/org.eclipse.higgins.saml2idp.server/SAMLEndpoint",
authnRequest.getDestination()
+ .toString());
+ assertEquals("a2sffdlgdhgfg32fdldsdghdsgdgfdglgx",
authnRequest.getID());
+ assertEquals(XMLTimeUtil.parse("2007-12-17T18:40:52.203Z"),
authnRequest.getIssueInstant());
+ assertEquals("urn:oasis:names.tc:SAML:2.0:bindings:HTTP-Redirect",
authnRequest.getProtocolBinding().toString());
+ assertEquals("Test SAML2 SP", authnRequest.getProviderName());
+ assertEquals("2.0", authnRequest.getVersion());
+
//Issuer
- assertEquals( "Test SAML2 SP", authnRequest.getIssuer().getValue() );
-
+ assertEquals("Test SAML2 SP", authnRequest.getIssuer().getValue());
+
//NameID Policy
NameIDPolicyType nameIDPolicy = authnRequest.getNameIDPolicy();
- assertEquals( "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
nameIDPolicy.getFormat().toString() );
- assertEquals( Boolean.TRUE , nameIDPolicy.isAllowCreate() );
-
+ assertEquals("urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
nameIDPolicy.getFormat().toString());
+ assertEquals(Boolean.TRUE, nameIDPolicy.isAllowCreate());
+
//Try out writing
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- SAMLRequestWriter writer = new
SAMLRequestWriter(StaxUtil.getXMLStreamWriter(baos));
- writer.write( authnRequest );
-
- System.out.println( new String( baos.toByteArray() ));
-
- ByteArrayInputStream bis = new ByteArrayInputStream( baos.toByteArray() );
- DocumentUtil.getDocument( bis ); //throws exceptions
+ SAMLRequestWriter writer = new
SAMLRequestWriter(StaxUtil.getXMLStreamWriter(baos));
+ writer.write(authnRequest);
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
+ DocumentUtil.getDocument(bis); //throws exceptions
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLResponseParserTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -50,8 +50,8 @@
import org.picketlink.identity.federation.saml.v2.assertion.SubjectType;
import
org.picketlink.identity.federation.saml.v2.profiles.xacml.assertion.XACMLAuthzDecisionStatementType;
import org.picketlink.identity.federation.saml.v2.protocol.ResponseType;
-import org.picketlink.identity.federation.saml.v2.protocol.StatusType;
import org.picketlink.identity.federation.saml.v2.protocol.ResponseType.RTChoiceType;
+import org.picketlink.identity.federation.saml.v2.protocol.StatusType;
/**
* Validate the parsing of SAML2 Response
@@ -126,8 +126,6 @@
SAMLResponseWriter writer = new
SAMLResponseWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(response);
- System.out.println(new String(baos.toByteArray()));
-
ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
DocumentUtil.getDocument(bis); //throws exceptions
}
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloRequestParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloRequestParserTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloRequestParserTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -33,7 +33,7 @@
import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLRequestWriter;
-import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.core.util.StaxUtil;
import org.picketlink.identity.federation.saml.v2.protocol.LogoutRequestType;
/**
@@ -45,28 +45,26 @@
{
@Test
public void testSAMLLogOutRequestParsing() throws Exception
- {
+ {
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream configStream = tcl.getResourceAsStream(
"parser/saml2/saml2-logout-request.xml" );
-
+ InputStream configStream =
tcl.getResourceAsStream("parser/saml2/saml2-logout-request.xml");
+
SAMLParser parser = new SAMLParser();
- LogoutRequestType lotRequest = ( LogoutRequestType ) parser.parse(configStream);
- assertNotNull( lotRequest );
-
- assertEquals( "ID_c3b5ae86-7fea-4d8b-a438-a3f47d8e92c3",
lotRequest.getID() );
- assertEquals( XMLTimeUtil.parse( "2010-07-29T13:46:20.647-05:00" ),
lotRequest.getIssueInstant() );
- assertEquals( "2.0", lotRequest.getVersion() );
+ LogoutRequestType lotRequest = (LogoutRequestType) parser.parse(configStream);
+ assertNotNull(lotRequest);
+
+ assertEquals("ID_c3b5ae86-7fea-4d8b-a438-a3f47d8e92c3",
lotRequest.getID());
+ assertEquals(XMLTimeUtil.parse("2010-07-29T13:46:20.647-05:00"),
lotRequest.getIssueInstant());
+ assertEquals("2.0", lotRequest.getVersion());
//Issuer
- assertEquals( "http://localhost:8080/sales/",
lotRequest.getIssuer().getValue() );
-
+ assertEquals("http://localhost:8080/sales/",
lotRequest.getIssuer().getValue());
+
//Try out writing
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- SAMLRequestWriter writer = new
SAMLRequestWriter(StaxUtil.getXMLStreamWriter(baos));
- writer.write( lotRequest );
-
- System.out.println( new String( baos.toByteArray() ));
-
- ByteArrayInputStream bis = new ByteArrayInputStream( baos.toByteArray() );
- DocumentUtil.getDocument( bis ); //throws exceptions
- }
+ SAMLRequestWriter writer = new
SAMLRequestWriter(StaxUtil.getXMLStreamWriter(baos));
+ writer.write(lotRequest);
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
+ DocumentUtil.getDocument(bis); //throws exceptions
+ }
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -76,8 +76,6 @@
SAMLResponseWriter writer = new
SAMLResponseWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(response, new QName(PROTOCOL_NSURI.get(), LOGOUT_RESPONSE.get(),
"samlp"));
- System.out.println(new String(baos.toByteArray()));
-
ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
DocumentUtil.getDocument(bis); //throws exceptions
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustBatchValidateParsingTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustBatchValidateParsingTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustBatchValidateParsingTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -44,38 +44,37 @@
*/
public class WSTrustBatchValidateParsingTestCase
{
- @Test
+ @Test
public void testWST_BatchValidate() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream configStream = tcl.getResourceAsStream(
"parser/wst/wst-batch-validate.xml" );
-
+ InputStream configStream =
tcl.getResourceAsStream("parser/wst/wst-batch-validate.xml");
+
WSTrustParser parser = new WSTrustParser();
- RequestSecurityTokenCollection requestCollection = (RequestSecurityTokenCollection)
parser.parse( configStream );
- assertNotNull( "Request Security Token Collection is null?",
requestCollection );
-
- List<RequestSecurityToken> tokens =
requestCollection.getRequestSecurityTokens();
- assertEquals( 2, tokens.size() );
-
- RequestSecurityToken rst1 = tokens.get( 0 );
- assertEquals( "validatecontext1", rst1.getContext() );
- assertEquals( WSTrustConstants.BATCH_VALIDATE_REQUEST,
rst1.getRequestType().toASCIIString() );
- assertEquals( WSTrustConstants.RSTR_STATUS_TOKEN_TYPE,
rst1.getTokenType().toASCIIString() );
-
- RequestSecurityToken rst2 = tokens.get( 1 );
- assertEquals( "validatecontext2", rst2.getContext() );
- assertEquals( WSTrustConstants.BATCH_VALIDATE_REQUEST ,
rst2.getRequestType().toASCIIString() );
- assertEquals( WSTrustConstants.RSTR_STATUS_TOKEN_TYPE ,
rst2.getTokenType().toASCIIString() );
-
+ RequestSecurityTokenCollection requestCollection = (RequestSecurityTokenCollection)
parser.parse(configStream);
+ assertNotNull("Request Security Token Collection is null?",
requestCollection);
+
+ List<RequestSecurityToken> tokens =
requestCollection.getRequestSecurityTokens();
+ assertEquals(2, tokens.size());
+
+ RequestSecurityToken rst1 = tokens.get(0);
+ assertEquals("validatecontext1", rst1.getContext());
+ assertEquals(WSTrustConstants.BATCH_VALIDATE_REQUEST,
rst1.getRequestType().toASCIIString());
+ assertEquals(WSTrustConstants.RSTR_STATUS_TOKEN_TYPE,
rst1.getTokenType().toASCIIString());
+
+ RequestSecurityToken rst2 = tokens.get(1);
+ assertEquals("validatecontext2", rst2.getContext());
+ assertEquals(WSTrustConstants.BATCH_VALIDATE_REQUEST,
rst2.getRequestType().toASCIIString());
+ assertEquals(WSTrustConstants.RSTR_STATUS_TOKEN_TYPE,
rst2.getTokenType().toASCIIString());
+
//Now for the writing part
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WSTrustRequestWriter rstWriter = new WSTrustRequestWriter(baos);
- rstWriter.write( requestCollection );
+ rstWriter.write(requestCollection);
- System.out.println( new String( baos.toByteArray() ));
- DocumentUtil.getDocument( new ByteArrayInputStream( baos.toByteArray() ));
- baos.close();
+ DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray()));
+ baos.close();
}
}
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -73,7 +73,6 @@
rstWriter.write(requestToken);
- System.out.println(new String(baos.toByteArray()));
DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray()));
}
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicCertificateTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -76,7 +76,6 @@
rstWriter.write(requestToken);
- System.out.println(new String(baos.toByteArray()));
DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray()));
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssuePublicKeyTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -73,7 +73,6 @@
rstWriter.write(requestToken);
- System.out.println(new String(baos.toByteArray()));
DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray()));
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueSymmetricKeyTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueSymmetricKeyTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueSymmetricKeyTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -44,39 +44,37 @@
* @since Oct 18, 2010
*/
public class WSTrustIssueSymmetricKeyTestCase
-{
+{
@Test
public void testSymKey() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream configStream = tcl.getResourceAsStream(
"parser/wst/wst-issue-symmetric-key.xml" );
-
+ InputStream configStream =
tcl.getResourceAsStream("parser/wst/wst-issue-symmetric-key.xml");
+
WSTrustParser parser = new WSTrustParser();
- RequestSecurityToken requestToken = ( RequestSecurityToken ) parser.parse(
configStream );
-
- assertEquals( "testcontext", requestToken.getContext() );
- assertEquals( WSTrustConstants.ISSUE_REQUEST ,
requestToken.getRequestType().toASCIIString() );
-
+ RequestSecurityToken requestToken = (RequestSecurityToken)
parser.parse(configStream);
+
+ assertEquals("testcontext", requestToken.getContext());
+ assertEquals(WSTrustConstants.ISSUE_REQUEST,
requestToken.getRequestType().toASCIIString());
+
AppliesTo appliesTo = requestToken.getAppliesTo();
EndpointReferenceType endpoint = (EndpointReferenceType)
appliesTo.getAny().get(0);
- assertEquals( "http://services.testcorp.org/provider2",
endpoint.getAddress().getValue() );
-
-
- assertEquals( WSTrustConstants.BS_TYPE_SYMMETRIC,
requestToken.getKeyType().toASCIIString() );
-
+
assertEquals("http://services.testcorp.org/provider2",
endpoint.getAddress().getValue());
+
+ assertEquals(WSTrustConstants.BS_TYPE_SYMMETRIC,
requestToken.getKeyType().toASCIIString());
+
EntropyType entropy = requestToken.getEntropy();
- BinarySecretType binarySecret = (BinarySecretType) entropy.getAny().get(0);
-
- assertEquals( WSTrustConstants.BS_TYPE_NONCE, binarySecret.getType() );
- assertEquals( "M0/7qLpV49c=" , new String( binarySecret.getValue() ));
-
+ BinarySecretType binarySecret = (BinarySecretType) entropy.getAny().get(0);
+
+ assertEquals(WSTrustConstants.BS_TYPE_NONCE, binarySecret.getType());
+ assertEquals("M0/7qLpV49c=", new String(binarySecret.getValue()));
+
//Now for the writing part
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WSTrustRequestWriter rstWriter = new WSTrustRequestWriter(baos);
- rstWriter.write(requestToken);
+ rstWriter.write(requestToken);
- System.out.println( new String( baos.toByteArray() ));
- DocumentUtil.getDocument( new ByteArrayInputStream( baos.toByteArray() ));
+ DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray()));
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -40,27 +40,26 @@
* @since Oct 18, 2010
*/
public class WSTrustIssueTestCase
-{
+{
@Test
public void testIssue() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream configStream = tcl.getResourceAsStream(
"parser/wst/wst-issue.xml" );
+ InputStream configStream =
tcl.getResourceAsStream("parser/wst/wst-issue.xml");
WSTrustParser parser = new WSTrustParser();
- RequestSecurityToken requestToken = ( RequestSecurityToken ) parser.parse(
configStream );
+ RequestSecurityToken requestToken = (RequestSecurityToken)
parser.parse(configStream);
- assertEquals( "testcontext", requestToken.getContext() );
- assertEquals( WSTrustConstants.ISSUE_REQUEST ,
requestToken.getRequestType().toASCIIString() );
- assertEquals( WSTrustConstants.SAML2_TOKEN_TYPE,
requestToken.getTokenType().toASCIIString() );
+ assertEquals("testcontext", requestToken.getContext());
+ assertEquals(WSTrustConstants.ISSUE_REQUEST,
requestToken.getRequestType().toASCIIString());
+ assertEquals(WSTrustConstants.SAML2_TOKEN_TYPE,
requestToken.getTokenType().toASCIIString());
//Now for the writing part
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WSTrustRequestWriter rstWriter = new WSTrustRequestWriter(baos);
- rstWriter.write(requestToken);
+ rstWriter.write(requestToken);
- System.out.println( new String( baos.toByteArray() ));
- DocumentUtil.getDocument( new ByteArrayInputStream( baos.toByteArray() ));
+ DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray()));
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustOnBehalfOfTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -70,7 +70,6 @@
rstWriter.write(requestToken);
- System.out.println(new String(baos.toByteArray()));
DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray()));
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/X500AttributeUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/X500AttributeUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/X500AttributeUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -79,13 +79,7 @@
SAMLResponseWriter writer = new
SAMLResponseWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(rt);
- /*Marshaller marshaller =
JBossSAMLAuthnResponseFactory.getValidatingMarshaller(false);
- JAXBElement<ResponseType> jaxb =
SAMLProtocolFactory.getObjectFactory().createResponse(rt);
- marshaller.marshal(jaxb, baos);
- *///marshaller.marshal(jaxb, System.out);
-
Document samlDom = DocumentUtil.getDocument(new String(baos.toByteArray()));
- System.out.println(DocumentUtil.getDocumentAsString(samlDom));
NodeList nl =
samlDom.getElementsByTagNameNS(JBossSAMLURIConstants.ASSERTION_NSURI.get(),
"Attribute");
assertEquals("nodes = 2", 2, nl.getLength());
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataParsingUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataParsingUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataParsingUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -57,45 +57,44 @@
public void testEntitiesDescriptor() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream is =
- tcl.getResourceAsStream("saml2/metadata/seam-entities.xml");
- assertNotNull("Inputstream not null", is);
-
+ InputStream is =
tcl.getResourceAsStream("saml2/metadata/seam-entities.xml");
+ assertNotNull("Inputstream not null", is);
+
SAMLParser parser = new SAMLParser();
EntitiesDescriptorType entities = (EntitiesDescriptorType) parser.parse(is);
- Assert.assertNotNull(entities);
- Assert.assertEquals( 2, entities.getEntityDescriptor().size() );
+ Assert.assertNotNull(entities);
+ Assert.assertEquals(2, entities.getEntityDescriptor().size());
EntityDescriptorType entity = (EntityDescriptorType)
entities.getEntityDescriptor().get(0);
IDPSSODescriptorType idp =
entity.getChoiceType().get(0).getDescriptors().get(0).getIdpDescriptor();
KeyDescriptorType keyDescriptor = idp.getKeyDescriptor().get(0);
X509Certificate cert = SAMLMetadataUtil.getCertificate(keyDescriptor);
Assert.assertNotNull(cert);
- Assert.assertEquals( "CN=test, OU=OpenSSO, O=Sun, L=Santa Clara,
ST=California, C=US", cert.getIssuerDN().getName() );
+ Assert.assertEquals("CN=test, OU=OpenSSO, O=Sun, L=Santa Clara, ST=California,
C=US", cert.getIssuerDN()
+ .getName());
}
-
+
@Test
public void parseOrganizationAndContactPerson() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream is =
-
tcl.getResourceAsStream("saml2/metadata/sp-entitydescOrgContact.xml");
- assertNotNull("Inputstream not null", is);
-
+ InputStream is =
tcl.getResourceAsStream("saml2/metadata/sp-entitydescOrgContact.xml");
+ assertNotNull("Inputstream not null", is);
+
SAMLParser parser = new SAMLParser();
EntityDescriptorType entity = (EntityDescriptorType) parser.parse(is);
- assertNotNull( entity );
+ assertNotNull(entity);
OrganizationType org = entity.getOrganization();
- assertNotNull( org );
-
+ assertNotNull(org);
+
List<ContactType> contactPersons = entity.getContactPerson();
- assertNotNull( contactPersons );
- assertTrue( contactPersons.size() == 1 );
-
- assertEquals( "technical", contactPersons.get(0).getContactType().value()
);
- assertEquals( "SAML SP Support", contactPersons.get(0).getSurName() );
- assertEquals( "mailto:saml-support@sp.example.com",
contactPersons.get(0).getEmailAddress().get(0) );
+ assertNotNull(contactPersons);
+ assertTrue(contactPersons.size() == 1);
+
+ assertEquals("technical",
contactPersons.get(0).getContactType().value());
+ assertEquals("SAML SP Support", contactPersons.get(0).getSurName());
+ assertEquals("mailto:saml-support@sp.example.com",
contactPersons.get(0).getEmailAddress().get(0));
}
-
+
/**
* PLFED-39
* @throws Exception
@@ -104,48 +103,45 @@
public void testShibbolethMetadataExtensions() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream is =
-
tcl.getResourceAsStream("saml2/metadata/testshib.org.idp-metadata.xml");
- assertNotNull("Inputstream not null", is);
+ InputStream is =
tcl.getResourceAsStream("saml2/metadata/testshib.org.idp-metadata.xml");
+ assertNotNull("Inputstream not null", is);
SAMLParser parser = new SAMLParser();
EntitiesDescriptorType entities = (EntitiesDescriptorType) parser.parse(is);
- assertNotNull(entities);
-
+ assertNotNull(entities);
+
//Another md
is = tcl.getResourceAsStream("saml2/metadata/shib.idp-metadata.xml");
- assertNotNull("Inputstream not null", is);
-
+ assertNotNull("Inputstream not null", is);
+
EntityDescriptorType entity = (EntityDescriptorType) parser.parse(is);
- assertNotNull( entity );
+ assertNotNull(entity);
}
-
+
@Test
public void testShibbolethMetadata() throws Exception
{
boolean runTest = false;
- System.out.println( "Test is disabled because of heap space issues in test
env" );
- if( runTest )
+ System.out.println("Test is disabled because of heap space issues in test
env");
+ if (runTest)
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream is =
-
tcl.getResourceAsStream("saml2/metadata/testshib-two-metadata.xml");
- assertNotNull("Inputstream not null", is);
+ InputStream is =
tcl.getResourceAsStream("saml2/metadata/testshib-two-metadata.xml");
+ assertNotNull("Inputstream not null", is);
SAMLParser parser = new SAMLParser();
EntitiesDescriptorType entities = (EntitiesDescriptorType) parser.parse(is);
assertNotNull(entities);
- assertEquals( "urn:mace:shibboleth:testshib:two", entities.getName()
);
-
+ assertEquals("urn:mace:shibboleth:testshib:two", entities.getName());
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- XMLStreamWriter writer = StaxUtil.getXMLStreamWriter( baos );
-
+
+ XMLStreamWriter writer = StaxUtil.getXMLStreamWriter(baos);
+
//write it back
- SAMLMetadataWriter mdWriter = new SAMLMetadataWriter( writer );
+ SAMLMetadataWriter mdWriter = new SAMLMetadataWriter(writer);
mdWriter.writeEntitiesDescriptor(entities);
-
- //System.out.println( new String( baos.toByteArray() ));
+
}
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -44,7 +44,6 @@
import org.picketlink.identity.federation.saml.v2.metadata.OrganizationType;
import org.picketlink.identity.federation.saml.v2.metadata.SPSSODescriptorType;
-
/**
* Unit test the {@code SAMLMetadataWriter}
* @author Anil.Saldhana(a)redhat.com
@@ -56,45 +55,42 @@
public void testWriteSPSSODescriptor() throws Exception
{
String fileName = "saml2/metadata/sp-entitydescriptor.xml";
- InputStream is =
Thread.currentThread().getContextClassLoader().getResourceAsStream( fileName );
- assertNotNull( is );
-
+ InputStream is =
Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
+ assertNotNull(is);
+
SAMLParser parser = new SAMLParser();
EntityDescriptorType entityDesc = (EntityDescriptorType) parser.parse(is);
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- XMLStreamWriter writer = StaxUtil.getXMLStreamWriter( baos );
-
+
+ XMLStreamWriter writer = StaxUtil.getXMLStreamWriter(baos);
+
//write it back
- SAMLMetadataWriter mdWriter = new SAMLMetadataWriter( writer );
- mdWriter.writeEntityDescriptor( entityDesc ) ;
-
- System.out.println( new String( baos.toByteArray() ));
+ SAMLMetadataWriter mdWriter = new SAMLMetadataWriter(writer);
+ mdWriter.writeEntityDescriptor(entityDesc);
+
}
-
+
@Test
public void testWriteEntityDescWithContactPerson() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream is =
-
tcl.getResourceAsStream("saml2/metadata/sp-entitydescOrgContact.xml");
- assertNotNull("Inputstream not null", is);
-
+ InputStream is =
tcl.getResourceAsStream("saml2/metadata/sp-entitydescOrgContact.xml");
+ assertNotNull("Inputstream not null", is);
+
SAMLParser parser = new SAMLParser();
EntityDescriptorType entity = (EntityDescriptorType) parser.parse(is);
- assertNotNull( entity );
+ assertNotNull(entity);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- XMLStreamWriter writer = StaxUtil.getXMLStreamWriter( baos );
-
+
+ XMLStreamWriter writer = StaxUtil.getXMLStreamWriter(baos);
+
//write it back
- SAMLMetadataWriter mdWriter = new SAMLMetadataWriter( writer );
- mdWriter.writeEntityDescriptor( entity ) ;
-
- System.out.println( new String( baos.toByteArray() ));
+ SAMLMetadataWriter mdWriter = new SAMLMetadataWriter(writer);
+ mdWriter.writeEntityDescriptor(entity);
+
}
-
+
/**
* PLFED-142
* @throws Exception
@@ -103,27 +99,26 @@
public void testDynamicMetadataCreation() throws Exception
{
OrganizationType org = new OrganizationType();
- AttributeType attributeType = new AttributeType( "hello" );
+ AttributeType attributeType = new AttributeType("hello");
List<AttributeType> attributes = new ArrayList<AttributeType>();
attributes.add(attributeType);
-
- URI test = URI.create( "http://test");
- EndpointType sloEndPoint = new EndpointType( test, test );
+
+ URI test = URI.create("http://test");
+ EndpointType sloEndPoint = new EndpointType(test, test);
KeyDescriptorType keyDescriptorType = new KeyDescriptorType();
String str = "<a/>";
- keyDescriptorType.setKeyInfo( DocumentUtil.getDocument( str ).getDocumentElement()
);
-
- SPSSODescriptorType spSSO = MetaDataBuilderDelegate.createSPSSODescriptor(false,
keyDescriptorType, sloEndPoint, attributes, org);
+ keyDescriptorType.setKeyInfo(DocumentUtil.getDocument(str).getDocumentElement());
+
+ SPSSODescriptorType spSSO = MetaDataBuilderDelegate.createSPSSODescriptor(false,
keyDescriptorType, sloEndPoint,
+ attributes, org);
EntityDescriptorType entity =
MetaDataBuilderDelegate.createEntityDescriptor(spSSO);
-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- XMLStreamWriter writer = StaxUtil.getXMLStreamWriter( baos );
-
+
+ XMLStreamWriter writer = StaxUtil.getXMLStreamWriter(baos);
+
//write it back
- SAMLMetadataWriter mdWriter = new SAMLMetadataWriter( writer );
- mdWriter.writeEntityDescriptor( entity ) ;
- System.out.println( new String( baos.toByteArray() ));
+ SAMLMetadataWriter mdWriter = new SAMLMetadataWriter(writer);
+ mdWriter.writeEntityDescriptor(entity);
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/stax/DomElementToStaxWritingTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/stax/DomElementToStaxWritingTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/stax/DomElementToStaxWritingTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -41,16 +41,15 @@
public void testDOM2Stax() throws Exception
{
String xml = "<a xmlns=\'urn:hello\' > <b> <c/>
<d xmlns=\'urn:t\' test=\'tt\'/> </b></a>";
-
- Document doc = DocumentUtil.getDocument( xml );
-
+
+ Document doc = DocumentUtil.getDocument(xml);
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- XMLStreamWriter writer = StaxUtil.getXMLStreamWriter( baos );
- StaxUtil.writeDOMElement(writer, doc.getDocumentElement() );
-
- String writtenDoc = new String( baos.toByteArray() );
- System.out.println( writtenDoc );
- doc = DocumentUtil.getDocument( writtenDoc );
+
+ XMLStreamWriter writer = StaxUtil.getXMLStreamWriter(baos);
+ StaxUtil.writeDOMElement(writer, doc.getDocumentElement());
+
+ String writtenDoc = new String(baos.toByteArray());
+ doc = DocumentUtil.getDocument(writtenDoc);
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLTimeUtilUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLTimeUtilUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/XMLTimeUtilUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -38,7 +38,7 @@
* @since Jan 6, 2009
*/
public class XMLTimeUtilUnitTestCase extends TestCase
-{
+{
public void testCompareViaParsing() throws Exception
{
DatatypeFactory dt = DatatypeFactory.newInstance();
@@ -47,39 +47,37 @@
XMLGregorianCalendar notOnOrAfter =
dt.newXMLGregorianCalendar("2009-06-03T17:47:05.901-04:00");
assertTrue(XMLTimeUtil.isValid(now, notBefore, notOnOrAfter));
}
-
+
public void testAdd() throws Exception
{
XMLGregorianCalendar now = XMLTimeUtil.getIssueInstant();
long min5 = XMLTimeUtil.inMilis(5);
-
+
XMLGregorianCalendar after5M = XMLTimeUtil.add(now, min5);
- assertTrue(now.compare(after5M) == DatatypeConstants.LESSER);
-
+ assertTrue(now.compare(after5M) == DatatypeConstants.LESSER);
+
GregorianCalendar nowG = now.toGregorianCalendar();
GregorianCalendar now5M = after5M.toGregorianCalendar();
-
+
//Add 5 minutes
nowG.roll(Calendar.MINUTE, 5);
-
+
int val = nowG.compareTo(now5M);
-
- System.out.println("Comparison value="+val);
-
- assertTrue( "Compared value is 0", val <= 0);
+
+ assertTrue("Compared value is 0", val <= 0);
}
public void testIsValid() throws Exception
- {
+ {
XMLGregorianCalendar now = XMLTimeUtil.getIssueInstant();
-
+
long milisFor5Mins = XMLTimeUtil.inMilis(5);
-
+
XMLGregorianCalendar after5M = XMLTimeUtil.add(now, milisFor5Mins);
XMLGregorianCalendar after10M = XMLTimeUtil.add(now, milisFor5Mins * 2);
-
+
//isValid(now, notbefore, notOnOrAfter)
assertTrue(XMLTimeUtil.isValid(after5M, now, after10M));
- assertFalse(XMLTimeUtil.isValid(now, after5M,after10M));
- }
+ assertFalse(XMLTimeUtil.isValid(now, after5M, after10M));
+ }
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/saml/handlers/SAML2AuthenticationHandlerUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/saml/handlers/SAML2AuthenticationHandlerUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/saml/handlers/SAML2AuthenticationHandlerUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -123,7 +123,6 @@
Document samlReq = response.getResultingDocument();
SAMLParser parser = new SAMLParser();
- System.out.println("Doc=" + DocumentUtil.asString(samlReq));
AuthnRequestType authnRequest = (AuthnRequestType)
parser.parse(DocumentUtil.getNodeAsStream(samlReq));
NameIDPolicyType nameIDPolicy = authnRequest.getNameIDPolicy();
assertEquals(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get(),
nameIDPolicy.getFormat().toString());
@@ -188,8 +187,6 @@
XMLEncryptionUtil.encryptElement(new QName(assertionNS, "Assertion",
"saml"), responseDoc, publicKey, secretKey,
128, assertionQName, true);
- System.out.println(DocumentUtil.asString(responseDoc));
-
SAMLParser parser = new SAMLParser();
saml2Object = (SAML2Object)
parser.parse(DocumentUtil.getNodeAsStream(responseDoc));
Modified:
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/saml2/SAML2LogoutWorkflowUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/saml2/SAML2LogoutWorkflowUnitTestCase.java 2011-06-24
17:59:14 UTC (rev 1031)
+++
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/saml2/SAML2LogoutWorkflowUnitTestCase.java 2011-06-24
18:10:38 UTC (rev 1032)
@@ -68,11 +68,14 @@
*/
public class SAML2LogoutWorkflowUnitTestCase
{
- private String profile = "saml2/logout";
+ private final String profile = "saml2/logout";
+
private ClassLoader tcl;
- private String employee = "http://localhost:8080/employee/";
- private String sales = "http://localhost:8080/sales/";
-
+
+ private final String employee = "http://localhost:8080/employee/";
+
+ private final String sales = "http://localhost:8080/sales/";
+
/**
* Test that the SP web filter generates the logout request
* to the IDP when there is a parameter "GLO" set to true
@@ -81,9 +84,9 @@
*/
@Test
public void testSPFilterLogOutRequestGeneration() throws Exception
- {
+ {
tcl = Thread.currentThread().getContextClassLoader();
-
+
MockHttpSession session = new MockHttpSession();
session.setAttribute(GeneralConstants.PRINCIPAL_ID, new Principal()
{
@@ -91,48 +94,45 @@
{
return "anil";
}
- });
+ });
List<String> rolesList = new ArrayList<String>();
rolesList.add("manager");
session.setAttribute(GeneralConstants.ROLES_ID, rolesList);
-
ServletContext servletContext = new MockServletContext();
session.setServletContext(servletContext);
-
+
//Let us feed the LogOutRequest to the SPFilter
MockContextClassLoader mclSPEmp = setupTCL(profile + "/sp/employee");
Thread.currentThread().setContextClassLoader(mclSPEmp);
SPFilter spEmpl = new SPFilter();
MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
filterConfig.addInitParameter(GeneralConstants.IGNORE_SIGNATURES,
"true");
-
+
spEmpl.init(filterConfig);
-
+
MockHttpSession filterSession = new MockHttpSession();
MockHttpServletRequest filterRequest = new MockHttpServletRequest(filterSession,
"POST");
- filterRequest.addParameter(GeneralConstants.GLOBAL_LOGOUT, "true");
-
+ filterRequest.addParameter(GeneralConstants.GLOBAL_LOGOUT, "true");
+
MockHttpServletResponse filterResponse = new MockHttpServletResponse();
ByteArrayOutputStream filterbaos = new ByteArrayOutputStream();
filterResponse.setWriter(new PrintWriter(filterbaos));
-
+
spEmpl.doFilter(filterRequest, filterResponse, new MockFilterChain());
-
-
+
String spResponse = new String(filterbaos.toByteArray());
Document spHTMLResponse = DocumentUtil.getDocument(spResponse);
NodeList nodes = spHTMLResponse.getElementsByTagName("INPUT");
- Element inputElement = (Element)nodes.item(0);
- String logoutRequest = inputElement.getAttributeNode("VALUE").getValue();
-
+ Element inputElement = (Element) nodes.item(0);
+ String logoutRequest =
inputElement.getAttributeNode("VALUE").getValue();
+
byte[] b64Decoded = PostBindingUtil.base64Decode(logoutRequest);
SAML2Request saml2Request = new SAML2Request();
- LogoutRequestType lor =
- (LogoutRequestType) saml2Request.getRequestType(new
ByteArrayInputStream(b64Decoded));
+ LogoutRequestType lor = (LogoutRequestType) saml2Request.getRequestType(new
ByteArrayInputStream(b64Decoded));
assertEquals("Match Employee URL", employee,
lor.getIssuer().getValue());
}
-
+
/**
* In this test case, we preload the IDP with 2 active participants
* namely the Sales app and Employee App. After this, the employee app
@@ -149,27 +149,27 @@
*/
@Test
public void testSAML2LogOutFromIDPServlet() throws Exception
- {
+ {
tcl = Thread.currentThread().getContextClassLoader();
MockHttpSession session = new MockHttpSession();
-
+
MockContextClassLoader mclIDP = setupTCL(profile + "/idp");
Thread.currentThread().setContextClassLoader(mclIDP);
-
+
ServletContext servletContext = new MockServletContext();
session.setServletContext(servletContext);
-
+
IdentityServer server = this.getIdentityServer(session);
servletContext.setAttribute("IDENTITY_SERVER", server);
MockServletConfig servletConfig = new MockServletConfig(servletContext);
-
+
IDPServlet idp = new IDPServlet();
//No signing outgoing messages
servletConfig.addInitParameter(GeneralConstants.SIGN_OUTGOING_MESSAGES,
"false");
-
+
//Initialize the servlet
- idp.init(servletConfig);
-
+ idp.init(servletConfig);
+
//Assume that we already have the principal and roles set in the session
session.setAttribute(GeneralConstants.PRINCIPAL_ID, new Principal()
{
@@ -177,153 +177,152 @@
{
return "anil";
}
- });
+ });
List<String> rolesList = new ArrayList<String>();
rolesList.add("manager");
session.setAttribute(GeneralConstants.ROLES_ID, rolesList);
-
- MockHttpServletRequest request = new MockHttpServletRequest(session,
"POST");
+
+ MockHttpServletRequest request = new MockHttpServletRequest(session,
"POST");
request.addHeader("Referer", sales);
-
+
String samlMessage = Base64.encodeBytes(createLogOutRequest(sales).getBytes());
session.setAttribute("SAMLRequest", samlMessage);
-
+
MockHttpServletResponse response = new MockHttpServletResponse();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.setWriter(new PrintWriter(baos));
-
+
// The IDP is preloaded with 2 participants :
"http://localhost:8080/sales/"
// and "http://localhost:8080/employee"
-
+
//Lets start the workflow with post
- idp.testPost(request, response);
+ idp.testPost(request, response);
String idpResponse = new String(baos.toByteArray());
assertNotNull(idpResponse);
-
+
Document htmlResponse = DocumentUtil.getDocument(idpResponse);
assertNotNull(htmlResponse);
NodeList nodes = htmlResponse.getElementsByTagName("INPUT");
- Element inputElement = (Element)nodes.item(0);
+ Element inputElement = (Element) nodes.item(0);
String logoutOrigResponse =
inputElement.getAttributeNode("VALUE").getValue();
-
+
String relayState = null;
- if(nodes.getLength() > 1)
- relayState =
((Element)nodes.item(1)).getAttributeNode("VALUE").getValue();
-
+ if (nodes.getLength() > 1)
+ relayState = ((Element)
nodes.item(1)).getAttributeNode("VALUE").getValue();
+
String logoutResponse = new String(Base64.decode(logoutOrigResponse));
- System.out.println(logoutResponse);
SAML2Request samlRequest = new SAML2Request();
ByteArrayInputStream bis = new ByteArrayInputStream(logoutResponse.getBytes());
SAML2Object samlObject = samlRequest.getSAML2ObjectFromStream(bis);
- assertTrue(samlObject instanceof LogoutRequestType);
-
+ assertTrue(samlObject instanceof LogoutRequestType);
+
//Let us feed the LogOutRequest to the SPFilter
MockContextClassLoader mclSPEmp = setupTCL(profile + "/sp/employee");
Thread.currentThread().setContextClassLoader(mclSPEmp);
SPFilter spEmpl = new SPFilter();
MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
filterConfig.addInitParameter(GeneralConstants.IGNORE_SIGNATURES,
"true");
-
+
spEmpl.init(filterConfig);
-
+
MockHttpSession filterSession = new MockHttpSession();
MockHttpServletRequest filterRequest = new MockHttpServletRequest(filterSession,
"POST");
filterRequest.addParameter("SAMLResponse", logoutOrigResponse);
filterRequest.addParameter("RelayState", relayState);
-
+
MockHttpServletResponse filterResponse = new MockHttpServletResponse();
ByteArrayOutputStream filterbaos = new ByteArrayOutputStream();
filterResponse.setWriter(new PrintWriter(filterbaos));
-
+
spEmpl.doFilter(filterRequest, filterResponse, new MockFilterChain());
String spResponse = new String(filterbaos.toByteArray());
Document spHTMLResponse = DocumentUtil.getDocument(spResponse);
nodes = spHTMLResponse.getElementsByTagName("INPUT");
- inputElement = (Element)nodes.item(0);
+ inputElement = (Element) nodes.item(0);
logoutOrigResponse = inputElement.getAttributeNode("VALUE").getValue();
relayState = null;
- if(nodes.getLength() > 1)
- relayState =
((Element)nodes.item(1)).getAttributeNode("VALUE").getValue();
-
+ if (nodes.getLength() > 1)
+ relayState = ((Element)
nodes.item(1)).getAttributeNode("VALUE").getValue();
+
//Now the SP (employee app) has logged out and sending a status response to IDP
Thread.currentThread().setContextClassLoader(mclIDP);
session.setAttribute("SAMLResponse", logoutOrigResponse);
session.setAttribute("RelayState", relayState);
-
- idp.testPost(request, response);
+ idp.testPost(request, response);
+
idpResponse = new String(filterbaos.toByteArray());
assertNotNull(idpResponse);
-
+
htmlResponse = DocumentUtil.getDocument(idpResponse);
assertNotNull(htmlResponse);
nodes = htmlResponse.getElementsByTagName("INPUT");
- inputElement = (Element)nodes.item(0);
+ inputElement = (Element) nodes.item(0);
logoutOrigResponse = inputElement.getAttributeNode("VALUE").getValue();
-
+
relayState = null;
- if(nodes.getLength() > 1)
- relayState =
((Element)nodes.item(1)).getAttributeNode("VALUE").getValue();
-
+ if (nodes.getLength() > 1)
+ relayState = ((Element)
nodes.item(1)).getAttributeNode("VALUE").getValue();
+
//Now we should have got a full success report from IDP
MockContextClassLoader mclSPSales = setupTCL(profile + "/sp/employee");
Thread.currentThread().setContextClassLoader(mclSPSales);
SPFilter spSales = new SPFilter();
-
+
spSales.init(filterConfig);
-
+
filterRequest.addParameter("SAMLResponse", logoutOrigResponse);
filterRequest.addParameter("RelayState", relayState);
-
+
spSales.doFilter(filterRequest, filterResponse, new MockFilterChain());
-
+
spResponse = new String(filterbaos.toByteArray());
-
+
assertEquals(0, server.stack().getParticipants(session.getId()));
assertEquals(0, server.stack().getNumOfParticipantsInTransit(session.getId()));
-
+
spHTMLResponse = DocumentUtil.getDocument(spResponse);
nodes = spHTMLResponse.getElementsByTagName("INPUT");
- inputElement = (Element)nodes.item(0);
+ inputElement = (Element) nodes.item(0);
logoutOrigResponse = inputElement.getAttributeNode("VALUE").getValue();
relayState = null;
- if(nodes.getLength() > 1)
- relayState =
((Element)nodes.item(1)).getAttributeNode("VALUE").getValue();
-
+ if (nodes.getLength() > 1)
+ relayState = ((Element)
nodes.item(1)).getAttributeNode("VALUE").getValue();
+
//Finally the session should be invalidated
assertTrue(filterSession.isInvalidated());
}
private MockContextClassLoader setupTCL(String resource)
{
- URL[] urls = new URL[] {tcl.getResource(resource)};
-
+ URL[] urls = new URL[]
+ {tcl.getResource(resource)};
+
MockContextClassLoader mcl = new MockContextClassLoader(urls);
mcl.setDelegate(tcl);
mcl.setProfile(resource);
return mcl;
}
-
+
private String createLogOutRequest(String url) throws Exception
{
SAML2Request samlRequest = new SAML2Request();
- LogoutRequestType lot =
- samlRequest.createLogoutRequest(url);
+ LogoutRequestType lot = samlRequest.createLogoutRequest(url);
StringWriter sw = new StringWriter();
samlRequest.marshall(lot, sw);
return sw.toString();
}
-
+
//Get the Identity server with 2 participants
private IdentityServer getIdentityServer(HttpSession session)
{
IdentityServer server = new IdentityServer();
server.sessionCreated(new HttpSessionEvent(session));
-
- server.stack().register( session.getId(), sales, false );
- server.stack().register( session.getId(), employee, false );
+
+ server.stack().register(session.getId(), sales, false);
+ server.stack().register(session.getId(), employee, false);
return server;
}
}
\ No newline at end of file