Author: klape
Date: 2012-02-29 17:40:07 -0500 (Wed, 29 Feb 2012)
New Revision: 1451
Added:
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/test/resources/parser/saml2/saml2-assertion-subjectconfirmation.xml
Modified:
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java
Log:
[JBPAPP-8304] Subelements of <saml2:Subject> are not parsed correctly
Modified:
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java
===================================================================
---
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java 2012-02-29
22:37:28 UTC (rev 1450)
+++
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java 2012-02-29
22:40:07 UTC (rev 1451)
@@ -110,8 +110,13 @@
StartElement startElement = (StartElement) xmlEvent;
String startTag = StaxParserUtil.getStartElementName(startElement);
- if (startTag.equals(JBossSAMLConstants.SUBJECT_CONFIRMATION_DATA.get()))
+ if (startTag.equals(JBossSAMLConstants.NAMEID.get()))
{
+ NameIDType nameID = SAMLParserUtil.parseNameIDType(xmlEventReader);
+ subjectConfirmationType.setNameID(nameID);
+ }
+ else if
(startTag.equals(JBossSAMLConstants.SUBJECT_CONFIRMATION_DATA.get()))
+ {
SubjectConfirmationDataType subjectConfirmationData =
parseSubjectConfirmationData(xmlEventReader);
subjectConfirmationType.setSubjectConfirmationData(subjectConfirmationData);
}
Modified:
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java
===================================================================
---
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java 2012-02-29
22:37:28 UTC (rev 1450)
+++
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAMLAssertionParserTestCase.java 2012-02-29
22:40:07 UTC (rev 1451)
@@ -227,4 +227,28 @@
System.out.println(writtenString);
validateSchema(writtenString);
}
+
+ /**
+ * PLFED-251
+ * @throws Exception
+ */
+ @Test
+ public void testSAML2AssertionWithSubjectConfirmationHavingNameID() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream configStream =
tcl.getResourceAsStream("parser/saml2/saml2-assertion-subjectconfirmation.xml");
+
+ SAMLParser parser = new SAMLParser();
+ AssertionType assertion = (AssertionType) parser.parse(configStream);
+ assertNotNull(assertion);
+
+ List<SubjectConfirmationType> subjectConfirmationTypes =
assertion.getSubject().getConfirmation();
+ assertNotNull(subjectConfirmationTypes);
+ assertEquals(1, subjectConfirmationTypes.size());
+ SubjectConfirmationType sct = subjectConfirmationTypes.get(0);
+ assertEquals("urn:oasis:names:tc:SAML:2.0:cm:sender-vouches",
sct.getMethod());
+ NameIDType nameID = sct.getNameID();
+ assertNotNull(nameID);
+ assertEquals("CN=theDUDE", nameID.getValue());
+ }
}
\ No newline at end of file
Added:
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/test/resources/parser/saml2/saml2-assertion-subjectconfirmation.xml
===================================================================
---
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/test/resources/parser/saml2/saml2-assertion-subjectconfirmation.xml
(rev 0)
+++
product/branches/2.0.x_JBPAPP-8304/picketlink-core/src/test/resources/parser/saml2/saml2-assertion-subjectconfirmation.xml 2012-02-29
22:40:07 UTC (rev 1451)
@@ -0,0 +1,23 @@
+<saml2:Assertion ID="ID_144fa48dc370c7a921414f3c53ed111b"
+ IssueInstant="2011-11-09T15:04:07.000Z" Version="2.0"
+ xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
+
+ <saml2:Issuer>TheDUDE</saml2:Issuer>
+ <saml2:Subject>
+ <saml2:SubjectConfirmation
+ Method="urn:oasis:names:tc:SAML:2.0:cm:sender-vouches">
+ <saml2:NameID>CN=theDUDE</saml2:NameID>
+ </saml2:SubjectConfirmation>
+ </saml2:Subject>
+
+ <saml2:Conditions NotBefore="2011-11-09T15:02:07.000Z"
+ NotOnOrAfter="2011-11-09T15:09:07.000Z" />
+
+ <saml2:AuthnStatement AuthnInstant="2011-11-09T15:04:07.000Z">
+ <saml2:SubjectLocality Address="10.103.121.235" />
+ <saml2:AuthnContext>
+ <saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password
+ </saml2:AuthnContextClassRef>
+ </saml2:AuthnContext>
+ </saml2:AuthnStatement>
+</saml2:Assertion>
\ No newline at end of file
Show replies by date