Re: [WSS4J] Rajesh Koilpillai <rajesh-KbPxBdIIuGhWk0Htik3J/[email protected]>; Mukund Balasubramanian <mukund-KbPxBdIIuGhWk0Htik3J/[email protected]>; Nithya <nithya-KbPxBdIIuGhWk0Htik3J/[email protected]>

Davanum Srinivas <dims-/[email protected]> Thu, 19 Feb 2004 05:41:46 -0800 (PST)
Newsgroups gmane.text.xml.wss4j
Message-ID <[email protected]>
check your crypto.properties and look at the location of the file.

--- Nachiappan Narayanan <Nachi-KbPxBdIIuGhWk0Htik3J/[email protected]> wrote:
> All,
> 
>   Im unable to get the instance of the Crypto. The following line itself fails.
> 
>  static final Crypto crypto = CryptoFactory.getInstance();
> 
>   When i compile and run the following program as, 
>         c:\test> java -Dlog4j.configuration=log.config TestWSSecurity
> 
>   I get the following info. on the console,
> 
> C:\test>java -Dlog4j.configuration=log.config TestWSSecurity
> 2004-02-19 18:42:28,312 [DEBUG] util.Loader          - Trying to find [crypto.properties] using
> [email protected] class loader.
> 2004-02-19 18:42:28,359 [INFO] crypto.CryptoFactory - Using Crypto Engine
> [org.apache.ws.security.components.crypto.Merlin]
> unknown attr1.3.6.1.4.1.311.17.1
> 
>   How do i resolve this?
> 
>   Am i doing any mistake?
> 
> Regards,
> Nachiappan.N

> ATTACHMENT part 2 application/octet-stream name=log.config
> import org.apache.axis.Message;
> import org.apache.axis.MessageContext;
> import org.apache.axis.client.AxisClient;
> 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.components.crypto.Crypto;
> import org.apache.ws.security.components.crypto.CryptoFactory;
> import org.apache.ws.security.message.WSSignEnvelope;
> import org.w3c.dom.Document;
> 
> import java.io.ByteArrayInputStream;
> import java.io.InputStream;
> 
> /**
>  * WS-Security Test Case
>  * <p/>
>  *
>  * @author Davanum Srinivas (dims-/[email protected])
>  */
> public class TestWSSecurity
> {
>     static final Crypto crypto = CryptoFactory.getInstance();
> 
> /*
>     private static Log log = LogFactory.getLog(TestWSSecurity.class);
>     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();
> 
>     MessageContext msgContext;
>     SOAPEnvelope unsignedEnvelope;
> 
>     public TestWSSecurity()
>     {
>     }
> 
>     public static void main(String[] args) throws Exception
>     {
>         TestWSSecurity wsse = new TestWSSecurity();
>         wsse.setUp();
>     }
> 
>     protected void setUp() throws Exception {
>         AxisClient tmpEngine = new AxisClient(new NullProvider());
>         msgContext = new MessageContext(tmpEngine);
>         unsignedEnvelope = getSOAPEnvelope();
>     }
> 
>     protected SOAPEnvelope getSOAPEnvelope() throws Exception {
>         InputStream in = new ByteArrayInputStream(soapMsg.getBytes());
>         Message msg = new Message(in);
>         msg.setMessageContext(msgContext);
>         return msg.getSOAPEnvelope();
>     }
> 
>     public void testX509Signature() throws Exception {
>         SOAPEnvelope envelope = null;
>         WSSignEnvelope builder = new WSSignEnvelope();
>         //builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
>         builder.setUserInfo("john", "keypass");
>         log.info("Before Signing....");
>         Document doc = unsignedEnvelope.getAsDocument();
>         Document signedDoc = builder.build(doc, crypto);
> 
>         Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
>         signedDoc = signedMsg.getSOAPEnvelope().getAsDocument();
>         log.info("After Signing....");
>         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);
>     }
> 
>     private void verify(Document doc) throws Exception {
>         secEngine.processSecurityHeader(doc, null, null, crypto);
>     }
> */
> 
> 	public static void main(String args[]) throws Exception
> 	{
> 		new TestWSSecurity();
> 	}
> 
> 
> }
> 
> 
> //set
>
CLASSPATH=D:\workspace\BMC\neo410\wss4j\lib\activation.jar;D:\workspace\BMC\neo410\wss4j\lib\axis.jar;D:\workspace\BMC\neo410\wss4j\lib\axis-ant.jar;D:\workspace\BMC\neo410\wss4j\lib\commons-discovery.jar;D:\workspace\BMC\neo410\wss4j\lib\commons-logging.jar;D:\workspace\BMC\neo410\wss4j\lib\cryptix32.jar;D:\workspace\BMC\neo410\wss4j\lib\cryptix.jar;D:\workspace\BMC\neo410\wss4j\lib\cryptix-asn1.jar;D:\workspace\BMC\neo410\wss4j\lib\jaxrpc.jar;D:\workspace\BMC\neo410\wss4j\lib\jce-jdk13-121.jar;D:\workspace\BMC\neo410\wss4j\lib\junit-3.8.1.jar;D:\workspace\BMC\neo410\wss4j\lib\log4j-1.2.8.jar;D:\workspace\BMC\neo410\wss4j\lib\mailapi-1_3.jar;D:\workspace\BMC\neo410\wss4j\lib\saaj.jar;D:\workspace\BMC\neo410\wss4j\lib\wsdl4j.jar;D:\workspace\BMC\neo410\wss4j\lib\xalan.jar;D:\workspace\BMC\neo410\wss4j\lib\xercesImpl.jar;D:\workspace\BMC\neo410\wss4j\lib\xml-apis.jar;D:\workspace\BMC\neo4
 10\wss4j\lib\xmlsec.jar;classes;
> 
> //-Djavax.net.ssl.keyStore=selfcert.pfx -Djavax.net.ssl.keyStoreType=PKCS12
> -Djavax.net.ssl.keyStorePassword=security
> > org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
> org.apache.ws.security.crypto.merlin.keystore.type=pkcs12
> org.apache.ws.security.crypto.merlin.keystore.password=security
> org.apache.ws.security.crypto.merlin.keystore.alias=16c73ab6-b892-458f-abf5-2f875f74882e
> org.apache.ws.security.crypto.merlin.alias.password=security
> org.apache.ws.security.crypto.merlin.file=keys/x509.PFX.MSFT
> 


=====
Davanum Srinivas - http://webservices.apache.org/~dims/


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click