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 co...@apache.org on 2008/10/01 15:56:11 UTC

svn commit: r700768 [3/4] - in /webservices/wss4j/trunk: ./ interop/org/apache/ws/axis/oasis/ src/org/apache/ws/axis/security/ src/org/apache/ws/axis/security/handler/ src/org/apache/ws/security/ src/org/apache/ws/security/action/ src/org/apache/ws/sec...

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java Wed Oct  1 06:56:10 2008
@@ -49,250 +49,250 @@
 import org.w3c.dom.NodeList;
 
 public class ReferenceListProcessor implements Processor {
-	private static Log log = LogFactory.getLog(ReferenceListProcessor.class
-			.getName());
+    private static Log log = 
+        LogFactory.getLog(ReferenceListProcessor.class.getName());
 
-	private boolean debug = false;
+    private boolean debug = false;
 
 
-	WSDocInfo wsDocInfo = null;
+    WSDocInfo wsDocInfo = null;
 
-	public void handleToken(Element elem, Crypto crypto, Crypto decCrypto,
-			CallbackHandler cb, WSDocInfo wdi, Vector returnResults,
-			WSSConfig wsc) throws WSSecurityException {
-
-		debug = log.isDebugEnabled();
-		if (debug) {
-			log.debug("Found reference list element");
-		}
-		if (cb == null) {
-			throw new WSSecurityException(WSSecurityException.FAILURE,
-					"noCallback");
-		}
-		wsDocInfo = wdi;
-		ArrayList uris = handleReferenceList((Element) elem, cb, crypto);
-		returnResults.add(0, new WSSecurityEngineResult(WSConstants.ENCR, uris));
-	}
-
-	/**
-	 * Dereferences and decodes encrypted data elements.
-	 * 
-	 * @param elem
-	 *            contains the <code>ReferenceList</code> to the encrypted
-	 *            data elements
-	 * @param cb
-	 *            the callback handler to get the key for a key name stored if
-	 *            <code>KeyInfo</code> inside the encrypted data elements
-	 */
-	private ArrayList handleReferenceList(Element elem, CallbackHandler cb,
-	        Crypto crypto) throws WSSecurityException {
-
-		Document doc = elem.getOwnerDocument();
-
-		Node tmpE = null;
-                ArrayList dataRefUris = new ArrayList();
-		for (tmpE = elem.getFirstChild(); tmpE != null; tmpE = tmpE
-				.getNextSibling()) {
-			if (tmpE.getNodeType() != Node.ELEMENT_NODE) {
-				continue;
-			}
-			if (!tmpE.getNamespaceURI().equals(WSConstants.ENC_NS)) {
-				continue;
-			}
-			if (tmpE.getLocalName().equals("DataReference")) {
-				String dataRefURI = ((Element) tmpE).getAttribute("URI");
-				WSDataRef dataRef = new WSDataRef(dataRefURI.substring(1));
-				decryptDataRefEmbedded(doc, dataRefURI, dataRef,cb, crypto);
+    public void handleToken(Element elem, Crypto crypto, Crypto decCrypto,
+            CallbackHandler cb, WSDocInfo wdi, Vector returnResults,
+            WSSConfig wsc) throws WSSecurityException {
+
+        debug = log.isDebugEnabled();
+        if (debug) {
+            log.debug("Found reference list element");
+        }
+        if (cb == null) {
+            throw new WSSecurityException(WSSecurityException.FAILURE,
+                    "noCallback");
+        }
+        wsDocInfo = wdi;
+        ArrayList uris = handleReferenceList((Element) elem, cb, crypto);
+        returnResults.add(0, new WSSecurityEngineResult(WSConstants.ENCR, uris));
+    }
+
+    /**
+     * Dereferences and decodes encrypted data elements.
+     * 
+     * @param elem
+     *            contains the <code>ReferenceList</code> to the encrypted
+     *            data elements
+     * @param cb
+     *            the callback handler to get the key for a key name stored if
+     *            <code>KeyInfo</code> inside the encrypted data elements
+     */
+    private ArrayList handleReferenceList(Element elem, CallbackHandler cb,
+            Crypto crypto) throws WSSecurityException {
+
+        Document doc = elem.getOwnerDocument();
+
+        Node tmpE = null;
+        ArrayList dataRefUris = new ArrayList();
+        for (tmpE = elem.getFirstChild(); tmpE != null; tmpE = tmpE
+                .getNextSibling()) {
+            if (tmpE.getNodeType() != Node.ELEMENT_NODE) {
+                continue;
+            }
+            if (!tmpE.getNamespaceURI().equals(WSConstants.ENC_NS)) {
+                continue;
+            }
+            if (tmpE.getLocalName().equals("DataReference")) {
+                String dataRefURI = ((Element) tmpE).getAttribute("URI");
+                WSDataRef dataRef = new WSDataRef(dataRefURI.substring(1));
+                decryptDataRefEmbedded(doc, dataRefURI, dataRef,cb, crypto);
                 dataRefUris.add(dataRef);
-			}
-		}
-		
+            }
+        }
+        
         return dataRefUris;
-	}
+    }
 
-	public void decryptDataRefEmbedded(Document doc, String dataRefURI, WSDataRef dataRef,
-			CallbackHandler cb, Crypto crypto) throws WSSecurityException {
+    public void decryptDataRefEmbedded(Document doc, String dataRefURI, WSDataRef dataRef,
+            CallbackHandler cb, Crypto crypto) throws WSSecurityException {
 
-		if (log.isDebugEnabled()) {
-			log.debug("Found data reference: " + dataRefURI);
-		}
-		/*
-		 * Look up the encrypted data. First try wsu:Id="someURI". If no such Id
-		 * then try the generic lookup to find Id="someURI"
-		 */
-		Element encBodyData = null;
-		if ((encBodyData = WSSecurityUtil.getElementByWsuId(doc, dataRefURI)) == null) {		    
-			encBodyData = WSSecurityUtil.getElementByGenId(doc, dataRefURI);
-		}
-		if (encBodyData == null) {
-			throw new WSSecurityException(WSSecurityException.INVALID_SECURITY,
-					"dataRef", new Object[] { dataRefURI });
-		}
-
-		boolean content = X509Util.isContent(encBodyData);
-
-		// Now figure out the encryption algorithm
-		String symEncAlgo = X509Util.getEncAlgo(encBodyData);
-
-		Element tmpE = (Element) WSSecurityUtil.findElement((Node) encBodyData,
-				"KeyInfo", WSConstants.SIG_NS);
-		if (tmpE == null) {
-			throw new WSSecurityException(WSSecurityException.INVALID_SECURITY,
-					"noKeyinfo");
-		}
-
-		/*
-		 * Try to get a security reference token, if none found try to get a
-		 * shared key using a KeyName.
-		 */
-		Element secRefToken = (Element) WSSecurityUtil.getDirectChild(tmpE,
-				"SecurityTokenReference", WSConstants.WSSE_NS);
-
-		SecretKey symmetricKey = null;
-		if (secRefToken == null) {
-			symmetricKey = X509Util.getSharedKey(tmpE, symEncAlgo, cb);
-		} else
-			symmetricKey = getKeyFromSecurityTokenReference(secRefToken, symEncAlgo, crypto, cb);
-
-		// initialize Cipher ....
-		XMLCipher xmlCipher = null;
-		try {
-		    xmlCipher = XMLCipher.getInstance(symEncAlgo);
-			xmlCipher.init(XMLCipher.DECRYPT_MODE, symmetricKey);
-		} catch (XMLEncryptionException e1) {
-			throw new WSSecurityException(
-					WSSecurityException.UNSUPPORTED_ALGORITHM, null, null, e1);
-		}
-
-		if (content) {
-			encBodyData = (Element) encBodyData.getParentNode();
-		}
-			
-		try {
-			Node parentEncBody =encBodyData.getParentNode();
-			
-		        final java.util.List before_peers = listChildren(parentEncBody);
-			
-			xmlCipher.doFinal(doc, encBodyData, content);
-			
-			if(parentEncBody.getLocalName().equals(WSConstants.ENCRYPTED_HEADER)
-					&& parentEncBody.getNamespaceURI().equals(WSConstants.WSSE11_NS)) {
-				Node decryptedHeader = parentEncBody.getFirstChild();
-				Element decryptedHeaderClone = (Element)decryptedHeader.cloneNode(true);
-			        String sigId = decryptedHeaderClone.getAttributeNS(WSConstants.WSU_NS, "Id");
-				
-			        if ( sigId == null || sigId.equals("") ) {
-        			        String id = ((Element)parentEncBody).getAttributeNS(WSConstants.WSU_NS, "Id");       			            
-        			        String wsuPrefix = WSSecurityUtil.setNamespace(decryptedHeaderClone,
-        			                    WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-        			        decryptedHeaderClone.setAttributeNS(WSConstants.WSU_NS, wsuPrefix + ":Id", id);
-        			        dataRef.setWsuId(id.substring(1));
-			        } else {
-			            dataRef.setWsuId(sigId);
-			        }
-			        
-				parentEncBody.getParentNode().appendChild(decryptedHeaderClone);
-				parentEncBody.getParentNode().removeChild(parentEncBody);
-				
-			} 
-			
-		        final java.util.List after_peers = listChildren(parentEncBody);
-		        final java.util.List new_nodes = newNodes(before_peers, after_peers);
-		        
-		        for (
-		                final java.util.Iterator pos = new_nodes.iterator();
-		                pos.hasNext();
-		            ) {
-		                Node node = (Node) pos.next();
-		                if (node instanceof Element) {
-		                    if(!Constants.SignatureSpecNS.equals(node.getNamespaceURI()) &&
-		                            node.getAttributes().getNamedItemNS(WSConstants.WSU_NS, "Id") == null) {
-		                        String wsuPrefix = WSSecurityUtil.setNamespace((Element)node,
-		                                WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-		                        ((Element)node).setAttributeNS(WSConstants.WSU_NS, wsuPrefix + ":Id", dataRefURI);
-		                        dataRef.setWsuId(dataRefURI.substring(1));		                        
-		                    }
-		                    dataRef.setName(new QName(node.getNamespaceURI(),node.getLocalName()));
-		                }
-		            }
-			
-		} catch (Exception e) {
-			throw new WSSecurityException(WSSecurityException.FAILED_CHECK,
-					null, null, e);
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.ws.security.processor.Processor#getId()
-	 * 
-	 * A reference list does not have an id.
-	 */
-	public String getId() {
-		return null;
-	}
-
-	/**
-	 * Retrieves a secret key (session key) from a already parsed EncryptedKey
-	 * element
-	 * 
-	 * This method takes a security token reference (STR) element and checks if
-	 * it contains a Reference element. Then it gets the vale of the URI
-	 * attribute of the Reference and uses the retrieved value to lookup an
-	 * EncrypteKey element to get the decrypted session key bytes. Using the
-	 * algorithm parameter these bytes are converted into a secret key.
-	 * 
-	 * <p/>
-	 * 
-	 * This method requires that the EncyrptedKey element is already available,
-	 * thus requires a strict layout of the security header. This method
-	 * supports EncryptedKey elements within the same message.
-	 * 
-	 * @param secRefToken
-	 *            The element containg the STR
-	 * @param algorithm
-	 *            A string that identifies the symmetric decryption algorithm
-	 * @param crypto Crypto instance to obtain key
-	 * @param cb CAllback handler to obtain the key passwords
-	 * @return The secret key for the specified algorithm
-	 * @throws WSSecurityException
-	 */
-	private SecretKey getKeyFromSecurityTokenReference(Element secRefToken, String algorithm,
-	        Crypto crypto, CallbackHandler cb)
-			throws WSSecurityException {
-
-		SecurityTokenReference secRef = new SecurityTokenReference(secRefToken);
-		byte[] decryptedData = null;
-
-		if (secRef.containsReference()) {
-			Reference reference = secRef.getReference();
-			String uri = reference.getURI();
-			String id = uri.substring(1);
-			Processor p = wsDocInfo.getProcessor(id);
-			if (p == null
+        if (log.isDebugEnabled()) {
+            log.debug("Found data reference: " + dataRefURI);
+        }
+        /*
+         * Look up the encrypted data. First try wsu:Id="someURI". If no such Id
+         * then try the generic lookup to find Id="someURI"
+         */
+        Element encBodyData = null;
+        if ((encBodyData = WSSecurityUtil.getElementByWsuId(doc, dataRefURI)) == null) {            
+            encBodyData = WSSecurityUtil.getElementByGenId(doc, dataRefURI);
+        }
+        if (encBodyData == null) {
+            throw new WSSecurityException(WSSecurityException.INVALID_SECURITY,
+                    "dataRef", new Object[] { dataRefURI });
+        }
+
+        boolean content = X509Util.isContent(encBodyData);
+
+        // Now figure out the encryption algorithm
+        String symEncAlgo = X509Util.getEncAlgo(encBodyData);
+
+        Element tmpE = (Element) WSSecurityUtil.findElement((Node) encBodyData,
+                "KeyInfo", WSConstants.SIG_NS);
+        if (tmpE == null) {
+            throw new WSSecurityException(WSSecurityException.INVALID_SECURITY,
+                    "noKeyinfo");
+        }
+
+        /*
+         * Try to get a security reference token, if none found try to get a
+         * shared key using a KeyName.
+         */
+        Element secRefToken = (Element) WSSecurityUtil.getDirectChild(tmpE,
+                "SecurityTokenReference", WSConstants.WSSE_NS);
+
+        SecretKey symmetricKey = null;
+        if (secRefToken == null) {
+            symmetricKey = X509Util.getSharedKey(tmpE, symEncAlgo, cb);
+        } else
+            symmetricKey = getKeyFromSecurityTokenReference(secRefToken, symEncAlgo, crypto, cb);
+
+        // initialize Cipher ....
+        XMLCipher xmlCipher = null;
+        try {
+            xmlCipher = XMLCipher.getInstance(symEncAlgo);
+            xmlCipher.init(XMLCipher.DECRYPT_MODE, symmetricKey);
+        } catch (XMLEncryptionException e1) {
+            throw new WSSecurityException(
+                    WSSecurityException.UNSUPPORTED_ALGORITHM, null, null, e1);
+        }
+
+        if (content) {
+            encBodyData = (Element) encBodyData.getParentNode();
+        }
+            
+        try {
+            Node parentEncBody =encBodyData.getParentNode();
+            
+                final java.util.List before_peers = listChildren(parentEncBody);
+            
+            xmlCipher.doFinal(doc, encBodyData, content);
+            
+            if(parentEncBody.getLocalName().equals(WSConstants.ENCRYPTED_HEADER)
+                    && parentEncBody.getNamespaceURI().equals(WSConstants.WSSE11_NS)) {
+                Node decryptedHeader = parentEncBody.getFirstChild();
+                Element decryptedHeaderClone = (Element)decryptedHeader.cloneNode(true);
+                    String sigId = decryptedHeaderClone.getAttributeNS(WSConstants.WSU_NS, "Id");
+                
+                    if ( sigId == null || sigId.equals("") ) {
+                            String id = ((Element)parentEncBody).getAttributeNS(WSConstants.WSU_NS, "Id");                              
+                            String wsuPrefix = WSSecurityUtil.setNamespace(decryptedHeaderClone,
+                                        WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+                            decryptedHeaderClone.setAttributeNS(WSConstants.WSU_NS, wsuPrefix + ":Id", id);
+                            dataRef.setWsuId(id.substring(1));
+                    } else {
+                        dataRef.setWsuId(sigId);
+                    }
+                    
+                parentEncBody.getParentNode().appendChild(decryptedHeaderClone);
+                parentEncBody.getParentNode().removeChild(parentEncBody);
+                
+            } 
+            
+            final java.util.List after_peers = listChildren(parentEncBody);
+            final java.util.List new_nodes = newNodes(before_peers, after_peers);
+
+            for (
+                final java.util.Iterator pos = new_nodes.iterator();
+                pos.hasNext();
+            ) {
+                Node node = (Node) pos.next();
+                if (node instanceof Element) {
+                    if(!Constants.SignatureSpecNS.equals(node.getNamespaceURI()) &&
+                            node.getAttributes().getNamedItemNS(WSConstants.WSU_NS, "Id") == null) {
+                        String wsuPrefix = WSSecurityUtil.setNamespace((Element)node,
+                                WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+                        ((Element)node).setAttributeNS(WSConstants.WSU_NS, wsuPrefix + ":Id", dataRefURI);
+                        dataRef.setWsuId(dataRefURI.substring(1));                              
+                    }
+                    dataRef.setName(new QName(node.getNamespaceURI(),node.getLocalName()));
+                }
+            }
+
+        } catch (Exception e) {
+            throw new WSSecurityException(WSSecurityException.FAILED_CHECK,
+                    null, null, e);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.ws.security.processor.Processor#getId()
+     * 
+     * A reference list does not have an id.
+     */
+    public String getId() {
+        return null;
+    }
+
+    /**
+     * Retrieves a secret key (session key) from a already parsed EncryptedKey
+     * element
+     * 
+     * This method takes a security token reference (STR) element and checks if
+     * it contains a Reference element. Then it gets the vale of the URI
+     * attribute of the Reference and uses the retrieved value to lookup an
+     * EncrypteKey element to get the decrypted session key bytes. Using the
+     * algorithm parameter these bytes are converted into a secret key.
+     * 
+     * <p/>
+     * 
+     * This method requires that the EncyrptedKey element is already available,
+     * thus requires a strict layout of the security header. This method
+     * supports EncryptedKey elements within the same message.
+     * 
+     * @param secRefToken
+     *            The element containing the STR
+     * @param algorithm
+     *            A string that identifies the symmetric decryption algorithm
+     * @param crypto Crypto instance to obtain key
+     * @param cb CAllback handler to obtain the key passwords
+     * @return The secret key for the specified algorithm
+     * @throws WSSecurityException
+     */
+    private SecretKey getKeyFromSecurityTokenReference(Element secRefToken, String algorithm,
+            Crypto crypto, CallbackHandler cb)
+            throws WSSecurityException {
+
+        SecurityTokenReference secRef = new SecurityTokenReference(secRefToken);
+        byte[] decryptedData = null;
+
+        if (secRef.containsReference()) {
+            Reference reference = secRef.getReference();
+            String uri = reference.getURI();
+            String id = uri.substring(1);
+            Processor p = wsDocInfo.getProcessor(id);
+            if (p == null
                     || (!(p instanceof EncryptedKeyProcessor)
                             && !(p instanceof DerivedKeyTokenProcessor) 
                             && !(p instanceof SAMLTokenProcessor))) {
-			    
-			    //Try custom token
-			    WSPasswordCallback pwcb = new WSPasswordCallback(id, WSPasswordCallback.CUSTOM_TOKEN);
-			    try {
+                
+                // Try custom token
+                WSPasswordCallback pwcb = new WSPasswordCallback(id, WSPasswordCallback.CUSTOM_TOKEN);
+                try {
                     cb.handle(new Callback[]{pwcb});
                 } catch (Exception e) {
                     throw new WSSecurityException(WSSecurityException.FAILURE,
                             "noPassword", new Object[] { id }, e);
                 }
-			    decryptedData = pwcb.getKey();
-			    
-			    if(decryptedData == null) {
-			        throw new WSSecurityException(
-						WSSecurityException.FAILED_CHECK, "unsupportedKeyId");
-			    }
-			}
-			if(p instanceof EncryptedKeyProcessor) {
-    			EncryptedKeyProcessor ekp = (EncryptedKeyProcessor) p;
-    			decryptedData = ekp.getDecryptedBytes();
+                decryptedData = pwcb.getKey();
+                
+                if(decryptedData == null) {
+                    throw new WSSecurityException(
+                        WSSecurityException.FAILED_CHECK, "unsupportedKeyId");
+                }
+            }
+            if(p instanceof EncryptedKeyProcessor) {
+                EncryptedKeyProcessor ekp = (EncryptedKeyProcessor) p;
+                decryptedData = ekp.getDecryptedBytes();
             } else if(p instanceof DerivedKeyTokenProcessor) {
                 DerivedKeyTokenProcessor dkp = (DerivedKeyTokenProcessor) p;
                 decryptedData = dkp.getKeyBytes(WSSecurityUtil.getKeyLength(algorithm));
@@ -304,98 +304,95 @@
                 //secret in them
                 decryptedData = keyInfo.getSecret();
             }
-		} else if (secRef.containsKeyIdentifier()){
-			
-			if ( secRef.getKeyIdentifierValueType().equals(SecurityTokenReference.ENC_KEY_SHA1_URI)) {
-			    
-				String sha = secRef.getKeyIdentifierValue();
-				
-				WSPasswordCallback pwcb = new WSPasswordCallback(sha, WSPasswordCallback.ENCRYPTED_KEY_TOKEN);
-			    
-				try {
+        } else if (secRef.containsKeyIdentifier()){
+            if (secRef.getKeyIdentifierValueType().equals(SecurityTokenReference.ENC_KEY_SHA1_URI)) {
+                String sha = secRef.getKeyIdentifierValue();
+                WSPasswordCallback pwcb = new WSPasswordCallback(sha, WSPasswordCallback.ENCRYPTED_KEY_TOKEN);
+                
+                try {
                     cb.handle(new Callback[]{pwcb});
                 } catch (Exception e) {
                     throw new WSSecurityException(WSSecurityException.FAILURE,
                             "noPassword", new Object[] { sha }, e);
                 }
-			    decryptedData = pwcb.getKey();
-			}
-		
-	    }else {
-			throw new WSSecurityException(WSSecurityException.FAILED_CHECK,
-					"noReference");
-		}
-		return WSSecurityUtil.prepareSecretKey(algorithm, decryptedData);
-	}
-	
-	    /**
-	     * @return      a list of Nodes, representing the 
-	     */
-	    private static java.util.List
-	    listChildren(
-	        final Node parent
-	    ) {
-	        if (parent == null) {
-	            return java.util.Collections.EMPTY_LIST;
-	        }
-	        final java.util.List ret = new java.util.ArrayList();
-	        if (parent.hasChildNodes()) {
-	            final NodeList children = parent.getChildNodes();
-	            if (children != null) {
-	                for (int i = 0, n = children.getLength();  i < n;  ++i) {
-	                    ret.add(children.item(i));
-	                }
-	            }
-	        }
-	        return ret;
-	    }
-	    
-	    /**
-	     * @return      a list of Nodes in b that are not in a 
-	     */
-	    private static java.util.List
-	    newNodes(
-	        final java.util.List a,
-	        final java.util.List b
-	    ) {
-	        if (a.size() == 0) {
-	            return b;
-	        }
-	        if (b.size() == 0) {
-	            return java.util.Collections.EMPTY_LIST;
-	        }
-	        final java.util.List ret = new java.util.ArrayList();
-	        for (
-	            final java.util.Iterator bpos = b.iterator();
-	            bpos.hasNext();
-	        ) {
-	            final Node bnode = (Node) bpos.next();
-	            final java.lang.String bns = bnode.getNamespaceURI();
-	            final java.lang.String bln = bnode.getLocalName();
-	            boolean found = false;
-	            for (
-	                final java.util.Iterator apos = a.iterator();
-	                apos.hasNext();
-	            ) {
-	                final Node anode = (Node) apos.next();
-	                final java.lang.String ans = anode.getNamespaceURI();
-	                final java.lang.String aln = anode.getLocalName();
-	                final boolean nsmatch =
-	                    ans == null
-	                    ? ((bns == null) ? true : false)
-	                    : ((bns == null) ? false : ans.equals(bns));
-	                final boolean lnmatch =
-	                    aln == null
-	                    ? ((bln == null) ? true : false)
-	                    : ((bln == null) ? false : aln.equals(bln));
-	                if (nsmatch && lnmatch) {
-	                    found = true;
-	                }
-	            }
-	            if (!found) {
-	                ret.add(bnode);
-	            }
-	        }
-	        return ret;
-	    }
-}
\ No newline at end of file
+                decryptedData = pwcb.getKey();
+            }
+        
+        } else {
+            throw new WSSecurityException(WSSecurityException.FAILED_CHECK,
+                    "noReference");
+        }
+        return WSSecurityUtil.prepareSecretKey(algorithm, decryptedData);
+    }
+    
+    /**
+     * @return      a list of Nodes, representing the 
+     */
+    private static java.util.List
+    listChildren(
+        final Node parent
+    ) {
+        if (parent == null) {
+            return java.util.Collections.EMPTY_LIST;
+        }
+        final java.util.List ret = new java.util.ArrayList();
+        if (parent.hasChildNodes()) {
+            final NodeList children = parent.getChildNodes();
+            if (children != null) {
+                for (int i = 0, n = children.getLength();  i < n;  ++i) {
+                    ret.add(children.item(i));
+                }
+            }
+        }
+        return ret;
+    }
+
+    /**
+     * @return      a list of Nodes in b that are not in a 
+     */
+    private static java.util.List
+    newNodes(
+        final java.util.List a,
+        final java.util.List b
+    ) {
+        if (a.size() == 0) {
+            return b;
+        }
+        if (b.size() == 0) {
+            return java.util.Collections.EMPTY_LIST;
+        }
+        final java.util.List ret = new java.util.ArrayList();
+        for (
+            final java.util.Iterator bpos = b.iterator();
+            bpos.hasNext();
+        ) {
+            final Node bnode = (Node) bpos.next();
+            final java.lang.String bns = bnode.getNamespaceURI();
+            final java.lang.String bln = bnode.getLocalName();
+            boolean found = false;
+            for (
+                final java.util.Iterator apos = a.iterator();
+                apos.hasNext();
+            ) {
+                final Node anode = (Node) apos.next();
+                final java.lang.String ans = anode.getNamespaceURI();
+                final java.lang.String aln = anode.getLocalName();
+                final boolean nsmatch =
+                    ans == null
+                    ? ((bns == null) ? true : false)
+                            : ((bns == null) ? false : ans.equals(bns));
+                final boolean lnmatch =
+                    aln == null
+                    ? ((bln == null) ? true : false)
+                            : ((bln == null) ? false : aln.equals(bln));
+                if (nsmatch && lnmatch) {
+                    found = true;
+                }
+            }
+            if (!found) {
+                ret.add(bnode);
+            }
+        }
+        return ret;
+    }
+}

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/SAMLTokenProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/SAMLTokenProcessor.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/SAMLTokenProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/SAMLTokenProcessor.java Wed Oct  1 06:56:10 2008
@@ -74,7 +74,7 @@
      * Return the id of the SAML token
      */
     public String getId() {
-    	return this.id;
+        return this.id;
     }
 
     public Element getSamlTokenElement() {

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureConfirmationProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureConfirmationProcessor.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureConfirmationProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureConfirmationProcessor.java Wed Oct  1 06:56:10 2008
@@ -55,6 +55,6 @@
      * @see org.apache.ws.security.processor.Processor#getId()
      */
     public String getId() {
-    	return scId;
+        return scId;
     }    
 }

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java Wed Oct  1 06:56:10 2008
@@ -93,7 +93,6 @@
             returnResults.add(0, new WSSecurityEngineResult(
                     WSConstants.UT_SIGN, lastPrincipalFound, null,
                     returnElements, protectedElements, signatureValue[0]));
-
         } else {
             returnResults.add(0, new WSSecurityEngineResult(
                     WSConstants.SIGN, lastPrincipalFound,
@@ -134,7 +133,7 @@
      *                    entry of this array. Ther caller may then further validate
      *                    the certificate
      * @param returnElements verifyXMLSignature adds the wsu:ID attribute values for
-     * 			     the signed elements to this Set
+     *               the signed elements to this Set
      * @param cb CallbackHandler instance to extract key passwords
      * @return the subject principal of the validated X509 certificate (the
      *         authenticated subject). The calling function may use this
@@ -237,7 +236,6 @@
                         secretKey = samlKi.getSecret();
 
                     } else if (el.equals(WSSecurityEngine.ENCRYPTED_KEY)){
-                        
                         String encryptedKeyID = token.getAttributeNS(null,"Id");                   
                         EncryptedKeyProcessor encryptKeyProcessor = (EncryptedKeyProcessor)
                                 wsDocInfo.getProcessor(encryptedKeyID);
@@ -251,10 +249,9 @@
                             encryptKeyProcessor.handleEncryptedKey((Element)token, cb, crypto);
                         
                         } 
-                        
                         secretKey = encryptKeyProcessor.getDecryptedBytes();
                      
-                    }else {
+                    } else {
                         
                         //Try custom token through callback handler
                         //try to find a custom token
@@ -283,24 +280,23 @@
             } else if (secRef.containsX509Data() || secRef.containsX509IssuerSerial()) {
                 certs = secRef.getX509IssuerSerial(crypto);
             } else if (secRef.containsKeyIdentifier()) {
-            	if (secRef.getKeyIdentifierValueType().equals
-            			(SecurityTokenReference.ENC_KEY_SHA1_URI)) {
+                if (secRef.getKeyIdentifierValueType().equals
+                        (SecurityTokenReference.ENC_KEY_SHA1_URI)) {
                     
-            		String id = secRef.getKeyIdentifierValue();
+                    String id = secRef.getKeyIdentifierValue();
                     WSPasswordCallback pwcb = new WSPasswordCallback(id,
                                                        WSPasswordCallback.ENCRYPTED_KEY_TOKEN);
                     try {
-                    	cb.handle(new Callback[]{pwcb});
-		            } catch (Exception e) {
-		                throw new WSSecurityException(WSSecurityException.FAILURE,
-		                        "noPassword", new Object[] { id }, e);
-		            }
-            
-		            secretKey = pwcb.getKey();
-		            
-            	} else {
-            		certs = secRef.getKeyIdentifier(crypto);
-            	}
+                        cb.handle(new Callback[]{pwcb});
+                    } catch (Exception e) {
+                        throw new WSSecurityException(WSSecurityException.FAILURE,
+                                "noPassword", new Object[] { id }, e);
+                    }
+                    secretKey = pwcb.getKey();
+                    
+                } else {
+                    certs = secRef.getKeyIdentifier(crypto);
+                }
             } else {
                 throw new WSSecurityException(
                         WSSecurityException.INVALID_SECURITY,
@@ -504,7 +500,7 @@
      * @see org.apache.ws.security.processor.Processor#getId()
      */
     public String getId() {
-    	return signatureId;
+        return signatureId;
     }
 
 }

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/TimestampProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/TimestampProcessor.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/TimestampProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/TimestampProcessor.java Wed Oct  1 06:56:10 2008
@@ -58,39 +58,39 @@
     }
 
     public void handleTimestamp(Timestamp timestamp) throws WSSecurityException {
-		if (log.isDebugEnabled()) {
-			log.debug("Preparing to verify the timestamp");
+        if (log.isDebugEnabled()) {
+            log.debug("Preparing to verify the timestamp");
 
-			DateFormat zulu = new XmlSchemaDateFormat();
+            DateFormat zulu = new XmlSchemaDateFormat();
 
-			log.debug("Current time: "
-					+ zulu.format(Calendar.getInstance().getTime()));
-			if (timestamp.getCreated() != null) {
-				log.debug("Timestamp created: "
-						+ zulu.format(timestamp.getCreated().getTime()));
-			}
-			if (timestamp.getExpires() != null) {
-				log.debug("Timestamp expires: "
-						+ zulu.format(timestamp.getExpires().getTime()));
-			}
-		}
+            log.debug("Current time: "
+                    + zulu.format(Calendar.getInstance().getTime()));
+            if (timestamp.getCreated() != null) {
+                log.debug("Timestamp created: "
+                        + zulu.format(timestamp.getCreated().getTime()));
+            }
+            if (timestamp.getExpires() != null) {
+                log.debug("Timestamp expires: "
+                        + zulu.format(timestamp.getExpires().getTime()));
+            }
+        }
 
-		// Validate whether the security semantics have expired
-		Calendar rightNow = Calendar.getInstance();
-		Calendar exp = timestamp.getExpires();
-		if (exp != null && wssConfig.isTimeStampStrict() && exp.before(rightNow)) {
-			throw new WSSecurityException(
-					WSSecurityException.MESSAGE_EXPIRED,
-					"invalidTimestamp",
-					new Object[] { "The security semantics of message have expired" });
-		}
-	}
+        // Validate whether the security semantics have expired
+        Calendar rightNow = Calendar.getInstance();
+        Calendar exp = timestamp.getExpires();
+        if (exp != null && wssConfig.isTimeStampStrict() && exp.before(rightNow)) {
+            throw new WSSecurityException(
+                    WSSecurityException.MESSAGE_EXPIRED,
+                    "invalidTimestamp",
+                    new Object[] { "The security semantics of message have expired" });
+        }
+    }
     
     /* (non-Javadoc)
      * @see org.apache.ws.security.processor.Processor#getId()
      */
     public String getId() {
-    	return tsId;
+        return tsId;
     }    
     
 }

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java Wed Oct  1 06:56:10 2008
@@ -179,7 +179,7 @@
      * @see org.apache.ws.security.processor.Processor#getId()
      */
     public String getId() {
-    	return utId;
+        return utId;
     }
 
     /**

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/util/Loader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/util/Loader.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/util/Loader.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/util/Loader.java Wed Oct  1 06:56:10 2008
@@ -153,7 +153,7 @@
      */
     static public Class loadClass(String clazz) throws ClassNotFoundException {
         try {
-            ClassLoader tcl = getTCL();	
+            ClassLoader tcl = getTCL(); 
             
             if (tcl != null) {
                 Class c = tcl.loadClass(clazz);

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/util/XmlSchemaDateFormat.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/util/XmlSchemaDateFormat.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/util/XmlSchemaDateFormat.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/util/XmlSchemaDateFormat.java Wed Oct  1 06:56:10 2008
@@ -37,176 +37,176 @@
  * @author Werner Dittmann
  */
 public class XmlSchemaDateFormat extends DateFormat {
-	/**
-	 * Logger.
-	 */
-	private static Log log = LogFactory.getLog(XmlSchemaDateFormat.class);
-
-	/**
-	 * Message retriever.
-	 */
-	//   private static final MessageRetriever MSG = ResourceKeys.MSG;
-	/**
-	 * DateFormat for Zulu (UTC) form of an XML Schema dateTime string.
-	 */
-	private static final DateFormat DATEFORMAT_XSD_ZULU = new SimpleDateFormat(
-			"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
-
-	static {
-		DATEFORMAT_XSD_ZULU.setTimeZone(TimeZone.getTimeZone("UTC"));
-	}
-
-	/**
-	 * This method was snarfed from <tt>org.apache.axis.encoding.ser.CalendarDeserializer</tt>,
-	 * which was written by Sam Ruby (rubys@us.ibm.com) and Rich Scheuerle (scheu@us.ibm.com).
-	 * Better error reporting was added.
-	 *
-	 * @see DateFormat#parse(java.lang.String)
-	 */
-	public Date parse(String src, ParsePosition parse_pos) {
-		Date date;
-
-		// validate fixed portion of format
-		int index = 0;
-		try {
-			if (src != null) {
-				if ((src.charAt(0) == '+') || (src.charAt(0) == '-')) {
-					src = src.substring(1);
-				}
-
-				if (src.length() < 19) {
-					parse_pos.setIndex(src.length() - 1);
-					handleParseError(parse_pos, "TOO_FEW_CHARS");
-				}
-				validateChar(src, parse_pos, index = 4, '-', "EXPECTED_DASH");
-				validateChar(src, parse_pos, index = 7, '-', "EXPECTED_DASH");
-				validateChar(src, parse_pos, index = 10, 'T', "EXPECTED_CAPITAL_T");
-				validateChar(src, parse_pos, index = 13, ':', "EXPECTED_COLON_IN_TIME");
-				validateChar(src, parse_pos, index = 16, ':', "EXPECTED_COLON_IN_TIME");
-			}
-
-			// convert what we have validated so far
-			try {
-				synchronized (DATEFORMAT_XSD_ZULU) {
-					date = DATEFORMAT_XSD_ZULU.parse((src == null) ? null
-							: (src.substring(0, 19) + ".000Z"));
-				}
-			} catch (Exception e) {
-				throw new NumberFormatException(e.toString());
-			}
-
-			index = 19;
-
-			// parse optional milliseconds
-			if (src != null) {
-				if ((index < src.length()) && (src.charAt(index) == '.')) {
-					int milliseconds = 0;
-					int start = ++index;
-
-					while ((index < src.length())
-							&& Character.isDigit(src.charAt(index))) {
-						index++;
-					}
-
-					String decimal = src.substring(start, index);
-
-					if (decimal.length() == 3) {
-						milliseconds = Integer.parseInt(decimal);
-					} else if (decimal.length() < 3) {
-						milliseconds = Integer.parseInt((decimal + "000")
-								.substring(0, 3));
-					} else {
-						milliseconds = Integer
-								.parseInt(decimal.substring(0, 3));
-
-						if (decimal.charAt(3) >= '5') {
-							++milliseconds;
-						}
-					}
-
-					// add milliseconds to the current date
-					date.setTime(date.getTime() + milliseconds);
-				}
-
-				// parse optional timezone
-				if (((index + 5) < src.length())
-						&& ((src.charAt(index) == '+') || (src.charAt(index) == '-'))) {
-					validateCharIsDigit(src, parse_pos, index + 1, "EXPECTED_NUMERAL");
-					validateCharIsDigit(src, parse_pos, index + 2, "EXPECTED_NUMERAL");
-					validateChar(src, parse_pos, index + 3, ':', "EXPECTED_COLON_IN_TIMEZONE");
-					validateCharIsDigit(src, parse_pos, index + 4, "EXPECTED_NUMERAL");
-					validateCharIsDigit(src, parse_pos, index + 5, "EXPECTED_NUMERAL");
-
-					final int hours = (((src.charAt(index + 1) - '0') * 10) + src
-							.charAt(index + 2)) - '0';
-					final int mins = (((src.charAt(index + 4) - '0') * 10) + src
-							.charAt(index + 5)) - '0';
-					int millisecs = ((hours * 60) + mins) * 60 * 1000;
-
-					// subtract millisecs from current date to obtain GMT
-					if (src.charAt(index) == '+') {
-						millisecs = -millisecs;
-					}
-
-					date.setTime(date.getTime() + millisecs);
-					index += 6;
-				}
-
-				if ((index < src.length()) && (src.charAt(index) == 'Z')) {
-					index++;
-				}
-
-				if (index < src.length()) {
-					handleParseError(parse_pos, "TOO_MANY_CHARS");
-				}
-			}
-		} catch (ParseException pe) {
-			log.error(pe.toString(), pe);
-			index = 0; // IMPORTANT: this tells DateFormat.parse() to throw a ParseException
-			parse_pos.setErrorIndex(index);
-			date = null;
-		}
-		parse_pos.setIndex(index);
-		return (date);
-	}
-
-	/**
-	 * @see DateFormat#format(java.util.Date)
-	 */
-	public StringBuffer format(Date date, StringBuffer append_buf,
-			FieldPosition field_pos) {
-		String str;
-
-		synchronized (DATEFORMAT_XSD_ZULU) {
-			str = DATEFORMAT_XSD_ZULU.format(date);
-		}
-
-		if (append_buf == null) {
-			append_buf = new StringBuffer();
-		}
-
-		append_buf.append(str);
-
-		return (append_buf);
-	}
-
-	private void validateChar(String str, ParsePosition parse_pos, int index,
-			char expected, String error_reason) throws ParseException {
-		if (str.charAt(index) != expected) {
-			handleParseError(parse_pos, error_reason);
-		}
-	}
-
-	private void validateCharIsDigit(String str, ParsePosition parse_pos,
-			int index, String error_reason) throws ParseException {
-		if (!Character.isDigit(str.charAt(index))) {
-			handleParseError(parse_pos, error_reason);
-		}
-	}
-
-	private void handleParseError(ParsePosition parse_pos, String error_reason)
-			throws ParseException {
-		throw new ParseException("INVALID_XSD_DATETIME", parse_pos.getErrorIndex());
-	}
+    /**
+     * Logger.
+     */
+    private static Log log = LogFactory.getLog(XmlSchemaDateFormat.class);
+
+    /**
+     * Message retriever.
+     */
+    //   private static final MessageRetriever MSG = ResourceKeys.MSG;
+    /**
+     * DateFormat for Zulu (UTC) form of an XML Schema dateTime string.
+     */
+    private static final DateFormat DATEFORMAT_XSD_ZULU = new SimpleDateFormat(
+            "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+
+    static {
+        DATEFORMAT_XSD_ZULU.setTimeZone(TimeZone.getTimeZone("UTC"));
+    }
+
+    /**
+     * This method was snarfed from <tt>org.apache.axis.encoding.ser.CalendarDeserializer</tt>,
+     * which was written by Sam Ruby (rubys@us.ibm.com) and Rich Scheuerle (scheu@us.ibm.com).
+     * Better error reporting was added.
+     *
+     * @see DateFormat#parse(java.lang.String)
+     */
+    public Date parse(String src, ParsePosition parse_pos) {
+        Date date;
+
+        // validate fixed portion of format
+        int index = 0;
+        try {
+            if (src != null) {
+                if ((src.charAt(0) == '+') || (src.charAt(0) == '-')) {
+                    src = src.substring(1);
+                }
+
+                if (src.length() < 19) {
+                    parse_pos.setIndex(src.length() - 1);
+                    handleParseError(parse_pos, "TOO_FEW_CHARS");
+                }
+                validateChar(src, parse_pos, index = 4, '-', "EXPECTED_DASH");
+                validateChar(src, parse_pos, index = 7, '-', "EXPECTED_DASH");
+                validateChar(src, parse_pos, index = 10, 'T', "EXPECTED_CAPITAL_T");
+                validateChar(src, parse_pos, index = 13, ':', "EXPECTED_COLON_IN_TIME");
+                validateChar(src, parse_pos, index = 16, ':', "EXPECTED_COLON_IN_TIME");
+            }
+
+            // convert what we have validated so far
+            try {
+                synchronized (DATEFORMAT_XSD_ZULU) {
+                    date = DATEFORMAT_XSD_ZULU.parse((src == null) ? null
+                            : (src.substring(0, 19) + ".000Z"));
+                }
+            } catch (Exception e) {
+                throw new NumberFormatException(e.toString());
+            }
+
+            index = 19;
+
+            // parse optional milliseconds
+            if (src != null) {
+                if ((index < src.length()) && (src.charAt(index) == '.')) {
+                    int milliseconds = 0;
+                    int start = ++index;
+
+                    while ((index < src.length())
+                            && Character.isDigit(src.charAt(index))) {
+                        index++;
+                    }
+
+                    String decimal = src.substring(start, index);
+
+                    if (decimal.length() == 3) {
+                        milliseconds = Integer.parseInt(decimal);
+                    } else if (decimal.length() < 3) {
+                        milliseconds = Integer.parseInt((decimal + "000")
+                                .substring(0, 3));
+                    } else {
+                        milliseconds = Integer
+                                .parseInt(decimal.substring(0, 3));
+
+                        if (decimal.charAt(3) >= '5') {
+                            ++milliseconds;
+                        }
+                    }
+
+                    // add milliseconds to the current date
+                    date.setTime(date.getTime() + milliseconds);
+                }
+
+                // parse optional timezone
+                if (((index + 5) < src.length())
+                        && ((src.charAt(index) == '+') || (src.charAt(index) == '-'))) {
+                    validateCharIsDigit(src, parse_pos, index + 1, "EXPECTED_NUMERAL");
+                    validateCharIsDigit(src, parse_pos, index + 2, "EXPECTED_NUMERAL");
+                    validateChar(src, parse_pos, index + 3, ':', "EXPECTED_COLON_IN_TIMEZONE");
+                    validateCharIsDigit(src, parse_pos, index + 4, "EXPECTED_NUMERAL");
+                    validateCharIsDigit(src, parse_pos, index + 5, "EXPECTED_NUMERAL");
+
+                    final int hours = (((src.charAt(index + 1) - '0') * 10) + src
+                            .charAt(index + 2)) - '0';
+                    final int mins = (((src.charAt(index + 4) - '0') * 10) + src
+                            .charAt(index + 5)) - '0';
+                    int millisecs = ((hours * 60) + mins) * 60 * 1000;
+
+                    // subtract millisecs from current date to obtain GMT
+                    if (src.charAt(index) == '+') {
+                        millisecs = -millisecs;
+                    }
+
+                    date.setTime(date.getTime() + millisecs);
+                    index += 6;
+                }
+
+                if ((index < src.length()) && (src.charAt(index) == 'Z')) {
+                    index++;
+                }
+
+                if (index < src.length()) {
+                    handleParseError(parse_pos, "TOO_MANY_CHARS");
+                }
+            }
+        } catch (ParseException pe) {
+            log.error(pe.toString(), pe);
+            index = 0; // IMPORTANT: this tells DateFormat.parse() to throw a ParseException
+            parse_pos.setErrorIndex(index);
+            date = null;
+        }
+        parse_pos.setIndex(index);
+        return (date);
+    }
+
+    /**
+     * @see DateFormat#format(java.util.Date)
+     */
+    public StringBuffer format(Date date, StringBuffer append_buf,
+            FieldPosition field_pos) {
+        String str;
+
+        synchronized (DATEFORMAT_XSD_ZULU) {
+            str = DATEFORMAT_XSD_ZULU.format(date);
+        }
+
+        if (append_buf == null) {
+            append_buf = new StringBuffer();
+        }
+
+        append_buf.append(str);
+
+        return (append_buf);
+    }
+
+    private void validateChar(String str, ParsePosition parse_pos, int index,
+            char expected, String error_reason) throws ParseException {
+        if (str.charAt(index) != expected) {
+            handleParseError(parse_pos, error_reason);
+        }
+    }
+
+    private void validateCharIsDigit(String str, ParsePosition parse_pos,
+            int index, String error_reason) throws ParseException {
+        if (!Character.isDigit(str.charAt(index))) {
+            handleParseError(parse_pos, error_reason);
+        }
+    }
+
+    private void handleParseError(ParsePosition parse_pos, String error_reason)
+            throws ParseException {
+        throw new ParseException("INVALID_XSD_DATETIME", parse_pos.getErrorIndex());
+    }
 
 }

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef.java Wed Oct  1 06:56:10 2008
@@ -68,210 +68,210 @@
  * 
  */
 public class TestWSSecurityDataRef extends TestCase implements CallbackHandler {
-	private static Log log = LogFactory.getLog(TestWSSecurityDataRef.class);
+    private static Log log = LogFactory.getLog(TestWSSecurityDataRef.class);
+
+    static final String soapMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+            + "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+            + "   <soapenv:Body>"
+            + "      <ns1:testMethod xmlns:ns1=\"uri:LogTestService2\"></ns1:testMethod>"
+            + "   </soapenv:Body>" + "</soapenv:Envelope>";
+
+    static final WSSecurityEngine secEngine = new WSSecurityEngine();
+
+    static final Crypto crypto = CryptoFactory
+            .getInstance("cryptoSKI.properties");
+
+    MessageContext msgContext;
+
+    Message message;
+
+    /**
+     * TestWSSecurityDataRef constructor <p/>
+     * 
+     * @param name
+     *            name of the test
+     */
+    public TestWSSecurityDataRef(String name) {
+        super(name);
+    }
+
+    /**
+     * JUnit suite <p/>
+     * 
+     * @return a junit test suite
+     */
+    public static Test suite() {
+        return new TestSuite( TestWSSecurityDataRef.class);
+    }
+
+    /**
+     * Main method <p/>
+     * 
+     * @param args
+     *            command line args
+     */
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(suite());
+    }
+
+    /**
+     * Setup method <p/>
+     * 
+     * @throws Exception
+     *             Thrown when there is a problem in setup
+     */
+    protected void setUp() throws Exception {
+        AxisClient tmpEngine = new AxisClient(new NullProvider());
+        msgContext = new MessageContext(tmpEngine);
+        message = getSOAPMessage();
+    }
+
+    /**
+     * Constructs a soap envelope <p/>
+     * 
+     * @return soap envelope
+     * @throws Exception
+     *             if there is any problem constructing the soap envelope
+     */
+    protected Message getSOAPMessage() throws Exception {
+        InputStream in = new ByteArrayInputStream(soapMsg.getBytes());
+        Message msg = new Message(in);
+        msg.setMessageContext(msgContext);
+        return msg;
+    }
+
+    /**
+     * Test that check for correct WSDataRef object from ReferenceList Processor 
+     * 
+     * 
+     * @throws Exception
+     *             Thrown when there is an error in encryption or decryption
+     */
+    public void testDataRefReferenceListProcessor() throws Exception {
+      
+        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
+        WSSecEncrypt builder = new WSSecEncrypt();
+        builder.setUserInfo("wss4jcert");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+        Document doc = unsignedEnvelope.getAsDocument();
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        log.info("Before Encryption Triple DES....");
+
+        /*
+         * Prepare the Encrypt object with the token, setup data structure
+         */
+        builder.prepare(doc, crypto);
+
+        /*
+         * Set up the parts structure to encrypt the body
+         */
+        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
+                .getDocumentElement());
+        Vector parts = new Vector();
+        WSEncryptionPart encP = new WSEncryptionPart("testMethod", "uri:LogTestService2",
+                "Element");
+        parts.add(encP);
+
+        /*
+         * Encrypt the element (testMethod), create EncrypedData elements that reference
+         * the EncryptedKey, and get a ReferenceList that can be put into the
+         * Security header. Be sure that the ReferenceList is after the
+         * EncryptedKey element in the Security header (strict layout)
+         */
+        Element refs = builder.encryptForExternalRef(null, parts);
+        builder.addExternalRefElement(refs, secHeader);
+
+        /*
+         * now add (prepend) the EncryptedKey element, then a
+         * BinarySecurityToken if one was setup during prepare
+         */
+        builder.prependToHeader(secHeader);
+
+        builder.prependBSTElementToHeader(secHeader);
+
+        Document encryptedDoc = doc;
+        log.info("After Encryption Triple DES....");
+
+        checkDataRef(encryptedDoc);
+    }
+
+    /**
+     * Verifies the soap envelope <p/>
+     * 
+     * @param envelope
+     * @throws Exception
+     *             Thrown when there is a problem in verification
+     */
+    private void checkDataRef(Document doc) throws Exception {
+        
+        // Retrieve the wsResults vector 
+        Vector wsResults = secEngine.processSecurityHeader(doc, null, this, crypto);
+        boolean found = false;
+                
+        for (int i = 0; i < wsResults.size(); i++) {
+            
+            WSSecurityEngineResult wsSecEngineResult = 
+                (WSSecurityEngineResult)wsResults.get(i);           
+            int action = ((java.lang.Integer) 
+                wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
+            
+            // We want to filter only encryption results
+            if (action != WSConstants.ENCR) {
+                continue;
+            }
+            ArrayList dataRefs = (ArrayList)wsSecEngineResult
+                .get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
+            
+            //We want check only the DATA_REF_URIS 
+            if (dataRefs != null && dataRefs.size() > 0) {
+                for (int j = 0; j < dataRefs.size(); j++) {
+                    Object obj = dataRefs.get(i);                            
+
+                    // ReferenceList Processor must Return a WSDataRef objects
+                    assertTrue(obj instanceof WSDataRef);
+
+                    WSDataRef dataRef = (WSDataRef) obj;
+
+                    // Check whether dataRef URI is set
+                    assertNotNull(dataRef.getDataref());
+
+                    // Check whether QName is correctly set
+                    assertEquals("testMethod", dataRef.getName().getLocalPart());
+                    assertEquals("uri:LogTestService2", dataRef.getName().getNamespaceURI());
+
+                    // Check whether wsu:Id is set
+                    assertNotNull(dataRef.getWsuId());
+
+                    // flag to indicate the element was found in TAG_DATA_REF_URIS
+                    found = true;
 
-	static final String soapMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-			+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
-			+ "   <soapenv:Body>"
-			+ "      <ns1:testMethod xmlns:ns1=\"uri:LogTestService2\"></ns1:testMethod>"
-			+ "   </soapenv:Body>" + "</soapenv:Envelope>";
-
-	static final WSSecurityEngine secEngine = new WSSecurityEngine();
-
-	static final Crypto crypto = CryptoFactory
-			.getInstance("cryptoSKI.properties");
-
-	MessageContext msgContext;
-
-	Message message;
-
-	/**
-	 * TestWSSecurityDataRef constructor <p/>
-	 * 
-	 * @param name
-	 *            name of the test
-	 */
-	public TestWSSecurityDataRef(String name) {
-		super(name);
-	}
-
-	/**
-	 * JUnit suite <p/>
-	 * 
-	 * @return a junit test suite
-	 */
-	public static Test suite() {
-		return new TestSuite( TestWSSecurityDataRef.class);
-	}
-
-	/**
-	 * Main method <p/>
-	 * 
-	 * @param args
-	 *            command line args
-	 */
-	public static void main(String[] args) {
-		junit.textui.TestRunner.run(suite());
-	}
-
-	/**
-	 * Setup method <p/>
-	 * 
-	 * @throws Exception
-	 *             Thrown when there is a problem in setup
-	 */
-	protected void setUp() throws Exception {
-		AxisClient tmpEngine = new AxisClient(new NullProvider());
-		msgContext = new MessageContext(tmpEngine);
-		message = getSOAPMessage();
-	}
-
-	/**
-	 * Constructs a soap envelope <p/>
-	 * 
-	 * @return soap envelope
-	 * @throws Exception
-	 *             if there is any problem constructing the soap envelope
-	 */
-	protected Message getSOAPMessage() throws Exception {
-		InputStream in = new ByteArrayInputStream(soapMsg.getBytes());
-		Message msg = new Message(in);
-		msg.setMessageContext(msgContext);
-		return msg;
-	}
-
-	/**
-	 * Test that check for correct WSDataRef object from ReferenceList Processor 
-	 * 
-	 * 
-	 * @throws Exception
-	 *             Thrown when there is an error in encryption or decryption
-	 */
-	public void testDataRefReferenceListProcessor() throws Exception {
-	  
-		SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
-		WSSecEncrypt builder = new WSSecEncrypt();
-		builder.setUserInfo("wss4jcert");
-		builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-		builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
-		Document doc = unsignedEnvelope.getAsDocument();
-		WSSecHeader secHeader = new WSSecHeader();
-		secHeader.insertSecurityHeader(doc);
-		log.info("Before Encryption Triple DES....");
-
-		/*
-		 * Prepare the Encrypt object with the token, setup data structure
-		 */
-		builder.prepare(doc, crypto);
-
-		/*
-		 * Set up the parts structure to encrypt the body
-		 */
-		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
-				.getDocumentElement());
-		Vector parts = new Vector();
-		WSEncryptionPart encP = new WSEncryptionPart("testMethod", "uri:LogTestService2",
-				"Element");
-		parts.add(encP);
-
-		/*
-		 * Encrypt the element (testMethod), create EncrypedData elements that reference
-		 * the EncryptedKey, and get a ReferenceList that can be put into the
-		 * Security header. Be sure that the ReferenceList is after the
-		 * EncryptedKey element in the Security header (strict layout)
-		 */
-		Element refs = builder.encryptForExternalRef(null, parts);
-		builder.addExternalRefElement(refs, secHeader);
-
-		/*
-		 * now add (prepend) the EncryptedKey element, then a
-		 * BinarySecurityToken if one was setup during prepare
-		 */
-		builder.prependToHeader(secHeader);
-
-		builder.prependBSTElementToHeader(secHeader);
-
-		Document encryptedDoc = doc;
-		log.info("After Encryption Triple DES....");
-
-		checkDataRef(encryptedDoc);
-	}
-
-	/**
-	 * Verifies the soap envelope <p/>
-	 * 
-	 * @param envelope
-	 * @throws Exception
-	 *             Thrown when there is a problem in verification
-	 */
-	private void checkDataRef(Document doc) throws Exception {
-	    
-	        // Retrive the wsResults vector 
-		Vector wsResults = secEngine.processSecurityHeader(doc, null, this, crypto);
-		boolean found = false;
-				
-		for (int i = 0; i < wsResults.size(); i++) {
-		    
-		    WSSecurityEngineResult wsSecEngineResult = 
-		        (WSSecurityEngineResult)wsResults.get(i);		    
-		    int action = ((java.lang.Integer) 
-		        wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
-		    
-		    // We want to filter only encryption results
-		    if (action != WSConstants.ENCR) {
-		        continue;
-		    }
-		    ArrayList dataRefs = (ArrayList)wsSecEngineResult
-		        .get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
-		    
-		    //We want check only the DATA_REF_URIS 
-		    if (dataRefs != null && dataRefs.size() > 0) {
-		        for (int j = 0; j < dataRefs.size(); j++) {
-                            Object obj = dataRefs.get(i);                            
-                            
-                            // ReferenceList Processor must Return a WSDataRef objects
-                            assertTrue(obj instanceof WSDataRef);
-                            
-                            WSDataRef dataRef = (WSDataRef) obj;
-                            
-                            // Check whether dataRef URI is set
-                            assertNotNull(dataRef.getDataref());
-                            
-                            // Check whether QName is correctly set
-                            assertEquals("testMethod", dataRef.getName().getLocalPart());
-                            assertEquals("uri:LogTestService2", dataRef.getName().getNamespaceURI());
-                            
-                            // Check whether wsu:Id is set
-                            assertNotNull(dataRef.getWsuId());
-                            
-                            // flag to indicate the element was found in TAG_DATA_REF_URIS
-                            found = true;
-                                                      
-                        }
-		    }
                 }
-		
-		// Make sure the element is actually found in the decrypted elements
-		assertTrue(found);
-		
-	}
-
-	public void handle(Callback[] callbacks) throws IOException,
-			UnsupportedCallbackException {
-		for (int i = 0; i < callbacks.length; i++) {
-			if (callbacks[i] instanceof WSPasswordCallback) {
-				WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
-				/*
-				 * here call a function/method to lookup the password for the
-				 * given identifier (e.g. a user name or keystore alias) e.g.:
-				 * pc.setPassword(passStore.getPassword(pc.getIdentfifier)) for
-				 * Testing we supply a fixed name here.
-				 */
-				pc.setPassword("security");
-			} else {
-				throw new UnsupportedCallbackException(callbacks[i],
-						"Unrecognized Callback");
-			}
-		}
-	}
+            }
+        }
+        
+        // Make sure the element is actually found in the decrypted elements
+        assertTrue(found);
+        
+    }
+
+    public void handle(Callback[] callbacks) throws IOException,
+            UnsupportedCallbackException {
+        for (int i = 0; i < callbacks.length; i++) {
+            if (callbacks[i] instanceof WSPasswordCallback) {
+                WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
+                /*
+                 * here call a function/method to lookup the password for the
+                 * given identifier (e.g. a user name or keystore alias) e.g.:
+                 * pc.setPassword(passStore.getPassword(pc.getIdentfifier)) for
+                 * Testing we supply a fixed name here.
+                 */
+                pc.setPassword("security");
+            } else {
+                throw new UnsupportedCallbackException(callbacks[i],
+                        "Unrecognized Callback");
+            }
+        }
+    }
 }

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef1.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef1.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef1.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef1.java Wed Oct  1 06:56:10 2008
@@ -70,214 +70,214 @@
  * 
  */
 public class TestWSSecurityDataRef1 extends TestCase implements CallbackHandler {
-	private static Log log = LogFactory.getLog(TestWSSecurityDataRef1.class);
+    private static Log log = LogFactory.getLog(TestWSSecurityDataRef1.class);
+
+    static final String soapMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+            + "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+            + "   <soapenv:Body>"
+            + "      <ns1:testMethod xmlns:ns1=\"uri:LogTestService2\"></ns1:testMethod>"
+            + "   </soapenv:Body>" + "</soapenv:Envelope>";
+
+    static final WSSecurityEngine secEngine = new WSSecurityEngine();
+
+    static final Crypto crypto = CryptoFactory
+            .getInstance("cryptoSKI.properties");
+
+    MessageContext msgContext;
+
+    Message message;
+
+    /**
+     * TestWSSecurityDataRef constructor <p/>
+     * 
+     * @param name
+     *            name of the test
+     */
+    public TestWSSecurityDataRef1(String name) {
+        super(name);
+    }
+
+    /**
+     * JUnit suite <p/>
+     * 
+     * @return a junit test suite
+     */
+    public static Test suite() {
+        return new TestSuite( TestWSSecurityDataRef1.class);
+    }
+
+    /**
+     * Main method <p/>
+     * 
+     * @param args
+     *            command line args
+     */
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(suite());
+    }
+
+    /**
+     * Setup method <p/>
+     * 
+     * @throws Exception
+     *             Thrown when there is a problem in setup
+     */
+    protected void setUp() throws Exception {
+        AxisClient tmpEngine = new AxisClient(new NullProvider());
+        msgContext = new MessageContext(tmpEngine);
+        message = getSOAPMessage();
+    }
+
+    /**
+     * Constructs a soap envelope <p/>
+     * 
+     * @return soap envelope
+     * @throws Exception
+     *             if there is any problem constructing the soap envelope
+     */
+    protected Message getSOAPMessage() throws Exception {
+        InputStream in = new ByteArrayInputStream(soapMsg.getBytes());
+        Message msg = new Message(in);
+        msg.setMessageContext(msgContext);
+        return msg;
+    }
+
+    /**
+     * Test that check for correct WSDataRef object from EncryptedKey Processor 
+     * 
+     * 
+     * @throws Exception
+     *             Thrown when there is an error in encryption or decryption
+     */
+    public void testDataRefEncryptedKeyProcessor() throws Exception {
+      
+        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
+        WSSecEncrypt builder = new WSSecEncrypt();
+        builder.setUserInfo("wss4jcert");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+        Document doc = unsignedEnvelope.getAsDocument();
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        log.info("Before Encryption Triple DES....");
+
+        /*
+         * Prepare the Encrypt object with the token, setup data structure
+         */
+        builder.prepare(doc, crypto);
+
+        /*
+         * Set up the parts structure to encrypt the body
+         */
+        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
+                .getDocumentElement());
+        Vector parts = new Vector();
+        WSEncryptionPart encP = new WSEncryptionPart("testMethod", "uri:LogTestService2",
+                "Element");
+        parts.add(encP);
+
+        /*
+         * Encrypt the element (testMethod), create EncrypedData elements that reference
+         * the EncryptedKey, and get a ReferenceList that can be put into the EncryptedKey
+         * itself as a child.
+         */
+        Element refs = builder.encryptForExternalRef(null, parts);
+        
+        /*
+         * We use this method because we want the reference list to be inside the 
+         * EncryptedKey element
+         */
+        builder.addInternalRefElement(refs);
+
+        /*
+         * now add (prepend) the EncryptedKey element, then a
+         * BinarySecurityToken if one was setup during prepare
+         */
+        builder.prependToHeader(secHeader);
+
+        builder.prependBSTElementToHeader(secHeader);
+
+        Document encryptedDoc = doc;
+        log.info("After Encryption Triple DES....");
+
+        checkDataRef(encryptedDoc);
+    }
+
+    /**
+     * Verifies the soap envelope <p/>
+     * 
+     * @param envelope
+     * @throws Exception
+     *             Thrown when there is a problem in verification
+     */
+    private void checkDataRef(Document doc) throws Exception {
+        
+        // Retrieve the wsResults vector 
+        Vector wsResults = secEngine.processSecurityHeader(doc, null, this, crypto);
+        boolean found = false;
+                
+        for (int i = 0; i < wsResults.size(); i++) {
+            
+            WSSecurityEngineResult wsSecEngineResult = 
+                (WSSecurityEngineResult)wsResults.get(i);           
+            int action = ((java.lang.Integer) 
+                wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
+            
+            // We want to filter only encryption results
+            if (action != WSConstants.ENCR) {
+                continue;
+            }
+            ArrayList dataRefs = (ArrayList)wsSecEngineResult
+                .get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
+            
+            //We want check only the DATA_REF_URIS 
+            if (dataRefs != null && dataRefs.size() > 0) {
+                for (int j = 0; j < dataRefs.size(); j++) {
+                    Object obj = dataRefs.get(i);                            
+
+                    // ReferenceList Processor must Return a WSDataRef objects
+                    assertTrue(obj instanceof WSDataRef);
+
+                    WSDataRef dataRef = (WSDataRef) obj;
+
+                    // Check whether dataRef URI is set
+                    assertNotNull(dataRef.getDataref());
+
+                    // Check whether QName is correctly set
+                    assertEquals("testMethod", dataRef.getName().getLocalPart());
+                    assertEquals("uri:LogTestService2", dataRef.getName().getNamespaceURI());
+
+                    // Check whether wsu:Id is set
+                    assertNotNull(dataRef.getWsuId());
+
+                    // flag to indicate the element was found in TAG_DATA_REF_URIS
+                    found = true;
 
-	static final String soapMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-			+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
-			+ "   <soapenv:Body>"
-			+ "      <ns1:testMethod xmlns:ns1=\"uri:LogTestService2\"></ns1:testMethod>"
-			+ "   </soapenv:Body>" + "</soapenv:Envelope>";
-
-	static final WSSecurityEngine secEngine = new WSSecurityEngine();
-
-	static final Crypto crypto = CryptoFactory
-			.getInstance("cryptoSKI.properties");
-
-	MessageContext msgContext;
-
-	Message message;
-
-	/**
-	 * TestWSSecurityDataRef constructor <p/>
-	 * 
-	 * @param name
-	 *            name of the test
-	 */
-	public TestWSSecurityDataRef1(String name) {
-		super(name);
-	}
-
-	/**
-	 * JUnit suite <p/>
-	 * 
-	 * @return a junit test suite
-	 */
-	public static Test suite() {
-		return new TestSuite( TestWSSecurityDataRef1.class);
-	}
-
-	/**
-	 * Main method <p/>
-	 * 
-	 * @param args
-	 *            command line args
-	 */
-	public static void main(String[] args) {
-		junit.textui.TestRunner.run(suite());
-	}
-
-	/**
-	 * Setup method <p/>
-	 * 
-	 * @throws Exception
-	 *             Thrown when there is a problem in setup
-	 */
-	protected void setUp() throws Exception {
-		AxisClient tmpEngine = new AxisClient(new NullProvider());
-		msgContext = new MessageContext(tmpEngine);
-		message = getSOAPMessage();
-	}
-
-	/**
-	 * Constructs a soap envelope <p/>
-	 * 
-	 * @return soap envelope
-	 * @throws Exception
-	 *             if there is any problem constructing the soap envelope
-	 */
-	protected Message getSOAPMessage() throws Exception {
-		InputStream in = new ByteArrayInputStream(soapMsg.getBytes());
-		Message msg = new Message(in);
-		msg.setMessageContext(msgContext);
-		return msg;
-	}
-
-	/**
-	 * Test that check for correct WSDataRef object from EncryptedKey Processor 
-	 * 
-	 * 
-	 * @throws Exception
-	 *             Thrown when there is an error in encryption or decryption
-	 */
-	public void testDataRefEncryptedKeyProcessor() throws Exception {
-	  
-		SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
-		WSSecEncrypt builder = new WSSecEncrypt();
-		builder.setUserInfo("wss4jcert");
-		builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-		builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
-		Document doc = unsignedEnvelope.getAsDocument();
-		WSSecHeader secHeader = new WSSecHeader();
-		secHeader.insertSecurityHeader(doc);
-		log.info("Before Encryption Triple DES....");
-
-		/*
-		 * Prepare the Encrypt object with the token, setup data structure
-		 */
-		builder.prepare(doc, crypto);
-
-		/*
-		 * Set up the parts structure to encrypt the body
-		 */
-		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
-				.getDocumentElement());
-		Vector parts = new Vector();
-		WSEncryptionPart encP = new WSEncryptionPart("testMethod", "uri:LogTestService2",
-				"Element");
-		parts.add(encP);
-
-		/*
-		 * Encrypt the element (testMethod), create EncrypedData elements that reference
-		 * the EncryptedKey, and get a ReferenceList that can be put into the EncryptedKey
-		 * itself as a child.
-		 */
-		Element refs = builder.encryptForExternalRef(null, parts);
-		
-		/*
-		 * We use this method because we want the reference list to be inside the 
-		 * EncryptedKey element
-		 */
-		builder.addInternalRefElement(refs);
-
-		/*
-		 * now add (prepend) the EncryptedKey element, then a
-		 * BinarySecurityToken if one was setup during prepare
-		 */
-		builder.prependToHeader(secHeader);
-
-		builder.prependBSTElementToHeader(secHeader);
-
-		Document encryptedDoc = doc;
-		log.info("After Encryption Triple DES....");
-
-		checkDataRef(encryptedDoc);
-	}
-
-	/**
-	 * Verifies the soap envelope <p/>
-	 * 
-	 * @param envelope
-	 * @throws Exception
-	 *             Thrown when there is a problem in verification
-	 */
-	private void checkDataRef(Document doc) throws Exception {
-	    
-	        // Retrive the wsResults vector 
-		Vector wsResults = secEngine.processSecurityHeader(doc, null, this, crypto);
-		boolean found = false;
-				
-		for (int i = 0; i < wsResults.size(); i++) {
-		    
-		    WSSecurityEngineResult wsSecEngineResult = 
-		        (WSSecurityEngineResult)wsResults.get(i);		    
-		    int action = ((java.lang.Integer) 
-		        wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
-		    
-		    // We want to filter only encryption results
-		    if (action != WSConstants.ENCR) {
-		        continue;
-		    }
-		    ArrayList dataRefs = (ArrayList)wsSecEngineResult
-		        .get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
-		    
-		    //We want check only the DATA_REF_URIS 
-		    if (dataRefs != null && dataRefs.size() > 0) {
-		        for (int j = 0; j < dataRefs.size(); j++) {
-                            Object obj = dataRefs.get(i);                            
-                            
-                            // ReferenceList Processor must Return a WSDataRef objects
-                            assertTrue(obj instanceof WSDataRef);
-                            
-                            WSDataRef dataRef = (WSDataRef) obj;
-                            
-                            // Check whether dataRef URI is set
-                            assertNotNull(dataRef.getDataref());
-                            
-                            // Check whether QName is correctly set
-                            assertEquals("testMethod", dataRef.getName().getLocalPart());
-                            assertEquals("uri:LogTestService2", dataRef.getName().getNamespaceURI());
-                            
-                            // Check whether wsu:Id is set
-                            assertNotNull(dataRef.getWsuId());
-                            
-                            // flag to indicate the element was found in TAG_DATA_REF_URIS
-                            found = true;
-                                                      
-                        }
-		    }
                 }
-		
-		// Make sure the element is actually found in the decrypted elements
-		assertTrue(found);
-		
-	}
-
-	public void handle(Callback[] callbacks) throws IOException,
-			UnsupportedCallbackException {
-		for (int i = 0; i < callbacks.length; i++) {
-			if (callbacks[i] instanceof WSPasswordCallback) {
-				WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
-				/*
-				 * here call a function/method to lookup the password for the
-				 * given identifier (e.g. a user name or keystore alias) e.g.:
-				 * pc.setPassword(passStore.getPassword(pc.getIdentfifier)) for
-				 * Testing we supply a fixed name here.
-				 */
-				pc.setPassword("security");
-			} else {
-				throw new UnsupportedCallbackException(callbacks[i],
-						"Unrecognized Callback");
-			}
-		}
-	}
+            }
+        }
+        
+        // Make sure the element is actually found in the decrypted elements
+        assertTrue(found);
+        
+    }
+
+    public void handle(Callback[] callbacks) throws IOException,
+            UnsupportedCallbackException {
+        for (int i = 0; i < callbacks.length; i++) {
+            if (callbacks[i] instanceof WSPasswordCallback) {
+                WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
+                /*
+                 * here call a function/method to lookup the password for the
+                 * given identifier (e.g. a user name or keystore alias) e.g.:
+                 * pc.setPassword(passStore.getPassword(pc.getIdentfifier)) for
+                 * Testing we supply a fixed name here.
+                 */
+                pc.setPassword("security");
+            } else {
+                throw new UnsupportedCallbackException(callbacks[i],
+                        "Unrecognized Callback");
+            }
+        }
+    }
 }

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityFaultCodes.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityFaultCodes.java?rev=700768&r1=700767&r2=700768&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityFaultCodes.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityFaultCodes.java Wed Oct  1 06:56:10 2008
@@ -166,7 +166,7 @@
         } catch (WSSecurityException ex) {
             assertTrue(ex.getErrorCode() == 2);
             assertTrue(ex.getMessage().startsWith(
-            	"An unsupported signature or encryption algorithm was used"));
+                "An unsupported signature or encryption algorithm was used"));
             QName faultCode = new QName(WSConstants.WSSE_NS, "UnsupportedAlgorithm");
             assertTrue(ex.getFaultCode().equals(faultCode));
         }



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