Author: anil.saldhana(a)jboss.com
Date: 2011-04-04 13:09:29 -0400 (Mon, 04 Apr 2011)
New Revision: 855
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLStatusResponseTypeParser.java
Log:
fix parsing
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLStatusResponseTypeParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLStatusResponseTypeParser.java 2011-04-04
17:09:09 UTC (rev 854)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLStatusResponseTypeParser.java 2011-04-04
17:09:29 UTC (rev 855)
@@ -33,7 +33,7 @@
import org.picketlink.identity.federation.core.exceptions.ParsingException;
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.util.XMLTimeUtil;
+import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusCodeType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusResponseType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusType;
@@ -51,108 +51,109 @@
* @param response
* @throws ParsingException
*/
- protected void parseBaseAttributes( StartElement startElement , StatusResponseType
response ) throws ParsingException
+ protected void parseBaseAttributes(StartElement startElement, StatusResponseType
response) throws ParsingException
{
- Attribute idAttr = startElement.getAttributeByName( new QName( "ID" ));
- if( idAttr == null )
- throw new RuntimeException( "ID attribute is missing" );
- response.setID( StaxParserUtil.getAttributeValue( idAttr ));
-
- Attribute version = startElement.getAttributeByName( new QName( "Version"
));
- if( version == null )
- throw new RuntimeException( "Version attribute required in Response"
);
- response.setVersion( StaxParserUtil.getAttributeValue( version ));
-
- Attribute issueInstant = startElement.getAttributeByName( new QName(
"IssueInstant" ));
- if( issueInstant == null )
- throw new RuntimeException( "IssueInstant attribute required in
Response" );
- response.setIssueInstant( XMLTimeUtil.parse( StaxParserUtil.getAttributeValue(
issueInstant )));
-
- Attribute destination = startElement.getAttributeByName( new QName(
"Destination" ));
- if( destination != null )
- response.setDestination( StaxParserUtil.getAttributeValue( destination ));
-
- Attribute consent = startElement.getAttributeByName( new QName( "Consent"
));
- if( consent != null )
- response.setConsent( StaxParserUtil.getAttributeValue( consent ));
-
- Attribute inResponseTo = startElement.getAttributeByName( new QName(
"InResponseTo" ));
- if( inResponseTo != null )
- response.setInResponseTo( StaxParserUtil.getAttributeValue( inResponseTo ));
+ Attribute idAttr = startElement.getAttributeByName(new QName("ID"));
+ if (idAttr == null)
+ throw new RuntimeException("ID attribute is missing");
+ response.setID(StaxParserUtil.getAttributeValue(idAttr));
+
+ Attribute version = startElement.getAttributeByName(new
QName("Version"));
+ if (version == null)
+ throw new RuntimeException("Version attribute required in Response");
+ response.setVersion(StaxParserUtil.getAttributeValue(version));
+
+ Attribute issueInstant = startElement.getAttributeByName(new
QName("IssueInstant"));
+ if (issueInstant == null)
+ throw new RuntimeException("IssueInstant attribute required in
Response");
+
response.setIssueInstant(XMLTimeUtil.parse(StaxParserUtil.getAttributeValue(issueInstant)));
+
+ Attribute destination = startElement.getAttributeByName(new
QName("Destination"));
+ if (destination != null)
+ response.setDestination(StaxParserUtil.getAttributeValue(destination));
+
+ Attribute consent = startElement.getAttributeByName(new
QName("Consent"));
+ if (consent != null)
+ response.setConsent(StaxParserUtil.getAttributeValue(consent));
+
+ Attribute inResponseTo = startElement.getAttributeByName(new
QName("InResponseTo"));
+ if (inResponseTo != null)
+ response.setInResponseTo(StaxParserUtil.getAttributeValue(inResponseTo));
}
-
- /**
- * Parse the status element
- * @param xmlEventReader
- * @return
- * @throws ParsingException
- */
- protected StatusType parseStatus( XMLEventReader xmlEventReader ) throws
ParsingException
+
+ /**
+ * Parse the status element
+ * @param xmlEventReader
+ * @return
+ * @throws ParsingException
+ */
+ protected StatusType parseStatus(XMLEventReader xmlEventReader) throws
ParsingException
{
//Get the Start Element
StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
String STATUS = JBossSAMLConstants.STATUS.get();
- StaxParserUtil.validate(startElement, STATUS );
-
+ StaxParserUtil.validate(startElement, STATUS);
+
StatusType status = new StatusType();
-
- while( xmlEventReader.hasNext() )
+
+ while (xmlEventReader.hasNext())
{
startElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
- if( startElement == null )
+ if (startElement == null)
break;
-
- QName startElementName = startElement.getName();
+
+ QName startElementName = startElement.getName();
String elementTag = startElementName.getLocalPart();
StatusCodeType statusCode = new StatusCodeType();
-
- if( JBossSAMLConstants.STATUS_CODE.get().equals( elementTag ))
+
+ if (JBossSAMLConstants.STATUS_CODE.get().equals(elementTag))
{
startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
- if( startElement == null )
+ if (startElement == null)
break;
- Attribute valueAttr = startElement.getAttributeByName( new QName(
"Value" ));
- if( valueAttr != null )
+ Attribute valueAttr = startElement.getAttributeByName(new
QName("Value"));
+ if (valueAttr != null)
{
- statusCode.setValue( URI.create( StaxParserUtil.getAttributeValue(
valueAttr ) ));
+
statusCode.setValue(URI.create(StaxParserUtil.getAttributeValue(valueAttr)));
}
- status.setStatusCode( statusCode );
-
+ status.setStatusCode(statusCode);
+
//Peek at the next start element to see if it is status code
- startElement = StaxParserUtil.peekNextStartElement( xmlEventReader );
- if( JBossSAMLConstants.STATUS_CODE.get().equals(
startElement.getName().getLocalPart() ))
+ startElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
+ elementTag = startElement.getName().getLocalPart();
+ if (JBossSAMLConstants.STATUS_CODE.get().equals(elementTag))
{
StatusCodeType subStatusCodeType = new StatusCodeType();
startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
- Attribute subValueAttr = startElement.getAttributeByName( new QName(
"Value" ));
- if( subValueAttr != null )
+ Attribute subValueAttr = startElement.getAttributeByName(new
QName("Value"));
+ if (subValueAttr != null)
{
- subStatusCodeType.setValue( URI.create(
StaxParserUtil.getAttributeValue( subValueAttr )));
- }
- statusCode.setStatusCode( subStatusCodeType );
-
+
subStatusCodeType.setValue(URI.create(StaxParserUtil.getAttributeValue(subValueAttr)));
+ }
+ statusCode.setStatusCode(subStatusCodeType);
+
// Go to Status code end element.
EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
StaxParserUtil.validate(endElement,
JBossSAMLConstants.STATUS_CODE.get());
continue;
}
- else
- break;
- }
-
+ }
+
//Get the next end element
XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
- if( xmlEvent instanceof EndElement )
+ if (xmlEvent instanceof EndElement)
{
EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
- if( StaxParserUtil.matches(endElement, STATUS ))
+ if (StaxParserUtil.matches(endElement, STATUS))
break;
else
- throw new RuntimeException( "unknown end element:" +
StaxParserUtil.getEndElementName( endElement ));
+ throw new RuntimeException("unknown end element:" +
StaxParserUtil.getEndElementName(endElement));
}
- }
+ else
+ break;
+ }
return status;
- }
+ }
}
\ No newline at end of file
Show replies by date