axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r452404 - in /webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy: ./ model/
Date Tue, 03 Oct 2006 10:39:30 GMT
Author: sanka
Date: Tue Oct  3 03:39:29 2006
New Revision: 452404

URL: http://svn.apache.org/viewvc?view=rev&rev=452404
Log:
Completed the serialization method of most of the Security Assertions.


Modified:
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/AbstractSecurityAssertion.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Binding.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/EncryptionToken.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/IssuedToken.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/ProtectionToken.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SecureConversationToken.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignatureToken.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignedEncryptedElements.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SymmetricBinding.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Wss11.java

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java
Tue Oct  3 03:39:29 2006
@@ -186,6 +186,9 @@
 
     // /////////////////////////////////////////////////////////////////////
 
+    public static final QName ATTR_XPATH_VERSION = new QName(SP_NS, "XPathVersion", Constants.SP_PREFIX);
+    
+    ////////////////////////////////////////////////////////////////////////
     public static final QName INCLUDE_TOKEN = new QName(SP_NS, "IncludeToken",
             Constants.SP_PREFIX);
 
@@ -410,4 +413,7 @@
 
     public final static QName REQUIRE_CLIENT_CERTIFICATE = new QName(
             "RequireClientCertificate");
+
+    public final static QName XPATH_ = new QName(Constants.SP_NS, "XPath",
+            Constants.SP_PREFIX);
 }

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/AbstractSecurityAssertion.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/AbstractSecurityAssertion.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/AbstractSecurityAssertion.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/AbstractSecurityAssertion.java
Tue Oct  3 03:39:29 2006
@@ -19,11 +19,11 @@
 import org.apache.neethi.Constants;
 import org.apache.neethi.PolicyComponent;
 
-public abstract class AbstractSecurityAssertion implements Assertion{
-    
-    private boolean normalized = false;
+public abstract class AbstractSecurityAssertion implements Assertion {
 
     private boolean isOptional;
+    
+    private boolean normalized = false;
 
     public boolean isOptional() {
         return isOptional;
@@ -46,6 +46,14 @@
     }
     
     public boolean isNormalized() {
-        return normalized;
+        return true;
     }
+
+    public PolicyComponent normalize() {
+        
+        /*
+         * TODO: Handling the isOptional:TRUE case
+         */
+        return this;
+    }    
 }

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Binding.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Binding.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Binding.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Binding.java
Tue Oct  3 03:39:29 2006
@@ -82,8 +82,4 @@
     public void setSignedSupportingToken(SupportingToken signedSupportingToken) {
         this.signedSupportingToken = signedSupportingToken;
     }
-    
-    
-    
-    
 }

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/EncryptionToken.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/EncryptionToken.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/EncryptionToken.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/EncryptionToken.java
Tue Oct  3 03:39:29 2006
@@ -20,7 +20,6 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
-import org.apache.neethi.PolicyComponent;
 import org.apache.ws.secpolicy.Constants;
 
 public class EncryptionToken extends AbstractSecurityAssertion implements TokenWrapper {
@@ -49,13 +48,61 @@
         return Constants.ENCRYPTION_TOKEN;
     }
 
-    public PolicyComponent normalize() {
-        throw new UnsupportedOperationException();
-    }
-
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-        throw new UnsupportedOperationException();
+        String localname = Constants.ENCRYPTION_TOKEN.getLocalPart();
+        String namespaceURI = Constants.ENCRYPTION_TOKEN.getNamespaceURI();
+        String prefix;
+        
+        String writerPrefix = writer.getPrefix(namespaceURI);
+        
+        if (writerPrefix == null) {
+            prefix = Constants.ENCRYPTION_TOKEN.getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        } else {
+            prefix = writerPrefix;
+        }
+        
+        // <sp:EncryptionToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+        
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+        
+        
+        String wspNamespaceURI = Constants.POLICY.getNamespaceURI();
+        
+        String wspPrefix;
+        
+        String wspWriterPrefix = writer.getPrefix(wspNamespaceURI);
+        
+        if (wspWriterPrefix == null) {
+            wspPrefix = Constants.POLICY.getPrefix();
+            writer.setPrefix(wspPrefix, wspNamespaceURI);
+            
+        } else {
+            wspPrefix = wspWriterPrefix;
+        }
+        
+        // <wsp:Policy>
+        writer.writeStartElement(wspPrefix, Constants.POLICY.getLocalPart(), wspNamespaceURI);
+        
+        if (wspWriterPrefix == null) {
+            // xmlns:wsp=".."
+            writer.writeNamespace(wspPrefix, wspNamespaceURI);
+        }
+        
+        if (encryptionToken == null) {
+            throw new RuntimeException("EncryptionToken is not set");
+        }
+        
+        encryptionToken.serialize(writer);
+        
+        // </wsp:Policy>
+        writer.writeEndElement();
+        
+        // </sp:EncryptionToken>
+        writer.writeEndElement();
     }
-    
-    
 }

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/IssuedToken.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/IssuedToken.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/IssuedToken.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/IssuedToken.java
Tue Oct  3 03:39:29 2006
@@ -28,13 +28,15 @@
  * Model bean for the IssuedToken assertion.
  */
 public class IssuedToken extends Token {
-    
+
     private OMElement issuerEpr;
+
     private OMElement rstTemplate;
-    
+
     boolean requireExternalReference;
+
     boolean requireInternalReference;
-    
+
     /**
      * @return Returns the issuerEpr.
      */
@@ -43,7 +45,8 @@
     }
 
     /**
-     * @param issuerEpr The issuerEpr to set.
+     * @param issuerEpr
+     *            The issuerEpr to set.
      */
     public void setIssuerEpr(OMElement issuerEpr) {
         this.issuerEpr = issuerEpr;
@@ -57,7 +60,8 @@
     }
 
     /**
-     * @param requireExternalReference The requireExternalReference to set.
+     * @param requireExternalReference
+     *            The requireExternalReference to set.
      */
     public void setRequireExternalReference(boolean requireExternalReference) {
         this.requireExternalReference = requireExternalReference;
@@ -71,7 +75,8 @@
     }
 
     /**
-     * @param requireInternalReference The requireInternalReference to set.
+     * @param requireInternalReference
+     *            The requireInternalReference to set.
      */
     public void setRequireInternalReference(boolean requireInternalReference) {
         this.requireInternalReference = requireInternalReference;
@@ -85,33 +90,106 @@
     }
 
     /**
-     * @param rstTemplate The rstTemplate to set.
+     * @param rstTemplate
+     *            The rstTemplate to set.
      */
     public void setRstTemplate(OMElement rstTemplate) {
         this.rstTemplate = rstTemplate;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.neethi.Assertion#getName()
-     */
     public QName getName() {
         return Constants.ISSUED_TOKEN;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.neethi.Assertion#normalize()
-     */
-    public PolicyComponent normalize() {
-        // TODO TODO sanka
-        throw new UnsupportedOperationException("TODO sanka");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.neethi.PolicyComponent#serialize(javax.xml.stream.XMLStreamWriter)
-     */
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-        // TODO TODO sanka
-        throw new UnsupportedOperationException("TODO sanka");
+        String localname = Constants.ISSUED_TOKEN.getLocalPart();
+        String namespaceURI = Constants.ISSUED_TOKEN.getNamespaceURI();
+
+        String prefix;
+        String writerPrefix = writer.getPrefix(namespaceURI);
+
+        if (writerPrefix == null) {
+            prefix = Constants.ISSUED_TOKEN.getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+
+        } else {
+            prefix = writerPrefix;
+        }
+
+        // <sp:IssuedToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+        if (writerPrefix == null) {
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+
+        String inclusion = getInclusion();
+        if (inclusion != null) {
+            writer.writeAttribute(prefix, namespaceURI,
+                    Constants.ATTR_INCLUDE_TOKEN, inclusion);
+        }
+
+        if (issuerEpr != null) {
+            writer.writeStartElement(prefix, Constants.ISSUER.getLocalPart(),
+                    namespaceURI);
+            issuerEpr.serialize(writer);
+            writer.writeEndElement();
+        }
+
+        if (rstTemplate != null) {
+            // <sp:RequestSecurityTokenTemplate>
+            writer.writeStartElement(prefix,
+                    Constants.REQUEST_SECURITY_TOKEN_TEMPLATE.getLocalPart(),
+                    namespaceURI);
+
+            rstTemplate.serialize(writer);
+
+            // </sp:RequestSecurityTokenTemplate>
+            writer.writeEndElement();
+        }
+
+        String policyLocalName = Constants.PROTECTION_TOKEN.getLocalPart();
+        String policyNamespaceURI = Constants.PROTECTION_TOKEN
+                .getNamespaceURI();
+
+        String wspPrefix;
+
+        String wspWriterPrefix = writer.getPrefix(policyNamespaceURI);
+
+        if (wspWriterPrefix == null) {
+            wspPrefix = Constants.PROTECTION_TOKEN.getPrefix();
+            writer.setPrefix(wspPrefix, policyNamespaceURI);
+        } else {
+            wspPrefix = wspWriterPrefix;
+        }
+
+        if (isRequireExternalReference() || isRequireInternalReference()) {
+
+            // <wsp:Policy>
+            writer.writeStartElement(wspPrefix, policyLocalName,
+                    policyNamespaceURI);
+
+            if (wspWriterPrefix == null) {
+                // xmlns:wsp=".."
+                writer.writeNamespace(wspPrefix, policyNamespaceURI);
+            }
+
+            if (isRequireExternalReference()) {
+                // <sp:RequireExternalReference />
+                writer.writeEmptyElement(prefix, Constants.REQUIRE_EXTERNAL_REFERNCE.getLocalPart(),
namespaceURI);
+            }
+            
+            if (isRequireInternalReference()) {
+                // <sp:RequireInternalReference />
+                writer.writeEmptyElement(prefix, Constants.REQUIRE_INTERNAL_REFERNCE.getLocalPart(),
namespaceURI);
+            }
+            
+            // <wsp:Policy>
+            writer.writeEndElement();
+        }
+
+        // </sp:IssuedToken>
+        writer.writeEndElement();
     }
 
 }

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/ProtectionToken.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/ProtectionToken.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/ProtectionToken.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/ProtectionToken.java
Tue Oct  3 03:39:29 2006
@@ -58,9 +58,60 @@
     }
 
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-        // TODO Auto-generated method stub
+        String localname = Constants.PROTECTION_TOKEN.getLocalPart();
+        String namespaceURI = Constants.PROTECTION_TOKEN.getNamespaceURI();
         
-    }
-    
-    
+        String prefix;
+        
+        String writerPrefix = writer.getPrefix(namespaceURI);
+        if (writerPrefix == null) {
+            prefix = Constants.PROTECTION_TOKEN.getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+            
+        } else {
+            prefix = writerPrefix;
+        }
+        
+        // <sp:ProtectionToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+        
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+        
+        String policyLocalName = Constants.PROTECTION_TOKEN.getLocalPart();
+        String policyNamespaceURI = Constants.PROTECTION_TOKEN.getNamespaceURI();
+        
+        String wspPrefix;
+        
+        String wspWriterPrefix = writer.getPrefix(policyNamespaceURI);
+        
+        if (wspWriterPrefix == null) {
+            wspPrefix = Constants.PROTECTION_TOKEN.getPrefix();
+            writer.setPrefix(wspPrefix, policyNamespaceURI);
+        } else {
+            wspPrefix = wspWriterPrefix;
+        }
+        
+        // <wsp:Policy>
+        writer.writeStartElement(wspPrefix, policyLocalName, policyNamespaceURI);
+        
+        if (wspWriterPrefix == null) {
+            // xmlns:wsp=".."
+            writer.writeNamespace(wspPrefix, policyNamespaceURI);
+        }
+        
+        if (protectionToken == null) {
+            throw new RuntimeException("ProtectionToken is not set");
+        }
+        
+        protectionToken.serialize(writer);
+        
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:ProtectionToken>
+        writer.writeEndElement();
+    }    
 }

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SecureConversationToken.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SecureConversationToken.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SecureConversationToken.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SecureConversationToken.java
Tue Oct  3 03:39:29 2006
@@ -28,12 +28,12 @@
 /**
  * Model class of SecureConversationToken asertion
  */
-public class SecureConversationToken extends SecurityContextToken  {
+public class SecureConversationToken extends SecurityContextToken {
 
     private Policy bootstrapPolicy;
-    
+
     private OMElement issuerEpr;
-    
+
     /**
      * @return Returns the bootstrapPolicy.
      */
@@ -42,33 +42,117 @@
     }
 
     /**
-     * @param bootstrapPolicy The bootstrapPolicy to set.
+     * @param bootstrapPolicy
+     *            The bootstrapPolicy to set.
      */
     public void setBootstrapPolicy(Policy bootstrapPolicy) {
         this.bootstrapPolicy = bootstrapPolicy;
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.neethi.Assertion#getName()
      */
     public QName getName() {
         return Constants.SECURE_CONVERSATION_TOKEN;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.neethi.Assertion#normalize()
-     */
-    public PolicyComponent normalize() {
-        // TODO TODO Sanka
-        throw new UnsupportedOperationException("TODO Sanka");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.neethi.PolicyComponent#serialize(javax.xml.stream.XMLStreamWriter)
-     */
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-        // TODO TODO Sanka
-        throw new UnsupportedOperationException("TODO Sanka");
+
+        String localname = Constants.SECURE_CONVERSATION_TOKEN.getLocalPart();
+        String namespaceURI = Constants.SECURE_CONVERSATION_TOKEN
+                .getNamespaceURI();
+        String prefix;
+
+        String writerPrefix = writer.getPrefix(namespaceURI);
+
+        if (writerPrefix == null) {
+            prefix = Constants.SECURE_CONVERSATION_TOKEN.getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        } else {
+            prefix = writerPrefix;
+        }
+
+        // <sp:SecureConversationToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+
+        String inclusion = getInclusion();
+
+        if (inclusion != null) {
+            writer.writeAttribute(prefix, namespaceURI, Constants.INCLUDE_TOKEN
+                    .getLocalPart(), inclusion);
+        }
+
+        if (issuerEpr != null) {
+            // <sp:Issuer>
+            writer.writeStartElement(prefix, Constants.ISSUER.getLocalPart(),
+                    namespaceURI);
+
+            issuerEpr.serialize(writer);
+
+            writer.writeEndElement();
+        }
+
+        if (isDerivedKeys() || isRequireExternalUriRef()
+                || isSc10SecurityContextToken() || (bootstrapPolicy != null)) {
+
+            String wspNamespaceURI = Constants.POLICY.getNamespaceURI();
+
+            String wspPrefix;
+
+            String wspWriterPrefix = writer.getPrefix(wspNamespaceURI);
+
+            if (wspWriterPrefix == null) {
+                wspPrefix = Constants.POLICY.getPrefix();
+                writer.setPrefix(wspPrefix, wspNamespaceURI);
+
+            } else {
+                wspPrefix = wspWriterPrefix;
+            }
+
+            // <wsp:Policy>
+            writer.writeStartElement(wspPrefix,
+                    Constants.POLICY.getLocalPart(), wspNamespaceURI);
+
+            if (wspWriterPrefix == null) {
+                // xmlns:wsp=".."
+                writer.writeNamespace(wspPrefix, wspNamespaceURI);
+            }
+            
+            if (isDerivedKeys()) {
+                // <sp:RequireDerivedKeys />
+                writer.writeEmptyElement(prefix, Constants.REQUIRE_DERIVED_KEYS.getLocalPart(),
wspWriterPrefix);
+            }
+            
+            if (isRequireExternalUriRef()) {
+                // <sp:RequireExternalUriReference />
+                writer.writeEmptyElement(prefix, Constants.REQUIRE_EXTERNAL_URI_REFERNCE.getLocalPart(),
namespaceURI);
+            }
+            
+            if (isSc10SecurityContextToken()) {
+                // <sp:SC10SecurityContextToken />
+                writer.writeEmptyElement(prefix, Constants.SC10_SECURITY_CONTEXT_TOKEN.getLocalPart(),
namespaceURI);
+            }
+            
+            if (bootstrapPolicy != null) {
+                // <sp:BootstrapPolicy ..>
+                writer.writeStartElement(prefix, Constants.BOOTSTRAP_POLICY.getLocalPart(),
namespaceURI);
+                bootstrapPolicy.serialize(writer);
+                writer.writeEndElement();
+            }
+
+            // </wsp:Policy>
+            writer.writeEndElement();
+        }
+
+        // </sp:SecureConversationToken>
+        writer.writeEndElement();
     }
 
     /**
@@ -79,7 +163,8 @@
     }
 
     /**
-     * @param issuerEpr The issuerEpr to set.
+     * @param issuerEpr
+     *            The issuerEpr to set.
      */
     public void setIssuerEpr(OMElement issuerEpr) {
         this.issuerEpr = issuerEpr;

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignatureToken.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignatureToken.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignatureToken.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignatureToken.java
Tue Oct  3 03:39:29 2006
@@ -16,12 +16,12 @@
 
 package org.apache.ws.secpolicy.model;
 
-import org.apache.neethi.PolicyComponent;
-
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.ws.secpolicy.Constants;
+
 public class SignatureToken extends AbstractSecurityAssertion implements TokenWrapper {
 
     private Token signatureToken;
@@ -40,36 +40,71 @@
         this.signatureToken = signatureToken;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.ws.security.policy.TokenWrapper#setToken(org.apache.ws.security.policy.Token)
-     */
     public void setToken(Token tok) {
         this.setSignatureToken(tok);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.neethi.Assertion#getName()
-     */
     public QName getName() {
-        // TODO TODO
-        throw new UnsupportedOperationException("TODO");
+        return Constants.SIGNATURE_TOKEN;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.neethi.Assertion#normalize()
-     */
-    public PolicyComponent normalize() {
-        // TODO TODO
-        throw new UnsupportedOperationException("TODO");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.neethi.PolicyComponent#serialize(javax.xml.stream.XMLStreamWriter)
-     */
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-        // TODO TODO
-        throw new UnsupportedOperationException("TODO");
+        
+        String localname = Constants.SIGNATURE_TOKEN.getLocalPart();
+        String namespaceURI = Constants.SIGNATURE_TOKEN.getNamespaceURI();
+        
+        String prefix;
+        String writerPrefix = writer.getPrefix(namespaceURI);
+        
+        if (writerPrefix == null) {
+            prefix = Constants.SIGNATURE_TOKEN.getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+            
+        } else {
+            prefix = writerPrefix;
+        }
+        
+        // <sp:SignatureToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+        
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+        
+        
+        String wspNamespaceURI = Constants.POLICY.getNamespaceURI();
+        
+        String wspPrefix;
+        
+        String wspWriterPrefix = writer.getPrefix(wspNamespaceURI);
+        
+        if (wspWriterPrefix == null) {
+            wspPrefix = Constants.POLICY.getPrefix();
+            writer.setPrefix(wspPrefix, wspNamespaceURI);
+            
+        } else {
+            wspPrefix = wspWriterPrefix;
+        }
+        
+        // <wsp:Policy>
+        writer.writeStartElement(wspPrefix, Constants.POLICY.getLocalPart(), wspNamespaceURI);
+        
+        if (wspWriterPrefix == null) {
+            // xmlns:wsp=".."
+            writer.writeNamespace(wspPrefix, wspNamespaceURI);
+        }
+        
+        if (signatureToken == null) {
+            throw new RuntimeException("EncryptionToken is not set");
+        }
+        
+        signatureToken.serialize(writer);
+        
+        // </wsp:Policy>
+        writer.writeEndElement();
+        
+        // </sp:SignatureToken>
+        writer.writeEndElement();
     }
-    
-    
 }

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignedEncryptedElements.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignedEncryptedElements.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignedEncryptedElements.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SignedEncryptedElements.java
Tue Oct  3 03:39:29 2006
@@ -17,6 +17,7 @@
 package org.apache.ws.secpolicy.model;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -28,18 +29,19 @@
 public class SignedEncryptedElements extends AbstractSecurityAssertion {
 
     private ArrayList xPathExpressions = new ArrayList();
+
     private String xPathVersion;
-    
+
     /**
-     * Just a flag to identify whether this holds 
-     * sign element info or encr elements info 
+     * Just a flag to identify whether this holds sign element info or encr
+     * elements info
      */
     private boolean signedElemets;
-    
+
     public SignedEncryptedElements(boolean signedElements) {
         this.signedElemets = signedElements;
     }
-    
+
     /**
      * @return Returns the xPathExpressions.
      */
@@ -59,7 +61,8 @@
     }
 
     /**
-     * @param pathVersion The xPathVersion to set.
+     * @param pathVersion
+     *            The xPathVersion to set.
      */
     public void setXPathVersion(String pathVersion) {
         xPathVersion = pathVersion;
@@ -73,18 +76,58 @@
     }
 
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-        throw new UnsupportedOperationException();
+
+        String localName = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix;
+        String writerPrefix = writer.getPrefix(namespaceURI);
+
+        if (writerPrefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        } else {
+            prefix = writerPrefix;
+        }
+
+        // <sp:SignedElements> | <sp:EncryptedElements>
+        writer.writeStartElement(prefix, localName, namespaceURI);
+
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+
+        if (xPathVersion != null) {
+            writer.writeAttribute(prefix, namespaceURI,
+                    Constants.ATTR_XPATH_VERSION.getLocalPart(), xPathVersion);
+        }
+
+        String xpathExpression;
+
+        for (Iterator iterator = xPathExpressions.iterator(); iterator
+                .hasNext();) {
+            xpathExpression = (String) iterator.next();
+            // <sp:XPath ..>
+            writer.writeStartElement(prefix, Constants.XPATH_.getLocalPart(),
+                    namespaceURI);
+            writer.writeCharacters(xpathExpression);
+            writer.writeEndElement();
+        }
+
+        // </sp:SignedElements> | </sp:EncryptedElements>
+        writer.writeEndElement();
     }
 
     public QName getName() {
         if (signedElemets) {
             return Constants.SIGNED_ELEMENTS;
-        } 
-        
+        }
+
         return Constants.ENCRYPTED_ELEMENTS;
     }
 
     public PolicyComponent normalize() {
         return this;
-    }  
+    }
 }

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SymmetricBinding.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SymmetricBinding.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SymmetricBinding.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SymmetricBinding.java
Tue Oct  3 03:39:29 2006
@@ -144,6 +144,96 @@
     }
 
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-        throw new UnsupportedOperationException();        
+        
+        String localname = Constants.SYMMETRIC_BINDING.getLocalPart();
+        String namespaceURI = Constants.SYMMETRIC_BINDING.getNamespaceURI();
+        
+        String prefix;
+        String writerPrefix = writer.getPrefix(namespaceURI);
+        
+        if (writerPrefix == null) {
+            prefix = Constants.SYMMETRIC_BINDING.getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        } else {
+            prefix = writerPrefix;
+        }
+
+        // <sp:SymmetricBinding>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+        
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+        
+        
+        String policyLocalName = Constants.POLICY.getLocalPart();
+        String policyNamespaceURI = Constants.POLICY.getNamespaceURI();
+        
+        String wspPrefix;
+        
+        String wspWriterPrefix = writer.getPrefix(policyNamespaceURI);
+        if (wspWriterPrefix == null) {
+            wspPrefix = Constants.POLICY.getPrefix();
+            writer.setPrefix(wspPrefix, policyNamespaceURI);
+            
+        } else {
+           wspPrefix = wspWriterPrefix;
+        }
+        // <wsp:Policy>
+        writer.writeStartElement(wspPrefix, policyLocalName, policyNamespaceURI);
+        
+        if (encryptionToken != null) {
+            encryptionToken.serialize(writer);
+            
+        } else if ( protectionToken != null) {
+            protectionToken.serialize(writer);
+            
+        } else {
+            throw new RuntimeException("Either EncryptionToken or ProtectionToken must be
set");
+        }
+        
+        AlgorithmSuite algorithmSuite = getAlgorithmSuite();
+        
+        if (algorithmSuite == null) {
+            throw new RuntimeException("AlgorithmSuite must be set");
+        }
+        // <sp:AlgorithmSuite />
+        algorithmSuite.serialize(writer);
+        
+        Layout layout = getLayout();
+        if (layout != null) {
+            // <sp:Layout />
+            layout.serialize(writer);
+        }
+        
+        if (isIncludeTimestamp()) {
+            // <sp:IncludeTimestamp />
+            writer.writeStartElement(prefix, Constants.INCLUDE_TIMESTAMP.getLocalPart(),
namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        if (Constants.ENCRYPT_BEFORE_SIGNING.equals(protectionToken)) {
+            // <sp:EncryptBeforeSigning />
+            writer.writeStartElement(prefix, Constants.ENCRYPT_BEFORE_SIGNING, namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        if (isSignatureProtection()) {
+            // <sp:EncryptSignature />
+            writer.writeStartElement(prefix, Constants.ENCRYPT_SIGNATURE.getLocalPart(),
namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        if (protectionToken != null) {
+            protectionToken.serialize(writer);
+        }
+        
+        // </wsp:Policy>
+        writer.writeEndElement();
+        
+        // </sp:SymmetricBinding>
+        writer.writeEndElement();
+        
     }
 }

Modified: webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Wss11.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Wss11.java?view=diff&rev=452404&r1=452403&r2=452404
==============================================================================
--- webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Wss11.java
(original)
+++ webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Wss11.java
Tue Oct  3 03:39:29 2006
@@ -16,6 +16,11 @@
 
 package org.apache.ws.secpolicy.model;
 
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.ws.secpolicy.Constants;
+
 public class Wss11 extends Wss10 {
     
     private boolean MustSupportRefThumbprint;
@@ -58,6 +63,76 @@
     public void setRequireSignatureConfirmation(boolean requireSignatureConfirmation) {
         RequireSignatureConfirmation = requireSignatureConfirmation;
     }
-    
-    
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+        String localname = Constants.WSS11.getLocalPart();
+        String namespaceURI = Constants.WSS11.getNamespaceURI();
+
+        String prefix = writer.getPrefix(namespaceURI);
+        if (prefix == null) {
+            prefix = Constants.WSS11.getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        }
+
+        // <sp:Wss11>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+        
+        // xmlns:sp=".."
+        writer.writeNamespace(prefix, namespaceURI);
+        
+        String pPrefix = writer.getPrefix(Constants.POLICY.getNamespaceURI());
+        if (pPrefix == null) {
+            writer.setPrefix(Constants.POLICY.getPrefix(), Constants.POLICY.getNamespaceURI());
+        }
+        
+        // <wsp:Policy>
+        writer.writeStartElement(prefix, Constants.POLICY.getLocalPart(), Constants.POLICY.getNamespaceURI());
+        
+        // <sp:MustSupportRefKeyIndentifier />
+        if (isMustSupportRefKeyIdentifier()) {
+            writer.writeStartElement(prefix, Constants.MUST_SUPPORT_REF_KEY_IDENTIFIER.getLocalPart(),
namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        if (isMustSupportRefIssuerSerial()) {
+            // <sp:MustSupportRefIssuerSerial />
+            writer.writeStartElement(prefix, Constants.MUST_SUPPORT_REF_ISSUER_SERIAL.getLocalPart(),
namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        if (isMustSupportRefExternalURI()) {
+            // <sp:MustSupportRefExternalURI />
+            writer.writeStartElement(prefix, Constants.MUST_SUPPORT_REF_EXTERNAL_URI.getLocalPart(),
namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        if (isMustSupportRefEmbeddedToken()) {
+            // <sp:MustSupportRefEmbeddedToken />
+            writer.writeStartElement(prefix, Constants.MUST_SUPPORT_REF_EMBEDDED_TOKEN.getLocalPart(),
namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        if (isMustSupportRefThumbprint()) {
+            // <sp:MustSupportRefThumbprint />
+            writer.writeStartElement(prefix, Constants.MUST_SUPPORT_REF_THUMBPRINT.getLocalPart(),
namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        if (isMustSupportRefEncryptedKey()) {
+            // <sp:MustSupportRefEncryptedKey />
+            writer.writeStartElement(prefix, Constants.MUST_SUPPORT_REF_ENCRYPTED_KEY.getLocalPart(),
namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        if (isRequireSignatureConfirmation()) {
+            // <sp:RequireSignatureConfirmation />
+            writer.writeStartElement(prefix, Constants.REQUIRE_SIGNATURE_CONFIRMATION.getLocalPart(),
namespaceURI);
+            writer.writeEndElement();
+        }
+        
+        // </wsp:Policy>
+        writer.writeEndElement();
+        
+        // </sp:Wss11>
+        writer.writeEndElement();
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message