Author: anil.saldhana(a)jboss.com
Date: 2010-11-04 12:51:05 -0400 (Thu, 04 Nov 2010)
New Revision: 529
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java
Log:
parse subject confirmation
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java 2010-11-04
16:50:18 UTC (rev 528)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java 2010-11-04
16:51:05 UTC (rev 529)
@@ -35,8 +35,10 @@
import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
+import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.saml.v2.assertion.NameIDType;
import org.picketlink.identity.federation.saml.v2.assertion.ObjectFactory;
+import org.picketlink.identity.federation.saml.v2.assertion.SubjectConfirmationDataType;
import org.picketlink.identity.federation.saml.v2.assertion.SubjectConfirmationType;
import org.picketlink.identity.federation.saml.v2.assertion.SubjectType;
@@ -80,7 +82,7 @@
try
{
StartElement nameIDElement = StaxParserUtil.getNextStartElement(
xmlEventReader );
- Attribute nameQualifier = nameIDElement.getAttributeByName( new QName(
"", JBossSAMLConstants.NAME_QUALIFIER.get() ));
+ Attribute nameQualifier = nameIDElement.getAttributeByName( new QName(
JBossSAMLConstants.NAME_QUALIFIER.get() ));
if( nameQualifier == null )
nameQualifier = nameIDElement.getAttributeByName( new QName(
JBossSAMLURIConstants.ASSERTION_NSURI.get(),
JBossSAMLConstants.NAME_QUALIFIER.get() ));
@@ -107,10 +109,7 @@
else if( JBossSAMLConstants.SUBJECT_CONFIRMATION.get().equalsIgnoreCase( tag )
)
{
StartElement subjectConfirmationElement = StaxParserUtil.getNextStartElement(
xmlEventReader );
- Attribute method = subjectConfirmationElement.getAttributeByName( new QName(
"", JBossSAMLConstants.METHOD.get() ));
- if( method == null )
- method = subjectConfirmationElement.getAttributeByName( new QName(
JBossSAMLURIConstants.ASSERTION_NSURI.get(),
- JBossSAMLConstants.METHOD.get() ));
+ Attribute method = subjectConfirmationElement.getAttributeByName( new QName(
JBossSAMLConstants.METHOD.get() ));
SubjectConfirmationType subjectConfirmationType = new
SubjectConfirmationType();
@@ -118,6 +117,20 @@
{
subjectConfirmationType.setMethod( StaxParserUtil.getAttributeValue(
method ) );
}
+
+ //There may be additional things under subject confirmation
+ xmlEvent = StaxParserUtil.peek(xmlEventReader);
+ if( xmlEvent instanceof StartElement )
+ {
+ StartElement startElement = (StartElement) xmlEvent;
+ String startTag = StaxParserUtil.getStartElementName(startElement);
+
+ if( startTag.equals( JBossSAMLConstants.SUBJECT_CONFIRMATION_DATA.get()
))
+ {
+ SubjectConfirmationDataType subjectConfirmationData =
parseSubjectConfirmationData(xmlEventReader);
+ subjectConfirmationType.setSubjectConfirmationData(
subjectConfirmationData );
+ }
+ }
JAXBElement<SubjectConfirmationType> jaxbSubjectConf =
objectFactory.createSubjectConfirmation( subjectConfirmationType );
subject.getContent().add(jaxbSubjectConf);
@@ -143,4 +156,47 @@
return nsURI.equals( JBossSAMLURIConstants.ASSERTION_NSURI.get() )
&& localPart.equals( JBossSAMLConstants.SUBJECT.get() );
}
+
+ private SubjectConfirmationDataType parseSubjectConfirmationData( XMLEventReader
xmlEventReader ) throws ParsingException
+ {
+ StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ StaxParserUtil.validate(startElement,
JBossSAMLConstants.SUBJECT_CONFIRMATION_DATA.get() );
+
+ SubjectConfirmationDataType subjectConfirmationData = new
SubjectConfirmationDataType();
+
+ Attribute inResponseTo = startElement.getAttributeByName( new QName(
JBossSAMLConstants.IN_RESPONSE_TO.get() ));
+ if( inResponseTo != null )
+ {
+ subjectConfirmationData.setInResponseTo( StaxParserUtil.getAttributeValue(
inResponseTo ));
+ }
+
+ Attribute notBefore = startElement.getAttributeByName( new QName(
JBossSAMLConstants.NOT_BEFORE.get() ));
+ if( notBefore != null )
+ {
+ subjectConfirmationData.setNotBefore( XMLTimeUtil.parse(
StaxParserUtil.getAttributeValue( notBefore )));
+ }
+
+ Attribute notOnOrAfter = startElement.getAttributeByName( new QName(
JBossSAMLConstants.NOT_ON_OR_AFTER.get() ));
+ if( notOnOrAfter != null )
+ {
+ subjectConfirmationData.setNotOnOrAfter( XMLTimeUtil.parse(
StaxParserUtil.getAttributeValue( notOnOrAfter )));
+ }
+
+ Attribute recipient = startElement.getAttributeByName( new QName(
JBossSAMLConstants.RECIPIENT.get() ));
+ if( recipient != null )
+ {
+ subjectConfirmationData.setRecipient( StaxParserUtil.getAttributeValue(
recipient ));
+ }
+
+ Attribute address = startElement.getAttributeByName( new QName(
JBossSAMLConstants.ADDRESS.get() ));
+ if( address != null )
+ {
+ subjectConfirmationData.setAddress( StaxParserUtil.getAttributeValue( address
));
+ }
+
+ //Get the end tag
+ EndElement endElement = (EndElement) StaxParserUtil.getNextEvent(xmlEventReader);
+ StaxParserUtil.matches(endElement,
JBossSAMLConstants.SUBJECT_CONFIRMATION_DATA.get() );
+ return subjectConfirmationData;
+ }
}
\ No newline at end of file
Show replies by date