Author: coheigea
Date: Fri Feb  7 16:51:12 2014
New Revision: 1565722

URL: http://svn.apache.org/r1565722
Log:
Removing ConversationException

Removed:
    
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/ConversationException.java
    
webservices/wss4j/trunk/ws-security-common/src/main/resources/messages/conversation/errors.properties
Modified:
    
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/AlgoFactory.java
    
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivationAlgorithm.java
    
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivedKeyUtils.java
    
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/P_SHA1.java
    
webservices/wss4j/trunk/ws-security-common/src/main/resources/messages/wss4j_errors.properties
    
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java
    
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
    
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java
    
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
    
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
    
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
    
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java
    
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/DerivedKeyTokenOutputProcessor.java

Modified: 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/AlgoFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/AlgoFactory.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/AlgoFactory.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/AlgoFactory.java
 Fri Feb  7 16:51:12 2014
@@ -19,6 +19,8 @@
 
 package org.apache.wss4j.common.derivedKey;
 
+import org.apache.wss4j.common.ext.WSSecurityException;
+
 public final class AlgoFactory {
     
     private AlgoFactory() {
@@ -33,13 +35,13 @@ public final class AlgoFactory {
      * @throws ConversationException If the specified algorithm is not 
available
      *                               in default implementations
      */
-    public static DerivationAlgorithm getInstance(String algorithm) throws
-            ConversationException {
+    public static DerivationAlgorithm getInstance(String algorithm) throws 
WSSecurityException {
         if 
(ConversationConstants.DerivationAlgorithm.P_SHA_1_2005_12.equals(algorithm)
             || 
ConversationConstants.DerivationAlgorithm.P_SHA_1.equals(algorithm)) {
             return new P_SHA1();
         } else {
-            throw new ConversationException("No such algorithm");
+            throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, 
+                                          "unknownAlgorithm", algorithm);
         }
     }
 

Modified: 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivationAlgorithm.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivationAlgorithm.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivationAlgorithm.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivationAlgorithm.java
 Fri Feb  7 16:51:12 2014
@@ -19,9 +19,11 @@
 
 package org.apache.wss4j.common.derivedKey;
 
+import org.apache.wss4j.common.ext.WSSecurityException;
+
 
 public interface DerivationAlgorithm {
 
     byte[] createKey(byte[] secret, byte[] seed, int offset,
-            long length) throws ConversationException;
+            long length) throws WSSecurityException;
 }

Modified: 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivedKeyUtils.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivedKeyUtils.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivedKeyUtils.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/DerivedKeyUtils.java
 Fri Feb  7 16:51:12 2014
@@ -18,6 +18,8 @@
  */
 package org.apache.wss4j.common.derivedKey;
 
+import java.io.UnsupportedEncodingException;
+
 import org.apache.wss4j.common.ext.WSSecurityException;
 
 public class DerivedKeyUtils {
@@ -30,28 +32,28 @@ public class DerivedKeyUtils {
      * @throws org.apache.wss4j.stax.wss.ext.WSSecurityException
      *
      */
-    public static byte[] deriveKey(String algorithm, String label, int length, 
byte[] secret, byte[] nonce, int offset) throws WSSecurityException {
+    public static byte[] deriveKey(String algorithm, String label, int length, 
byte[] secret, byte[] nonce, int offset) 
+        throws WSSecurityException {
+        DerivationAlgorithm algo = AlgoFactory.getInstance(algorithm);
+        byte[] labelBytes;
         try {
-            DerivationAlgorithm algo = AlgoFactory.getInstance(algorithm);
-            byte[] labelBytes;
             if (label == null || label.length() == 0) {
                 String defaultLabel = ConversationConstants.DEFAULT_LABEL + 
ConversationConstants.DEFAULT_LABEL;
                 labelBytes = defaultLabel.getBytes("UTF-8");
             } else {
                 labelBytes = label.getBytes("UTF-8");
             }
+        } catch (UnsupportedEncodingException ex) {
+            throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex);
+        }
 
-            byte[] seed = new byte[labelBytes.length + nonce.length];
-            System.arraycopy(labelBytes, 0, seed, 0, labelBytes.length);
-            System.arraycopy(nonce, 0, seed, labelBytes.length, nonce.length);
-
-            if (length <= 0) {
-                length = 32;
-            }
-            return algo.createKey(secret, seed, offset, length);
+        byte[] seed = new byte[labelBytes.length + nonce.length];
+        System.arraycopy(labelBytes, 0, seed, 0, labelBytes.length);
+        System.arraycopy(nonce, 0, seed, labelBytes.length, nonce.length);
 
-        } catch (Exception e) {
-            throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
+        if (length <= 0) {
+            length = 32;
         }
+        return algo.createKey(secret, seed, offset, length);
     }
 }

Modified: 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/P_SHA1.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/P_SHA1.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/P_SHA1.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/P_SHA1.java
 Fri Feb  7 16:51:12 2014
@@ -41,6 +41,9 @@ package org.apache.wss4j.common.derivedK
 
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
+
+import org.apache.wss4j.common.ext.WSSecurityException;
+
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 
@@ -48,7 +51,7 @@ public class P_SHA1 implements Derivatio
 
     @Override
     public byte[] createKey(byte[] secret, byte[] seed, int offset, long 
length)
-            throws ConversationException {
+            throws WSSecurityException {
 
         try {
             Mac mac = Mac.getInstance("HmacSHA1");
@@ -61,9 +64,9 @@ public class P_SHA1 implements Derivatio
 
             return key;
         } catch (NoSuchAlgorithmException e) {
-            throw new ConversationException("errorInKeyDerivation", null, e);
+            throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, 
"errorInKeyDerivation", e);
         } catch (InvalidKeyException e) {
-            throw new ConversationException("errorInKeyDerivation", null, e);
+            throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, 
"errorInKeyDerivation", e);
         }
     }
 

Modified: 
webservices/wss4j/trunk/ws-security-common/src/main/resources/messages/wss4j_errors.properties
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/resources/messages/wss4j_errors.properties?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-common/src/main/resources/messages/wss4j_errors.properties
 (original)
+++ 
webservices/wss4j/trunk/ws-security-common/src/main/resources/messages/wss4j_errors.properties
 Fri Feb  7 16:51:12 2014
@@ -85,6 +85,7 @@ signatureKeyStoreNotSet = Signature KeyS
 signatureVerificationCryptoFailure = SignatureVerificationCrypto instantiation 
failed
 signatureVerificationKeyStoreNotSet = Signature verification KeyStore is not 
set
 spnegoKeyError = An error occurred in trying to unwrap a SPNEGO key
+unknownAlgorithm = An unknown algorithm was specified: {0}
 unableToLoadClass = Unable to load class {0}
 unhandledToken = Security token supported but currently not handled \"{0}\"
 unknownSignatureAlgorithm = An unknown signature algorithm was specified: {0}
@@ -95,3 +96,12 @@ unsupportedKeyInfo = Unsupported KeyInfo
 unsupportedKeyTransp = unsupported key transport encryption algorithm: {0}
 unsupportedSecurityToken = Unsupported SecurityToken {0}
 secureProcessing.AllowRSA15KeyTransportAlgorithm = The use of RSAv1.5 key 
transport algorithm is discouraged. Nonetheless can it be enabled via the 
\"AllowRSA15KeyTransportAlgorithm\" property in the configuration.
+
+BadContextToken = The requested context elements are insufficient or 
unsupported
+UnsupportedContextToken = Not all of the values associated with the SCT are 
supported
+UnknownDerivationSource = The specified source for the derivation is unknown
+RenewNeeded = The provided context token has expired
+UnableToRenew = The specified context token could not be renewed.
+errorInKeyDerivation = Error in key derivation
+unsupportedSecConvVersion = Unsupported WS-SecureConversation version
+offsetError =  "Offset cannot be set along with generation - generation is 
already set"

Modified: 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java
 Fri Feb  7 16:51:12 2014
@@ -28,7 +28,6 @@ import org.apache.wss4j.common.SecurityA
 import org.apache.wss4j.common.SignatureActionToken;
 import org.apache.wss4j.common.WSEncryptionPart;
 import org.apache.wss4j.common.crypto.Crypto;
-import org.apache.wss4j.common.derivedKey.ConversationException;
 import org.apache.wss4j.common.ext.WSPasswordCallback;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.dom.WSConstants;
@@ -135,19 +134,13 @@ public class SignatureDerivedAction impl
             if (encrKeyBuilder != null) {
                 encrKeyBuilder.prependToHeader(reqData.getSecHeader());
             } else if (sctId != null) {
-                try {
-                    SecurityContextToken sct = new SecurityContextToken(doc, 
sctId);
-                    
WSSecurityUtil.prependChildElement(reqData.getSecHeader().getSecurityHeader(), 
sct.getElement());
-                } catch (ConversationException ex) {
-                    ex.printStackTrace();
-                }
+                SecurityContextToken sct = new SecurityContextToken(doc, 
sctId);
+                
WSSecurityUtil.prependChildElement(reqData.getSecHeader().getSecurityHeader(), 
sct.getElement());
             }
             
             reqData.getSignatureValues().add(wsSign.getSignatureValue());
         } catch (WSSecurityException e) {
             throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty", e, "Error 
during Signature: ");
-        } catch (ConversationException e) {
-            throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty", e, "Error 
during Signature: ");
         }
     }
 

Modified: 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
 Fri Feb  7 16:51:12 2014
@@ -25,7 +25,6 @@ import org.apache.wss4j.common.WSEncrypt
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.util.KeyUtils;
 import org.apache.wss4j.common.derivedKey.ConversationConstants;
-import org.apache.wss4j.common.derivedKey.ConversationException;
 import org.apache.wss4j.dom.message.token.Reference;
 import org.apache.wss4j.dom.message.token.SecurityTokenReference;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
@@ -55,8 +54,7 @@ public class WSSecDKEncrypt extends WSSe
         super(config);
     }
     
-    public Document build(Document doc, WSSecHeader secHeader)
-        throws WSSecurityException, ConversationException {
+    public Document build(Document doc, WSSecHeader secHeader) throws 
WSSecurityException {
         
         //
         // Setup the encrypted key

Modified: 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java
 Fri Feb  7 16:51:12 2014
@@ -26,7 +26,6 @@ import org.apache.wss4j.common.WSEncrypt
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.util.KeyUtils;
 import org.apache.wss4j.common.derivedKey.ConversationConstants;
-import org.apache.wss4j.common.derivedKey.ConversationException;
 import org.apache.wss4j.dom.message.token.Reference;
 import org.apache.wss4j.dom.message.token.SecurityTokenReference;
 import org.apache.wss4j.dom.transform.STRTransform;
@@ -102,8 +101,7 @@ public class WSSecDKSign extends WSSecDe
         }
     }
     
-    public Document build(Document doc, WSSecHeader secHeader)
-        throws WSSecurityException, ConversationException {
+    public Document build(Document doc, WSSecHeader secHeader) throws 
WSSecurityException {
         
         prepare(doc, secHeader);
         String soapNamespace = 
WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
@@ -136,8 +134,7 @@ public class WSSecDKSign extends WSSecDe
         return doc;
     }
     
-    public void prepare(Document doc, WSSecHeader secHeader)
-        throws WSSecurityException, ConversationException {
+    public void prepare(Document doc, WSSecHeader secHeader) throws 
WSSecurityException {
         super.prepare(doc);
         wsDocInfo = new WSDocInfo(doc);
         securityHeader = secHeader.getSecurityHeader();

Modified: 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
 Fri Feb  7 16:51:12 2014
@@ -25,7 +25,6 @@ import org.apache.wss4j.common.ext.WSSec
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.crypto.CryptoType;
 import org.apache.wss4j.common.derivedKey.ConversationConstants;
-import org.apache.wss4j.common.derivedKey.ConversationException;
 import org.apache.wss4j.common.derivedKey.AlgoFactory;
 import org.apache.wss4j.common.derivedKey.DerivationAlgorithm;
 import org.apache.wss4j.dom.message.token.DerivedKeyToken;
@@ -198,7 +197,7 @@ public abstract class WSSecDerivedKeyBas
      * @param doc The unsigned SOAP envelope as <code>Document</code>
      * @throws WSSecurityException
      */
-    public void prepare(Document doc) throws WSSecurityException, 
ConversationException {
+    public void prepare(Document doc) throws WSSecurityException {
         
         document = doc;
 

Modified: 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
 Fri Feb  7 16:51:12 2014
@@ -22,7 +22,6 @@ package org.apache.wss4j.dom.message;
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.derivedKey.ConversationConstants;
-import org.apache.wss4j.common.derivedKey.ConversationException;
 import org.apache.wss4j.dom.message.token.SecurityContextToken;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Document;
@@ -57,8 +56,7 @@ public class WSSecSecurityContextToken {
     
     private int wscVersion = ConversationConstants.DEFAULT_VERSION;
 
-    public void prepare(Document doc, Crypto crypto)
-        throws WSSecurityException, ConversationException  {
+    public void prepare(Document doc, Crypto crypto) throws 
WSSecurityException {
 
         if (sct == null) {
             if (identifier != null) {

Modified: 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
 Fri Feb  7 16:51:12 2014
@@ -28,7 +28,6 @@ import javax.xml.namespace.QName;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.derivedKey.ConversationConstants;
-import org.apache.wss4j.common.derivedKey.ConversationException;
 import org.apache.wss4j.common.derivedKey.AlgoFactory;
 import org.apache.wss4j.common.derivedKey.DerivationAlgorithm;
 import org.apache.wss4j.common.principal.WSDerivedKeyTokenPrincipal;
@@ -77,7 +76,7 @@ public class DerivedKeyToken {
      *
      * @param doc The DOM document
      */
-    public DerivedKeyToken(Document doc) throws ConversationException {
+    public DerivedKeyToken(Document doc) throws WSSecurityException {
         this(ConversationConstants.DEFAULT_VERSION, doc);
     }
 
@@ -86,7 +85,7 @@ public class DerivedKeyToken {
      *
      * @param doc The DOM document
      */
-    public DerivedKeyToken(int version, Document doc) throws 
ConversationException {
+    public DerivedKeyToken(int version, Document doc) throws 
WSSecurityException {
         LOG.debug("DerivedKeyToken: created");
         
         ns = ConversationConstants.getWSCNs(version);
@@ -303,7 +302,7 @@ public class DerivedKeyToken {
      *
      * @param offset The offset value as an integer
      */
-    public void setOffset(int offset) throws ConversationException {
+    public void setOffset(int offset) throws WSSecurityException {
         //This element MUST NOT be used if the <Generation> element is 
specified
         if (elementGeneration == null) {
             elementOffset = 
@@ -315,9 +314,7 @@ public class DerivedKeyToken {
             );
             element.appendChild(elementOffset);
         } else {
-            throw new ConversationException(
-                "Offset cannot be set along with generation - generation is 
already set"
-            );
+            throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "offsetError");
         }
 
     }
@@ -334,7 +331,7 @@ public class DerivedKeyToken {
      *
      * @param generation generation value as an integer
      */
-    public void setGeneration(int generation) throws ConversationException {
+    public void setGeneration(int generation) throws WSSecurityException {
         //This element MUST NOT be used if the <Offset> element is specified
         if (elementOffset == null) {
             elementGeneration = 
@@ -346,9 +343,7 @@ public class DerivedKeyToken {
             );
             element.appendChild(elementGeneration);
         } else {
-            throw new ConversationException(
-                "Generation cannot be set along with offset - Offset is 
already set"
-            );
+            throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "offsetError");
         }
     }
 

Modified: 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java
 Fri Feb  7 16:51:12 2014
@@ -19,12 +19,13 @@
 
 package org.apache.wss4j.dom.message.token;
 
+import javax.xml.namespace.QName;
+
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSSConfig;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.util.DOM2Writer;
 import org.apache.wss4j.common.derivedKey.ConversationConstants;
-import org.apache.wss4j.common.derivedKey.ConversationException;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
 import org.w3c.dom.Document;
@@ -32,7 +33,6 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
 
-import javax.xml.namespace.QName;
 public class SecurityContextToken {
 
     /**
@@ -54,7 +54,7 @@ public class SecurityContextToken {
      *
      * @param doc
      */
-    public SecurityContextToken(Document doc) throws ConversationException {
+    public SecurityContextToken(Document doc) throws WSSecurityException {
         this(ConversationConstants.DEFAULT_VERSION, doc);
     }
 
@@ -63,7 +63,7 @@ public class SecurityContextToken {
      *
      * @param doc
      */
-    public SecurityContextToken(Document doc, String uuid) throws 
ConversationException {
+    public SecurityContextToken(Document doc, String uuid) throws 
WSSecurityException {
         this(ConversationConstants.DEFAULT_VERSION, doc, uuid);
     }
 
@@ -72,7 +72,7 @@ public class SecurityContextToken {
      *
      * @param doc
      */
-    public SecurityContextToken(int version, Document doc) throws 
ConversationException {
+    public SecurityContextToken(int version, Document doc) throws 
WSSecurityException {
 
         String ns = ConversationConstants.getWSCNs(version);
         
@@ -98,7 +98,7 @@ public class SecurityContextToken {
      *
      * @param doc
      */
-    public SecurityContextToken(int version, Document doc, String uuid) throws 
ConversationException {
+    public SecurityContextToken(int version, Document doc, String uuid) throws 
WSSecurityException {
 
         String ns = ConversationConstants.getWSCNs(version);
         

Modified: 
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/DerivedKeyTokenOutputProcessor.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/DerivedKeyTokenOutputProcessor.java?rev=1565722&r1=1565721&r2=1565722&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/DerivedKeyTokenOutputProcessor.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/DerivedKeyTokenOutputProcessor.java
 Fri Feb  7 16:51:12 2014
@@ -20,7 +20,6 @@ package org.apache.wss4j.stax.impl.proce
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.wss4j.common.derivedKey.AlgoFactory;
-import org.apache.wss4j.common.derivedKey.ConversationException;
 import org.apache.wss4j.common.derivedKey.DerivationAlgorithm;
 import org.apache.wss4j.common.ext.WSPasswordCallback;
 import org.apache.wss4j.common.ext.WSSecurityException;
@@ -106,32 +105,23 @@ public class DerivedKeyTokenOutputProces
             System.arraycopy(label, 0, seed, 0, label.length);
             System.arraycopy(nonce, 0, seed, label.length, nonce.length);
 
-            DerivationAlgorithm derivationAlgorithm;
-            try {
-                derivationAlgorithm = 
AlgoFactory.getInstance(WSSConstants.P_SHA_1);
-            } catch (ConversationException e) {
-                throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
-            }
+            DerivationAlgorithm derivationAlgorithm = 
+                AlgoFactory.getInstance(WSSConstants.P_SHA_1);
             
-            final byte[] derivedKeyBytes;
-            try {
-                byte[] secret;
-                if 
(WSSecurityTokenConstants.SecurityContextToken.equals(wrappingSecurityToken.getTokenType()))
 {
-                    WSPasswordCallback passwordCallback = new 
WSPasswordCallback(wsuIdDKT, WSPasswordCallback.SECRET_KEY);
-                    
WSSUtils.doSecretKeyCallback(((WSSSecurityProperties)securityProperties).getCallbackHandler(),
 passwordCallback, wsuIdDKT);
-                    if (passwordCallback.getKey() == null) {
-                        throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noKey", wsuIdDKT);
-                    }
-                    secret = passwordCallback.getKey();
-                } else {
-                    secret = 
wrappingSecurityToken.getSecretKey("").getEncoded();
+            byte[] secret;
+            if 
(WSSecurityTokenConstants.SecurityContextToken.equals(wrappingSecurityToken.getTokenType()))
 {
+                WSPasswordCallback passwordCallback = new 
WSPasswordCallback(wsuIdDKT, WSPasswordCallback.SECRET_KEY);
+                
WSSUtils.doSecretKeyCallback(((WSSSecurityProperties)securityProperties).getCallbackHandler(),
 passwordCallback, wsuIdDKT);
+                if (passwordCallback.getKey() == null) {
+                    throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noKey", wsuIdDKT);
                 }
-
-                derivedKeyBytes = derivationAlgorithm.createKey(secret, seed, 
offset, length);
-            } catch (ConversationException e) {
-                throw new 
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
+                secret = passwordCallback.getKey();
+            } else {
+                secret = wrappingSecurityToken.getSecretKey("").getEncoded();
             }
 
+            final byte[] derivedKeyBytes = 
derivationAlgorithm.createKey(secret, seed, offset, length);
+
             final GenericOutboundSecurityToken derivedKeySecurityToken =
                     new GenericOutboundSecurityToken(wsuIdDKT, 
WSSecurityTokenConstants.DerivedKeyToken) {
 


Reply via email to