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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 8 12:07:53 EST 2010


Author: anil.saldhana at jboss.com
Date: 2010-11-08 12:07:52 -0500 (Mon, 08 Nov 2010)
New Revision: 540

Added:
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/WSAddressingConstants.java
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/WSPolicyConstants.java
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/AbstractWSWriter.java
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSAddressingWriter.java
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSPolicyWriter.java
Modified:
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java
Log:
add ws-t writing

Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/WSAddressingConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/WSAddressingConstants.java	                        (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wsa/WSAddressingConstants.java	2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.identity.federation.core.wsa;
+
+/**
+ * WS-Addressing Constants
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 5, 2010
+ */
+public interface WSAddressingConstants
+{ 
+   String ADDRESS = "Address";
+   String ENDPOINT_REFERENCE = "EndpointReference";
+   String WSA_PREFIX = "wsa"; 
+   String WSA_NS = "http://www.w3.org/2005/08/addressing";
+}
\ No newline at end of file

Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/WSPolicyConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/WSPolicyConstants.java	                        (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wspolicy/WSPolicyConstants.java	2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.identity.federation.core.wspolicy;
+
+/**
+ * Constants for WS-Policy
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 5, 2010
+ */
+public interface WSPolicyConstants
+{
+   String APPLIES_TO = "AppliesTo";
+   String WSP_PREFIX = "wsp";
+   String WSP_NS = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+}
\ No newline at end of file

Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/AbstractWSWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/AbstractWSWriter.java	                        (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/AbstractWSWriter.java	2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.identity.federation.core.wstrust.writers;
+
+import java.io.OutputStream;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+
+/**
+ * Base class for the WS Stax Writers
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 5, 2010
+ */
+public class AbstractWSWriter
+{
+   protected XMLStreamWriter writer = null;
+   
+   protected void verifyWriter( OutputStream out ) throws ProcessingException
+   {
+      if( writer == null )
+      {
+         writer = StaxUtil.getXMLStreamWriter( out ); 
+      }
+   }
+
+}
\ No newline at end of file

Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSAddressingWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSAddressingWriter.java	                        (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSAddressingWriter.java	2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.identity.federation.core.wstrust.writers;
+
+
+import static org.picketlink.identity.federation.core.wsa.WSAddressingConstants.ADDRESS;
+import static org.picketlink.identity.federation.core.wsa.WSAddressingConstants.ENDPOINT_REFERENCE;
+import static org.picketlink.identity.federation.core.wsa.WSAddressingConstants.WSA_NS;
+import static org.picketlink.identity.federation.core.wsa.WSAddressingConstants.WSA_PREFIX;
+
+import java.io.OutputStream;
+
+import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.ws.addressing.AttributedURIType;
+import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
+
+/**
+ * Write WS-Addressing Elements
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 5, 2010
+ */
+public class WSAddressingWriter extends AbstractWSWriter
+{
+   public void write( EndpointReferenceType endpointReference, OutputStream out ) throws ProcessingException
+   {
+      verifyWriter(out);
+      
+      StaxUtil.writeStartElement( writer, WSA_PREFIX, ENDPOINT_REFERENCE, WSA_NS );   
+      StaxUtil.writeNameSpace( writer, WSA_PREFIX, WSA_NS );
+       
+      AttributedURIType attributedURI = endpointReference.getAddress();
+      if( attributedURI != null )
+      {
+         String value = attributedURI.getValue();
+         
+         StaxUtil.writeStartElement( writer, WSA_PREFIX, ADDRESS, WSA_NS );  
+         StaxUtil.writeCharacters( writer, value );
+         StaxUtil.writeEndElement( writer ); 
+      } 
+
+      StaxUtil.writeEndElement( writer ); 
+      StaxUtil.flush( writer ); 
+   } 
+}
\ No newline at end of file

Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSPolicyWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSPolicyWriter.java	                        (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSPolicyWriter.java	2010-11-08 17:07:52 UTC (rev 540)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.identity.federation.core.wstrust.writers;
+
+
+import static org.picketlink.identity.federation.core.wspolicy.WSPolicyConstants.APPLIES_TO;
+import static org.picketlink.identity.federation.core.wspolicy.WSPolicyConstants.WSP_PREFIX;
+import static org.picketlink.identity.federation.core.wstrust.WSTrustConstants.WSP_NS;
+
+import java.io.OutputStream;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
+import org.picketlink.identity.federation.ws.policy.AppliesTo;
+
+/**
+ * Write the WS-Policy Elements
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 5, 2010
+ */
+public class WSPolicyWriter extends AbstractWSWriter
+{
+   /**
+    * Write an {@code AppliesTo} to the stream
+    * @param appliesTo
+    * @param out
+    * @throws ProcessingException
+    */
+   public void write( AppliesTo appliesTo, OutputStream out ) throws ProcessingException
+   {
+      verifyWriter(out); 
+
+      StaxUtil.writeStartElement( writer, WSP_PREFIX, APPLIES_TO, WSP_NS );   
+      StaxUtil.writeNameSpace( writer, WSP_PREFIX, WSP_NS );
+      StaxUtil.writeCharacters(writer, "" ); //Seems like JDK bug - not writing end character
+      
+      List<Object> contentList = appliesTo.getAny();
+      if( contentList != null )
+      {
+         for( Object content: contentList )
+         {
+            JAXBElement<?> jaxb = (JAXBElement<?>) content;
+            if( EndpointReferenceType.class.equals( jaxb.getDeclaredType() ) )
+            {
+               EndpointReferenceType endpointReference = (EndpointReferenceType) jaxb.getValue();
+               WSAddressingWriter wsAddressingWriter = new WSAddressingWriter();
+               wsAddressingWriter.write(endpointReference, out);
+            }
+         }
+      }
+
+      StaxUtil.writeEndElement( writer ); 
+      StaxUtil.flush( writer );
+   } 
+}
\ No newline at end of file

Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java	2010-11-08 17:06:59 UTC (rev 539)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/writers/WSTrustRSTWriter.java	2010-11-08 17:07:52 UTC (rev 540)
@@ -36,6 +36,8 @@
 import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
 import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
 import org.picketlink.identity.federation.ws.policy.AppliesTo;
+import org.picketlink.identity.federation.ws.trust.UseKeyType;
+import org.w3c.dom.Element;
 
 /**
  * Given a {@code RequestSecurityToken}, write into an {@code OutputStream}
@@ -85,6 +87,19 @@
          StaxUtil.writeEndElement( writer ); 
       }
       
+      UseKeyType useKeyType = requestToken.getUseKey();
+      if( useKeyType != null )
+      {
+         Object useKeyTypeValue = useKeyType.getAny();
+         if( useKeyTypeValue instanceof Element )
+         {
+            Element domElement = (Element) useKeyTypeValue;
+            StaxUtil.writeDOMElement( writer, domElement ); 
+         }
+         else
+            throw new RuntimeException( " Unknown use key type:" + useKeyTypeValue.getClass().getName() );
+      }
+      
       StaxUtil.writeEndElement( writer ); 
       StaxUtil.flush( writer );
    }



More information about the jboss-cvs-commits mailing list