Author: anil.saldhana(a)jboss.com
Date: 2011-04-04 13:08:04 -0400 (Mon, 04 Apr 2011)
New Revision: 852
Added:
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml2/saml2-logout-response-sig.xml
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java
Log:
add sig case
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-04-04
17:07:40 UTC (rev 851)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLSloResponseParserTestCase.java 2011-04-04
17:08:04 UTC (rev 852)
@@ -23,8 +23,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static
org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants.PROTOCOL_NSURI;
import static
org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants.LOGOUT_RESPONSE;
+import static
org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants.PROTOCOL_NSURI;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -37,9 +37,10 @@
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.SAMLResponseWriter;
-import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.core.util.StaxUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusResponseType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusType;
+
/**
* Validate the parsing of SLO Response
* @author Anil.Saldhana(a)redhat.com
@@ -51,33 +52,58 @@
public void testSAMLResponseParse() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream configStream = tcl.getResourceAsStream(
"parser/saml2/saml2-logout-response.xml" );
-
+ InputStream configStream =
tcl.getResourceAsStream("parser/saml2/saml2-logout-response.xml");
+
SAMLParser parser = new SAMLParser();
- StatusResponseType response = ( StatusResponseType ) parser.parse(configStream);
- assertNotNull( "ResponseType is not null", response );
-
- assertEquals( XMLTimeUtil.parse( "2010-07-29T13:46:03.862-05:00" ),
response.getIssueInstant() );
- assertEquals( "2.0", response.getVersion() );
- assertEquals( "ID_97d332a8-3224-4653-a1ff-65c966e56852", response.getID()
);
-
+ StatusResponseType response = (StatusResponseType) parser.parse(configStream);
+ assertNotNull("ResponseType is not null", response);
+
+ assertEquals(XMLTimeUtil.parse("2010-07-29T13:46:03.862-05:00"),
response.getIssueInstant());
+ assertEquals("2.0", response.getVersion());
+ assertEquals("ID_97d332a8-3224-4653-a1ff-65c966e56852",
response.getID());
+
//Issuer
- assertEquals( "http://localhost:8080/employee-post/",
response.getIssuer().getValue() );
-
+ assertEquals("http://localhost:8080/employee-post/",
response.getIssuer().getValue());
+
//Status
StatusType status = response.getStatus();
- assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Responder",
status.getStatusCode().getValue().toString() );
- assertEquals( "urn:oasis:names:tc:SAML:2.0:status:Success",
status.getStatusCode().getStatusCode().getValue().toString() );
-
+ assertEquals("urn:oasis:names:tc:SAML:2.0:status:Responder",
status.getStatusCode().getValue().toString());
+ assertEquals("urn:oasis:names:tc:SAML:2.0:status:Success",
status.getStatusCode().getStatusCode().getValue()
+ .toString());
+
//Let us do some writing - currently only visual inspection. We will do proper
validation later.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
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
-
- }
+ 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
+
+ }
+
+ @Test
+ public void testSLOResponseWithSig() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream configStream =
tcl.getResourceAsStream("parser/saml2/saml2-logout-response-sig.xml");
+
+ SAMLParser parser = new SAMLParser();
+ StatusResponseType response = (StatusResponseType) parser.parse(configStream);
+ assertNotNull("ResponseType is not null", response);
+
+ assertEquals(XMLTimeUtil.parse("2011-04-04T11:48:32.372-05:00"),
response.getIssueInstant());
+ assertEquals("2.0", response.getVersion());
+ assertEquals("ID_2b178fbb-224c-4f01-950d-e3d1be2d3821",
response.getID());
+
+ //Issuer
+ assertEquals("http://localhost:8080/idp-sig/",
response.getIssuer().getValue());
+
+ //Status
+ StatusType status = response.getStatus();
+ assertEquals("urn:oasis:names:tc:SAML:2.0:status:Responder",
status.getStatusCode().getValue().toString());
+ assertEquals("urn:oasis:names:tc:SAML:2.0:status:Success",
status.getStatusCode().getStatusCode().getValue()
+ .toString());
+ }
}
\ No newline at end of file
Added:
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml2/saml2-logout-response-sig.xml
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml2/saml2-logout-response-sig.xml
(rev 0)
+++
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml2/saml2-logout-response-sig.xml 2011-04-04
17:08:04 UTC (rev 852)
@@ -0,0 +1,40 @@
+<samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
+ xmlns="urn:oasis:names:tc:SAML:2.0:assertion"
ID="ID_2b178fbb-224c-4f01-950d-e3d1be2d3821"
+ InResponseTo="ID_3709478a-4818-47d6-9d38-5cac7221ac0b"
IssueInstant="2011-04-04T11:48:32.372-05:00"
+ Version="2.0">
+ <Issuer>http://localhost:8080/idp-sig/</Issuer>
+ <samlp:Status>
+ <samlp:StatusCode
Value="urn:oasis:names:tc:SAML:2.0:status:Responder">
+ <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"
/>
+ </samlp:StatusCode>
+ </samlp:Status>
+ <dsig:Signature
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
+ <dsig:SignedInfo>
+ <dsig:CanonicalizationMethod
+
Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments" />
+ <dsig:SignatureMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
+ <dsig:Reference URI="#ID_2b178fbb-224c-4f01-950d-e3d1be2d3821">
+ <dsig:Transforms>
+ <dsig:Transform
+
Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
+ <dsig:Transform
Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"
/>
+ </dsig:Transforms>
+ <dsig:DigestMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"
/>
+ <dsig:DigestValue>BPisd+dKE3LyHTXQUuYeVWr3rM8=</dsig:DigestValue>
+ </dsig:Reference>
+ </dsig:SignedInfo>
+ <dsig:SignatureValue>aCMsh9lMJ/YZYYUAUnj/mcwCnmKOVSRHeNSvYxARYCzZv3FU9ieL4X+vr5rQ+LgU98NVfMO9YmEh
+ hgNhOYy7klRTVDa0RsrYX56T99Dhun9hZIXBKxHbx9T9W3glU1uiCuT4zlJuKJA9nGNRdkstf3Fn
+ qy0vEhxhhZymvh1lkXQ=</dsig:SignatureValue>
+ <dsig:KeyInfo>
+ <dsig:KeyValue>
+ <dsig:RSAKeyValue>
+ <dsig:Modulus>7KiaO7wWGffrZcXyLcY3syZ7TWVE5wBzU08/DvglTvvSQeotmJDKBTea8N8Kf8SKqdBANH8dnYT0
+ wRXkedAQ+97YwwWKiwTz+EHYvfwBWQaV3BBu2kLVe9w+hykXPmEEIQzXXbfoBt9xi5pworDsjJJR
+ OifK5+eUtjIK2jkGzKM=</dsig:Modulus>
+ <dsig:Exponent>AQAB</dsig:Exponent>
+ </dsig:RSAKeyValue>
+ </dsig:KeyValue>
+ </dsig:KeyInfo>
+ </dsig:Signature>
+</samlp:LogoutResponse>
\ No newline at end of file