Author: anil.saldhana(a)jboss.com
Date: 2011-05-17 11:03:46 -0400 (Tue, 17 May 2011)
New Revision: 945
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenResponseParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustOnBehalfOfParser.java
Log:
add some logging
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2011-05-17
14:55:04 UTC (rev 944)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2011-05-17
15:03:46 UTC (rev 945)
@@ -31,6 +31,7 @@
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
+import org.apache.log4j.Logger;
import org.picketlink.identity.federation.core.exceptions.ParsingException;
import org.picketlink.identity.federation.core.parsers.ParserController;
import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
@@ -60,6 +61,10 @@
*/
public class WSTRequestSecurityTokenParser implements ParserNamespaceSupport
{
+ protected Logger log = Logger.getLogger(WSTRequestSecurityTokenParser.class);
+
+ protected boolean trace = log.isTraceEnabled();
+
public static final String X509CERTIFICATE = "X509Certificate";
public static final String KEYVALUE = "KeyValue";
@@ -298,6 +303,10 @@
else
{
QName qname = subEvent.getName();
+ if (trace)
+ {
+ log.trace("Looking for Parser for :" + qname);
+ }
ParserNamespaceSupport parser = ParserController.get(qname);
if (parser == null)
throw new RuntimeException("Cannot parse " + qname);
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenResponseParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenResponseParser.java 2011-05-17
14:55:04 UTC (rev 944)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenResponseParser.java 2011-05-17
15:03:46 UTC (rev 945)
@@ -27,6 +27,7 @@
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
+import org.apache.log4j.Logger;
import org.picketlink.identity.federation.core.exceptions.ParsingException;
import org.picketlink.identity.federation.core.parsers.ParserController;
import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
@@ -52,13 +53,17 @@
import org.w3c.dom.Element;
/**
- * Parse the WS-Trust RequestSecurityToken
+ * Parse the WS-Trust RequestSecurityTokenResponse
*
* @author Anil.Saldhana(a)redhat.com
* @since Oct 11, 2010
*/
public class WSTRequestSecurityTokenResponseParser implements ParserNamespaceSupport
{
+ protected Logger log = Logger.getLogger(WSTRequestSecurityTokenResponseParser.class);
+
+ protected boolean trace = log.isTraceEnabled();
+
public static final String X509CERTIFICATE = "X509Certificate";
public static final String KEYVALUE = "KeyValue";
@@ -92,7 +97,7 @@
if (endElementTag.equals(WSTrustConstants.RSTR))
break;
else
- throw new RuntimeException( "Unknown End Element:" +
endElementTag );
+ throw new RuntimeException("Unknown End Element:" +
endElementTag);
}
try
@@ -216,7 +221,7 @@
}
responseToken.setEntropy(entropy);
EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
- StaxParserUtil.validate(endElement, WSTrustConstants.ENTROPY );
+ StaxParserUtil.validate(endElement, WSTrustConstants.ENTROPY);
}
else if (tag.equals(WSTrustConstants.USE_KEY))
{
@@ -275,7 +280,7 @@
}
responseToken.setRequestedProofToken(requestedProofToken);
EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
- StaxParserUtil.validate(endElement,
WSTrustConstants.REQUESTED_PROOF_TOKEN );
+ StaxParserUtil.validate(endElement,
WSTrustConstants.REQUESTED_PROOF_TOKEN);
}
else if (tag.equals(WSTrustConstants.REQUESTED_TOKEN))
{
@@ -292,6 +297,10 @@
else
{
QName qname = subEvent.getName();
+ if (trace)
+ {
+ log.trace("Looking for Parser for :" + qname);
+ }
ParserNamespaceSupport parser = ParserController.get(qname);
if (parser == null)
throw new RuntimeException("Cannot parse " + qname);
@@ -336,13 +345,13 @@
if (xmlEvent instanceof EndElement)
{
String endElementTag = StaxParserUtil.getEndElementName((EndElement)
xmlEvent);
- if ( endElementTag.equals(WSTrustConstants.STATUS))
+ if (endElementTag.equals(WSTrustConstants.STATUS))
{
xmlEvent = StaxParserUtil.getNextEndElement(xmlEventReader);
break;
- }
+ }
else
- throw new RuntimeException( "unknown end element:" +
endElementTag );
+ throw new RuntimeException("unknown end element:" +
endElementTag);
}
startElement = (StartElement) xmlEvent;
String tag = StaxParserUtil.getStartElementName(startElement);
@@ -383,14 +392,14 @@
xmlEvent = StaxParserUtil.peek(xmlEventReader);
if (xmlEvent instanceof EndElement)
{
- String endElementTag = StaxParserUtil.getEndElementName( (EndElement)
xmlEvent );
- if ( endElementTag.equals(WSTrustConstants.REQUESTED_TOKEN))
+ String endElementTag = StaxParserUtil.getEndElementName((EndElement)
xmlEvent);
+ if (endElementTag.equals(WSTrustConstants.REQUESTED_TOKEN))
{
xmlEvent = StaxParserUtil.getNextEndElement(xmlEventReader);
break;
}
else
- throw new RuntimeException( "unknown end element:" +
endElementTag );
+ throw new RuntimeException("unknown end element:" +
endElementTag);
}
Element tokenElement = StaxParserUtil.getDOMElement(xmlEventReader);
requestedSecurityTokenType.setAny(tokenElement);
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustOnBehalfOfParser.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustOnBehalfOfParser.java 2011-05-17
14:55:04 UTC (rev 944)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustOnBehalfOfParser.java 2011-05-17
15:03:46 UTC (rev 945)
@@ -39,28 +39,29 @@
* @since Oct 18, 2010
*/
public class WSTrustOnBehalfOfParser implements ParserNamespaceSupport
-{
+{
/**
* @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
*/
public Object parse(XMLEventReader xmlEventReader) throws ParsingException
- {
+ {
OnBehalfOfType onBehalfType = new OnBehalfOfType();
- StartElement startElement = StaxParserUtil.peekNextStartElement( xmlEventReader );
- String tag = StaxParserUtil.getStartElementName( startElement );
-
- if( tag.equals( WSTrustConstants.WSSE.USERNAME_TOKEN ) )
+ StartElement startElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
+ String tag = StaxParserUtil.getStartElementName(startElement);
+
+ if (tag.equals(WSTrustConstants.WSSE.USERNAME_TOKEN))
{
WSSecurityParser wsseParser = new WSSecurityParser();
-
- UsernameTokenType userNameToken = (UsernameTokenType) wsseParser.parse(
xmlEventReader );
- onBehalfType.setAny( userNameToken );
+
+ UsernameTokenType userNameToken = (UsernameTokenType)
wsseParser.parse(xmlEventReader);
+ onBehalfType.setAny(userNameToken);
}
-
+ else
+ throw new RuntimeException("Unknown tag:" + tag);
+
return onBehalfType;
}
-
/**
* @see {@link ParserNamespaceSupport#supports(QName)}
*/
@@ -68,8 +69,7 @@
{
String nsURI = qname.getNamespaceURI();
String localPart = qname.getLocalPart();
-
- return WSTrustConstants.BASE_NAMESPACE.equals( nsURI )
- && WSTrustConstants.ON_BEHALF_OF.equals( localPart );
- }
+
+ return WSTrustConstants.BASE_NAMESPACE.equals(nsURI) &&
WSTrustConstants.ON_BEHALF_OF.equals(localPart);
+ }
}
\ No newline at end of file
Show replies by date