Author: anil.saldhana(a)jboss.com
Date: 2011-06-29 16:15:26 -0400 (Wed, 29 Jun 2011)
New Revision: 1044
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/SAML11Constants.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/writers/SAML11RequestWriter.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/writers/SAML11ResponseWriter.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11RequestParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11ResponseParserTestCase.java
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-request-authzquery.xml
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-response.xml
Log:
PLFED-192: writing
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/SAML11Constants.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/SAML11Constants.java 2011-06-29
20:14:53 UTC (rev 1043)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/SAML11Constants.java 2011-06-29
20:15:26 UTC (rev 1044)
@@ -94,7 +94,7 @@
String NAME_QUALIFIER = "NameQualifier";
- String NAMESPACE = "NameSpace";
+ String NAMESPACE = "Namespace";
String PROTOCOL_11_NSURI = "urn:oasis:names:tc:SAML:1.0:protocol";
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/writers/SAML11RequestWriter.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/writers/SAML11RequestWriter.java 2011-06-29
20:14:53 UTC (rev 1043)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/writers/SAML11RequestWriter.java 2011-06-29
20:15:26 UTC (rev 1044)
@@ -62,6 +62,7 @@
{
StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, SAML11Constants.REQUEST,
namespace);
StaxUtil.writeNameSpace(writer, PROTOCOL_PREFIX, namespace);
+ StaxUtil.writeNameSpace(writer, ASSERTION_PREFIX,
SAML11Constants.ASSERTION_11_NSURI);
StaxUtil.writeDefaultNameSpace(writer, namespace);
// Attributes
@@ -73,7 +74,8 @@
List<String> assertionIDRefs = request.getAssertionIDRef();
for (String assertionIDRef : assertionIDRefs)
{
- StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX,
SAML11Constants.ASSERTION_ID_REF, namespace);
+ StaxUtil.writeStartElement(writer, ASSERTION_PREFIX,
SAML11Constants.ASSERTION_ID_REF,
+ SAML11Constants.ASSERTION_11_NSURI);
StaxUtil.writeCharacters(writer, assertionIDRef);
StaxUtil.writeEndElement(writer);
}
@@ -166,7 +168,7 @@
public void write(SAML11AuthorizationDecisionQueryType attr) throws
ProcessingException
{
- StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX,
SAML11Constants.ATTRIBUTE_QUERY, namespace);
+ StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX,
SAML11Constants.AUTHORIZATION_DECISION_QUERY, namespace);
URI resource = attr.getResource();
if (resource != null)
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/writers/SAML11ResponseWriter.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/writers/SAML11ResponseWriter.java 2011-06-29
20:14:53 UTC (rev 1043)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/writers/SAML11ResponseWriter.java 2011-06-29
20:15:26 UTC (rev 1044)
@@ -60,6 +60,7 @@
{
StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, SAML11Constants.RESPONSE,
namespace);
StaxUtil.writeNameSpace(writer, PROTOCOL_PREFIX, namespace);
+ StaxUtil.writeNameSpace(writer, ASSERTION_PREFIX,
SAML11Constants.ASSERTION_11_NSURI);
// Attributes
StaxUtil.writeAttribute(writer, SAML11Constants.RESPONSE_ID, response.getID());
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11RequestParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11RequestParserTestCase.java 2011-06-29
20:14:53 UTC (rev 1043)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11RequestParserTestCase.java 2011-06-29
20:15:26 UTC (rev 1044)
@@ -27,10 +27,15 @@
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import java.io.StringReader;
import java.util.List;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Validator;
+
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v1.SAML11Constants;
import org.picketlink.identity.federation.core.saml.v1.writers.SAML11RequestWriter;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
@@ -77,7 +82,12 @@
//Lets do the writing
SAML11RequestWriter writer = new
SAML11RequestWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(request);
- System.out.println(new String(baos.toByteArray()));
+ String writtenString = new String(baos.toByteArray());
+ System.out.println(writtenString);
+
+ Validator validator = StaxParserUtil.getSchemaValidator();
+ assertNotNull(validator);
+ validator.validate(new StreamSource(new StringReader(writtenString)));
}
@Test
@@ -107,7 +117,12 @@
//Lets do the writing
SAML11RequestWriter writer = new
SAML11RequestWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(request);
- System.out.println(new String(baos.toByteArray()));
+ String writtenString = new String(baos.toByteArray());
+ System.out.println(writtenString);
+
+ Validator validator = StaxParserUtil.getSchemaValidator();
+ assertNotNull(validator);
+ validator.validate(new StreamSource(new StringReader(writtenString)));
}
@Test
@@ -122,7 +137,7 @@
assertEquals(1, request.getMajorVersion());
assertEquals(1, request.getMinorVersion());
- assertEquals("1234", request.getID());
+ assertEquals("R1234", request.getID());
assertEquals(XMLTimeUtil.parse("2002-08-05T10:04:15"),
request.getIssueInstant());
SAML11QueryAbstractType query = request.getQuery();
@@ -146,7 +161,12 @@
//Lets do the writing
SAML11RequestWriter writer = new
SAML11RequestWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(request);
- System.out.println(new String(baos.toByteArray()));
+ String writtenString = new String(baos.toByteArray());
+ System.out.println(writtenString);
+
+ Validator validator = StaxParserUtil.getSchemaValidator();
+ assertNotNull(validator);
+ validator.validate(new StreamSource(new StringReader(writtenString)));
}
@Test
@@ -170,7 +190,12 @@
//Lets do the writing
SAML11RequestWriter writer = new
SAML11RequestWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(request);
- System.out.println(new String(baos.toByteArray()));
+ String writtenString = new String(baos.toByteArray());
+ System.out.println(writtenString);
+
+ Validator validator = StaxParserUtil.getSchemaValidator();
+ assertNotNull(validator);
+ validator.validate(new StreamSource(new StringReader(writtenString)));
}
@Test
@@ -194,6 +219,11 @@
//Lets do the writing
SAML11RequestWriter writer = new
SAML11RequestWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(request);
- System.out.println(new String(baos.toByteArray()));
+ String writtenString = new String(baos.toByteArray());
+ System.out.println(writtenString);
+
+ Validator validator = StaxParserUtil.getSchemaValidator();
+ assertNotNull(validator);
+ validator.validate(new StreamSource(new StringReader(writtenString)));
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11ResponseParserTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11ResponseParserTestCase.java 2011-06-29
20:14:53 UTC (rev 1043)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11ResponseParserTestCase.java 2011-06-29
20:15:26 UTC (rev 1044)
@@ -26,11 +26,16 @@
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import java.io.StringReader;
import java.util.List;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Validator;
+
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.saml.SAML11ResponseParser;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v1.writers.SAML11ResponseWriter;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.util.StaxUtil;
@@ -58,7 +63,7 @@
assertEquals(1, response.getMajorVersion());
assertEquals(1, response.getMinorVersion());
- assertEquals("_P1YaA+Q/wSM/t/8E3R8rNhcpPTM=", response.getID());
+ assertEquals("P1234", response.getID());
assertEquals(XMLTimeUtil.parse("2002-06-19T17:05:37.795Z"),
response.getIssueInstant());
assertNotNull(response.getSignature());
@@ -76,6 +81,11 @@
//Lets do the writing
SAML11ResponseWriter writer = new
SAML11ResponseWriter(StaxUtil.getXMLStreamWriter(baos));
writer.write(response);
- System.out.println(new String(baos.toByteArray()));
+ String writtenString = new String(baos.toByteArray());
+ System.out.println(writtenString);
+
+ Validator validator = StaxParserUtil.getSchemaValidator();
+ assertNotNull(validator);
+ validator.validate(new StreamSource(new StringReader(writtenString)));
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-request-authzquery.xml
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-request-authzquery.xml 2011-06-29
20:14:53 UTC (rev 1043)
+++
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-request-authzquery.xml 2011-06-29
20:15:26 UTC (rev 1044)
@@ -1,4 +1,4 @@
-<Request RequestID="1234" MajorVersion="1"
MinorVersion="1"
+<Request RequestID="R1234" MajorVersion="1"
MinorVersion="1"
IssueInstant="2002-08-05T10:04:15"
xmlns="urn:oasis:names:tc:SAML:1.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
@@ -10,6 +10,6 @@
anil(a)anil.org
</saml:NameIdentifier>
</saml:Subject>
- <saml:Action
NameSpace="http://www.jboss.org">create</saml:Action>
+ <saml:Action
Namespace="http://www.jboss.org">create</saml:Action>
</AuthorizationDecisionQuery>
</Request>
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-response.xml
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-response.xml 2011-06-29
20:14:53 UTC (rev 1043)
+++
federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-response.xml 2011-06-29
20:15:26 UTC (rev 1044)
@@ -1,7 +1,7 @@
<samlp:Response
xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"
MajorVersion="1" MinorVersion="1"
- ResponseID="_P1YaA+Q/wSM/t/8E3R8rNhcpPTM="
+ ResponseID="P1234"
IssueInstant="2002-06-19T17:05:37.795Z">
<Signature
xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
@@ -19,7 +19,7 @@
<SignatureValue>ApcX/Ddfsfdslkfd</SignatureValue>
<KeyInfo>
<X509Data>
- <X509Certificate>MIICmjdfdflkfdslfaf;sjdposafhpofhpowfowqpowqfow
+ <X509Certificate>YWJjZA==
</X509Certificate>
</X509Data>
</KeyInfo>