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 2005/09/10 21:43:06 UTC
svn commit: r280034 - in /webservices/wss4j/trunk/test/wssec:
PackageTests.java PrivilegedAccessor.java TestBase64.java
TestWSSecurity.java TestWSSecurity10.java
Author: werner
Date: Sat Sep 10 12:42:59 2005
New Revision: 280034
URL: http://svn.apache.org/viewcvs?rev=280034&view=rev
Log:
Implment the WSS 1.1 Thumprint key identifier. The unit test.
Added:
webservices/wss4j/trunk/test/wssec/TestBase64.java
Modified:
webservices/wss4j/trunk/test/wssec/PackageTests.java
webservices/wss4j/trunk/test/wssec/PrivilegedAccessor.java
webservices/wss4j/trunk/test/wssec/TestWSSecurity.java
webservices/wss4j/trunk/test/wssec/TestWSSecurity10.java
Modified: webservices/wss4j/trunk/test/wssec/PackageTests.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/wssec/PackageTests.java?rev=280034&r1=280033&r2=280034&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/PackageTests.java (original)
+++ webservices/wss4j/trunk/test/wssec/PackageTests.java Sat Sep 10 12:42:59 2005
@@ -49,7 +49,6 @@
public static Test suite() {
TestSuite suite = new TestSuite();
- // suite.addTestSuite(TestMSFTWebService.class);
suite.addTestSuite(TestWSSecurity.class);
suite.addTestSuite(TestWSSecurity2.class);
suite.addTestSuite(TestWSSecurity3.class);
@@ -62,6 +61,7 @@
suite.addTestSuite(TestWSSecurity11.class);
suite.addTestSuite(TestWSSecurity12.class);
suite.addTestSuite(TestWSSecurity13.class);
+ suite.addTestSuite(TestWSSecurity14.class);
suite.addTestSuite(TestWSSecuritySOAP12.class);
// suite.addTestSuite(TestWSSecurityHooks.class);
suite.addTestSuite(TestWSSecurityST1.class);
Modified: webservices/wss4j/trunk/test/wssec/PrivilegedAccessor.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/wssec/PrivilegedAccessor.java?rev=280034&r1=280033&r2=280034&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/PrivilegedAccessor.java (original)
+++ webservices/wss4j/trunk/test/wssec/PrivilegedAccessor.java Sat Sep 10 12:42:59 2005
@@ -152,4 +152,4 @@
return getMethod(thisClass.getSuperclass(), methodName, classTypes);
}
}
-}
\ No newline at end of file
+}
Added: webservices/wss4j/trunk/test/wssec/TestBase64.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/wssec/TestBase64.java?rev=280034&view=auto
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestBase64.java (added)
+++ webservices/wss4j/trunk/test/wssec/TestBase64.java Sat Sep 10 12:42:59 2005
@@ -0,0 +1,121 @@
+/*
+ * Created on 09.09.2005
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package wssec;
+
+import java.util.Arrays;
+import junit.framework.TestCase;
+import org.apache.ws.security.util.Base64;
+import org.apache.ws.security.WSSecurityException;
+
+public class TestBase64 extends TestCase {
+
+ private byte[] dataBinary = null;
+
+ /*
+ * The following String is the value "This is a test\n" encoded
+ * in Base64
+ */
+ private String thisIsATestEnc = "VGhpcyBpcyBhIHRlc3QK";
+ private String thisIsATestClear = "This is a test\n";
+ private String thisIsATestEnc4group = "VGhp\ncyBp\ncyBh\nIHRl\nc3QK";
+
+ private String encodedBinary;
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(TestBase64.class);
+ }
+
+ public TestBase64(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ dataBinary = new byte[256];
+ for (int i = 0; i < 256; i++) {
+ dataBinary[i] = (byte)i;
+ }
+ }
+
+ /*
+ * Class under test for String encode(byte[])
+ */
+ public void testEncodebyteArray() {
+ String isATestEnc = Base64.encode(thisIsATestClear.getBytes());
+ assertEquals(isATestEnc, thisIsATestEnc);
+
+ encodedBinary = Base64.encode(dataBinary);
+ byte[] outBinary = null;
+ try {
+ outBinary = Base64.decode(encodedBinary);
+ } catch (WSSecurityException ex) {
+
+ }
+ assertTrue(Arrays.equals(outBinary, dataBinary));
+ }
+
+ /*
+ * Class under test for String encode(byte[], int, boolean)
+ */
+ public void testEncodebyteArrayintboolean() {
+ String isATestEnc = Base64.encode(thisIsATestClear.getBytes(), 4, false);
+ assertEquals(isATestEnc, thisIsATestEnc);
+
+ isATestEnc = Base64.encode(thisIsATestClear.getBytes(), 76, false);
+ assertEquals(isATestEnc, thisIsATestEnc);
+
+ isATestEnc = Base64.encode(thisIsATestClear.getBytes(), 4, true);
+ assertEquals(isATestEnc, thisIsATestEnc4group);
+
+ isATestEnc = Base64.encode(thisIsATestClear.getBytes(), 76, true);
+ assertEquals(isATestEnc, thisIsATestEnc);
+
+ encodedBinary = Base64.encode(dataBinary, 4, false);
+ byte[] outBinary = null;
+ try {
+ outBinary = Base64.decode(encodedBinary);
+ } catch (WSSecurityException ex) {
+ }
+ assertTrue(Arrays.equals(outBinary, dataBinary));
+
+ encodedBinary = Base64.encode(dataBinary, 76, false);
+ outBinary = null;
+ try {
+ outBinary = Base64.decode(encodedBinary);
+ } catch (WSSecurityException ex) {
+ }
+ assertTrue(Arrays.equals(outBinary, dataBinary));
+
+ encodedBinary = Base64.encode(dataBinary, 4, true);
+ outBinary = null;
+ try {
+ outBinary = Base64.decode(encodedBinary);
+ } catch (WSSecurityException ex) {
+ }
+ assertTrue(Arrays.equals(outBinary, dataBinary));
+
+ encodedBinary = Base64.encode(dataBinary, 76, true);
+ outBinary = null;
+ try {
+ outBinary = Base64.decode(encodedBinary);
+ } catch (WSSecurityException ex) {
+ }
+ assertTrue(Arrays.equals(outBinary, dataBinary));
+ }
+
+ public void testDecode() {
+ byte[] out = null;
+ byte[] outBinary = null;
+ try {
+ out = Base64.decode(thisIsATestEnc);
+ } catch (WSSecurityException ex) {
+
+ }
+ assertEquals(new String(out), thisIsATestClear);
+ }
+
+}
Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurity.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/wssec/TestWSSecurity.java?rev=280034&r1=280033&r2=280034&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurity.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurity.java Sat Sep 10 12:42:59 2005
@@ -114,7 +114,7 @@
/**
* Test that signs and verifies a WS-Security envelope.
- * The test uses the IssuerSerial key identifier type.
+ * The test uses the ThumbprintSHA1 key identifier type.
* <p/>
*
* @throws java.lang.Exception Thrown when there is any problem in signing or verification
@@ -146,39 +146,10 @@
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) SOAPUtil.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.
- * The test uses the IssuerSerial key identifier type.
+ * The test uses the ThumbprintSHA1 key identifier type.
* <p/>
*
* @throws java.lang.Exception Thrown when there is any problem in signing or verification
Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurity10.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/wssec/TestWSSecurity10.java?rev=280034&r1=280033&r2=280034&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurity10.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurity10.java Sat Sep 10 12:42:59 2005
@@ -252,4 +252,4 @@
}
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org