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

"Nachiappan Narayanan" <Nachi-KbPxBdIIuGhWk0Htik3J/[email protected]> Thu, 19 Feb 2004 18:56:58 +0530
Newsgroups gmane.text.xml.wss4j
Organization Roxer.com Pvt. Ltd.
Message-ID <003e01c3f6ec$1031f4d0$1f05a8c0@NACHU>
This is a multi-part message in MIME format.

------=_NextPart_000_003A_01C3F71A.267A8580
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_003B_01C3F71A.267A8580"


------=_NextPart_001_003B_01C3F71A.267A8580
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

All,

  Im unable to get the instance of the Crypto. The following line itself =
fails.

 static final Crypto crypto =3D CryptoFactory.getInstance();

  When i compile and run the following program as,=20
        c:\test> java -Dlog4j.configuration=3Dlog.config TestWSSecurity

  I get the following info. on the console,

C:\test>java -Dlog4j.configuration=3Dlog.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
------=_NextPart_001_003B_01C3F71A.267A8580
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>
<DIV><FONT face=3DArial size=3D2>All,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; Im unable to get the instance of =
the Crypto.=20
The following line itself fails.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;static final Crypto crypto =3D=20
CryptoFactory.getInstance();<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;When i compile and run the =
following=20
program as, </FONT><FONT face=3DArial size=3D2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
c:\test&gt;=20
java -Dlog4j.configuration=3Dlog.config TestWSSecurity</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; I get the following info. on the =

console,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>C:\test&gt;java&nbsp;-Dlog4j.configuration=3Dlog.config=20
TestWSSecurity<BR>2004-02-19 18:42:28,312 [DEBUG]=20
util.Loader&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - =
Trying to=20
find [crypto.properties] using <A=20
href=3D"mailto:[email protected]">sun.misc.Launcher=
[email protected]</A>=20
class loader.<BR>2004-02-19 18:42:28,359 [INFO] crypto.CryptoFactory - =
Using=20
Crypto Engine =
[org.apache.ws.security.components.crypto.Merlin]<BR>unknown=20
attr1.3.6.1.4.1.311.17.1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; How do i resolve =
this?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; Am i doing any =
mistake?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>Nachiappan.N</FONT></DIV></DIV></BODY></HTML>

------=_NextPart_001_003B_01C3F71A.267A8580--

------=_NextPart_000_003A_01C3F71A.267A8580
Content-Type: application/octet-stream;
	name="log.config"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="log.config"

# XML Agent Toolkit log configuration file
# General usage is to append your categories to the
# TOOLKIT CATEGORY section at the end of this file.
#
# *ONLY* modify the APPENDERS and CATEGORY section
# if you are familiar with log4j configuration

#
# APPENDERS section
#

#=20
# A1 - a console appender
log4j.appender.A1=3Dorg.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=3Dorg.apache.log4j.PatternLayout
# the appender threshold will override the settings used
# by any category using the appender
# log4j.appender.A1.Threshold=3DDEBUG
log4j.appender.A1.layout.ConversionPattern=3D%d [%p] %-20.30c{2} - %m%n

# A2 - a file appender
# Appender A2 writes to the specified file in txmhome .
log4j.appender.A2=3Dorg.apache.log4j.FileAppender
log4j.appender.A2.File=3Dtmxmltoolkit.log

# Append or Truncate option if the log file exists
log4j.appender.A2.Append=3Dfalse

# Appender A2 uses the PatternLayout.
log4j.appender.A2.layout=3Dorg.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=3D%d [%p] %c{3} - %m%n

# chtest console appender
#log4j.appender.chtestConsole=3Dorg.apache.log4j.ConsoleAppender
#log4j.appender.chtestConsole.layout=3Dorg.apache.log4j.PatternLayout
#log4j.appender.chtestConsole.layout.ConversionPattern=3D%d [%p] =
%-20.30c{2} - %m%n

# chtest file appender
# Appender chtestFile writes to the specified file in txmhome .
#log4j.appender.chtestFile=3Dorg.apache.log4j.FileAppender
#log4j.appender.chtestFile.File=3D${NETE_TXM_ROOT}/QA/chtest/chtest.log
#log4j.appender.chtestFile.Append=3Dfalse
#log4j.appender.chtestFile.layout=3Dorg.apache.log4j.PatternLayout
#log4j.appender.chtestFile.layout.ConversionPattern=3D%d [%p] %c{3} - =
%m%n

#
# CATEGORY section
#
# fomat is:
# log4j.category.YourCategoryName=3D PriorityValue, AppenderName, ..., =
AppenderNameN
# where PriorityValue =3D DEBUG, INFO, WARN, ERROR, FATAL
#
# priorities are ordered as follows: DEBUG < INFO < WARN < ERROR < =
FATAL.=20
# This means, for example, setting a priority of INFO means no DEBUG log =
statements will appear
# setting a priority of ERROR means no DEBUG, INFO, or WARN log =
statements will appear.
#
# AppenderName is a log4j.appender.AppenderName defined above (i.e. A1 =
or A2)

#=20
# root category
# Attach appender A2 to root. Set root priority to INFO
# we explicitly set defaults for root in situations where toolkit add-on =
classes
# may not want to inherit settings from the toolkit category =
'com.netegrity.b2' defined below
#
log4j.rootCategory=3DALL, A1

#
# XML Agent toolkit top-level category
# Set the priority of the tm top-level category
# this setting defines the default log priority setting for all b2b =
categories that
# inherit from this top-level.=20
#log4j.category.org.apache.ws.security=3DDEBUG

------=_NextPart_000_003A_01C3F71A.267A8580
Content-Type: text/java;
	name="TestWSSecurity.java"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="TestWSSecurity.java"

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 =3D CryptoFactory.getInstance();

/*
    private static Log log =3D LogFactory.getLog(TestWSSecurity.class);
    static final String NS =3D "http://www.w3.org/2000/09/xmldsig#";
    static final String soapMsg =3D "<?xml version=3D\"1.0\" =
encoding=3D\"UTF-8\"?>" + "<SOAP-ENV:Envelope =
xmlns:SOAP-ENV=3D\"http://schemas.xmlsoap.org/soap/envelope/\" =
xmlns:xsd=3D\"http://www.w3.org/2001/XMLSchema\" =
xmlns:xsi=3D\"http://www.w3.org/2001/XMLSchema-instance\">" + =
"<SOAP-ENV:Body>" + "<add =
xmlns=3D\"http://ws.apache.org/counter/counter_port_type\">" + "<value =
xmlns=3D\"\">15</value>" + "</add>" + "</SOAP-ENV:Body>\r\n       \r\n" =
+ "</SOAP-ENV:Envelope>";
    static final WSSecurityEngine secEngine =3D new WSSecurityEngine();

    MessageContext msgContext;
    SOAPEnvelope unsignedEnvelope;

    public TestWSSecurity()
    {
    }

    public static void main(String[] args) throws Exception
    {
        TestWSSecurity wsse =3D new TestWSSecurity();
        wsse.setUp();
    }

    protected void setUp() throws Exception {
        AxisClient tmpEngine =3D new AxisClient(new NullProvider());
        msgContext =3D new MessageContext(tmpEngine);
        unsignedEnvelope =3D getSOAPEnvelope();
    }

    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
        InputStream in =3D new ByteArrayInputStream(soapMsg.getBytes());
        Message msg =3D new Message(in);
        msg.setMessageContext(msgContext);
        return msg.getSOAPEnvelope();
    }

    public void testX509Signature() throws Exception {
        SOAPEnvelope envelope =3D null;
        WSSignEnvelope builder =3D new WSSignEnvelope();
        //builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", =
"security");
        builder.setUserInfo("john", "keypass");
        log.info("Before Signing....");
        Document doc =3D unsignedEnvelope.getAsDocument();
        Document signedDoc =3D builder.build(doc, crypto);

        Message signedMsg =3D (Message) =
AxisUtil.toSOAPMessage(signedDoc);
        signedDoc =3D signedMsg.getSOAPEnvelope().getAsDocument();
        log.info("After Signing....");
        verify(signedDoc);
    }

    public void testDoubleX509Signature() throws Exception {
        SOAPEnvelope envelope =3D null;
        WSSignEnvelope builder =3D new WSSignEnvelope();
        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", =
"security");
        // builder.setUserInfo("john", "keypass");
        Document doc =3D unsignedEnvelope.getAsDocument();
        Document signedDoc =3D builder.build(doc, crypto);
        Document signedDoc1 =3D 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=3DD:\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\l=
ib\cryptix32.jar;D:\workspace\BMC\neo410\wss4j\lib\cryptix.jar;D:\workspa=
ce\BMC\neo410\wss4j\lib\cryptix-asn1.jar;D:\workspace\BMC\neo410\wss4j\li=
b\jaxrpc.jar;D:\workspace\BMC\neo410\wss4j\lib\jce-jdk13-121.jar;D:\works=
pace\BMC\neo410\wss4j\lib\junit-3.8.1.jar;D:\workspace\BMC\neo410\wss4j\l=
ib\log4j-1.2.8.jar;D:\workspace\BMC\neo410\wss4j\lib\mailapi-1_3.jar;D:\w=
orkspace\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\n=
eo410\wss4j\lib\xercesImpl.jar;D:\workspace\BMC\neo410\wss4j\lib\xml-apis=
.jar;D:\workspace\BMC\neo410\wss4j\lib\xmlsec.jar;classes;

//-Djavax.net.ssl.keyStore=3Dselfcert.pfx =
-Djavax.net.ssl.keyStoreType=3DPKCS12 =
-Djavax.net.ssl.keyStorePassword=3Dsecurity

------=_NextPart_000_003A_01C3F71A.267A8580
Content-Type: text/properties;
	name="crypto.properties"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="crypto.properties"

org.apache.ws.security.crypto.provider=3Dorg.apache.ws.security.component=
s.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=3Dpkcs12
org.apache.ws.security.crypto.merlin.keystore.password=3Dsecurity
org.apache.ws.security.crypto.merlin.keystore.alias=3D16c73ab6-b892-458f-=
abf5-2f875f74882e
org.apache.ws.security.crypto.merlin.alias.password=3Dsecurity
org.apache.ws.security.crypto.merlin.file=3Dkeys/x509.PFX.MSFT

------=_NextPart_000_003A_01C3F71A.267A8580--



-------------------------------------------------------
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