You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by we...@apache.org on 2004/02/29 13:32:22 UTC

cvs commit: ws-fx/wss4j/test/wssec TestWSSecurity4.java TestWSSecurity11.java TestWSSecurity8.java TestWSSecurity.java PackageTests.java

werner      2004/02/29 04:32:22

  Modified:    wss4j/test/wssec TestWSSecurity4.java TestWSSecurity11.java
                        TestWSSecurity8.java TestWSSecurity.java
                        PackageTests.java
  Log:
  Finish SKI stuff (refer to test4 and  test11), modify the package
  to exclude the MSFT test (fails because we updated to latest OASIS
  WSS specifications).
  
  Revision  Changes    Path
  1.2       +6 -4      ws-fx/wss4j/test/wssec/TestWSSecurity4.java
  
  Index: TestWSSecurity4.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/wss4j/test/wssec/TestWSSecurity4.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestWSSecurity4.java	24 Feb 2004 12:45:52 -0000	1.1
  +++ TestWSSecurity4.java	29 Feb 2004 12:32:22 -0000	1.2
  @@ -52,7 +52,7 @@
       static final String NS = "http://www.w3.org/2000/09/xmldsig#";
       static final String soapMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "<SOAP-ENV:Body>" + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">" + "<value xmlns=\"\">15</value>" + "</add>" + "</SOAP-ENV:Body>\r\n       \r\n" + "</SOAP-ENV:Envelope>";
       static final WSSecurityEngine secEngine = new WSSecurityEngine();
  -    static final Crypto crypto = CryptoFactory.getInstance();
  +    static final Crypto crypto = CryptoFactory.getInstance("cryptoSKI.properties");
   
       MessageContext msgContext;
       SOAPEnvelope unsignedEnvelope;
  @@ -114,7 +114,9 @@
       }
   
       /**
  -     * Test that signs and verifies a WS-Security envelope
  +     * Test that signs and verifies a WS-Security envelope using SubjectKeyIdentifier.
  +     * This test uses the SubjectKeyIdentifier to identify the certificate. It
  +     * uses the Direct version, that is it embedds the certificate in the message.
        * <p/>
        * 
        * @throws java.lang.Exception Thrown when there is any problem in signing or verification
  @@ -122,7 +124,7 @@
       public void testX509SignatureSKIDirect() throws Exception {
           SOAPEnvelope envelope = null;
           WSSignEnvelope builder = new WSSignEnvelope();
  -        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
  +        builder.setUserInfo("wss4jcert", "security");
   		builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER_DIRECT);
   
           // builder.setUserInfo("john", "keypass");
  @@ -154,7 +156,7 @@
       public void testDoubleX509SignatureSKIDirect() throws Exception {
           SOAPEnvelope envelope = null;
           WSSignEnvelope builder = new WSSignEnvelope();
  -        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
  +        builder.setUserInfo("wss4jcert", "security");
   		builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER_DIRECT);
   
           // builder.setUserInfo("john", "keypass");
  
  
  
  1.2       +223 -24   ws-fx/wss4j/test/wssec/TestWSSecurity11.java
  
  Index: TestWSSecurity11.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/wss4j/test/wssec/TestWSSecurity11.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestWSSecurity11.java	13 Feb 2004 20:43:09 -0000	1.1
  +++ TestWSSecurity11.java	29 Feb 2004 12:32:22 -0000	1.2
  @@ -55,7 +55,7 @@
       static final String NS = "http://www.w3.org/2000/09/xmldsig#";
       static final String soapMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "<SOAP-ENV:Body>" + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">" + "<value xmlns=\"\">15</value>" + "</add>" + "</SOAP-ENV:Body>\r\n       \r\n" + "</SOAP-ENV:Envelope>";
       static final WSSecurityEngine secEngine = new WSSecurityEngine();
  -    static final Crypto crypto = CryptoFactory.getInstance();
  +    static final Crypto crypto = CryptoFactory.getInstance("cryptoSKI.properties");
   
       MessageContext msgContext;
       SOAPEnvelope unsignedEnvelope;
  @@ -117,15 +117,18 @@
       }
   
       /**
  -     * Test that signs and verifies a WS-Security envelope
  +     * Test that signs and verifies a WS-Security envelope.
  +     * This test uses the direct reference key identifier (certificate included
  +     * as a BinarySecurityToken (BST) in the message). The test signs the message
  +     * body (SOAP Body) and uses the STRTransform to sign the embedded certificate
        * <p/>
        * 
        * @throws java.lang.Exception Thrown when there is any problem in signing or verification
        */
  -    public void testX509SignatureSTR() throws Exception {
  +    public void testX509SignatureDirectSTR() throws Exception {
           SOAPEnvelope envelope = null;
           WSSignEnvelope builder = new WSSignEnvelope();
  -        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
  +        builder.setUserInfo("wss4jcert", "security");
           // builder.setUserInfo("john", "keypass");
   		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope);
   		Vector parts = new Vector();
  @@ -150,9 +153,8 @@
   		builder.setParts(parts);
   		builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
   
  -        log.info("Before Signing....");
  +        log.info("Before Signing STR DirectReference....");
           Document doc = unsignedEnvelope.getAsDocument();
  -        System.out.println("test STR document: " + doc.toString() + ", " + doc.hashCode());
           Document signedDoc = builder.build(doc, crypto);
   
           /*
  @@ -163,29 +165,226 @@
            */
   
           Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
  -		XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		if (log.isDebugEnabled()) {
  +			log.debug("Signed message with STR DirectReference key identifier:");
  +			XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		}
           signedDoc = signedMsg.getSOAPEnvelope().getAsDocument();
  -        log.info("After Signing....");
  +        log.info("After Signing STR DirectReference....");
           verify(signedDoc);
       }
   
  -    /**
  -     * Test that signs (twice) and verifies a WS-Security envelope
  -     * <p/>
  -     * 
  -     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
  +	/**
  +	 * Test that signs and verifies a WS-Security envelope.
  +	 * This test uses the IssuerSerialDirect reference key identifier (certificate included
  +	 * as a BinarySecurityToken (BST) in the message) but identified with IssuerSerialNumber
  +	 * and <b>not</b> with a Reference (relative URI). The test signs the message
  +	 * body (SOAP Body) and uses the STRTransform to sign the embedded certificate
  +	 * <p/>
  +	 * 
  +	 * @throws java.lang.Exception Thrown when there is any problem in signing or verification
  +	 */
  +	public void testX509SignatureISDirectSTR() throws Exception {
  +		SOAPEnvelope envelope = null;
  +		WSSignEnvelope builder = new WSSignEnvelope();
  +		builder.setUserInfo("wss4jcert", "security");
  +		// builder.setUserInfo("john", "keypass");
  +		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope);
  +		Vector parts = new Vector();
  +		
  +		/*
  +		 * Set up to sign body and use STRTransorm to sign
  +		 * the signature token (e.g. X.509 certificate)
  +		 */
  +		WSEncryptionPart encP =
  +			new WSEncryptionPart(
  +				soapConstants.getBodyQName().getLocalPart(),	// define the body
  +				soapConstants.getEnvelopeURI(),
  +				"Content");
  +		parts.add(encP);
  +		encP =
  +			new WSEncryptionPart(
  +				"STRTransform",				// reserved word to use STRTransform
  +				soapConstants.getEnvelopeURI(),
  +				"Content");
  +		parts.add(encP);
  +
  +		builder.setParts(parts);
  +		builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL_DIRECT);
  +
  +		log.info("Before Signing STR ISDirect....");
  +		Document doc = unsignedEnvelope.getAsDocument();
  +		Document signedDoc = builder.build(doc, crypto);
  +
  +		Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
  +		if (log.isDebugEnabled()) {
  +			log.debug("Signed message with STR IssuerSerialDirect key identifier:");
  +			XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		}
  +		signedDoc = signedMsg.getSOAPEnvelope().getAsDocument();
  +		log.info("After Signing STR ISDirect....");
  +		verify(signedDoc);
  +	}
  +
  +	/**
  +	 * Test that signs and verifies a WS-Security envelope.
  +	 * This test uses the IssuerSerial reference key identifier (certificate not included
  +	 * in the message)and reads the certificate from a keystore using IssuerSerialNumber
  +	 * to identify it.
  +	 * <p/>
  +	 * 
  +	 * @throws java.lang.Exception Thrown when there is any problem in signing or verification
  +	 */
  +	
  +
  +	public void testX509SignatureISSTR() throws Exception {
  +		SOAPEnvelope envelope = null;
  +		WSSignEnvelope builder = new WSSignEnvelope();
  +		builder.setUserInfo("wss4jcert", "security");
  +		// builder.setUserInfo("john", "keypass");
  +		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope);
  +		Vector parts = new Vector();
  +		
  +		/*
  +		 * Set up to sign body and use STRTransorm to sign
  +		 * the signature token (e.g. X.509 certificate)
  +		 */
  +		WSEncryptionPart encP =
  +			new WSEncryptionPart(
  +				soapConstants.getBodyQName().getLocalPart(),	// define the body
  +				soapConstants.getEnvelopeURI(),
  +				"Content");
  +		parts.add(encP);
  +		encP =
  +			new WSEncryptionPart(
  +				"STRTransform",				// reserved word to use STRTransform
  +				soapConstants.getEnvelopeURI(),
  +				"Content");
  +		parts.add(encP);
  +
  +		builder.setParts(parts);
  +		builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
  +
  +		log.info("Before Signing STR IS....");
  +		Document doc = unsignedEnvelope.getAsDocument();
  +		Document signedDoc = builder.build(doc, crypto);
  +
  +		Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
  +		if (log.isDebugEnabled()) {
  +			log.debug("Signed message with STR IssuerSerial key identifier:");
  +			XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		}
  +		signedDoc = signedMsg.getSOAPEnvelope().getAsDocument();
  +		log.info("After Signing STR IS....");
  +		verify(signedDoc);
  +	}
  +	
  +	/**
  +	 * Test that signs and verifies a WS-Security envelope.
  +	 * This test uses the SubjectKeyIdentifier key identifier (certificate not included
  +	 * in the message) and reads the certificate from a keystore using SKI
  +	 * to identify it.
  +	 * <p/>
  +	 * 
  +	 * @throws java.lang.Exception Thrown when there is any problem in signing or verification
  +	 */
  +	
  +
  +	public void testX509SignatureSKISTR() throws Exception {
  +		SOAPEnvelope envelope = null;
  +		WSSignEnvelope builder = new WSSignEnvelope();
  +		builder.setUserInfo("wss4jcert", "security");
  +		// builder.setUserInfo("john", "keypass");
  +		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope);
  +		Vector parts = new Vector();
  +		
  +		/*
  +		 * Set up to sign body and use STRTransorm to sign
  +		 * the signature token (e.g. X.509 certificate)
  +		 */
  +		WSEncryptionPart encP =
  +			new WSEncryptionPart(
  +				soapConstants.getBodyQName().getLocalPart(),	// define the body
  +				soapConstants.getEnvelopeURI(),
  +				"Content");
  +		parts.add(encP);
  +		encP =
  +			new WSEncryptionPart(
  +				"STRTransform",				// reserved word to use STRTransform
  +				soapConstants.getEnvelopeURI(),
  +				"Content");
  +		parts.add(encP);
  +
  +		builder.setParts(parts);
  +		builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
  +
  +		log.info("Before Signing STR SKI....");
  +		Document doc = unsignedEnvelope.getAsDocument();
  +		Document signedDoc = builder.build(doc, crypto);
  +
  +		Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
  +		if (log.isDebugEnabled()) {
  +			log.debug("Signed message with STR SKI key identifier:");
  +			XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		}
  +		signedDoc = signedMsg.getSOAPEnvelope().getAsDocument();
  +		log.info("After Signing STR SKI....");
  +		verify(signedDoc);
  +	}
  +
  +	/**
  +	 * Test that signs and verifies a WS-Security envelope.
  +	 * This test uses the SubjectKeyIdentifierDirect key identifier (certificate included
  +	 * in the message).
  +	 * <p/>
  +	 * 
  +	 * @throws java.lang.Exception Thrown when there is any problem in signing or verification
  +	 */
  +	
  +
  +	public void testX509SignatureSKIDirectSTR() throws Exception {
  +		SOAPEnvelope envelope = null;
  +		WSSignEnvelope builder = new WSSignEnvelope();
  +		builder.setUserInfo("wss4jcert", "security");
  +		// builder.setUserInfo("john", "keypass");
  +		SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope);
  +		Vector parts = new Vector();
  +		
  +		/*
  +		 * Set up to sign body and use STRTransorm to sign
  +		 * the signature token (e.g. X.509 certificate)
  +		 */
  +		WSEncryptionPart encP =
  +			new WSEncryptionPart(
  +				soapConstants.getBodyQName().getLocalPart(),	// define the body
  +				soapConstants.getEnvelopeURI(),
  +				"Content");
  +		parts.add(encP);
  +		encP =
  +			new WSEncryptionPart(
  +				"STRTransform",				// reserved word to use STRTransform
  +				soapConstants.getEnvelopeURI(),
  +				"Content");
  +		parts.add(encP);
  +
  +		builder.setParts(parts);
  +		builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER_DIRECT);
  +
  +		log.info("Before Signing STR SKIDirect....");
  +		Document doc = unsignedEnvelope.getAsDocument();
  +		Document signedDoc = builder.build(doc, crypto);
  +
  +		Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
  +		if (log.isDebugEnabled()) {
  +			log.debug("Signed message with STR SKIDirect key identifier:");
  +			XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		}
  +		signedDoc = signedMsg.getSOAPEnvelope().getAsDocument();
  +		log.info("After Signing STR SKIDirect....");
  +		verify(signedDoc);
  +	}
  +
   
  -    public void testDoubleX509Signature() throws Exception {
  -        SOAPEnvelope envelope = null;
  -        WSSignEnvelope builder = new WSSignEnvelope();
  -        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
  -        // builder.setUserInfo("john", "keypass");
  -        Document doc = unsignedEnvelope.getAsDocument();
  -        Document signedDoc = builder.build(doc, crypto);
  -        Document signedDoc1 = builder.build(signedDoc, crypto);
  -        verify(signedDoc1);
  -    }
  -     */
       /**
        * Verifies the soap envelope
        * 
  
  
  
  1.2       +25 -9     ws-fx/wss4j/test/wssec/TestWSSecurity8.java
  
  Index: TestWSSecurity8.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/wss4j/test/wssec/TestWSSecurity8.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestWSSecurity8.java	13 Feb 2004 20:43:09 -0000	1.1
  +++ TestWSSecurity8.java	29 Feb 2004 12:32:22 -0000	1.2
  @@ -32,6 +32,7 @@
   import org.apache.ws.axis.security.util.AxisUtil;
   import org.apache.ws.security.WSPasswordCallback;
   import org.apache.ws.security.WSSecurityEngine;
  +import org.apache.ws.security.WSConstants;
   import org.apache.ws.security.components.crypto.Crypto;
   import org.apache.ws.security.components.crypto.CryptoFactory;
   import org.apache.ws.security.message.WSEncryptBody;
  @@ -57,7 +58,7 @@
       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=\"http://axis/service/security/test6/LogTestService6\"></ns1:testMethod>" +
  +            "      <ns1:testMethod xmlns:ns1=\"http://axis/service/security/test6/LogTestService8\"></ns1:testMethod>" +
               "   </soapenv:Body>" +
               "</soapenv:Envelope>";
   
  @@ -123,37 +124,49 @@
       }
   
       /**
  -     * Test that encrypts and signs a WS-Security envelope, then performs
  -     * verification and decryption
  +     * Test that first signs, then encrypts a WS-Security envelope.
  +     * The test uses the IssuerSerial key identifier to get the keys for
  +     * signature and encryption. Encryption uses 3DES.
        * <p/>
        * 
        * @throws Exception Thrown when there is any problem in signing, encryption,
        *                   decryption, or verification
        */
  -    public void testSigningEncryption() throws Exception {
  +    public void testSigningEncryptionIS3DES() throws Exception {
           SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
           SOAPEnvelope envelope = null;
  +        
           WSEncryptBody encrypt = new WSEncryptBody();
  -        WSSignEnvelope sign = new WSSignEnvelope();
           encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
  +		encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
  +		encrypt.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
  +
  +		WSSignEnvelope sign = new WSSignEnvelope();
           sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
  -        log.info("Before Encryption....");
  +		sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
  +
  +        log.info("Before Sign/Encryption....");
           Document doc = unsignedEnvelope.getAsDocument();
   		Document signedDoc = sign.build(doc, crypto);
           Document encryptedSignedDoc = encrypt.build(signedDoc, crypto);
           /*
            * convert the resulting document into a message first. The toSOAPMessage()
  -         * mehtod performs the necessary c14n call to properly set up the signed
  +         * method performs the necessary c14n call to properly set up the signed
            * document and convert it into a SOAP message. After that we extract it
            * as a document again for further processing.
            */
   
   		Message encryptedMsg = (Message) AxisUtil.toSOAPMessage(encryptedSignedDoc);
  +		if (log.isDebugEnabled()) {
  +			log.debug("Signed and encrypted message with IssuerSerial key identifier (both), 3DES:");
  +			XMLUtils.PrettyElementToWriter(encryptedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		}
  +		
   		String s = encryptedMsg.getSOAPPartAsString();
   		((SOAPPart)message.getSOAPPart()).setCurrentMessage(s, SOAPPart.FORM_STRING);
   		        
   		Document encryptedSignedDoc1 = message.getSOAPEnvelope().getAsDocument();
  -        log.info("After Encryption....");
  +        log.info("After Sign/Encryption....");
           verify(encryptedSignedDoc1);
       }
   
  @@ -167,7 +180,10 @@
       private void verify(Document doc) throws Exception {
           secEngine.processSecurityHeader(doc, null, this, crypto);
           AxisUtil.updateSOAPMessage(doc, message);
  -        XMLUtils.PrettyElementToWriter(message.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		if (log.isDebugEnabled()) {
  +			log.debug("Verfied and decrypted message:");
  +			XMLUtils.PrettyElementToWriter(message.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		}
       }
   
       public void handle(Callback[] callbacks)
  
  
  
  1.2       +48 -7     ws-fx/wss4j/test/wssec/TestWSSecurity.java
  
  Index: TestWSSecurity.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/wss4j/test/wssec/TestWSSecurity.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestWSSecurity.java	13 Feb 2004 20:43:09 -0000	1.1
  +++ TestWSSecurity.java	29 Feb 2004 12:32:22 -0000	1.2
  @@ -23,12 +23,14 @@
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.client.AxisClient;
  +import org.apache.axis.utils.XMLUtils;
   import org.apache.axis.configuration.NullProvider;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.ws.axis.security.util.AxisUtil;
   import org.apache.ws.security.WSSecurityEngine;
  +import org.apache.ws.security.WSConstants;
   import org.apache.ws.security.components.crypto.Crypto;
   import org.apache.ws.security.components.crypto.CryptoFactory;
   import org.apache.ws.security.message.WSSignEnvelope;
  @@ -36,6 +38,8 @@
   
   import java.io.ByteArrayInputStream;
   import java.io.InputStream;
  +import java.io.PrintWriter;
  +
   
   /**
    * WS-Security Test Case
  @@ -110,17 +114,19 @@
       }
   
       /**
  -     * Test that signs and verifies a WS-Security envelope
  +     * Test that signs and verifies a WS-Security envelope.
  +     * The test uses the IssuerSerial key identifier type. 
        * <p/>
        * 
        * @throws java.lang.Exception Thrown when there is any problem in signing or verification
        */
  -    public void testX509Signature() throws Exception {
  +    public void testX509SignatureIS() throws Exception {
           SOAPEnvelope envelope = null;
           WSSignEnvelope builder = new WSSignEnvelope();
           builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
  +        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
           // builder.setUserInfo("john", "keypass");
  -        log.info("Before Signing....");
  +        log.info("Before Signing IS....");
           Document doc = unsignedEnvelope.getAsDocument();
           Document signedDoc = builder.build(doc, crypto);
   
  @@ -132,18 +138,52 @@
            */
   
           Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
  +        if (log.isDebugEnabled()) {
  +        	log.debug("Signed message with IssuerSerial key identifier:");
  +			XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +        }
           signedDoc = signedMsg.getSOAPEnvelope().getAsDocument();
  -        log.info("After Signing....");
  +        log.info("After Signing IS....");
           verify(signedDoc);
       }
   
  +	/**
  +	 * Test that signs and verifies a WS-Security envelope.
  +	 * The test uses the IssuerSerialDirect key identifier type. With
  +	 * this key identifier the signing functions inserts the certificate
  +	 * into the message.  
  +	 * <p/>
  +	 * TODO: use another certificate that is not stored in the keystore.
  +	 * 
  +	 * @throws java.lang.Exception Thrown when there is any problem in signing or verification
  +	 */
  +	public void testX509SignatureISDirect() throws Exception {
  +		SOAPEnvelope envelope = null;
  +		WSSignEnvelope builder = new WSSignEnvelope();
  +		builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
  +		builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL_DIRECT);
  +		// builder.setUserInfo("john", "keypass");
  +		log.info("Before Signing ISDirect....");
  +		Document doc = unsignedEnvelope.getAsDocument();
  +		Document signedDoc = builder.build(doc, crypto);
  +
  +		Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
  +		if (log.isDebugEnabled()) {
  +			log.debug("Signed message with IssuerSerialDirect key identifier:");
  +			XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
  +		}
  +		signedDoc = signedMsg.getSOAPEnvelope().getAsDocument();
  +		log.info("After Signing ISDirect....");
  +		verify(signedDoc);
  +	}
       /**
  -     * Test that signs (twice) and verifies a WS-Security envelope
  +     * Test that signs (twice) and verifies a WS-Security envelope.
  +     * The test uses the IssuerSerial key identifier type.
        * <p/>
        * 
        * @throws java.lang.Exception Thrown when there is any problem in signing or verification
        */
  -    public void testDoubleX509Signature() throws Exception {
  +    public void testDoubleX509SignatureIS() throws Exception {
           SOAPEnvelope envelope = null;
           WSSignEnvelope builder = new WSSignEnvelope();
           builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
  @@ -155,7 +195,8 @@
       }
   
       /**
  -     * Verifies the soap envelope
  +     * Verifies the soap envelope.
  +     * This method verfies all the signature generated. 
        * 
        * @param env soap envelope
        * @throws java.lang.Exception Thrown when there is a problem in verification
  
  
  
  1.2       +1 -1      ws-fx/wss4j/test/wssec/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/wss4j/test/wssec/PackageTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PackageTests.java	13 Feb 2004 20:43:09 -0000	1.1
  +++ PackageTests.java	29 Feb 2004 12:32:22 -0000	1.2
  @@ -49,7 +49,7 @@
   
       public static Test suite() {
           TestSuite suite = new TestSuite();
  -        suite.addTestSuite(TestMSFTWebService.class);
  +        // suite.addTestSuite(TestMSFTWebService.class);
           suite.addTestSuite(TestWSSecurity.class);
           suite.addTestSuite(TestWSSecurity2.class);
           suite.addTestSuite(TestWSSecurity3.class);