Hi,

The problem is in this line :
encrypt.setSymmetricEncAlgorithm("WSConstants.TRIPLE_DES");

Please change it to :
encrypt.setSymmetricEncAlgorithm(org.apache.ws.security.WSConstants.TRIPLE_DES);

Also you can change :
encrypt.setUserInfo("wss4jcert", "security");
to
encrypt.setUserInfo("wss4jcert");
since for encryption you just need to have the public key. We do not
require the key password to retrieve the public key.

Thanks,
Ruchith

On 2/24/07, Lule Chen <[EMAIL PROTECTED]> wrote:



Hi, dims:

I adopted the code in TestWSSecurityNew15.java that encrypts the soap body,
but I got the null pointer exception as the following:

Exception in thread "main" java.lang.NullPointerException
        at
org.apache.ws.security.message.WSSecEncrypt.prepare(WSSecEncrypt.java:197)
        at
com.nortel.cdma.axis.Client.NEServiceClient.main(NEServiceClient.java:240)

I looked at the line of code in WSSecEncrypt.java, it seems failed at

                this.symmetricKey = keyGen.generateKey();

I suspect that keyGen is null. My code snips are as the following:

    static final WSSecurityEngine secEngine = new WSSecurityEngine();
    static final Crypto crypto =
CryptoFactory.getInstance("cryptoSKI.properties");

...

        SOAPEnvelope env = new SOAPEnvelope(new
ByteArrayInputStream(byteBuf));

        WSSecEncrypt encrypt = new WSSecEncrypt();
        encrypt.setUserInfo("wss4jcert", "security");

encrypt.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);

encrypt.setSymmetricEncAlgorithm("WSConstants.TRIPLE_DES");

        Document doc = env.getAsDocument();

        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);
        encrypt.prepare(doc, crypto);

...

Do you have any idea whats wrong of my code?

Thanks,


Lule




--
www.ruchith.org
www.wso2.org

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to