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 we...@apache.org on 2006/01/25 15:35:27 UTC
svn commit: r372226 - in /webservices/wss4j/trunk/test/wssec:
TestWSSecurity.java TestWSSecurityNew.java TestWSSecurityNew2.java
TestWSSecurityNew9.java
Author: werner
Date: Wed Jan 25 06:35:23 2006
New Revision: 372226
URL: http://svn.apache.org/viewcvs?rev=372226&view=rev
Log:
Refactor the WSS4J message classes to allow for more flexible control. Testcases.
Added:
webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java
webservices/wss4j/trunk/test/wssec/TestWSSecurityNew9.java
Modified:
webservices/wss4j/trunk/test/wssec/TestWSSecurity.java
webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java
Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurity.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/wssec/TestWSSecurity.java?rev=372226&r1=372225&r2=372226&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurity.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurity.java Wed Jan 25 06:35:23 2006
@@ -114,7 +114,7 @@
/**
* Test that signs and verifies a WS-Security envelope.
- * The test uses the ThumbprintSHA1 key identifier type.
+ * The test uses the IssuerSerial key identifier type.
* <p/>
*
* @throws java.lang.Exception Thrown when there is any problem in signing or verification
Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java?rev=372226&r1=372225&r2=372226&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java Wed Jan 25 06:35:23 2006
@@ -33,6 +33,7 @@
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.components.crypto.CryptoFactory;
import org.apache.ws.security.message.WSSecSignature;
+import org.apache.ws.security.message.WSSecHeader;
import org.w3c.dom.Document;
import java.io.ByteArrayInputStream;
@@ -121,14 +122,15 @@
* @throws java.lang.Exception Thrown when there is any problem in signing or verification
*/
public void testX509SignatureIS() throws Exception {
- SOAPEnvelope envelope = null;
WSSecSignature builder = new WSSecSignature();
builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
// builder.setUserInfo("john", "keypass");
log.info("Before Signing IS....");
Document doc = unsignedEnvelope.getAsDocument();
- Document signedDoc = builder.build(doc, crypto);
+ WSSecHeader secHeader = new WSSecHeader();
+ secHeader.insertSecurityHeader(doc);
+ Document signedDoc = builder.build(doc, crypto, secHeader);
/*
* convert the resulting document into a message first. The toSOAPMessage()
@@ -150,19 +152,19 @@
/**
* Test that signs (twice) and verifies a WS-Security envelope.
- * The test uses the ThumbprintSHA1 key identifier type.
* <p/>
*
* @throws java.lang.Exception Thrown when there is any problem in signing or verification
*/
public void testDoubleX509SignatureIS() throws Exception {
- SOAPEnvelope envelope = null;
WSSecSignature builder = new WSSecSignature();
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);
+ WSSecHeader secHeader = new WSSecHeader();
+ secHeader.insertSecurityHeader(doc);
+ Document signedDoc = builder.build(doc, crypto, secHeader);
+ Document signedDoc1 = builder.build(signedDoc, crypto, secHeader);
verify(signedDoc1);
}
Added: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java?rev=372226&view=auto
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java (added)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java Wed Jan 25 06:35:23 2006
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package wssec;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+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.security.WSConstants;
+import org.apache.ws.security.WSPasswordCallback;
+import org.apache.ws.security.WSSecurityEngine;
+import org.apache.ws.security.WSEncryptionPart;
+import org.apache.ws.security.components.crypto.Crypto;
+import org.apache.ws.security.components.crypto.CryptoFactory;
+import org.apache.ws.security.message.WSSecEncrypt;
+import org.apache.ws.security.message.WSSecHeader;
+import org.w3c.dom.Document;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+
+import java.util.Vector;
+
+/**
+ * WS-Security Test Case
+ * <p/>
+ *
+ * @author Davanum Srinivas (dims@yahoo.com)
+ */
+public class TestWSSecurityNew2 extends TestCase implements CallbackHandler {
+ private static Log log = LogFactory.getLog(TestWSSecurityNew2.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;
+
+ /**
+ * TestWSSecurity constructor
+ * <p/>
+ *
+ * @param name name of the test
+ */
+ public TestWSSecurityNew2(String name) {
+ super(name);
+ }
+
+ /**
+ * JUnit suite
+ * <p/>
+ *
+ * @return a junit test suite
+ */
+ public static Test suite() {
+ return new TestSuite(TestWSSecurityNew2.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 encrypt and decrypt a WS-Security envelope.
+ * This test uses the RSA_15 alogrithm to transport (wrap) the symmetric
+ * key.
+ * <p/>
+ *
+ * @throws Exception Thrown when there is any problem in signing or verification
+ */
+ public void testEncryptionDecryptionRSA15() throws Exception {
+ SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
+ SOAPEnvelope envelope = null;
+ WSSecEncrypt builder = new WSSecEncrypt();
+ builder.setUserInfo("wss4jcert");
+ builder.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
+ builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+ Document doc = unsignedEnvelope.getAsDocument();
+ WSSecHeader secHeader = new WSSecHeader();
+ secHeader.insertSecurityHeader(doc);
+ log.info("Before Encryption Triple DES....");
+ Document encryptedDoc = builder.build(doc, crypto, secHeader);
+ log.info("After Encryption Triple DES....");
+
+ /*
+ * convert the resulting document into a message first. The toSOAPMessage()
+ * method performs the necessary c14n call to properly set up the signed
+ * document and convert it into a SOAP message. Check that the contents can't
+ * be read (cheching if we can find a specific substring). After that we extract it
+ * as a document again for further processing.
+ */
+
+ Message encryptedMsg = (Message) SOAPUtil.toSOAPMessage(encryptedDoc);
+ if (log.isDebugEnabled()) {
+ log.debug("Encrypted message, RSA-15 keytransport, 3DES:");
+ XMLUtils.PrettyElementToWriter(encryptedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
+ }
+ String encryptedString = encryptedMsg.getSOAPPartAsString();
+ assertTrue(encryptedString.indexOf("LogTestService2") == -1 ? true : false);
+ encryptedDoc = encryptedMsg.getSOAPEnvelope().getAsDocument();
+ verify(encryptedDoc);
+
+ /*
+ * second run, same Junit set up, but change encryption method,
+ * key identification, encryption mode (Element now), and data to encrypt.
+ * This tests if several runs of different algorithms on same builder/cipher
+ * setup are ok.
+ */
+ message = getSOAPMessage(); // create fresh message envrionment
+ builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+ builder.setSymmetricEncAlgorithm(WSConstants.AES_128);
+ Vector parts = new Vector();
+ WSEncryptionPart encP =
+ new WSEncryptionPart("testMethod", "uri:LogTestService2", "Element");
+ parts.add(encP);
+ builder.setParts(parts);
+ unsignedEnvelope = message.getSOAPEnvelope();
+ doc = unsignedEnvelope.getAsDocument();
+ secHeader = new WSSecHeader();
+ secHeader.insertSecurityHeader(doc);
+ log.info("Before Encryption AES 128/RSA-15....");
+ encryptedDoc = builder.build(doc, crypto, secHeader);
+ log.info("After Encryption AES 128/RSA-15....");
+ encryptedMsg = (Message) SOAPUtil.toSOAPMessage(encryptedDoc);
+ if (log.isDebugEnabled()) {
+ log.debug("Encrypted message, RSA-15 keytransport, AES 128:");
+ XMLUtils.PrettyElementToWriter(encryptedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
+ }
+ encryptedString = encryptedMsg.getSOAPPartAsString();
+ assertTrue(encryptedString.indexOf("LogTestService2") == -1 ? true : false);
+ encryptedDoc = encryptedMsg.getSOAPEnvelope().getAsDocument();
+ verify(encryptedDoc);
+ }
+
+ /**
+ * Test that encrypt and decrypt a WS-Security envelope.
+ * This test uses the RSA OAEP alogrithm to transport (wrap) the symmetric
+ * key.
+ * <p/>
+ *
+ * @throws Exception Thrown when there is any problem in signing or verification
+ */
+ public void testEncryptionDecryptionOAEP() throws Exception {
+ SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
+ SOAPEnvelope envelope = null;
+ WSSecEncrypt builder = new WSSecEncrypt();
+ builder.setUserInfo("wss4jcert");
+ builder.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
+ builder.setKeyEnc(WSConstants.KEYTRANSPORT_RSAOEP);
+ Document doc = unsignedEnvelope.getAsDocument();
+ WSSecHeader secHeader = new WSSecHeader();
+ secHeader.insertSecurityHeader(doc);
+ log.info("Before Encryption Triple DES/RSA-OAEP....");
+ Document encryptedDoc = builder.build(doc, crypto, secHeader);
+ log.info("After Encryption Triple DES/RSA-OAEP....");
+
+ Message encryptedMsg = (Message) SOAPUtil.toSOAPMessage(encryptedDoc);
+ if (log.isDebugEnabled()) {
+ log.debug("Encrypted message, RSA-OAEP keytransport, 3DES:");
+ XMLUtils.PrettyElementToWriter(encryptedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
+ }
+ String encryptedString = encryptedMsg.getSOAPPartAsString();
+ assertTrue(encryptedString.indexOf("LogTestService2") == -1 ? true : false);
+ encryptedDoc = encryptedMsg.getSOAPEnvelope().getAsDocument();
+ verify(encryptedDoc);
+
+ }
+
+ /**
+ * Verifies the soap envelope
+ * <p/>
+ *
+ * @param envelope
+ * @throws Exception Thrown when there is a problem in verification
+ */
+ private void verify(Document doc) throws Exception {
+ secEngine.processSecurityHeader(doc, null, this, crypto);
+ SOAPUtil.updateSOAPMessage(doc, message);
+ String decryptedString = message.getSOAPPartAsString();
+ assertTrue(decryptedString.indexOf("LogTestService2") > 0 ? true : false);
+ }
+
+ 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");
+ }
+ }
+ }
+}
Added: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew9.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew9.java?rev=372226&view=auto
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew9.java (added)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew9.java Wed Jan 25 06:35:23 2006
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package wssec;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.axis.Message;
+import org.apache.axis.MessageContext;
+import org.apache.axis.SOAPPart;
+import org.apache.axis.client.AxisClient;
+import org.apache.axis.configuration.NullProvider;
+import org.apache.axis.message.SOAPEnvelope;
+import org.apache.axis.utils.XMLUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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.WSSecEncrypt;
+import org.apache.ws.security.message.WSSecHeader;
+import org.apache.ws.security.message.WSSecSignature;
+import org.w3c.dom.Document;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.ByteArrayInputStream;
+// import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+
+/**
+ * WS-Security Test Case
+ * <p/>
+ *
+ * @author Davanum Srinivas (dims@yahoo.com)
+ */
+public class TestWSSecurityNew9 extends TestCase implements CallbackHandler {
+ private static Log log = LogFactory.getLog(TestWSSecurityNew9.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=\"http://axis/service/security/test9/LogTestService9\"></ns1:testMethod>" +
+ " </soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ static final WSSecurityEngine secEngine = new WSSecurityEngine();
+ static final Crypto crypto = CryptoFactory.getInstance();
+ MessageContext msgContext;
+ Message message;
+
+ private static final byte[] key = {
+ (byte)0x31, (byte)0xfd,
+ (byte)0xcb, (byte)0xda,
+ (byte)0xfb, (byte)0xcd,
+ (byte)0x6b, (byte)0xa8,
+ (byte)0xe6, (byte)0x19,
+ (byte)0xa7, (byte)0xbf,
+ (byte)0x51, (byte)0xf7,
+ (byte)0xc7, (byte)0x3e,
+ (byte)0x80, (byte)0xae,
+ (byte)0x98, (byte)0x51,
+ (byte)0xc8, (byte)0x51,
+ (byte)0x34, (byte)0x04,
+ };
+
+
+ /**
+ * TestWSSecurity constructor
+ * <p/>
+ *
+ * @param name name of the test
+ */
+ public TestWSSecurityNew9(String name) {
+ super(name);
+ }
+
+ /**
+ * JUnit suite
+ * <p/>
+ *
+ * @return a junit test suite
+ */
+ public static Test suite() {
+ return new TestSuite(TestWSSecurityNew9.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 encrypts and signs a WS-Security envelope, then performs
+ * verification and decryption.
+ * <p/>
+ *
+ * @throws Exception Thrown when there is any problem in signing, encryption,
+ * decryption, or verification
+ */
+ public void testSigningEncryptionEmbedded() throws Exception {
+ SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
+ SOAPEnvelope envelope = null;
+ WSSecEncrypt encrypt = new WSSecEncrypt();
+ WSSecSignature sign = new WSSecSignature();
+
+ encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
+ encrypt.setKeyIdentifierType(WSConstants.EMBEDDED_KEYNAME);
+ encrypt.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+ encrypt.setKey(key);
+
+ sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+ log.info("Before Encryption....");
+ Document doc = unsignedEnvelope.getAsDocument();
+ WSSecHeader secHeader = new WSSecHeader();
+ secHeader.insertSecurityHeader(doc);
+ Document signedDoc = sign.build(doc, crypto, secHeader);
+ Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);
+ /*
+ * convert the resulting document into a message first. The toSOAPMessage()
+ * mehtod 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) SOAPUtil.toSOAPMessage(encryptedSignedDoc);
+ if (log.isDebugEnabled()) {
+ log.debug("Encrypted message, RSA-OAEP keytransport, 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....");
+ verify(encryptedSignedDoc1);
+ }
+
+ /**
+ * Verifies the soap envelope
+ * <p/>
+ *
+ * @param doc
+ * @throws Exception Thrown when there is a problem in verification
+ */
+ private void verify(Document doc) throws Exception {
+ secEngine.processSecurityHeader(doc, null, this, crypto);
+ SOAPUtil.updateSOAPMessage(doc, message);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
+ */
+ 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.
+ */
+ if (pc.getUsage() == WSPasswordCallback.KEY_NAME) {
+ pc.setKey(key);
+ }
+ else {
+ pc.setPassword("security");
+ }
+ } else {
+ throw new UnsupportedCallbackException(
+ callbacks[i],
+ "Unrecognized Callback");
+ }
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org