[jboss-cvs] Picketlink SVN: r206 - in federation/trunk: picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 13 13:58:57 EDT 2010


Author: sguilhen at redhat.com
Date: 2010-04-13 13:58:56 -0400 (Tue, 13 Apr 2010)
New Revision: 206

Modified:
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/DocumentUtil.java
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/PicketLinkSTS.java
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClient.java
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustJAXBFactory.java
   federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/SOAPSAMLXACMLServlet.java
Log:
PLFED-60: STSClient and WSTrustJAXBFactory now first transform the incoming Source object to DOMResult in order to get the Document node. The previous cast to DOMSource has been removed as it resulted in CCE being thrown when JDK6 classes were used to invoke the STS

Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/DocumentUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/DocumentUtil.java	2010-04-09 19:27:55 UTC (rev 205)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/DocumentUtil.java	2010-04-13 17:58:56 UTC (rev 206)
@@ -31,16 +31,17 @@
 import java.io.StringWriter;
 
 import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory; 
+import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
-import javax.xml.transform.Transformer; 
+import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory; 
+import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.xpath.XPathException;
@@ -63,37 +64,37 @@
  * @since Jan 14, 2009
  */
 public class DocumentUtil
-{ 
+{
    private static Logger log = Logger.getLogger(DocumentUtil.class);
+
    private static boolean trace = log.isTraceEnabled();
-   
-   
+
    /**
     * Check whether a node belongs to a document
     * @param doc
     * @param node
     * @return 
     */
-   public static boolean containsNode(Document doc, Node node)  
-   {  
-     if(node.getNodeType() == Node.ELEMENT_NODE)
-     {
-        Element elem = (Element) node;
-        NodeList nl = doc.getElementsByTagNameNS(elem.getNamespaceURI(), elem.getLocalName());
-        if(nl != null && nl.getLength() > 0)
-           return true;
-        else
-           return false;
-     }
-     throw new UnsupportedOperationException();
+   public static boolean containsNode(Document doc, Node node)
+   {
+      if (node.getNodeType() == Node.ELEMENT_NODE)
+      {
+         Element elem = (Element) node;
+         NodeList nl = doc.getElementsByTagNameNS(elem.getNamespaceURI(), elem.getLocalName());
+         if (nl != null && nl.getLength() > 0)
+            return true;
+         else
+            return false;
+      }
+      throw new UnsupportedOperationException();
    }
-   
+
    /**
     * Create a new document
     * @return
     * @throws ParserConfigurationException  
     */
-   public static Document createDocument() throws ConfigurationException 
+   public static Document createDocument() throws ConfigurationException
    {
       DocumentBuilderFactory factory = getDocumentBuilderFactory();
       DocumentBuilder builder;
@@ -105,7 +106,7 @@
       {
          throw new ConfigurationException(e);
       }
-      return builder.newDocument(); 
+      return builder.newDocument();
    }
 
    /**
@@ -116,12 +117,12 @@
     * @throws SAXException 
     * @throws ParserConfigurationException 
     */
-   public static Document getDocument(String docString) 
-   throws ConfigurationException,ParsingException, ProcessingException
+   public static Document getDocument(String docString) throws ConfigurationException, ParsingException,
+         ProcessingException
    {
       return getDocument(new StringReader(docString));
    }
-   
+
    /**
     * Parse a document from a reader
     * @param reader
@@ -131,8 +132,8 @@
     * @throws IOException 
     * @throws SAXException 
     */
-   public static Document getDocument(Reader reader) 
-   throws ConfigurationException, ProcessingException, ParsingException 
+   public static Document getDocument(Reader reader) throws ConfigurationException, ProcessingException,
+         ParsingException
    {
       try
       {
@@ -153,7 +154,7 @@
          throw new ProcessingException(e);
       }
    }
-   
+
    /**
     * Get Document from a file
     * @param file
@@ -162,13 +163,12 @@
     * @throws IOException 
     * @throws SAXException 
     */
-   public static Document getDocument(File file) 
-   throws ConfigurationException, ProcessingException, ParsingException 
+   public static Document getDocument(File file) throws ConfigurationException, ProcessingException, ParsingException
    {
-      DocumentBuilderFactory factory = getDocumentBuilderFactory(); 
+      DocumentBuilderFactory factory = getDocumentBuilderFactory();
       try
       {
-         DocumentBuilder builder = factory.newDocumentBuilder(); 
+         DocumentBuilder builder = factory.newDocumentBuilder();
          return builder.parse(file);
       }
       catch (ParserConfigurationException e)
@@ -184,7 +184,7 @@
          throw new ProcessingException(e);
       }
    }
-   
+
    /**
     * Get Document from an inputstream
     * @param is
@@ -193,13 +193,13 @@
     * @throws IOException 
     * @throws SAXException 
     */
-   public static Document getDocument(InputStream is) 
-   throws ConfigurationException, ProcessingException, ParsingException 
+   public static Document getDocument(InputStream is) throws ConfigurationException, ProcessingException,
+         ParsingException
    {
-      DocumentBuilderFactory factory = getDocumentBuilderFactory(); 
+      DocumentBuilderFactory factory = getDocumentBuilderFactory();
       try
       {
-         DocumentBuilder builder = factory.newDocumentBuilder(); 
+         DocumentBuilder builder = factory.newDocumentBuilder();
          return builder.parse(is);
       }
       catch (ParserConfigurationException e)
@@ -215,7 +215,7 @@
          throw new ProcessingException(e);
       }
    }
-   
+
    /**
     * Marshall a document into a String
     * @param signedDoc
@@ -223,27 +223,26 @@
     * @throws TransformerFactoryConfigurationError 
     * @throws TransformerException  
     */
-   public static String getDocumentAsString(Document signedDoc) 
-   throws ProcessingException, ConfigurationException
+   public static String getDocumentAsString(Document signedDoc) throws ProcessingException, ConfigurationException
    {
-     Source source = new DOMSource(signedDoc);
-     StringWriter sw = new StringWriter();
- 
-     Result streamResult = new StreamResult(sw);
-     // Write the DOM document to the stream
-     Transformer xformer = getTransformer();
-     try
-     {
-        xformer.transform(source, streamResult);
-     }
-     catch (TransformerException e)
-     {
-        throw new ProcessingException(e);
-     }
-     
-     return sw.toString();
+      Source source = new DOMSource(signedDoc);
+      StringWriter sw = new StringWriter();
+
+      Result streamResult = new StreamResult(sw);
+      // Write the DOM document to the stream
+      Transformer xformer = getTransformer();
+      try
+      {
+         xformer.transform(source, streamResult);
+      }
+      catch (TransformerException e)
+      {
+         throw new ProcessingException(e);
+      }
+
+      return sw.toString();
    }
- 
+
    /**
     * Marshall a DOM Element as string
     * @param element
@@ -251,27 +250,26 @@
     * @throws TransformerFactoryConfigurationError 
     * @throws TransformerException  
     */
-   public static String getDOMElementAsString(Element element) 
-   throws ProcessingException, ConfigurationException
+   public static String getDOMElementAsString(Element element) throws ProcessingException, ConfigurationException
    {
-     Source source = new DOMSource(element);
-     StringWriter sw = new StringWriter();
- 
-     Result streamResult = new StreamResult(sw);
-     // Write the DOM document to the file
-     Transformer xformer = getTransformer();
-     try
-     {
-        xformer.transform(source, streamResult);
-     }
-     catch (TransformerException e)
-     {
-        throw new ProcessingException(e);
-     }
-     
-     return sw.toString();
+      Source source = new DOMSource(element);
+      StringWriter sw = new StringWriter();
+
+      Result streamResult = new StreamResult(sw);
+      // Write the DOM document to the file
+      Transformer xformer = getTransformer();
+      try
+      {
+         xformer.transform(source, streamResult);
+      }
+      catch (TransformerException e)
+      {
+         throw new ProcessingException(e);
+      }
+
+      return sw.toString();
    }
-   
+
    /**
     * Stream a DOM Node as an input stream
     * @param node
@@ -279,12 +277,11 @@
     * @throws TransformerFactoryConfigurationError 
     * @throws TransformerException  
     */
-   public static InputStream getNodeAsStream(Node node) 
-   throws ConfigurationException, ProcessingException 
+   public static InputStream getNodeAsStream(Node node) throws ConfigurationException, ProcessingException
    {
       Source source = new DOMSource(node);
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      
+
       Result streamResult = new StreamResult(baos);
       // Write the DOM document to the stream
       Transformer transformer = getTransformer();
@@ -296,12 +293,12 @@
       {
          throw new ProcessingException(e);
       }
-      
+
       ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
-      
+
       return bis;
    }
-   
+
    /**
     * Stream a DOM Node as a String
     * @param node
@@ -310,12 +307,11 @@
     * @throws TransformerFactoryConfigurationError 
     * @throws TransformerException  
     */
-   public static String getNodeAsString(Node node) 
-   throws ConfigurationException, ProcessingException 
+   public static String getNodeAsString(Node node) throws ConfigurationException, ProcessingException
    {
       Source source = new DOMSource(node);
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      
+
       Result streamResult = new StreamResult(baos);
       // Write the DOM document to the stream
       Transformer transformer = getTransformer();
@@ -327,10 +323,10 @@
       {
          throw new ProcessingException(e);
       }
-      
-      return new String(baos.toByteArray()); 
+
+      return new String(baos.toByteArray());
    }
-   
+
    /**
     * Given a document, return a Node with the given node name
     * and an attribute with a particular attribute value
@@ -343,32 +339,31 @@
     * @throws XPathException
     * @throws TransformerFactoryConfigurationError
     * @throws TransformerException
-    */ 
-   public static Node getNodeWithAttribute(Document document, final String nsURI,
-         String nodeName,
-         String attributeName, String attributeValue) throws XPathException,
-         TransformerFactoryConfigurationError, TransformerException
+    */
+   public static Node getNodeWithAttribute(Document document, final String nsURI, String nodeName,
+         String attributeName, String attributeValue) throws XPathException, TransformerFactoryConfigurationError,
+         TransformerException
    {
       NodeList nl = document.getElementsByTagNameNS(nsURI, nodeName);
       int len = nl != null ? nl.getLength() : 0;
-      
+
       for (int i = 0; i < len; i++)
       {
          Node n = nl.item(i);
-         if(n.getNodeType() != Node.ELEMENT_NODE)
-            continue; 
+         if (n.getNodeType() != Node.ELEMENT_NODE)
+            continue;
          Element el = (Element) n;
          String attrValue = el.getAttributeNS(nsURI, attributeName);
-         if(attributeValue.equals(attrValue))
+         if (attributeValue.equals(attrValue))
             return el;
          //Take care of attributes with null NS
          attrValue = el.getAttribute(attributeName);
-         if(attributeValue.equals(attrValue))
+         if (attributeValue.equals(attrValue))
             return el;
       }
       return null;
    }
-   
+
    /**
     * DOM3 method: Normalize the document with namespaces
     * @param doc
@@ -376,12 +371,12 @@
     */
    public static Document normalizeNamespaces(Document doc)
    {
-      DOMConfiguration docConfig = doc.getDomConfig(); 
-      docConfig.setParameter("namespaces", Boolean.TRUE);  
+      DOMConfiguration docConfig = doc.getDomConfig();
+      docConfig.setParameter("namespaces", Boolean.TRUE);
       doc.normalizeDocument();
       return doc;
    }
-   
+
    /**
     * Get a {@link Source} given a {@link Document}
     * @param doc
@@ -391,7 +386,7 @@
    {
       return new DOMSource(doc);
    }
-   
+
    /**
     * Get the document as a string while
     * ignoring any exceptions
@@ -401,54 +396,69 @@
    public static String asString(Document doc)
    {
       String str = null;
-      
+
       try
       {
-         str = getDocumentAsString(doc);   
+         str = getDocumentAsString(doc);
       }
-      catch(Exception ignore)
-      {}
+      catch (Exception ignore)
+      {
+      }
       return str;
    }
-   
+
    /**
     * Log the nodes in the document
     * @param doc
     */
    public static void logNodes(Document doc)
    {
-     visit(doc, 0); 
-   } 
-    
-   private static void visit(Node node, int level) 
-   { 
+      visit(doc, 0);
+   }
+
+   public static Node getNodeFromSource(Source source) throws ProcessingException, ConfigurationException
+   {
+      try
+      {
+         Transformer transformer = getTransformer();
+         DOMResult result = new DOMResult();
+         transformer.transform(source, result);
+         return result.getNode();
+      }
+      catch (TransformerException te)
+      {
+         throw new ProcessingException(te);
+      }
+   }
+
+   private static void visit(Node node, int level)
+   {
       // Visit each child
       NodeList list = node.getChildNodes();
-      for (int i=0; i<list.getLength(); i++) 
+      for (int i = 0; i < list.getLength(); i++)
       {
          // Get child node
          Node childNode = list.item(i);
-         if(trace) 
-            log.trace("Node="+ childNode.getNamespaceURI()+ "::"+childNode.getLocalName());
+         if (trace)
+            log.trace("Node=" + childNode.getNamespaceURI() + "::" + childNode.getLocalName());
          // Visit child node
-         visit(childNode, level+1);
+         visit(childNode, level + 1);
       }
    }
-   
+
    /**
     * Create a namespace aware Document builder factory
     * @return
     */
    private static DocumentBuilderFactory getDocumentBuilderFactory()
    {
-      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
+      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
       factory.setNamespaceAware(true);
       factory.setXIncludeAware(true);
       return factory;
    }
-   
-   private static Transformer getTransformer() 
-   throws ProcessingException, ConfigurationException
+
+   private static Transformer getTransformer() throws ProcessingException, ConfigurationException
    {
       Transformer transformer;
       try
@@ -457,12 +467,12 @@
       }
       catch (TransformerConfigurationException e)
       {
-        throw new ConfigurationException(e);
+         throw new ConfigurationException(e);
       }
       catch (TransformerFactoryConfigurationError e)
       {
          throw new ConfigurationException(e);
-      } 
+      }
       transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
       transformer.setOutputProperty(OutputKeys.INDENT, "no");
       return transformer;

Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/PicketLinkSTS.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/PicketLinkSTS.java	2010-04-09 19:27:55 UTC (rev 205)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/PicketLinkSTS.java	2010-04-13 17:58:56 UTC (rev 206)
@@ -37,7 +37,6 @@
 import org.apache.log4j.Logger;
 import org.picketlink.identity.federation.core.config.STSType;
 import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
-import org.picketlink.identity.federation.core.exceptions.ParsingException;
 import org.picketlink.identity.federation.core.saml.v2.common.SAMLDocumentHolder;
 import org.picketlink.identity.federation.core.util.JAXBUtil;
 import org.picketlink.identity.federation.core.wstrust.wrappers.BaseRequestSecurityToken;
@@ -81,9 +80,9 @@
       {
          baseRequest = WSTrustJAXBFactory.getInstance().parseRequestSecurityToken(request);
       }
-      catch (ParsingException e)
+      catch (WSTrustException we)
       {
-         throw new RuntimeException(e);
+         throw new RuntimeException(we);
       }
       
       if (baseRequest instanceof RequestSecurityToken)

Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClient.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClient.java	2010-04-09 19:27:55 UTC (rev 205)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/STSClient.java	2010-04-13 17:58:56 UTC (rev 206)
@@ -37,9 +37,6 @@
 import javax.xml.ws.soap.SOAPBinding;
 
 import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
-import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
-import org.picketlink.identity.federation.core.wstrust.WSTrustException;
-import org.picketlink.identity.federation.core.wstrust.WSTrustJAXBFactory;
 import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
 import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityTokenResponse;
 import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityTokenResponseCollection;
@@ -153,13 +150,13 @@
       DOMSource requestSource = (DOMSource) jaxbFactory.marshallRequestSecurityToken(request);
       Source response = dispatchLocal.get().invoke(requestSource);
 
-      Node documentNode = ((DOMSource) response).getNode();
-      Document responseDoc = documentNode instanceof Document ? (Document) documentNode : documentNode
-            .getOwnerDocument();
-
       NodeList nodes;
       try
       {
+         Node documentNode = DocumentUtil.getNodeFromSource(response);
+         Document responseDoc = documentNode instanceof Document ? (Document) documentNode : documentNode
+               .getOwnerDocument();
+
          Document myDocument = DocumentUtil.createDocument();
          Node importedNode = myDocument.importNode(responseDoc.getDocumentElement(), true);
          myDocument.appendChild(importedNode);

Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustJAXBFactory.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustJAXBFactory.java	2010-04-09 19:27:55 UTC (rev 205)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustJAXBFactory.java	2010-04-13 17:58:56 UTC (rev 206)
@@ -27,10 +27,8 @@
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
 
 import org.apache.log4j.Logger;
-import org.picketlink.identity.federation.core.exceptions.ParsingException;
 import org.picketlink.identity.federation.core.saml.v2.common.SAMLDocumentHolder;
 import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
 import org.picketlink.identity.federation.core.util.JAXBUtil;
@@ -57,18 +55,19 @@
 public class WSTrustJAXBFactory
 {
    private static Logger log = Logger.getLogger(WSTrustJAXBFactory.class);
+
    private boolean trace = log.isTraceEnabled();
-   
+
    private static final WSTrustJAXBFactory instance = new WSTrustJAXBFactory();
 
    private Marshaller marshaller;
 
    private Unmarshaller unmarshaller;
-   
+
    private Binder<Node> binder;
 
    private final ObjectFactory objectFactory;
-   
+
    private ThreadLocal<SAMLDocumentHolder> holders = new ThreadLocal<SAMLDocumentHolder>();
 
    /**
@@ -124,33 +123,33 @@
     * @return the constructed {@code BaseRequestSecurityToken} instance. It will be an instance of {@code
     *         RequestSecurityToken} the message contains a single token request, and an instance of {@code
     *         RequestSecurityTokenCollection} if multiples requests are being made in the same message.
-    * @throws ParsingException 
     */
    @SuppressWarnings("unchecked")
-   public BaseRequestSecurityToken parseRequestSecurityToken(Source request) throws ParsingException
+   public BaseRequestSecurityToken parseRequestSecurityToken(Source request) throws WSTrustException
    {
       // if the request contains a validate, cancel, or renew target, we must preserve it from JAXB unmarshalling.
-	  Node documentNode = ((DOMSource) request).getNode();
-      Document document = documentNode instanceof Document ? (Document) documentNode : documentNode.getOwnerDocument();
-      
-      JAXBElement<RequestSecurityTokenType> jaxbRST;
       try
       {
+         Node documentNode = DocumentUtil.getNodeFromSource(request);
+         Document document = documentNode instanceof Document ? (Document) documentNode : documentNode
+               .getOwnerDocument();
+
+         JAXBElement<RequestSecurityTokenType> jaxbRST;
          Node rst = this.findNodeByNameNS(document, "RequestSecurityToken", WSTrustConstants.BASE_NAMESPACE);
-         if(rst == null)
+         if (rst == null)
             throw new RuntimeException("Request Security Token node not found");
-         
+
          jaxbRST = (JAXBElement<RequestSecurityTokenType>) binder.unmarshal(rst);
 
          RequestSecurityTokenType rstt = jaxbRST.getValue();
-         
+
          SAML2SecurityToken samlSecurityToken = new SAML2SecurityToken(rstt);
          holders.set(new SAMLDocumentHolder(samlSecurityToken, document));
          return new RequestSecurityToken(rstt);
       }
-      catch (JAXBException e)
+      catch (Exception e)
       {
-         throw new ParsingException(e);
+         throw new WSTrustException("Error parsing security token request", e);
       }
    }
 
@@ -165,11 +164,20 @@
     *         specification, the returned object will be an instance of {@code RequestSecurityTokenResponseCollection}.
     */
    @SuppressWarnings("unchecked")
-   public BaseRequestSecurityTokenResponse parseRequestSecurityTokenResponse(Source response)
+   public BaseRequestSecurityTokenResponse parseRequestSecurityTokenResponse(Source response) throws WSTrustException
    {
       // if the response contains an issued token, we must preserve it from the JAXB unmarshalling.
       Element tokenElement = null;
-	  Node documentNode = ((DOMSource) response).getNode();
+      Node documentNode = null;
+      try
+      {
+         documentNode = DocumentUtil.getNodeFromSource(response);
+      }
+      catch (Exception e)
+      {
+         throw new WSTrustException("Failed to transform request source", e);
+      }
+
       Document document = documentNode instanceof Document ? (Document) documentNode : documentNode.getOwnerDocument();
       Node requestedTokenNode = this.findNodeByNameNS(document, "RequestedSecurityToken",
             WSTrustConstants.BASE_NAMESPACE);
@@ -178,10 +186,10 @@
 
       try
       {
-         Object object = this.unmarshaller.unmarshal(response);
+         Object object = this.unmarshaller.unmarshal(documentNode);
          if (object instanceof JAXBElement)
          {
-            JAXBElement<?> element = (JAXBElement<?>) unmarshaller.unmarshal(response);
+            JAXBElement<?> element = (JAXBElement<?>) object;
             if (element.getDeclaredType().equals(RequestSecurityTokenResponseCollectionType.class))
             {
                RequestSecurityTokenResponseCollection collection = new RequestSecurityTokenResponseCollection(
@@ -200,7 +208,7 @@
          else
             throw new RuntimeException("Invalid response type: " + object.getClass().getName());
       }
-      catch (Exception e)
+      catch (JAXBException e)
       {
          throw new RuntimeException("Failed to unmarshall security token response", e);
       }
@@ -252,7 +260,7 @@
                node = this.findNodeByNameNS(result, "RenewTarget", WSTrustConstants.BASE_NAMESPACE);
             else if (requestType.equalsIgnoreCase(WSTrustConstants.CANCEL_REQUEST))
                node = this.findNodeByNameNS(result, "CancelTarget", WSTrustConstants.BASE_NAMESPACE);
-            if(node == null)
+            if (node == null)
                throw new RuntimeException("Unsupported request type:" + requestType);
             node.appendChild(result.importNode(targetElement, true));
          }
@@ -304,11 +312,11 @@
             Node node = this.findNodeByNameNS(result, "RequestedSecurityToken", WSTrustConstants.BASE_NAMESPACE);
             node.appendChild(result.importNode(tokenElement, true));
          }
-         if(trace)
+         if (trace)
          {
-            log.trace("Final RSTR doc:" + DocumentUtil.asString(result)); 
+            log.trace("Final RSTR doc:" + DocumentUtil.asString(result));
          }
-            
+
       }
       catch (Exception e)
       {
@@ -316,7 +324,7 @@
       }
       return DocumentUtil.getXMLSource(result);
    }
-   
+
    /**
     * Return the {@code SAMLDocumentHolder} for the thread
     * @return
@@ -350,26 +358,4 @@
       return list.item(0);
    }
 
-   /**
-    * <p>
-    * Searches the specified document for an element that represents a validate, renew, or cancel target.
-    * </p>
-    * 
-    * @param document
-    *           the {@code Document} upon which the search is to be made.
-    * @return an {@code Element} representing the validate, renew, or cancel target.
-    */
-   /*private Element getValidateOrRenewOrCancelTarget(Document document)
-   {
-      Node target = this.findNodeByNameNS(document, "ValidateTarget", WSTrustConstants.BASE_NAMESPACE);
-      if (target != null)
-         return (Element) target.getFirstChild();
-      target = this.findNodeByNameNS(document, "RenewTarget", WSTrustConstants.BASE_NAMESPACE);
-      if (target != null)
-         return (Element) target.getFirstChild();
-      target = this.findNodeByNameNS(document, "CancelTarget", WSTrustConstants.BASE_NAMESPACE);
-      if (target != null)
-         return (Element) target.getFirstChild();
-      return null;
-   }*/
 }
\ No newline at end of file

Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/SOAPSAMLXACMLServlet.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/SOAPSAMLXACMLServlet.java	2010-04-09 19:27:55 UTC (rev 205)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/SOAPSAMLXACMLServlet.java	2010-04-13 17:58:56 UTC (rev 206)
@@ -173,7 +173,6 @@
                Object samlRequest = soapBody.getAny().get(0);
                if(samlRequest instanceof JAXBElement)
                {
-                  jaxbRequestType = (JAXBElement<RequestAbstractType>)samlRequest; 
                   jaxbRequestType = (JAXBElement<RequestAbstractType>)samlRequest;
                   xacmlRequest = (XACMLAuthzDecisionQueryType) jaxbRequestType.getValue();
                }




More information about the jboss-cvs-commits mailing list