You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by fa...@apache.org on 2008/04/11 20:40:30 UTC

svn commit: r647260 [2/8] - in /webservices/wss4j/trunk: interop/org/apache/ws/axis/oasis/ src/org/apache/ws/security/ src/org/apache/ws/security/action/ src/org/apache/ws/security/components/crypto/ src/org/apache/ws/security/conversation/ src/org/apa...

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/BouncyCastle.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/BouncyCastle.java?rev=647260&r1=647259&r2=647260&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/BouncyCastle.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/BouncyCastle.java Fri Apr 11 11:40:21 2008
@@ -1,188 +1,188 @@
-/*
- * Copyright  2003-2004 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.ws.security.components.crypto;
-
-import org.apache.ws.security.WSSecurityException;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertPath;
-import java.security.cert.CertPathValidator;
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.PKIXParameters;
-import java.security.cert.X509Certificate;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Vector;
-
-/**
- * JDK1.4 based implementation of Crypto (uses keystore).
- * <p/>
- *
- * @author Davanum Srinivas (dims@yahoo.com).
- */
-public class BouncyCastle extends AbstractCrypto {
-
-    /**
-     * Constructor.
-     * <p/>
-     *
-     * @param properties
-     * @throws CredentialException
-     * @throws java.io.IOException
-     */
-    public BouncyCastle(Properties properties) throws CredentialException, IOException {
-        super(properties);
-    }
-
-    public BouncyCastle(Properties properties, ClassLoader loader) throws CredentialException, IOException {
-    	super(properties,loader);
-    }
-
-    /**
-     * Construct an array of X509Certificate's from the byte array.
-     * <p/>
-     *
-     * @param data    The <code>byte</code> array containing the X509 data
-     * @param reverse If set the first certificate in input data will
-     *                the last in the array
-     * @return An array of X509 certificates, ordered according to
-     *         the reverse flag
-     * @throws org.apache.ws.security.WSSecurityException
-     *
-     */
-    public X509Certificate[] getX509Certificates(byte[] data, boolean reverse)
-            throws WSSecurityException {
-        InputStream in = new ByteArrayInputStream(data);
-        CertPath path = null;
-        try {
-            CertificateFactory factory = CertificateFactory.getInstance("X.509");
-            path = factory.generateCertPath(in);
-        } catch (CertificateException e) {
-            throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
-                    "parseError");
-        }
-        List l = path.getCertificates();
-        X509Certificate[] certs = new X509Certificate[l.size()];
-        Iterator iterator = l.iterator();
-        for (int i = 0; i < l.size(); i++) {
-            certs[(reverse) ? (l.size() - 1 - i) : i] = (X509Certificate) iterator.next();
-        }
-        return certs;
-    }
-
-    /**
-     * get a byte array given an array of X509 certificates.
-     * <p/>
-     *
-     * @param reverse If set the first certificate in the array data will
-     *                the last in the byte array
-     * @param certs   The certificates to convert
-     * @return The byte array for the certificates ordered according
-     *         to the reverse flag
-     * @throws org.apache.ws.security.WSSecurityException
-     *
-     */
-    public byte[] getCertificateData(boolean reverse, X509Certificate[] certs)
-            throws WSSecurityException {
-        Vector list = new Vector();
-        for (int i = 0; i < certs.length; i++) {
-            if (reverse) {
-                list.insertElementAt(certs[i], 0);
-            } else {
-                list.add(certs[i]);
-            }
-        }
-        try {
-            CertificateFactory factory = CertificateFactory.getInstance("X.509");
-            CertPath path = factory.generateCertPath(list);
-            return path.getEncoded();
-        } catch (CertificateEncodingException e) {
-            throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
-                    "encodeError");
-        } catch (CertificateException e) {
-            throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
-                    "parseError");
-        }
-    }
-
-    /**
-     * Uses the CertPath API to validate a given certificate chain
-     *
-     * @param certs Certificate chain to validate
-     * @return true if the certificate chain is valid, false otherwise
-     * @throws org.apache.ws.security.WSSecurityException
-     *
-     */
-    public boolean validateCertPath(X509Certificate[] certs) throws WSSecurityException {
-
-        try {
-            // Generate cert path
-            List certList = Arrays.asList(certs);
-            CertificateFactory factory = CertificateFactory.getInstance("X.509");
-            CertPath path = factory.generateCertPath(certList);
-
-            // Use the certificates in the keystore as TrustAnchors
-            PKIXParameters param = new PKIXParameters(this.keystore);
-
-            // Do not check a revocation list
-            param.setRevocationEnabled(false);
-
-            // Verify the trust path using the above settings            
-            CertPathValidator certPathValidator = CertPathValidator.getInstance("PKIX");
-            certPathValidator.validate(path, param);
-        } catch (NoSuchAlgorithmException ex) {
-            throw new WSSecurityException(WSSecurityException.FAILURE,
-                    "certpath",
-                    new Object[]{ex.getMessage()},
-                    (Throwable) ex);
-        } catch (CertificateException ex) {
-            throw new WSSecurityException(WSSecurityException.FAILURE,
-                    "certpath",
-                    new Object[]{ex.getMessage()},
-                    (Throwable) ex);
-        } catch (InvalidAlgorithmParameterException ex) {
-            throw new WSSecurityException(WSSecurityException.FAILURE,
-                    "certpath",
-                    new Object[]{ex.getMessage()},
-                    (Throwable) ex);
-        } catch (KeyStoreException ex) {
-            throw new WSSecurityException(WSSecurityException.FAILURE,
-                    "certpath",
-                    new Object[]{ex.getMessage()},
-                    (Throwable) ex);
-        } catch (CertPathValidatorException ex) {
-            throw new WSSecurityException(WSSecurityException.FAILURE,
-                    "certpath",
-                    new Object[]{ex.getMessage()},
-                    (Throwable) ex);
-        }
-        return true;
-    }
-}
-
-
+/*
+ * Copyright  2003-2004 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ws.security.components.crypto;
+
+import org.apache.ws.security.WSSecurityException;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertPath;
+import java.security.cert.CertPathValidator;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.PKIXParameters;
+import java.security.cert.X509Certificate;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Vector;
+
+/**
+ * JDK1.4 based implementation of Crypto (uses keystore).
+ * <p/>
+ *
+ * @author Davanum Srinivas (dims@yahoo.com).
+ */
+public class BouncyCastle extends AbstractCrypto {
+
+    /**
+     * Constructor.
+     * <p/>
+     *
+     * @param properties
+     * @throws CredentialException
+     * @throws java.io.IOException
+     */
+    public BouncyCastle(Properties properties) throws CredentialException, IOException {
+        super(properties);
+    }
+
+    public BouncyCastle(Properties properties, ClassLoader loader) throws CredentialException, IOException {
+    	super(properties,loader);
+    }
+
+    /**
+     * Construct an array of X509Certificate's from the byte array.
+     * <p/>
+     *
+     * @param data    The <code>byte</code> array containing the X509 data
+     * @param reverse If set the first certificate in input data will
+     *                the last in the array
+     * @return An array of X509 certificates, ordered according to
+     *         the reverse flag
+     * @throws org.apache.ws.security.WSSecurityException
+     *
+     */
+    public X509Certificate[] getX509Certificates(byte[] data, boolean reverse)
+            throws WSSecurityException {
+        InputStream in = new ByteArrayInputStream(data);
+        CertPath path = null;
+        try {
+            CertificateFactory factory = CertificateFactory.getInstance("X.509");
+            path = factory.generateCertPath(in);
+        } catch (CertificateException e) {
+            throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
+                    "parseError");
+        }
+        List l = path.getCertificates();
+        X509Certificate[] certs = new X509Certificate[l.size()];
+        Iterator iterator = l.iterator();
+        for (int i = 0; i < l.size(); i++) {
+            certs[(reverse) ? (l.size() - 1 - i) : i] = (X509Certificate) iterator.next();
+        }
+        return certs;
+    }
+
+    /**
+     * get a byte array given an array of X509 certificates.
+     * <p/>
+     *
+     * @param reverse If set the first certificate in the array data will
+     *                the last in the byte array
+     * @param certs   The certificates to convert
+     * @return The byte array for the certificates ordered according
+     *         to the reverse flag
+     * @throws org.apache.ws.security.WSSecurityException
+     *
+     */
+    public byte[] getCertificateData(boolean reverse, X509Certificate[] certs)
+            throws WSSecurityException {
+        Vector list = new Vector();
+        for (int i = 0; i < certs.length; i++) {
+            if (reverse) {
+                list.insertElementAt(certs[i], 0);
+            } else {
+                list.add(certs[i]);
+            }
+        }
+        try {
+            CertificateFactory factory = CertificateFactory.getInstance("X.509");
+            CertPath path = factory.generateCertPath(list);
+            return path.getEncoded();
+        } catch (CertificateEncodingException e) {
+            throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
+                    "encodeError");
+        } catch (CertificateException e) {
+            throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
+                    "parseError");
+        }
+    }
+
+    /**
+     * Uses the CertPath API to validate a given certificate chain
+     *
+     * @param certs Certificate chain to validate
+     * @return true if the certificate chain is valid, false otherwise
+     * @throws org.apache.ws.security.WSSecurityException
+     *
+     */
+    public boolean validateCertPath(X509Certificate[] certs) throws WSSecurityException {
+
+        try {
+            // Generate cert path
+            List certList = Arrays.asList(certs);
+            CertificateFactory factory = CertificateFactory.getInstance("X.509");
+            CertPath path = factory.generateCertPath(certList);
+
+            // Use the certificates in the keystore as TrustAnchors
+            PKIXParameters param = new PKIXParameters(this.keystore);
+
+            // Do not check a revocation list
+            param.setRevocationEnabled(false);
+
+            // Verify the trust path using the above settings            
+            CertPathValidator certPathValidator = CertPathValidator.getInstance("PKIX");
+            certPathValidator.validate(path, param);
+        } catch (NoSuchAlgorithmException ex) {
+            throw new WSSecurityException(WSSecurityException.FAILURE,
+                    "certpath",
+                    new Object[]{ex.getMessage()},
+                    (Throwable) ex);
+        } catch (CertificateException ex) {
+            throw new WSSecurityException(WSSecurityException.FAILURE,
+                    "certpath",
+                    new Object[]{ex.getMessage()},
+                    (Throwable) ex);
+        } catch (InvalidAlgorithmParameterException ex) {
+            throw new WSSecurityException(WSSecurityException.FAILURE,
+                    "certpath",
+                    new Object[]{ex.getMessage()},
+                    (Throwable) ex);
+        } catch (KeyStoreException ex) {
+            throw new WSSecurityException(WSSecurityException.FAILURE,
+                    "certpath",
+                    new Object[]{ex.getMessage()},
+                    (Throwable) ex);
+        } catch (CertPathValidatorException ex) {
+            throw new WSSecurityException(WSSecurityException.FAILURE,
+                    "certpath",
+                    new Object[]{ex.getMessage()},
+                    (Throwable) ex);
+        }
+        return true;
+    }
+}
+
+

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/BouncyCastle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/conversation/ConversationConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/conversation/ConversationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/conversation/dkalgo/AlgoFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/conversation/dkalgo/DerivationAlgorithm.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/conversation/dkalgo/P_SHA1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java?rev=647260&r1=647259&r2=647260&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java Fri Apr 11 11:40:21 2008
@@ -1,131 +1,131 @@
-/*
- * Copyright  2003-2005 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.ws.security.message;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ws.security.message.token.SignatureConfirmation;
-import org.apache.ws.security.util.WSSecurityUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Builds a WS SignatureConfirmation and inserts it into the SOAP Envelope.
- * 
- * @author Werner Dittmann (Werner.Dittmann@t-online.de).
- */
-
-public class WSAddSignatureConfirmation extends WSBaseMessage {
-    private static Log log = LogFactory.getLog(WSAddSignatureConfirmation.class
-            .getName());
-
-    private SignatureConfirmation sc = null;
-
-    private String id = null;
-
-    /**
-     * Constructor.
-     * 
-     * @deprecated replaced by {@link WSSecSignatureConfirmation#WSSecSignatureConfirmation()}
-     */
-    public WSAddSignatureConfirmation() {
-    }
-
-    /**
-     * Constructor.
-     * 
-     * @param actor
-     *            the name of the actor of the <code>wsse:Security</code>
-     *            header
-     * 
-     * @deprecated replaced by {@link WSSecSignatureConfirmation#WSSecSignatureConfirmation()}
-     *             and {@link WSSecHeader} for actor specification.
-     */
-    public WSAddSignatureConfirmation(String actor) {
-        super(actor);
-    }
-
-    /**
-     * Constructor.
-     * 
-     * @param actor
-     *            The name of the actor of the <code>wsse:Security</code>
-     *            header
-     * @param mu
-     *            Set <code>mustUnderstand</code> to true or false
-     * 
-     * @deprecated replaced by {@link WSSecSignatureConfirmation#WSSecSignatureConfirmation()}
-     *             and {@link WSSecHeader} for actor and mustunderstand
-     *             specification.
-     */
-    public WSAddSignatureConfirmation(String actor, boolean mu) {
-        super(actor, mu);
-    }
-
-    /**
-     * Adds a new <code>SignatureConfirmation</code> to a soap envelope.
-     * 
-     * A complete <code>SignatureConfirmation</code> is constructed and added
-     * to the <code>wsse:Security</code> header.
-     * 
-     * @param doc
-     *            The SOAP enevlope as W3C document
-     * @param sigVal
-     *            the Signature value. This will be the content of the "Value"
-     *            attribute.
-     * @return Document with SignatureConfirmation added
-     * 
-     * @deprecated replaced by
-     *             {@link WSSecSignatureConfirmation#build(Document, byte[], WSSecHeader)}
-     */
-    public Document build(Document doc, byte[] sigVal) {
-        log.debug("Begin add signature confirmation...");
-        Element securityHeader = insertSecurityHeader(doc);
-        sc = new SignatureConfirmation(doc, sigVal);
-        if (id != null) {
-            sc.setID(id);
-        }
-        WSSecurityUtil.prependChildElement(doc, securityHeader,
-                sc.getElement(), true);
-        sc = null;
-        return doc;
-    }
-
-    /**
-     * Set the wsu:Id value of the SignatureConfirmation
-     * 
-     * @param id
-     * 
-     * @deprecated no replacement, id is created by default in
-     *             {@link WSSecSignatureConfirmation}
-     */
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    /**
-     * Get the wsu:Id value of the SignatureConfirmation
-     * 
-     * @return Returns the wsu:id value
-     * 
-     * @deprecated replaced by {@link WSSecSignatureConfirmation#getId()}
-     */
-    public String getId() {
-        return id;
-    }
-}
+/*
+ * Copyright  2003-2005 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ws.security.message;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.message.token.SignatureConfirmation;
+import org.apache.ws.security.util.WSSecurityUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Builds a WS SignatureConfirmation and inserts it into the SOAP Envelope.
+ * 
+ * @author Werner Dittmann (Werner.Dittmann@t-online.de).
+ */
+
+public class WSAddSignatureConfirmation extends WSBaseMessage {
+    private static Log log = LogFactory.getLog(WSAddSignatureConfirmation.class
+            .getName());
+
+    private SignatureConfirmation sc = null;
+
+    private String id = null;
+
+    /**
+     * Constructor.
+     * 
+     * @deprecated replaced by {@link WSSecSignatureConfirmation#WSSecSignatureConfirmation()}
+     */
+    public WSAddSignatureConfirmation() {
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param actor
+     *            the name of the actor of the <code>wsse:Security</code>
+     *            header
+     * 
+     * @deprecated replaced by {@link WSSecSignatureConfirmation#WSSecSignatureConfirmation()}
+     *             and {@link WSSecHeader} for actor specification.
+     */
+    public WSAddSignatureConfirmation(String actor) {
+        super(actor);
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param actor
+     *            The name of the actor of the <code>wsse:Security</code>
+     *            header
+     * @param mu
+     *            Set <code>mustUnderstand</code> to true or false
+     * 
+     * @deprecated replaced by {@link WSSecSignatureConfirmation#WSSecSignatureConfirmation()}
+     *             and {@link WSSecHeader} for actor and mustunderstand
+     *             specification.
+     */
+    public WSAddSignatureConfirmation(String actor, boolean mu) {
+        super(actor, mu);
+    }
+
+    /**
+     * Adds a new <code>SignatureConfirmation</code> to a soap envelope.
+     * 
+     * A complete <code>SignatureConfirmation</code> is constructed and added
+     * to the <code>wsse:Security</code> header.
+     * 
+     * @param doc
+     *            The SOAP enevlope as W3C document
+     * @param sigVal
+     *            the Signature value. This will be the content of the "Value"
+     *            attribute.
+     * @return Document with SignatureConfirmation added
+     * 
+     * @deprecated replaced by
+     *             {@link WSSecSignatureConfirmation#build(Document, byte[], WSSecHeader)}
+     */
+    public Document build(Document doc, byte[] sigVal) {
+        log.debug("Begin add signature confirmation...");
+        Element securityHeader = insertSecurityHeader(doc);
+        sc = new SignatureConfirmation(doc, sigVal);
+        if (id != null) {
+            sc.setID(id);
+        }
+        WSSecurityUtil.prependChildElement(doc, securityHeader,
+                sc.getElement(), true);
+        sc = null;
+        return doc;
+    }
+
+    /**
+     * Set the wsu:Id value of the SignatureConfirmation
+     * 
+     * @param id
+     * 
+     * @deprecated no replacement, id is created by default in
+     *             {@link WSSecSignatureConfirmation}
+     */
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    /**
+     * Get the wsu:Id value of the SignatureConfirmation
+     * 
+     * @return Returns the wsu:id value
+     * 
+     * @deprecated replaced by {@link WSSecSignatureConfirmation#getId()}
+     */
+    public String getId() {
+        return id;
+    }
+}

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddSignatureConfirmation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java?rev=647260&r1=647259&r2=647260&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java Fri Apr 11 11:40:21 2008
@@ -1,163 +1,163 @@
-/*
- * Copyright  2003-2004 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.ws.security.message;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ws.security.SOAPConstants;
-import org.apache.ws.security.WSConstants;
-import org.apache.ws.security.WSSConfig;
-import org.apache.ws.security.components.crypto.Crypto;
-import org.apache.ws.security.util.WSSecurityUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import java.util.Vector;
-
-/**
- * This is the base class for WS Security messages. It provides common functions
- * and fields used by the specific message classes such as sign, encrypt, and
- * username token.
- * 
- * @author Werner Dittmann (Werner.Dittmann@apache.org)
- */
-public class WSSecBase {
-	private static Log log = LogFactory.getLog(WSSecBase.class.getName());
-
-	protected String user = null;
-
-	protected String password = null;
-
-	protected int keyIdentifierType = WSConstants.ISSUER_SERIAL;
-
-	protected Vector parts = null;
-
-	protected boolean doDebug = false;
-
-	protected WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();
-
-	/**
-	 * Constructor.
-	 */
-	public WSSecBase() {
-	}
-
-	/**
-	 * Set which parts of the message to encrypt/sign. <p/>
-	 * 
-	 * @param parts
-	 *            The vector containing the WSEncryptionPart objects
-	 */
-	public void setParts(Vector parts) {
-		this.parts = parts;
-	}
-
-	/**
-	 * Sets which key identifier to use. 
-     * 
-     * <p/> 
-     * 
-     * Defines the key identifier type to
-	 * use in the {@link WSSecSignature#prepare(Document, Crypto, WSSecHeader) method} or
-	 * the {@link WSSecEncrypt#prepare(Document, Crypto) method} function to
-	 * set up the key identification elements.
-	 * 
-	 * @param keyIdType
-	 * @see WSConstants#ISSUER_SERIAL
-	 * @see WSConstants#BST_DIRECT_REFERENCE
-	 * @see WSConstants#X509_KEY_IDENTIFIER
-	 * @see WSConstants#SKI_KEY_IDENTIFIER
-	 */
-	public void setKeyIdentifierType(int keyIdType) {
-		keyIdentifierType = keyIdType;
-	}
-
-	/**
-	 * Gets the value of the <code>keyIdentifyerType</code>.
-	 * 
-	 * @return The <code>keyIdentifyerType</code>.
-	 * @see WSConstants#ISSUER_SERIAL
-	 * @see WSConstants#BST_DIRECT_REFERENCE
-	 * @see WSConstants#X509_KEY_IDENTIFIER
-	 * @see WSConstants#SKI_KEY_IDENTIFIER
-	 */
-	public int getKeyIdentifierType() {
-		return keyIdentifierType;
-	}
-
-	/**
-	 * @param wsConfig
-	 *            The wsConfig to set.
-	 */
-	public void setWsConfig(WSSConfig wsConfig) {
-		this.wssConfig = wsConfig;
-	}
-
-	/**
-	 * Looks up or adds a body id. <p/> First try to locate the
-	 * <code>wsu:Id</code> in the SOAP body element. If one is found, the
-	 * value of the <code>wsu:Id</code> attribute is returned. Otherwise the
-	 * method generates a new <code>wsu:Id</code> and an appropriate value.
-	 * 
-	 * @param doc
-	 *            The SOAP envelope as <code>Document</code>
-	 * @return The value of the <code>wsu:Id</code> attribute of the SOAP body
-	 * @throws Exception
-	 */
-	protected String setBodyID(Document doc) throws Exception {
-		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
-				.getDocumentElement());
-		Element bodyElement = (Element) WSSecurityUtil.getDirectChild(doc
-				.getFirstChild(), soapConstants.getBodyQName().getLocalPart(),
-				soapConstants.getEnvelopeURI());
-		if (bodyElement == null) {
-			throw new Exception("SOAP Body Element node not found");
-		}
-		return setWsuId(bodyElement);
-	}
-
-	protected String setWsuId(Element bodyElement) {
-		String id = null;
-		id = bodyElement.getAttributeNS(WSConstants.WSU_NS, "Id");
-
-		if ((id == null) || (id.length() == 0)) {
-			id = "id-" + Integer.toString(bodyElement.hashCode());
-			String prefix = WSSecurityUtil.setNamespace(bodyElement,
-					WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-			bodyElement.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
-		}
-		return id;
-	}
-
-	/**
-	 * Set the user and password info. 
-	 * 
-	 * Both information is used to get the user's private signing key.
-	 * 
-	 * @param user
-	 *            This is the user's alias name in the keystore that identifies
-	 *            the private key to sign the document
-	 * @param password
-	 *            The user's password to get the private signing key from the
-	 *            keystore
-	 */
-	public void setUserInfo(String user, String password) {
-		this.user = user;
-		this.password = password;
-	}
-}
+/*
+ * Copyright  2003-2004 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ws.security.message;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.SOAPConstants;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSSConfig;
+import org.apache.ws.security.components.crypto.Crypto;
+import org.apache.ws.security.util.WSSecurityUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import java.util.Vector;
+
+/**
+ * This is the base class for WS Security messages. It provides common functions
+ * and fields used by the specific message classes such as sign, encrypt, and
+ * username token.
+ * 
+ * @author Werner Dittmann (Werner.Dittmann@apache.org)
+ */
+public class WSSecBase {
+	private static Log log = LogFactory.getLog(WSSecBase.class.getName());
+
+	protected String user = null;
+
+	protected String password = null;
+
+	protected int keyIdentifierType = WSConstants.ISSUER_SERIAL;
+
+	protected Vector parts = null;
+
+	protected boolean doDebug = false;
+
+	protected WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();
+
+	/**
+	 * Constructor.
+	 */
+	public WSSecBase() {
+	}
+
+	/**
+	 * Set which parts of the message to encrypt/sign. <p/>
+	 * 
+	 * @param parts
+	 *            The vector containing the WSEncryptionPart objects
+	 */
+	public void setParts(Vector parts) {
+		this.parts = parts;
+	}
+
+	/**
+	 * Sets which key identifier to use. 
+     * 
+     * <p/> 
+     * 
+     * Defines the key identifier type to
+	 * use in the {@link WSSecSignature#prepare(Document, Crypto, WSSecHeader) method} or
+	 * the {@link WSSecEncrypt#prepare(Document, Crypto) method} function to
+	 * set up the key identification elements.
+	 * 
+	 * @param keyIdType
+	 * @see WSConstants#ISSUER_SERIAL
+	 * @see WSConstants#BST_DIRECT_REFERENCE
+	 * @see WSConstants#X509_KEY_IDENTIFIER
+	 * @see WSConstants#SKI_KEY_IDENTIFIER
+	 */
+	public void setKeyIdentifierType(int keyIdType) {
+		keyIdentifierType = keyIdType;
+	}
+
+	/**
+	 * Gets the value of the <code>keyIdentifyerType</code>.
+	 * 
+	 * @return The <code>keyIdentifyerType</code>.
+	 * @see WSConstants#ISSUER_SERIAL
+	 * @see WSConstants#BST_DIRECT_REFERENCE
+	 * @see WSConstants#X509_KEY_IDENTIFIER
+	 * @see WSConstants#SKI_KEY_IDENTIFIER
+	 */
+	public int getKeyIdentifierType() {
+		return keyIdentifierType;
+	}
+
+	/**
+	 * @param wsConfig
+	 *            The wsConfig to set.
+	 */
+	public void setWsConfig(WSSConfig wsConfig) {
+		this.wssConfig = wsConfig;
+	}
+
+	/**
+	 * Looks up or adds a body id. <p/> First try to locate the
+	 * <code>wsu:Id</code> in the SOAP body element. If one is found, the
+	 * value of the <code>wsu:Id</code> attribute is returned. Otherwise the
+	 * method generates a new <code>wsu:Id</code> and an appropriate value.
+	 * 
+	 * @param doc
+	 *            The SOAP envelope as <code>Document</code>
+	 * @return The value of the <code>wsu:Id</code> attribute of the SOAP body
+	 * @throws Exception
+	 */
+	protected String setBodyID(Document doc) throws Exception {
+		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
+				.getDocumentElement());
+		Element bodyElement = (Element) WSSecurityUtil.getDirectChild(doc
+				.getFirstChild(), soapConstants.getBodyQName().getLocalPart(),
+				soapConstants.getEnvelopeURI());
+		if (bodyElement == null) {
+			throw new Exception("SOAP Body Element node not found");
+		}
+		return setWsuId(bodyElement);
+	}
+
+	protected String setWsuId(Element bodyElement) {
+		String id = null;
+		id = bodyElement.getAttributeNS(WSConstants.WSU_NS, "Id");
+
+		if ((id == null) || (id.length() == 0)) {
+			id = "id-" + Integer.toString(bodyElement.hashCode());
+			String prefix = WSSecurityUtil.setNamespace(bodyElement,
+					WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+			bodyElement.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
+		}
+		return id;
+	}
+
+	/**
+	 * Set the user and password info. 
+	 * 
+	 * Both information is used to get the user's private signing key.
+	 * 
+	 * @param user
+	 *            This is the user's alias name in the keystore that identifies
+	 *            the private key to sign the document
+	 * @param password
+	 *            The user's password to get the private signing key from the
+	 *            keystore
+	 */
+	public void setUserInfo(String user, String password) {
+		this.user = user;
+		this.password = password;
+	}
+}

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKSign.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDerivedKeyBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java?rev=647260&r1=647259&r2=647260&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java Fri Apr 11 11:40:21 2008
@@ -1,194 +1,194 @@
-/*
- * Copyright  2003-2004 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.ws.security.message;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ws.security.SOAPConstants;
-import org.apache.ws.security.WSConstants;
-import org.apache.ws.security.util.WSSecurityUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * This class implements WS Security header.
- * 
- * Setup a Security header with a specified actor and mustunderstand flag.
- * 
- * <p/>
- * 
- * The defaults for actor and mustunderstand are: empty <code>actor</code> and
- * <code>mustunderstand</code> is true.
- * 
- * @author Werner Dittmann (Werner.Dittmann@apache.org)
- */
-public class WSSecHeader {
-    private static Log log = LogFactory.getLog(WSSecHeader.class.getName());
-
-    protected String actor = null;
-
-    protected boolean mustunderstand = true;
-
-    protected boolean doDebug = false;
-
-    private Element securityHeader = null;
-
-    /**
-     * Constructor.
-     */
-    public WSSecHeader() {
-    }
-
-    /**
-     * Constructor.
-     * 
-     * @param actor
-     *            The actor name of the <code>wsse:Security</code> header
-     */
-    public WSSecHeader(String actor) {
-        this(actor, true);
-    }
-
-    /**
-     * Constructor.
-     * 
-     * @param actor
-     *            The actor name of the <code>wsse:Security</code> header
-     * @param mu
-     *            Set <code>mustUnderstand</code> to true or false
-     */
-    public WSSecHeader(String act, boolean mu) {
-        actor = act;
-        mustunderstand = mu;
-    }
-
-    /**
-     * set actor name.
-     * 
-     * @param act
-     *            The actor name of the <code>wsse:Security</code> header
-     */
-    public void setActor(String act) {
-        actor = act;
-    }
-
-    /**
-     * Set the <code>mustUnderstand</code> flag for the
-     * <code>wsse:Security</code> header.
-     * 
-     * @param mu
-     *            Set <code>mustUnderstand</code> to true or false
-     */
-    public void setMustUnderstand(boolean mu) {
-        mustunderstand = mu;
-    }
-
-    /**
-     * Get the security header element of this instance.
-     * 
-     * @return The security header element.
-     */
-    public Element getSecurityHeader() {
-        return securityHeader;
-    }
-    
-    /**
-     * Returns whether the security header is empty
-     * 
-     * @return true if empty or if there is no security header
-     *         false if non empty security header
-     */
-    public boolean isEmpty(Document doc) {
-        
-        if (securityHeader == null) {            
-            securityHeader = WSSecurityUtil.findWsseSecurityHeaderBlock(doc, doc
-                    .getDocumentElement(), actor, false);
-            if ( securityHeader == null ) {
-                return true;
-            }
-        }
-        
-        if ( securityHeader.getChildNodes().getLength() == 0 ) {
-            return true;
-        } else {
-            return false;
-        }
-
-        
-    }
-
-    /**
-     * Creates a security header and inserts it as child into the SOAP Envelope.
-     * 
-     * <p/>
-     * 
-     * Check if a WS Security header block for an actor is already available in
-     * the document. If a header block is found return it, otherwise a new
-     * wsse:Security header block is created and the attributes set
-     * 
-     * @param doc
-     *            A SOAP envelope as <code>Document</code>
-     * @return A <code>wsse:Security</code> element
-     */
-    public Element insertSecurityHeader(Document doc) {
-
-        /*
-         * If there is already a security header in this instance just return it
-         */
-        if (securityHeader != null) {
-            return securityHeader;
-        }
-        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
-                .getDocumentElement());
-
-        securityHeader = WSSecurityUtil.findWsseSecurityHeaderBlock(doc, doc
-                .getDocumentElement(), actor, true);
-
-        String soapPrefix = WSSecurityUtil.getPrefixNS(soapConstants
-                .getEnvelopeURI(), securityHeader);
-        if (actor != null && actor.length() > 0) {
-            securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
-                    soapPrefix
-                            + ":"
-                            + soapConstants.getRoleAttributeQName()
-                                    .getLocalPart(), actor);
-        }
-        if (mustunderstand) {
-            securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
-                    soapPrefix + ":" + WSConstants.ATTR_MUST_UNDERSTAND,
-                    soapConstants.getMustunderstand());
-        }
-        return securityHeader;
-    }
-    
-    public void removeSecurityHeader(Document doc) {
-        
-        if (securityHeader == null) {            
-            securityHeader = WSSecurityUtil.findWsseSecurityHeaderBlock(doc, doc
-                    .getDocumentElement(), actor, false);
-            if ( securityHeader == null ) {
-                return;
-            }
-        }
-        
-        Node parent = securityHeader.getParentNode();
-        parent.removeChild(securityHeader);
-    }
-    
-}
+/*
+ * Copyright  2003-2004 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ws.security.message;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.SOAPConstants;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.util.WSSecurityUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * This class implements WS Security header.
+ * 
+ * Setup a Security header with a specified actor and mustunderstand flag.
+ * 
+ * <p/>
+ * 
+ * The defaults for actor and mustunderstand are: empty <code>actor</code> and
+ * <code>mustunderstand</code> is true.
+ * 
+ * @author Werner Dittmann (Werner.Dittmann@apache.org)
+ */
+public class WSSecHeader {
+    private static Log log = LogFactory.getLog(WSSecHeader.class.getName());
+
+    protected String actor = null;
+
+    protected boolean mustunderstand = true;
+
+    protected boolean doDebug = false;
+
+    private Element securityHeader = null;
+
+    /**
+     * Constructor.
+     */
+    public WSSecHeader() {
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param actor
+     *            The actor name of the <code>wsse:Security</code> header
+     */
+    public WSSecHeader(String actor) {
+        this(actor, true);
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param actor
+     *            The actor name of the <code>wsse:Security</code> header
+     * @param mu
+     *            Set <code>mustUnderstand</code> to true or false
+     */
+    public WSSecHeader(String act, boolean mu) {
+        actor = act;
+        mustunderstand = mu;
+    }
+
+    /**
+     * set actor name.
+     * 
+     * @param act
+     *            The actor name of the <code>wsse:Security</code> header
+     */
+    public void setActor(String act) {
+        actor = act;
+    }
+
+    /**
+     * Set the <code>mustUnderstand</code> flag for the
+     * <code>wsse:Security</code> header.
+     * 
+     * @param mu
+     *            Set <code>mustUnderstand</code> to true or false
+     */
+    public void setMustUnderstand(boolean mu) {
+        mustunderstand = mu;
+    }
+
+    /**
+     * Get the security header element of this instance.
+     * 
+     * @return The security header element.
+     */
+    public Element getSecurityHeader() {
+        return securityHeader;
+    }
+    
+    /**
+     * Returns whether the security header is empty
+     * 
+     * @return true if empty or if there is no security header
+     *         false if non empty security header
+     */
+    public boolean isEmpty(Document doc) {
+        
+        if (securityHeader == null) {            
+            securityHeader = WSSecurityUtil.findWsseSecurityHeaderBlock(doc, doc
+                    .getDocumentElement(), actor, false);
+            if ( securityHeader == null ) {
+                return true;
+            }
+        }
+        
+        if ( securityHeader.getChildNodes().getLength() == 0 ) {
+            return true;
+        } else {
+            return false;
+        }
+
+        
+    }
+
+    /**
+     * Creates a security header and inserts it as child into the SOAP Envelope.
+     * 
+     * <p/>
+     * 
+     * Check if a WS Security header block for an actor is already available in
+     * the document. If a header block is found return it, otherwise a new
+     * wsse:Security header block is created and the attributes set
+     * 
+     * @param doc
+     *            A SOAP envelope as <code>Document</code>
+     * @return A <code>wsse:Security</code> element
+     */
+    public Element insertSecurityHeader(Document doc) {
+
+        /*
+         * If there is already a security header in this instance just return it
+         */
+        if (securityHeader != null) {
+            return securityHeader;
+        }
+        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
+                .getDocumentElement());
+
+        securityHeader = WSSecurityUtil.findWsseSecurityHeaderBlock(doc, doc
+                .getDocumentElement(), actor, true);
+
+        String soapPrefix = WSSecurityUtil.getPrefixNS(soapConstants
+                .getEnvelopeURI(), securityHeader);
+        if (actor != null && actor.length() > 0) {
+            securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
+                    soapPrefix
+                            + ":"
+                            + soapConstants.getRoleAttributeQName()
+                                    .getLocalPart(), actor);
+        }
+        if (mustunderstand) {
+            securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
+                    soapPrefix + ":" + WSConstants.ATTR_MUST_UNDERSTAND,
+                    soapConstants.getMustunderstand());
+        }
+        return securityHeader;
+    }
+    
+    public void removeSecurityHeader(Document doc) {
+        
+        if (securityHeader == null) {            
+            securityHeader = WSSecurityUtil.findWsseSecurityHeaderBlock(doc, doc
+                    .getDocumentElement(), actor, false);
+            if ( securityHeader == null ) {
+                return;
+            }
+        }
+        
+        Node parent = securityHeader.getParentNode();
+        parent.removeChild(securityHeader);
+    }
+    
+}

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSAMLToken.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSecurityContextToken.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java?rev=647260&r1=647259&r2=647260&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java Fri Apr 11 11:40:21 2008
@@ -1,144 +1,144 @@
-/*
- * Copyright  2003-2005 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.ws.security.message;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ws.security.message.token.SignatureConfirmation;
-import org.apache.ws.security.util.WSSecurityUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Builds a WS SignatureConfirmation and inserts it into the SOAP Envelope.
- * 
- * @author Werner Dittmann (Werner.Dittmann@t-online.de).
- */
-
-public class WSSecSignatureConfirmation extends WSSecBase {
-    private static Log log = LogFactory.getLog(WSSecSignatureConfirmation.class
-            .getName());
-
-    private SignatureConfirmation sc = null;
-
-    private Document document = null;
-    
-    byte[] signatureValue = null;
-
-    /**
-     * Constructor.
-     */
-    public WSSecSignatureConfirmation() {
-    }
-
-	/**
-	 * Set the Signature value to store in this SignatureConfirmation.
-	 * 
-	 * @param signatureValue
-	 *            The Signature value to store in the SignatureConfirmation
-	 *            element
-	 */
-	public void setSignatureValue(byte[] signatureValue) {
-		this.signatureValue = signatureValue;
-	}
-
-
-	/**
-	 * Creates a SignatureConfimation element.
-	 * 
-	 * The method prepares and initializes a WSSec SignatureConfirmation structure after
-	 * the relevant information was set. Before calling <code>prepare()</code> the
-	 * filed <code>signatureValue</code> must be set
-	 * 
-	 * @param doc
-	 *            The SOAP envelope as W3C document
-	 */
-	public void prepare(Document doc) {
-		document = doc;
-        sc = new SignatureConfirmation(doc, signatureValue);;
-		String scId = "SigConf-" + sc.hashCode();
-		sc.setID(scId);
-	}
-    
-	/**
-	 * Prepends the SignatureConfirmation element to the elements already in the
-	 * Security header.
-	 * 
-	 * The method can be called any time after <code>prepare()</code>.
-	 * This allows to insert the SignatureConfirmation element at any position in the
-	 * Security header.
-	 * 
-	 * @param secHeader
-	 *            The security header that holds the Signature element.
-	 */
-	public void prependToHeader(WSSecHeader secHeader) {
-		WSSecurityUtil.prependChildElement(document, secHeader
-				.getSecurityHeader(), sc.getElement(), false);
-	}
-    
-    /**
-     * Adds a new <code>SignatureConfirmation</code> to a soap envelope.
-     * 
-     * A complete <code>SignatureConfirmation</code> is constructed and added
-     * to the <code>wsse:Security</code> header.
-     * 
-     * @param doc
-     *            The SOAP enevlope as W3C document
-     * @param sigVal
-     *            the Signature value. This will be the content of the "Value"
-     *            attribute.
- 	 * @param secHeader
-	 *            The security header that holds the Signature element.
-    * @return Document with SignatureConfirmation added
-     */
-    public Document build(Document doc, byte[] sigVal, WSSecHeader secHeader) {
-        log.debug("Begin add signature confirmation...");
-        
-        signatureValue = sigVal;
-		prepare(doc);
-		prependToHeader(secHeader);
-        
-        return doc;
-    }
-
-	/**
-	 * Get the id generated during <code>prepare()</code>.
-	 * 
-	 * Returns the the value of wsu:Id attribute of this SignatureConfirmation. 
-	 * 
-	 * @return Return the wsu:Id of this token or null if <code>prepareToken()</code>
-	 * was not called before.
-	 */
-    public String getId() {
-    	if (sc == null) {
-    		return null;
-    	}
-        return sc.getID();
-    }
-    
-    /**
-     * Get the SignatureConfirmation element generated during 
-     * <code>prepare()</code>.
-     * 
-     * @return Return the SignatureConfirmation element or null if <code>prepare()</code>
-     * was not called before.
-     */
-    public Element getSignatureConfirmationElement() {
-        return (this.sc != null) ? this.sc.getElement() : null;
-    }
-}
+/*
+ * Copyright  2003-2005 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ws.security.message;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.message.token.SignatureConfirmation;
+import org.apache.ws.security.util.WSSecurityUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Builds a WS SignatureConfirmation and inserts it into the SOAP Envelope.
+ * 
+ * @author Werner Dittmann (Werner.Dittmann@t-online.de).
+ */
+
+public class WSSecSignatureConfirmation extends WSSecBase {
+    private static Log log = LogFactory.getLog(WSSecSignatureConfirmation.class
+            .getName());
+
+    private SignatureConfirmation sc = null;
+
+    private Document document = null;
+    
+    byte[] signatureValue = null;
+
+    /**
+     * Constructor.
+     */
+    public WSSecSignatureConfirmation() {
+    }
+
+	/**
+	 * Set the Signature value to store in this SignatureConfirmation.
+	 * 
+	 * @param signatureValue
+	 *            The Signature value to store in the SignatureConfirmation
+	 *            element
+	 */
+	public void setSignatureValue(byte[] signatureValue) {
+		this.signatureValue = signatureValue;
+	}
+
+
+	/**
+	 * Creates a SignatureConfimation element.
+	 * 
+	 * The method prepares and initializes a WSSec SignatureConfirmation structure after
+	 * the relevant information was set. Before calling <code>prepare()</code> the
+	 * filed <code>signatureValue</code> must be set
+	 * 
+	 * @param doc
+	 *            The SOAP envelope as W3C document
+	 */
+	public void prepare(Document doc) {
+		document = doc;
+        sc = new SignatureConfirmation(doc, signatureValue);;
+		String scId = "SigConf-" + sc.hashCode();
+		sc.setID(scId);
+	}
+    
+	/**
+	 * Prepends the SignatureConfirmation element to the elements already in the
+	 * Security header.
+	 * 
+	 * The method can be called any time after <code>prepare()</code>.
+	 * This allows to insert the SignatureConfirmation element at any position in the
+	 * Security header.
+	 * 
+	 * @param secHeader
+	 *            The security header that holds the Signature element.
+	 */
+	public void prependToHeader(WSSecHeader secHeader) {
+		WSSecurityUtil.prependChildElement(document, secHeader
+				.getSecurityHeader(), sc.getElement(), false);
+	}
+    
+    /**
+     * Adds a new <code>SignatureConfirmation</code> to a soap envelope.
+     * 
+     * A complete <code>SignatureConfirmation</code> is constructed and added
+     * to the <code>wsse:Security</code> header.
+     * 
+     * @param doc
+     *            The SOAP enevlope as W3C document
+     * @param sigVal
+     *            the Signature value. This will be the content of the "Value"
+     *            attribute.
+ 	 * @param secHeader
+	 *            The security header that holds the Signature element.
+    * @return Document with SignatureConfirmation added
+     */
+    public Document build(Document doc, byte[] sigVal, WSSecHeader secHeader) {
+        log.debug("Begin add signature confirmation...");
+        
+        signatureValue = sigVal;
+		prepare(doc);
+		prependToHeader(secHeader);
+        
+        return doc;
+    }
+
+	/**
+	 * Get the id generated during <code>prepare()</code>.
+	 * 
+	 * Returns the the value of wsu:Id attribute of this SignatureConfirmation. 
+	 * 
+	 * @return Return the wsu:Id of this token or null if <code>prepareToken()</code>
+	 * was not called before.
+	 */
+    public String getId() {
+    	if (sc == null) {
+    		return null;
+    	}
+        return sc.getID();
+    }
+    
+    /**
+     * Get the SignatureConfirmation element generated during 
+     * <code>prepare()</code>.
+     * 
+     * @return Return the SignatureConfirmation element or null if <code>prepare()</code>
+     * was not called before.
+     */
+    public Element getSignatureConfirmationElement() {
+        return (this.sc != null) ? this.sc.getElement() : null;
+    }
+}

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java?rev=647260&r1=647259&r2=647260&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java Fri Apr 11 11:40:21 2008
@@ -1,143 +1,143 @@
-/*
- * Copyright  2003-2005 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.ws.security.message;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ws.security.message.token.Timestamp;
-import org.apache.ws.security.util.WSSecurityUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Builds a WS Timestamp and inserts it into the SOAP Envelope. Refer to the WS
- * specification 1.0. chapter 10 / appendix A.2
- * 
- * @author Christof Soehngen (Christof.Soehngen@syracom.de).
- * @author Werner Dittmann (werner@apache.org).
- */
-
-public class WSSecTimestamp extends WSSecBase {
-    private static Log log = LogFactory.getLog(WSSecTimestamp.class.getName());
-
-    private Timestamp ts = null;
-
-    private Document document = null;
-
-    private int timeToLive = 300; // time between Created and Expires
-
-    /**
-     * Constructor.
-     */
-    public WSSecTimestamp() {
-    }
-
-    /**
-     * Set the time to live. This is the time difference in seconds between the
-     * <code>Created</code> and the <code>Expires</code> in
-     * <code>Timestamp</code>. <p/>
-     * 
-     * @param ttl
-     *            The time to live in second
-     */
-    public void setTimeToLive(int ttl) {
-        timeToLive = ttl;
-    }
-
-    /**
-     * Creates a Timestamp element.
-     * 
-     * The method prepares and initializes a WSSec Timestamp structure after the
-     * relevant information was set. Before calling <code>prepare()</code> the
-     * parameter such as <code>timeToLive</code> can be set if the deafult
-     * value is not suitable.
-     * 
-     * @param doc
-     *            The SOAP enevlope as W3C document
-     */
-    public void prepare(Document doc) {
-        document = doc;
-        ts = new Timestamp(wssConfig.isPrecisionInMilliSeconds(), doc,
-                timeToLive);
-        String tsId = "Timestamp-" + ts.hashCode();
-        ts.setID(tsId);
-    }
-
-    /**
-     * Prepends the Timestamp element to the elements already in the Security
-     * header.
-     * 
-     * The method can be called any time after <code>prepare()</code>. This
-     * allows to insert the Timestamp element at any position in the Security
-     * header.
-     * 
-     * @param secHeader
-     *            The security header that holds the Signature element.
-     */
-    public void prependToHeader(WSSecHeader secHeader) {
-        WSSecurityUtil.prependChildElement(document, secHeader
-                .getSecurityHeader(), ts.getElement(), false);
-    }
-
-    /**
-     * Adds a new <code>Timestamp</code> to a soap envelope.
-     * 
-     * A complete <code>Timestamp</code> is constructed and added to the
-     * <code>wsse:Security</code> header.
-     * 
-     * @param doc
-     *            The SOAP envelope as W3C document
-     * @param secHeader
-     *            The security header that hold this Timestamp
-     * @return Document with Timestamp added
-     * @throws Exception
-     */
-    public Document build(Document doc, WSSecHeader secHeader) {
-        log.debug("Begin add timestamp...");
-
-        prepare(doc);
-        prependToHeader(secHeader);
-
-        return doc;
-    }
-
-    /**
-     * Get the id generated during <code>prepare()</code>.
-     * 
-     * Returns the the value of wsu:Id attribute of this Timestamp.
-     * 
-     * @return Return the wsu:Id of this token or null if
-     *         <code>prepareToken()</code> was not called before.
-     */
-    public String getId() {
-        if (ts == null) {
-            return null;
-        }
-        return ts.getID();
-    }
-    
-    /**
-     * Get the timestamp element generated during <code>prepare()</code>.
-     */
-    public Element getElement() {
-        if (ts == null) {
-            return null;
-        }
-        return ts.getElement();
-    }
-}
+/*
+ * Copyright  2003-2005 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ws.security.message;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.message.token.Timestamp;
+import org.apache.ws.security.util.WSSecurityUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Builds a WS Timestamp and inserts it into the SOAP Envelope. Refer to the WS
+ * specification 1.0. chapter 10 / appendix A.2
+ * 
+ * @author Christof Soehngen (Christof.Soehngen@syracom.de).
+ * @author Werner Dittmann (werner@apache.org).
+ */
+
+public class WSSecTimestamp extends WSSecBase {
+    private static Log log = LogFactory.getLog(WSSecTimestamp.class.getName());
+
+    private Timestamp ts = null;
+
+    private Document document = null;
+
+    private int timeToLive = 300; // time between Created and Expires
+
+    /**
+     * Constructor.
+     */
+    public WSSecTimestamp() {
+    }
+
+    /**
+     * Set the time to live. This is the time difference in seconds between the
+     * <code>Created</code> and the <code>Expires</code> in
+     * <code>Timestamp</code>. <p/>
+     * 
+     * @param ttl
+     *            The time to live in second
+     */
+    public void setTimeToLive(int ttl) {
+        timeToLive = ttl;
+    }
+
+    /**
+     * Creates a Timestamp element.
+     * 
+     * The method prepares and initializes a WSSec Timestamp structure after the
+     * relevant information was set. Before calling <code>prepare()</code> the
+     * parameter such as <code>timeToLive</code> can be set if the deafult
+     * value is not suitable.
+     * 
+     * @param doc
+     *            The SOAP enevlope as W3C document
+     */
+    public void prepare(Document doc) {
+        document = doc;
+        ts = new Timestamp(wssConfig.isPrecisionInMilliSeconds(), doc,
+                timeToLive);
+        String tsId = "Timestamp-" + ts.hashCode();
+        ts.setID(tsId);
+    }
+
+    /**
+     * Prepends the Timestamp element to the elements already in the Security
+     * header.
+     * 
+     * The method can be called any time after <code>prepare()</code>. This
+     * allows to insert the Timestamp element at any position in the Security
+     * header.
+     * 
+     * @param secHeader
+     *            The security header that holds the Signature element.
+     */
+    public void prependToHeader(WSSecHeader secHeader) {
+        WSSecurityUtil.prependChildElement(document, secHeader
+                .getSecurityHeader(), ts.getElement(), false);
+    }
+
+    /**
+     * Adds a new <code>Timestamp</code> to a soap envelope.
+     * 
+     * A complete <code>Timestamp</code> is constructed and added to the
+     * <code>wsse:Security</code> header.
+     * 
+     * @param doc
+     *            The SOAP envelope as W3C document
+     * @param secHeader
+     *            The security header that hold this Timestamp
+     * @return Document with Timestamp added
+     * @throws Exception
+     */
+    public Document build(Document doc, WSSecHeader secHeader) {
+        log.debug("Begin add timestamp...");
+
+        prepare(doc);
+        prependToHeader(secHeader);
+
+        return doc;
+    }
+
+    /**
+     * Get the id generated during <code>prepare()</code>.
+     * 
+     * Returns the the value of wsu:Id attribute of this Timestamp.
+     * 
+     * @return Return the wsu:Id of this token or null if
+     *         <code>prepareToken()</code> was not called before.
+     */
+    public String getId() {
+        if (ts == null) {
+            return null;
+        }
+        return ts.getID();
+    }
+    
+    /**
+     * Get the timestamp element generated during <code>prepare()</code>.
+     */
+    public Element getElement() {
+        if (ts == null) {
+            return null;
+        }
+        return ts.getElement();
+    }
+}

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecTimestamp.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecUsernameToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecUsernameToken.java?rev=647260&r1=647259&r2=647260&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecUsernameToken.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecUsernameToken.java Fri Apr 11 11:40:21 2008
@@ -1,213 +1,213 @@
-/*
- * Copyright  2003-2004 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.ws.security.message;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ws.security.WSConstants;
-import org.apache.ws.security.message.token.UsernameToken;
-import org.apache.ws.security.util.WSSecurityUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Builds a WS UsernameToken.
- * 
- * Refer to the WS specification, UsernameToken profile
- * 
- * @author Werner Dittmann (werner@apache.org).
- */
-
-public class WSSecUsernameToken extends WSSecBase {
-	private static Log log = LogFactory.getLog(WSSecUsernameToken.class
-			.getName());
-
-	private String passwordType = WSConstants.PASSWORD_DIGEST;
-
-	private UsernameToken ut = null;
-
-	private String id = null;
-
-	private boolean nonce = false;
-
-	private boolean created = false;
-
-	private Document document = null;
-
-	/**
-	 * Constructor.
-	 */
-	public WSSecUsernameToken() {
-	}
-
-	/**
-	 * Defines how to construct the password element of the
-	 * <code>UsernameToken</code>.
-	 * 
-	 * @param pwType
-	 *            contains the password type. Only allowed values are
-	 *            {@link WSConstants#PASSWORD_DIGEST} and
-	 *            {@link WSConstants#PASSWORD_TEXT}.
-	 * 			  or null when no password is needed.
-	 */
-	public void setPasswordType(String pwType) {
-		this.passwordType = pwType;
-	}
-
-	/**
-	 * Add a Nonce element to the UsernameToken.
-	 */
-	public void addNonce() {
-		nonce = true;
-	}
-
-	/**
-	 * Add a Created element to the UsernameToken.
-	 */
-	public void addCreated() {
-		created = true;
-	}
-
-	
-	/**
-	 * Get the derived secret key.
-	 * 
-	 * After the <code>prepare()</code> method was called use this method
-	 * to compute a derived secret key. The generation of this secret key is according
-	 * to WS-Trust specification.
-	 * 
-	 * @return Return the derived secret key of this token or null if <code>prepare()</code>
-	 * was not called before.
-	 */
-	public byte[] getSecretKey() {
-		if (ut == null) {
-			return null;
-		}
-		return ut.getSecretKey();
-	}
-
-	/**
-	 * Get the id generated during <code>prepare()</code>.
-	 * 
-	 * Returns the the value of wsu:Id attribute of this UsernameToken. 
-	 * 
-	 * @return Return the wsu:Id of this token or null if <code>prepare()</code>
-	 * was not called before.
-	 */
-	public String getId() {
-		if (ut == null) {
-			return null;
-		}
-		return ut.getID();
-	}
-
-	/**
-	 * Creates a Username token.
-	 * 
-	 * The method prepares and initializes a WSSec UsernameToken structure after
-	 * the relevant information was set. A Before calling
-	 * <code>prepare()</code> all parameters such as user, password,
-	 * passwordType etc. must be set. A complete <code>UsernameToken</code> is
-	 * constructed.
-	 * 
-	 * @param doc
-	 *            The SOAP envelope as W3C document
-	 */
-	public void prepare(Document doc) {
-		document = doc;
-		ut = new UsernameToken(wssConfig.isPrecisionInMilliSeconds(), doc,
-				passwordType);
-		ut.setName(user);
-		ut.setPassword(password);
-		String utId = "UsernameToken-" + ut.hashCode();
-		ut.setID(utId);
-		if (nonce) {
-			ut.addNonce(doc);
-		}
-		if (created) {
-			ut.addCreated(wssConfig.isPrecisionInMilliSeconds(), doc);
-		}
-	}
-
-	/**
-	 * Prepends the UsernameToken element to the elements already in the
-	 * Security header.
-	 * 
-	 * The method can be called any time after <code>prepare()</code>.
-	 * This allows to insert the UsernameToken element at any position in the
-	 * Security header.
-	 * 
-	 * @param secHeader
-	 *            The security header that holds the Signature element.
-	 */
-	public void prependToHeader(WSSecHeader secHeader) {
-		WSSecurityUtil.prependChildElement(document, secHeader
-				.getSecurityHeader(), ut.getElement(), false);
-	}
-
-    /**
-     * Appends the UsernameToken element to the elements already in the
-     * Security header.
-     * 
-     * The method can be called any time after <code>prepare()</code>.
-     * This allows to insert the UsernameToken element at any position in the
-     * Security header.
-     * 
-     * @param secHeader
-     *            The security header that holds the Signature element.
-     */
-    public void appendToHeader(WSSecHeader secHeader) {
-        WSSecurityUtil.appendChildElement(document, secHeader
-                .getSecurityHeader(), ut.getElement());
-    }
-	/**
-	 * Adds a new <code>UsernameToken</code> to a soap envelope.
-	 * 
-	 * Before calling <code>build()</code> all parameters such as user,
-	 * password, passwordType etc. must be set. A complete
-	 * <code>UsernameToken</code> is constructed and added to the
-	 * <code>wsse:Security</code> header.
-	 * 
-	 * @param doc
-	 *            The SOAP envelope as W3C document
-	 * @param secHeader
-	 *            The security header inside the SOAP envelope
-	 * @return Document with UsernameToken added
-	 */
-	public Document build(Document doc, WSSecHeader secHeader) {
-		log.debug("Begin add username token...");
-
-		prepare(doc);
-		prependToHeader(secHeader);
-
-		return doc;
-	}
-
-    /**
-     * Returns the <code>UsernameToken</code> element.
-     * 
-     * The method can be called any time after <code>prepare()</code>.
-     * This allows to insert the UsernameToken element at any position in the
-     * Security header.
-     * 
-     * @return
-     */
-    public Element getUsernameTokenElement() {
-       return this.ut.getElement(); 
-    }
-}
+/*
+ * Copyright  2003-2004 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ws.security.message;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.message.token.UsernameToken;
+import org.apache.ws.security.util.WSSecurityUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Builds a WS UsernameToken.
+ * 
+ * Refer to the WS specification, UsernameToken profile
+ * 
+ * @author Werner Dittmann (werner@apache.org).
+ */
+
+public class WSSecUsernameToken extends WSSecBase {
+	private static Log log = LogFactory.getLog(WSSecUsernameToken.class
+			.getName());
+
+	private String passwordType = WSConstants.PASSWORD_DIGEST;
+
+	private UsernameToken ut = null;
+
+	private String id = null;
+
+	private boolean nonce = false;
+
+	private boolean created = false;
+
+	private Document document = null;
+
+	/**
+	 * Constructor.
+	 */
+	public WSSecUsernameToken() {
+	}
+
+	/**
+	 * Defines how to construct the password element of the
+	 * <code>UsernameToken</code>.
+	 * 
+	 * @param pwType
+	 *            contains the password type. Only allowed values are
+	 *            {@link WSConstants#PASSWORD_DIGEST} and
+	 *            {@link WSConstants#PASSWORD_TEXT}.
+	 * 			  or null when no password is needed.
+	 */
+	public void setPasswordType(String pwType) {
+		this.passwordType = pwType;
+	}
+
+	/**
+	 * Add a Nonce element to the UsernameToken.
+	 */
+	public void addNonce() {
+		nonce = true;
+	}
+
+	/**
+	 * Add a Created element to the UsernameToken.
+	 */
+	public void addCreated() {
+		created = true;
+	}
+
+	
+	/**
+	 * Get the derived secret key.
+	 * 
+	 * After the <code>prepare()</code> method was called use this method
+	 * to compute a derived secret key. The generation of this secret key is according
+	 * to WS-Trust specification.
+	 * 
+	 * @return Return the derived secret key of this token or null if <code>prepare()</code>
+	 * was not called before.
+	 */
+	public byte[] getSecretKey() {
+		if (ut == null) {
+			return null;
+		}
+		return ut.getSecretKey();
+	}
+
+	/**
+	 * Get the id generated during <code>prepare()</code>.
+	 * 
+	 * Returns the the value of wsu:Id attribute of this UsernameToken. 
+	 * 
+	 * @return Return the wsu:Id of this token or null if <code>prepare()</code>
+	 * was not called before.
+	 */
+	public String getId() {
+		if (ut == null) {
+			return null;
+		}
+		return ut.getID();
+	}
+
+	/**
+	 * Creates a Username token.
+	 * 
+	 * The method prepares and initializes a WSSec UsernameToken structure after
+	 * the relevant information was set. A Before calling
+	 * <code>prepare()</code> all parameters such as user, password,
+	 * passwordType etc. must be set. A complete <code>UsernameToken</code> is
+	 * constructed.
+	 * 
+	 * @param doc
+	 *            The SOAP envelope as W3C document
+	 */
+	public void prepare(Document doc) {
+		document = doc;
+		ut = new UsernameToken(wssConfig.isPrecisionInMilliSeconds(), doc,
+				passwordType);
+		ut.setName(user);
+		ut.setPassword(password);
+		String utId = "UsernameToken-" + ut.hashCode();
+		ut.setID(utId);
+		if (nonce) {
+			ut.addNonce(doc);
+		}
+		if (created) {
+			ut.addCreated(wssConfig.isPrecisionInMilliSeconds(), doc);
+		}
+	}
+
+	/**
+	 * Prepends the UsernameToken element to the elements already in the
+	 * Security header.
+	 * 
+	 * The method can be called any time after <code>prepare()</code>.
+	 * This allows to insert the UsernameToken element at any position in the
+	 * Security header.
+	 * 
+	 * @param secHeader
+	 *            The security header that holds the Signature element.
+	 */
+	public void prependToHeader(WSSecHeader secHeader) {
+		WSSecurityUtil.prependChildElement(document, secHeader
+				.getSecurityHeader(), ut.getElement(), false);
+	}
+
+    /**
+     * Appends the UsernameToken element to the elements already in the
+     * Security header.
+     * 
+     * The method can be called any time after <code>prepare()</code>.
+     * This allows to insert the UsernameToken element at any position in the
+     * Security header.
+     * 
+     * @param secHeader
+     *            The security header that holds the Signature element.
+     */
+    public void appendToHeader(WSSecHeader secHeader) {
+        WSSecurityUtil.appendChildElement(document, secHeader
+                .getSecurityHeader(), ut.getElement());
+    }
+	/**
+	 * Adds a new <code>UsernameToken</code> to a soap envelope.
+	 * 
+	 * Before calling <code>build()</code> all parameters such as user,
+	 * password, passwordType etc. must be set. A complete
+	 * <code>UsernameToken</code> is constructed and added to the
+	 * <code>wsse:Security</code> header.
+	 * 
+	 * @param doc
+	 *            The SOAP envelope as W3C document
+	 * @param secHeader
+	 *            The security header inside the SOAP envelope
+	 * @return Document with UsernameToken added
+	 */
+	public Document build(Document doc, WSSecHeader secHeader) {
+		log.debug("Begin add username token...");
+
+		prepare(doc);
+		prependToHeader(secHeader);
+
+		return doc;
+	}
+
+    /**
+     * Returns the <code>UsernameToken</code> element.
+     * 
+     * The method can be called any time after <code>prepare()</code>.
+     * This allows to insert the UsernameToken element at any position in the
+     * Security header.
+     * 
+     * @return
+     */
+    public Element getUsernameTokenElement() {
+       return this.ut.getElement(); 
+    }
+}

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecUsernameToken.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java
------------------------------------------------------------------------------
    svn:eol-style = native



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