Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java (revision 0)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java (revision 0)
@@ -0,0 +1,219 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.spec;
+
+import java.math.BigInteger;
+import java.security.spec.ECFieldF2m;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for ECFieldF2m class fields and methods.
+ *
+ */
+public class ECFieldF2m_ImplTest extends TestCase {
+
+ /**
+ * Support class for this test.
+ * Incapsulates ECFieldF2m testing
+ * domain parameters.
+ *
+ */
+ private static final class ECFieldF2mDomainParams {
+
+ /**
+ * NPE reference object of class NullPointerException.
+ * NullPointerException must be thrown by ECFieldF2m
+ * ctors in some circumstances
+ */
+ static final NullPointerException NPE = new NullPointerException();
+ /**
+ * IArgE reference object of class IllegalArgumentException.
+ * IllegalArgumentException must be thrown by ECFieldF2m
+ * ctors in some circumstances
+ */
+ static final IllegalArgumentException IArgE = new IllegalArgumentException();
+
+ /**
+ * The m parameter for ECFieldF2m
+ * ctor for the current test.
+ */
+ final int m;
+ /**
+ * The rp parameter for ECFieldF2m
+ * ctor for the current test.
+ */
+ final BigInteger rp;
+ /**
+ * The ks parameter for ECFieldF2m
+ * ctor for the current test.
+ */
+ final int[] ks;
+
+
+ /**
+ * Exception expected with this parameters set or null
+ * if no exception expected.
+ */
+ final Exception x;
+
+ /**
+ * Constructs ECFieldF2mDomainParams
+ *
+ * @param m
+ * @param rp
+ * @param ks
+ * @param expectedException
+ */
+ ECFieldF2mDomainParams(final int m,
+ final BigInteger rp,
+ final int[] ks,
+ final Exception expectedException) {
+ this.m = m;
+ this.rp = rp;
+ this.ks = ks;
+ this.x = expectedException;
+ }
+ }
+
+
+ /**
+ * Set of parameters used for ECFieldF2m(int, BigInteger)
+ * constructor tests.
+ */
+ private final ECFieldF2mDomainParams[] intBigIntegerCtorTestParameters =
+ new ECFieldF2mDomainParams[] {
+ // set 0: valid m and rp - trinomial basis params
+ new ECFieldF2mDomainParams(
+ 1999,
+ BigInteger.valueOf(0L).setBit(0).setBit(367).setBit(1999),
+ null,
+ null),
+ // set 1: valid m and rp - pentanomial basis params
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(981).setBit(2000),
+ null,
+ null),
+ // set 2: valid m, invalid (null) rp
+ new ECFieldF2mDomainParams(
+ 1963,
+ (BigInteger)null,
+ null,
+ ECFieldF2mDomainParams.NPE),
+ // set 3: valid m, invalid rp - bit 0 not set
+ new ECFieldF2mDomainParams(
+ 1999,
+ BigInteger.valueOf(0L).setBit(1).setBit(367).setBit(1999),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 4: valid m, invalid rp - bit m not set
+ new ECFieldF2mDomainParams(
+ 1999,
+ BigInteger.valueOf(0L).setBit(0).setBit(367).setBit(1998),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 5: valid m, invalid rp - bit k improperly set
+ new ECFieldF2mDomainParams(
+ 1999,
+ BigInteger.valueOf(0L).setBit(0).setBit(2367).setBit(1999),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 6: valid m, invalid rp - k1 k2 k3
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(2001).setBit(2002).setBit(2003).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 7: valid m, invalid rp - number of bits set
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 8: valid m, invalid rp - number of bits set
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 9: valid m, invalid rp - number of bits set
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).
+ setBit(981).setBit(985).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 10: valid m, invalid rp
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 11: invalid m
+ new ECFieldF2mDomainParams(
+ -2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).
+ setBit(981).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ };
+
+ /**
+ * Tests for constructor ECFieldF2m(int, BigInteger)
+ *
+ * Assertion: constructs new ECFieldF2m object
+ * using valid parameters m and rp. rp represents trinomial basis.
+ *
+ * Assertion: constructs new ECFieldF2m object
+ * using valid parameters m and rp. rp represents pentanomial basis.
+ *
+ * Assertion: IllegalArgumentException if m is not positive.
+ *
+ * Assertion: NullPointerException if rp is null.
+ *
+ * Assertion: IllegalArgumentException if rp is invalid.
+ */
+ public final void testECFieldF2mintBigInteger() {
+ for(int i=0; iECParameterSpec class fields and methods.
*
*/
-public class ECParameterSpecTest extends TestCase {
+public class ECParameterSpec_ImplTest extends TestCase {
- /**
- * Constructor for ECParameterSpecTest.
- * @param name
- */
- public ECParameterSpecTest(String name) {
- super(name);
- }
-
//
// Tests
//
Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java (revision 0)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java (working copy)
@@ -19,27 +19,23 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.ECFieldFp;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.ECPrivateKeySpec;
+import java.security.spec.EllipticCurve;
import junit.framework.TestCase;
-
/**
* Tests for ECPrivateKeySpec class fields and methods.
*
*/
-public class ECPrivateKeySpecTest extends TestCase {
+public class ECPrivateKeySpec_ImplTest extends TestCase {
- /**
- * Constructor for ECPrivateKeySpecTest.
- * @param name
- */
- public ECPrivateKeySpecTest(String name) {
- super(name);
- }
-
//
// Tests
//
Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java (revision 0)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java (working copy)
@@ -19,27 +19,23 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.ECFieldFp;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.ECPublicKeySpec;
+import java.security.spec.EllipticCurve;
import junit.framework.TestCase;
-
/**
* Tests for ECPublicKeySpec class fields and methods.
*
*/
-public class ECPublicKeySpecTest extends TestCase {
+public class ECPublicKeySpec_ImplTest extends TestCase {
- /**
- * Constructor for ECPublicKeySpecTest.
- * @param name
- */
- public ECPublicKeySpecTest(String name) {
- super(name);
- }
-
//
// Tests
//
Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java (revision 0)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java (revision 0)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.spec;
+
+import java.math.BigInteger;
+import java.security.spec.ECFieldF2m;
+import java.security.spec.ECFieldFp;
+import java.security.spec.EllipticCurve;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for EllipticCurve class fields and methods.
+ *
+ */
+public class EllipticCurve_ImplTest extends TestCase {
+
+ /**
+ * Test #2 for equals(Object other) method
+ * Assertion: return false if this and other objects are not equal
+ * Test preconditions: see test comments
+ * Expected: all objects in this test must be NOT equal
+ */
+ public final void testEqualsObject02() {
+ // test case 1: must not be equal to null
+ EllipticCurve c2=null, c1 =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.ONE,
+ BigInteger.valueOf(19L));
+ assertFalse(c1.equals(c2));
+
+ // test case 2: not equal objects - field
+ c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.ONE,
+ BigInteger.valueOf(19L));
+ c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(31L)),
+ BigInteger.valueOf(1L),
+ BigInteger.valueOf(19L));
+ assertFalse(c1.equals(c2) || c2.equals(c1));
+
+ // test case 3: not equal objects - a
+ c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.ONE,
+ BigInteger.valueOf(19L));
+ c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(19L));
+ assertFalse(c1.equals(c2) || c2.equals(c1));
+
+ // test case 4: not equal objects - b
+ c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.ONE,
+ BigInteger.valueOf(19L));
+ c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.ONE,
+ BigInteger.valueOf(17L));
+ assertFalse(c1.equals(c2) || c2.equals(c1));
+
+ // test case 5: not equal objects - both seed not null
+ c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.ONE,
+ BigInteger.valueOf(19L),
+ new byte[24]);
+ c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.valueOf(1L),
+ BigInteger.valueOf(19L),
+ new byte[25]);
+ assertFalse(c1.equals(c2) || c2.equals(c1));
+
+ // test case 6: not equal objects - one seed is null
+ c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.ONE,
+ BigInteger.valueOf(19L),
+ null);
+ c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.valueOf(1L),
+ BigInteger.valueOf(19L),
+ new byte[24]);
+ assertFalse(c1.equals(c2) || c2.equals(c1));
+
+ // test case 7: not equal objects - field class
+ c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+ BigInteger.ONE,
+ BigInteger.valueOf(19L),
+ new byte[24]);
+ c2 = new EllipticCurve(new ECFieldF2m(5),
+ BigInteger.ONE,
+ BigInteger.valueOf(19L),
+ new byte[24]);
+ assertFalse(c1.equals(c2) || c2.equals(c1));
+ }
+}
Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSource_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSource_ImplTest.java (revision 415258)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSource_ImplTest.java (working copy)
@@ -206,5 +206,17 @@
TestCertUtils.uninstall_test_x509_factory();
}
}
+
+ /**
+ * @tests java.security.CodeSource#toString()
+ */
+ public void test_toString() throws Exception {
+ // Test for method java.lang.String java.security.CodeSource.toString()
+ CodeSource cs = new CodeSource(new java.net.URL("file:///test"),
+ (Certificate[]) null);
+ assertEquals("toString did not return expected value.",
+ "CodeSource, url=file:/test, ", cs.toString());
+ }
+
}
Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java (revision 0)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java (revision 0)
@@ -0,0 +1,286 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.cert;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertPathParameters;
+import java.security.cert.CertStore;
+import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.PKIXCertPathChecker;
+import java.security.cert.PKIXParameters;
+import java.security.cert.X509CertSelector;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for PKIXParameters fields and methods
+ *
+ */
+public class PKIXParameters_ImplTest extends TestCase {
+
+ /**
+ * Test #1 for PKIXParameters(KeyStore) constructor
+ * Assertion: Creates an instance of PKIXParameters
+ * that populates the set of most-trusted CAs from the trusted
+ * certificate entries contained in the specified KeyStore
+ * @throws InvalidAlgorithmParameterException
+ * @throws KeyStoreException
+ */
+ public final void testPKIXParametersKeyStore01() throws Exception {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ // use valid parameter - KeyStore containing
+ // only trusted X.509 certificates
+ CertPathParameters cpp = new PKIXParameters(ks);
+ assertTrue(cpp instanceof PKIXParameters);
+ }
+
+ /**
+ * Test #2 for PKIXParameters(KeyStore) constructor
+ * Assertion: Only keystore entries that contain trusted
+ * X509Certificates are considered; all other
+ * certificate types are ignored
+ * @throws InvalidAlgorithmParameterException
+ * @throws KeyStoreException
+ */
+ public final void testPKIXParametersKeyStore02() throws Exception {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ // use valid parameter - KeyStore containing
+ // both trusted and untrusted X.509 certificates
+ PKIXParameters cpp = new PKIXParameters(ks);
+ assertEquals("size", 1, cpp.getTrustAnchors().size());
+ }
+
+ /**
+ * Test #4 for PKIXParameters(KeyStore) constructor
+ * Assertion: KeyStoreException -
+ * if the keystore has not been initialized
+ */
+ public final void testPKIXParametersKeyStore04() throws Exception {
+ KeyStore ks = TestUtils.getKeyStore(false, 0);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ try {
+ // pass not initialized KeyStore
+ new PKIXParameters(ks);
+ fail("KeyStoreException expected");
+ } catch (KeyStoreException e) {
+ }
+ }
+
+ /**
+ * Test #5 for PKIXParameters(KeyStore) constructor
+ * Assertion: InvalidAlgorithmParameterException -
+ * if the keystore does not contain at least one
+ * trusted certificate entry
+ */
+ public final void testPKIXParametersKeyStore05() throws Exception {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ try {
+ // pass KeyStore that does not contain trusted certificates
+ new PKIXParameters(ks);
+ fail("InvalidAlgorithmParameterException expected");
+ } catch (InvalidAlgorithmParameterException e) {
+ }
+ }
+
+ /**
+ * Test #5 for setTrustAnchors(Set) method
+ * Assertion: Set is copied to protect against
+ * subsequent modifications
+ * @throws InvalidAlgorithmParameterException
+ * @throws KeyStoreException
+ */
+ public final void testSetTrustAnchors05() throws Exception {
+ // use several trusted certs in this test
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ PKIXParameters p = new PKIXParameters(ks);
+ // prepare new Set
+ HashSet newSet = new HashSet(p.getTrustAnchors());
+ HashSet newSetCopy = (HashSet)newSet.clone();
+ // set new Set
+ p.setTrustAnchors(newSetCopy);
+ // modify set - remove one element
+ assertTrue("modified", newSetCopy.remove(newSetCopy.iterator().next()));
+ // check that set maintained internally has
+ // not been changed by the above modification
+ assertEquals("isCopied", newSet, p.getTrustAnchors());
+ }
+
+ /**
+ * Test #1 for clone() method
+ * Assertion: Makes a copy of this PKIXParameters object
+ * @throws KeyStoreException
+ * @throws InvalidAlgorithmParameterException
+ * @throws NoSuchAlgorithmException
+ */
+ public final void testClone01() throws Exception {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ PKIXParameters p1 = new PKIXParameters(ks);
+ // set to some non-default values
+ p1.setPolicyQualifiersRejected(false);
+ p1.setAnyPolicyInhibited(true);
+ p1.setExplicitPolicyRequired(true);
+ p1.setPolicyMappingInhibited(true);
+ p1.setRevocationEnabled(false);
+
+ String sigProviderName = "Some Provider";
+ p1.setSigProvider(sigProviderName);
+
+ X509CertSelector x509cs = new X509CertSelector();
+ p1.setTargetCertConstraints(x509cs);
+
+ p1.setCertStores(TestUtils.getCollectionCertStoresList());
+
+ PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
+ List l = new ArrayList();
+ assertTrue("addedOk", l.add(cpc));
+ p1.setCertPathCheckers(l);
+
+ p1.setDate(new Date(555L));
+
+ Set s = new HashSet();
+ s.add("1.2.3.4.5.6.7");
+ s.add("1.2.3.4.5.6.8");
+ p1.setInitialPolicies(s);
+
+ // TrustAnchors already set
+
+ PKIXParameters p2 = (PKIXParameters)p1.clone();
+
+ // check that objects match
+ assertEquals("check1", p1.getPolicyQualifiersRejected(),
+ p2.getPolicyQualifiersRejected());
+ assertEquals("check2", p1.isAnyPolicyInhibited(),
+ p2.isAnyPolicyInhibited());
+ assertEquals("check3", p1.isExplicitPolicyRequired(),
+ p2.isExplicitPolicyRequired());
+ assertEquals("check4", p1.isPolicyMappingInhibited(),
+ p2.isPolicyMappingInhibited());
+ assertEquals("check5", p1.isRevocationEnabled(),
+ p2.isRevocationEnabled());
+ assertEquals("check6", p1.getSigProvider(), p2.getSigProvider());
+
+ // just check that not null
+ assertNotNull("check7", p2.getTargetCertConstraints());
+
+ assertEquals("check8", p1.getCertStores(), p2.getCertStores());
+
+ // just check that not empty
+ assertFalse("check9", p2.getCertPathCheckers().isEmpty());
+
+ assertEquals("check10", p1.getDate(), p2.getDate());
+ assertEquals("check11", p1.getInitialPolicies(),
+ p2.getInitialPolicies());
+ assertEquals("check12", p1.getTrustAnchors(), p2.getTrustAnchors());
+ }
+
+ /**
+ * Test #2 for clone() method
+ * Assertion: Changes to the copy will not affect
+ * the original and vice versa
+ * @throws KeyStoreException
+ * @throws InvalidAlgorithmParameterException
+ * @throws NoSuchAlgorithmException
+ */
+ public final void testClone02() throws Exception {
+ PKIXParameters[] p = new PKIXParameters[2];
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ for (int i = 0; itoString() method
+ * Assertion: Returns a formatted string describing the parameters
+ * @throws InvalidAlgorithmParameterException
+ * @throws KeyStoreException
+ */
+ public final void testToString() throws Exception {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ PKIXParameters p = new PKIXParameters(ks);
+ assertNotNull(p.toString());
+ }
+
+}
Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java (revision 0)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java (revision 0)
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.cert;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidParameterException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.PKIXParameters;
+import java.security.cert.X509CertSelector;
+
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for PKIXBuilderParameters fields and methods
+ *
+ */
+public class PKIXBuilderParameters_ImplTest extends TestCase {
+ private static final int DEFAULT_MAX_PATH_LEN = 5;
+
+ /**
+ * Test #1 for PKIXBuilderParameters(KeyStore, CertSelector)
+ * constructor
+ * Assertion: creates an instance of PKIXBuilderParameters
+ * @throws InvalidAlgorithmParameterException
+ * @throws KeyStoreException
+ */
+ public final void testPKIXBuilderParametersKeyStoreCertSelector01()
+ throws KeyStoreException,
+ InvalidAlgorithmParameterException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+ // both parameters are valid and non-null
+ PKIXParameters p =
+ new PKIXBuilderParameters(ks, new X509CertSelector());
+ assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
+ assertNotNull("certSelector", p.getTargetCertConstraints());
+ }
+
+ /**
+ * Test #2 for PKIXBuilderParameters(KeyStore, CertSelector)
+ * constructor
+ * Assertion: creates an instance of PKIXBuilderParameters
+ * @throws InvalidAlgorithmParameterException
+ * @throws KeyStoreException
+ */
+ public final void testPKIXBuilderParametersKeyStoreCertSelector02()
+ throws KeyStoreException,
+ InvalidAlgorithmParameterException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+ // both parameters are valid but CertSelector is null
+ PKIXParameters p =
+ new PKIXBuilderParameters(ks, null);
+ assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
+ assertNull("certSelector", p.getTargetCertConstraints());
+ }
+
+ /**
+ * Test #3 for PKIXBuilderParameters(KeyStore, CertSelector)
+ * constructor
+ * Assertion: Only keystore entries that contain trusted
+ * X509Certificates are considered; all other
+ * certificate types are ignored
+ * @throws InvalidAlgorithmParameterException
+ * @throws KeyStoreException
+ */
+ public final void testPKIXBuilderParametersKeyStoreCertSelector03()
+ throws KeyStoreException,
+ InvalidAlgorithmParameterException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+ // both parameters are valid but CertSelector is null
+ PKIXParameters p =
+ new PKIXBuilderParameters(ks, null);
+ assertTrue("instanceof", p instanceof PKIXBuilderParameters);
+ assertEquals("size", 1, p.getTrustAnchors().size());
+ }
+
+ /**
+ * Test #5 for PKIXBuilderParameters(KeyStore, CertSelector)
+ * constructor
+ * Assertion: KeyStoreException -
+ * if the keystore has not been initialized
+ */
+ public final void testPKIXBuilderParametersKeyStoreCertSelector05() throws Exception {
+ KeyStore ks = TestUtils.getKeyStore(false, 0);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ try {
+ // pass not initialized KeyStore
+ new PKIXBuilderParameters(ks, null);
+ fail("KeyStoreException expected");
+ } catch (KeyStoreException e) {
+ }
+ }
+
+ /**
+ * Test #6 for PKIXBuilderParameters(KeyStore, CertSelector)
+ * constructor
+ * Assertion: InvalidAlgorithmParameterException -
+ * if the keystore does not contain at least one
+ * trusted certificate entry
+ */
+ public final void testPKIXBuilderParametersKeyStoreCertSelector06() throws Exception {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ return;
+ }
+
+ try {
+ // pass KeyStore that does not contain trusted certificates
+ new PKIXBuilderParameters(ks, null);
+ fail("InvalidAlgorithmParameterException expected");
+ } catch (InvalidAlgorithmParameterException e) {
+ }
+ }
+
+ /**
+ * Test for getMaxPathLength() method
+ * Assertion: The default maximum path length, if not specified, is 5
+ * @throws KeyStoreException
+ * @throws InvalidAlgorithmParameterException
+ */
+ public final void testGetMaxPathLength01()
+ throws KeyStoreException,
+ InvalidAlgorithmParameterException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+ PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
+ assertEquals(DEFAULT_MAX_PATH_LEN, p.getMaxPathLength());
+ }
+
+ /**
+ * Test #1 for setMaxPathLength(int) method
+ * Assertion: sets the maximum number of non-self-signed certificates
+ * in the cert path
+ * @throws KeyStoreException
+ * @throws InvalidAlgorithmParameterException
+ */
+ public final void testSetMaxPathLength01()
+ throws KeyStoreException,
+ InvalidAlgorithmParameterException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+ // all these VALID maxPathLength values must be
+ // set (and get) without exceptions
+ int[] testPathLength = new int[] {-1, 0, 1, 999, Integer.MAX_VALUE};
+ for (int i=0; isetMaxPathLength(int) method
+ * Assertion: throws InvalidParameterException if parameter is
+ * less than -1
+ * @throws InvalidAlgorithmParameterException
+ * @throws KeyStoreException
+ */
+ public final void testSetMaxPathLength02()
+ throws KeyStoreException,
+ InvalidAlgorithmParameterException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+ PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
+
+ try {
+ // pass parameter less than -1
+ p.setMaxPathLength(Integer.MIN_VALUE);
+ fail("InvalidParameterException expected");
+ } catch (InvalidParameterException e) {
+ }
+ }
+
+ /**
+ * Test for toString() method
+ * Assertion: returns string describing this object
+ * @throws InvalidAlgorithmParameterException
+ * @throws KeyStoreException
+ */
+ public final void testToString()
+ throws KeyStoreException,
+ InvalidAlgorithmParameterException {
+ KeyStore ks = TestUtils.getKeyStore(true,TestUtils.TRUSTED_AND_UNTRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+ PKIXBuilderParameters p =
+ new PKIXBuilderParameters(ks, new X509CertSelector());
+ String rep = p.toString();
+
+ assertNotNull(rep);
+ }
+
+}
Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java (revision 0)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java (working copy)
@@ -19,28 +19,37 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
+import java.security.cert.CRLSelector;
+import java.security.cert.CertSelector;
+import java.security.cert.CertStore;
+import java.security.cert.CertStoreException;
+import java.security.cert.CertStoreParameters;
+import java.security.cert.X509CRLSelector;
+import java.security.cert.X509CertSelector;
import java.util.Collection;
import org.apache.harmony.security.tests.support.SpiEngUtils;
+import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
+import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters;
import junit.framework.TestCase;
-
/**
* Tests for CertStore class constructors and methods
*
*/
-public class CertStore2Test extends TestCase {
+public class CertStore_ImplTest extends TestCase {
+ private static final String srvCertStore = "CertStore";
private static final String defaultAlg = "CertStore";
- private static final String CertStoreProviderClass = "java.security.cert.MyCertStoreSpi";
+ private static final String CertStoreProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertStoreSpi";
private static final String[] invalidValues = SpiEngUtils.invalidValues;
@@ -59,7 +68,7 @@
protected void setUp() throws Exception {
super.setUp();
mProv = (new SpiEngUtils()).new MyProvider("MyCertStoreProvider",
- "Provider for testing", CertStore1Test.srvCertStore
+ "Provider for testing", srvCertStore
.concat(".").concat(defaultAlg),
CertStoreProviderClass);
Security.insertProviderAt(mProv, 1);
@@ -73,15 +82,6 @@
Security.removeProvider(mProv.getName());
}
- /**
- * Constructor for CertStore2Test.
- *
- * @param arg0
- */
- public CertStore2Test(String arg0) {
- super(arg0);
- }
-
private void checkResult(CertStore certS) throws CertStoreException,
InvalidAlgorithmParameterException {
CertSelector certSelector = new X509CertSelector();
Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory_ImplTest.java (revision 0)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory_ImplTest.java (working copy)
@@ -33,9 +33,7 @@
import java.util.Iterator;
import org.apache.harmony.luni.util.Base64;
-import junit.framework.Test;
import junit.framework.TestCase;
-import junit.framework.TestSuite;
/**
* X.509 CertificateFactory provider implementation test.
@@ -46,7 +44,7 @@
* The testing data was generated by use of classes from
* org.apache.harmony.security.x509 package.
*/
-public class CertificateFactoryTest extends TestCase {
+public class CertificateFactory_ImplTest extends TestCase {
/**
* Base64 encoded PKCS7 SignedObject containing two X.509 CRLs.
@@ -212,11 +210,4 @@
}
}
- public static Test suite() {
- return new TestSuite(CertificateFactoryTest.class);
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
Index: modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchor_ImplTest.java
===================================================================
--- modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchor_ImplTest.java (revision 0)
+++ modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchor_ImplTest.java (revision 0)
@@ -0,0 +1,757 @@
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.cert;
+
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.PublicKey;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509Certificate;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Arrays;
+
+import javax.security.auth.x500.X500Principal;
+
+import org.apache.harmony.security.tests.support.TestKeyPair;
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for TrustAnchor
+ */
+public class TrustAnchor_ImplTest extends TestCase {
+ private static final String keyAlg = "DSA";
+ // Sample of some valid CA name
+ private static final String validCaNameRfc2253 =
+ "CN=Test CA,"+
+ "OU=Testing Division,"+
+ "O=Test It All,"+
+ "L=Test Town,"+
+ "ST=Testifornia,"+
+ "C=Testland";
+
+ /**
+ * Test #1 for TrustAnchor(X509Certificate, byte[]) constructor
+ * Assertion: creates TrustAnchor instance
+ * Test preconditions: valid parameters passed
+ * Expected: must pass without any exceptions
+ */
+ public final void testTrustAnchorX509CertificatebyteArray01()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "testca1";
+ // sub testcase 1
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ getFullEncoding());
+ // sub testcase 2
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ getEncodingPSOnly());
+ // sub testcase 3
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ getEncodingESOnly());
+ // sub testcase 4
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ getEncodingNoMinMax());
+ }
+
+ /**
+ * Test #2 for TrustAnchor(X509Certificate, byte[]) constructor
+ * Assertion: creates TrustAnchor instance
+ * Test preconditions: null as nameConstraints passed
+ * Expected: must pass without any exceptions
+ */
+ public final void testTrustAnchorX509CertificatebyteArray02()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "testca1";
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ null);
+ }
+
+ /**
+ * Test #3 for TrustAnchor(X509Certificate, byte[]) constructor
+ * Assertion: nameConstraints cloned by the constructor
+ * Test preconditions: modify passed nameConstraints
+ * Expected: modification must not change object internal state
+ */
+ public final void testTrustAnchorX509CertificatebyteArray03()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "testca1";
+ byte[] nc = getEncodingPSOnly();
+ byte[] ncCopy = nc.clone();
+ // sub testcase 5 - nameConstraints can be null
+ TrustAnchor ta = new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ ncCopy);
+ // modify
+ ncCopy[0]=(byte)0;
+ // check that above modification did not change
+ // object internal state
+ assertTrue(Arrays.equals(nc, ta.getNameConstraints()));
+ }
+
+ /**
+ * Test #4 for TrustAnchor(X509Certificate, byte[]) constructor
+ * Assertion: NullPointerException if X509Certificate
+ * parameter is null
+ * Test preconditions: pass null as X509Certificate
+ * Expected: NullPointerException
+ */
+ public final void testTrustAnchorX509CertificatebyteArray04()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ try {
+ new TrustAnchor(null, getFullEncoding());
+ fail("NullPointerException has not been thrown");
+ } catch (NullPointerException ok) {
+ }
+ }
+
+ /**
+ * Test #5 for TrustAnchor(X509Certificate, byte[]) constructor
+ * Assertion: IllegalArgumentException if nameConstraints
+ * parameter can not be decoded
+ * Test preconditions: pass invalid nameConstraints encoding
+ * Expected: IllegalArgumentException
+ */
+ public final void testTrustAnchorX509CertificatebyteArray05()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "testca1";
+
+ // sub testcase 1:
+ byte [] nameConstraints = getFullEncoding();
+ // corrupt encoding:
+ // set wrong root seq length
+ nameConstraints[2] = (byte)0x8d;
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ nameConstraints);
+ fail("IllegalArgumentException has not been thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+ // sub testcase 2:
+ nameConstraints = getFullEncoding();
+ // corrupt encoding:
+ // set wrong root seq length
+ nameConstraints[2] = (byte)0x8b;
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ nameConstraints);
+ fail("IllegalArgumentException has not been thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+ // sub testcase 3:
+ nameConstraints = getFullEncoding();
+ // corrupt encoding:
+ // remove right class from seq tag
+ nameConstraints[3] &= (byte)0x3f;
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ nameConstraints);
+ fail("IllegalArgumentException has not been thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+ // sub testcase 4:
+ nameConstraints = getEncodingESOnly();
+ // corrupt encoding:
+ // set wrong tagged value (excludedSubtrees SEQ OF) tag [2]
+ nameConstraints[2] = (byte)0xa2;
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ nameConstraints);
+ fail("IllegalArgumentException has not been thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+ // sub testcase 5:
+ nameConstraints = getEncodingESOnly();
+ // corrupt encoding:
+ // remove CONSTRUCTED flag from tagged value (excludedSubtrees SEQ OF) tag
+ nameConstraints[2] &= (byte)0xdf;
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ nameConstraints);
+ fail("IllegalArgumentException has not been thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+ // sub testcase 6:
+ nameConstraints = getEncodingESOnly();
+ // corrupt encoding:
+ // set CONSTRUCTED flag for PROMITIVE tagged value tag
+ // (generalSubtree's 'base' as IA5String)
+ nameConstraints[5] |= (byte)0x20;
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ nameConstraints);
+ fail("IllegalArgumentException has not been thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+ // sub testcase 7:
+ nameConstraints = getEncodingESOnly();
+ // corrupt encoding:
+ // remove scheme from URI
+ // (generalSubtree's 'base' as IA5String (uniformResourceIdentifier))
+ nameConstraints[12] = nameConstraints[13] = nameConstraints[14] =
+ (byte)0x6f;
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ nameConstraints);
+ fail("IllegalArgumentException has not been thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+ }
+
+ /**
+ * Test #6 for TrustAnchor(X509Certificate, byte[]) constructor
+ * Assertion: creates TrustAnchor instance
+ * Test preconditions: valid parameters passed (base as OID)
+ * Expected: must pass without any exceptions
+ */
+ public final void testTrustAnchorX509CertificatebyteArray06()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "testca1";
+ byte [] nameConstraints = getEncodingOid();
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ nameConstraints);
+ }
+
+ /**
+ * Test #7 for TrustAnchor(X509Certificate, byte[]) constructor
+ * Assertion: IllegalArgumentException if nameConstraints
+ * parameter can not be decoded
+ * Test preconditions: pass invalid nameConstraints (OID) encoding
+ * Expected: IllegalArgumentException
+ */
+ public final void testTrustAnchorX509CertificatebyteArray07()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "testca1";
+ byte [] nameConstraints = getEncodingOid();
+ //corrupt Oid
+ nameConstraints[10]= (byte) 0xFF;
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ nameConstraints);
+ fail("IllegalArgumentException has not been thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+ }
+
+ /**
+ * Test #8 for TrustAnchor(X509Certificate, byte[]) constructor
+ * Assertion: IllegalArgumentException if nameConstraints
+ * parameter can not be decoded
+ * Test preconditions: pass invalid nameConstraints encodings
+ * Expected: IllegalArgumentException
+ */
+ public final void testTrustAnchorX509CertificatebyteArray08()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "testca1";
+ // GeneralName tags for this test (1,2 and 3 are omitted)
+ byte[] generalNameTag = new byte[] {
+ (byte)0xa0,(byte)0xa4,(byte)0xa5,
+ (byte)0x86,(byte)0x87,(byte)0x88
+ };
+ // wrong (for above tags) nameConstraints encoding
+ byte[] wrongEncoding = new byte[] {
+ (byte)0x30,(byte)0x0c, // sequence + length
+ (byte)0xa1,(byte)0x0a, // excluded subtrees, tag, len
+ (byte)0x30,(byte)0x08, // sequence of, tag, len
+ (byte)0xa0, // element 6 - tag identifying GeneralName choice
+ (byte)0x03, // GeneralName length
+ (byte)0x01,(byte)0x01,(byte)0xff, // wrong GeneralName for any choice
+ (byte)0x80,(byte)0x01,(byte)0x00 // minimum
+ };
+ for (int i=0; iTrustAnchor(X509Certificate, byte[]) constructor
+ * Assertion: IllegalArgumentException if nameConstraints
+ * parameter can not be decoded
+ * Test preconditions: pass valid and then invalid nameConstraints encodings
+ * (GeneralName choice is [0] OtherName)
+ * Expected: no exception for valid encoding and IllegalArgumentException for invalid
+ * @throws KeyStoreException
+ */
+ public final void testTrustAnchorX509CertificatebyteArray09()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "testca1";
+ byte[] encoding = new byte[] {
+ (byte)0x30,(byte)0x13,(byte)0xa1,(byte)0x11,
+ (byte)0x30,(byte)0x0f,(byte)0xa0,(byte)0x0a,
+ (byte)0x06,(byte)0x03,(byte)0x00,(byte)0x01,(byte)0x02,
+ (byte)0xA0,(byte)0x03,1,1,(byte)0xff,
+ (byte)0x80,(byte)0x01,(byte)0x00
+ };
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias), encoding);
+ } catch (IllegalArgumentException failed) {
+ fail("valid encoding not accepted");
+ }
+ // now corrupt encoding: set OtherName value tag to 1 (must be 0)
+ encoding[13] = 1;
+ try {
+ new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias), encoding);
+ fail("invalid encoding accepted");
+ } catch (IllegalArgumentException ok) {
+ }
+ }
+
+ /**
+ * Test for getNameConstraints() method
+ * Assertion: returns nameConstraints der encoding
+ * Test preconditions: valid nameConstraints parameter passed (not null)
+ * Expected: encoding passed to the ctor must match returned one
+ * Assertion: returns new nameConstraints der encoding each time
+ * Test preconditions: valid nameConstraints parameter passed (not null)
+ * Expected: must return new reference each time called
+ */
+ public final void testGetNameConstraints()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "testca1";
+ byte[] nc = getFullEncoding();
+ // sub testcase 1
+ TrustAnchor ta = new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias), nc);
+ byte[] ncRet = ta.getNameConstraints();
+ // assert 1
+ assertTrue(Arrays.equals(nc, ncRet));
+ assertNotSame(nc, ncRet);
+ // assert 2
+ assertNotSame(ncRet, ta.getNameConstraints());
+ }
+
+ /**
+ * Test #2 for getCAName() method
+ *
+ * Assertion: returns ... null if TrustAnchor
+ * was not specified as public key and CA name or CA principal pair
+ * Test preconditions: test object is not specified as public key
+ * and CA name or CA principal pair
+ * Expected: null as return value
+ * @throws KeyStoreException
+ *
+ */
+ public final void testGetCAPublicKey02()
+ throws InvalidKeySpecException, KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ TrustAnchor ta = new TrustAnchor(
+ (X509Certificate)ks.getCertificate("testca1"),
+ null);
+ assertNull(ta.getCAPublicKey());
+ }
+
+ /**
+ * Test #2 for getCAName() method
+ *
+ * Assertion: returns ... null if TrustAnchor
+ * was not specified as public key and CA name or CA principal pair
+ * Test preconditions: test object is not specified as public key
+ * and CA name or CA principal pair
+ * Expected: null as return value
+ * @throws KeyStoreException
+ */
+ public final void testGetCAName02()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ TrustAnchor ta = new TrustAnchor(
+ (X509Certificate)ks.getCertificate("testca1"),
+ null);
+ assertNull(ta.getCAName());
+ }
+
+ /**
+ * Test #1 for getCAName() method
+ *
+ * Assertion: returns most trusted CA certificate
+ * Test preconditions: valid certificate passed to the constructor
+ * Expected: the same certificate must be returned by the method
+ * @throws KeyStoreException
+ *
+ */
+ public final void testGetTrustedCert01()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ X509Certificate cert =
+ (X509Certificate)ks.getCertificate("testca1");
+ TrustAnchor ta = new TrustAnchor(cert, null);
+ assertEquals(cert, ta.getTrustedCert());
+ }
+
+ /**
+ * Test #2 for getCA() method
+ *
+ * Assertion: returns ... null if TrustAnchor
+ * was not specified as public key and CA name or CA principal pair
+ * Test preconditions: test object is not specified as public key
+ * and CA name or CA principal pair
+ * Expected: null as return value
+ * @throws KeyStoreException
+ */
+ public final void testGetCA02()
+ throws KeyStoreException {
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ TrustAnchor ta = new TrustAnchor(
+ (X509Certificate)ks.getCertificate("testca1"),
+ null);
+ assertNull(ta.getCA());
+ }
+
+ /**
+ * Test for toString() method
+ *
+ * Assertion: returns string representation of this TrustAnchor
+ * Test preconditions: several valid test objects created
+ * Expected: method returns not null in all cases
+ */
+ public final void testToString() throws Exception {
+
+ KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
+ if (ks == null) {
+ fail(getName() + ": not performed (could not create test KeyStore)");
+ }
+
+ String certAlias = "test";
+
+ // sub testcase 1
+ TrustAnchor ta = new TrustAnchor(
+ (X509Certificate)ks.getCertificate(certAlias),
+ getFullEncoding());
+
+ assertNotNull("#1", ta.toString());
+
+ PublicKey pk = new TestKeyPair(keyAlg).getPublic();
+
+
+ // sub testcase 2
+ ta = new TrustAnchor(validCaNameRfc2253, pk, getEncodingESOnly());
+
+ assertNotNull("#2", ta.toString());
+
+ // sub testcase 3
+ X500Principal x500p = new X500Principal(validCaNameRfc2253);
+ ta = new TrustAnchor(x500p, pk, getEncodingNoMinMax());
+
+ assertNotNull("#3", ta.toString());
+
+ // sub testcase 4
+ ta = new TrustAnchor(x500p, pk, null);
+ assertNotNull("#4", ta.toString());
+ }
+
+ //
+ // Private stuff
+ //
+
+ /*
+ * The following methods return valid DER encoding
+ * for the following ASN.1 definition (as specified in RFC 3280 -
+ * Internet X.509 Public Key Infrastructure.
+ * Certificate and Certificate Revocation List (CRL) Profile.
+ * http://www.ietf.org/rfc/rfc3280.txt):
+ *
+ * NameConstraints ::= SEQUENCE {
+ * permittedSubtrees [0] GeneralSubtrees OPTIONAL,
+ * excludedSubtrees [1] GeneralSubtrees OPTIONAL }
+ *
+ * GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
+ *
+ * GeneralSubtree ::= SEQUENCE {
+ * base GeneralName,
+ * minimum [0] BaseDistance DEFAULT 0,
+ * maximum [1] BaseDistance OPTIONAL }
+ *
+ * BaseDistance ::= INTEGER (0..MAX)
+ *
+ * GeneralName ::= CHOICE {
+ * otherName [0] OtherName,
+ * rfc822Name [1] IA5String,
+ * dNSName [2] IA5String,
+ * x400Address [3] ORAddress,
+ * directoryName [4] Name,
+ * ediPartyName [5] EDIPartyName,
+ * uniformResourceIdentifier [6] IA5String,
+ * iPAddress [7] OCTET STRING,
+ * registeredID [8] OBJECT IDENTIFIER}
+ */
+
+ //
+ // Full NameConstraints encoding
+ // (generated by own encoder class created durind test development)
+ //
+ // @return Full NameConstraints encoding
+ // with all OPTIONAL values presented.
+ //
+ private static final byte[] getFullEncoding() {
+ // DO NOT MODIFY!
+ return new byte[] {
+ (byte)0x30,(byte)0x81,(byte)0x8c,(byte)0xa0,
+ (byte)0x44,(byte)0x30,(byte)0x16,(byte)0x86,
+ (byte)0x0e,(byte)0x66,(byte)0x69,(byte)0x6c,
+ (byte)0x65,(byte)0x3a,(byte)0x2f,(byte)0x2f,
+ (byte)0x66,(byte)0x6f,(byte)0x6f,(byte)0x2e,
+ (byte)0x63,(byte)0x6f,(byte)0x6d,(byte)0x80,
+ (byte)0x01,(byte)0x00,(byte)0x81,(byte)0x01,
+ (byte)0x01,(byte)0x30,(byte)0x16,(byte)0x86,
+ (byte)0x0e,(byte)0x66,(byte)0x69,(byte)0x6c,
+ (byte)0x65,(byte)0x3a,(byte)0x2f,(byte)0x2f,
+ (byte)0x62,(byte)0x61,(byte)0x72,(byte)0x2e,
+ (byte)0x63,(byte)0x6f,(byte)0x6d,(byte)0x80,
+ (byte)0x01,(byte)0x00,(byte)0x81,(byte)0x01,
+ (byte)0x01,(byte)0x30,(byte)0x12,(byte)0x86,
+ (byte)0x0a,(byte)0x66,(byte)0x69,(byte)0x6c,
+ (byte)0x65,(byte)0x3a,(byte)0x2f,(byte)0x2f,
+ (byte)0x6d,(byte)0x75,(byte)0x75,(byte)0x80,
+ (byte)0x01,(byte)0x00,(byte)0x81,(byte)0x01,
+ (byte)0x01,(byte)0xa1,(byte)0x44,(byte)0x30,
+ (byte)0x16,(byte)0x86,(byte)0x0e,(byte)0x68,
+ (byte)0x74,(byte)0x74,(byte)0x70,(byte)0x3a,
+ (byte)0x2f,(byte)0x2f,(byte)0x66,(byte)0x6f,
+ (byte)0x6f,(byte)0x2e,(byte)0x63,(byte)0x6f,
+ (byte)0x6d,(byte)0x80,(byte)0x01,(byte)0x00,
+ (byte)0x81,(byte)0x01,(byte)0x01,(byte)0x30,
+ (byte)0x16,(byte)0x86,(byte)0x0e,(byte)0x68,
+ (byte)0x74,(byte)0x74,(byte)0x70,(byte)0x3a,
+ (byte)0x2f,(byte)0x2f,(byte)0x62,(byte)0x61,
+ (byte)0x72,(byte)0x2e,(byte)0x63,(byte)0x6f,
+ (byte)0x6d,(byte)0x80,(byte)0x01,(byte)0x00,
+ (byte)0x81,(byte)0x01,(byte)0x01,(byte)0x30,
+ (byte)0x12,(byte)0x86,(byte)0x0a,(byte)0x68,
+ (byte)0x74,(byte)0x74,(byte)0x70,(byte)0x3a,
+ (byte)0x2f,(byte)0x2f,(byte)0x6d,(byte)0x75,
+ (byte)0x75,(byte)0x80,(byte)0x01,(byte)0x00,
+ (byte)0x81,(byte)0x01,(byte)0x01
+ };
+ }
+
+ //
+ // NameConstraints encoding without excludedSubtrees
+ // (generated by own encoder class created durind test development)
+ //
+ // @return NameConstraints encoding with
+ // permittedSubtrees only; all OPTIONAL
+ // values in permittedSubtrees are presented.
+ //
+ private static final byte[] getEncodingPSOnly() {
+ // DO NOT MODIFY!
+ return new byte[] {
+ (byte)0x30,(byte)0x46,(byte)0xa0,(byte)0x44,
+ (byte)0x30,(byte)0x16,(byte)0x86,(byte)0x0e,
+ (byte)0x66,(byte)0x69,(byte)0x6c,(byte)0x65,
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x66,
+ (byte)0x6f,(byte)0x6f,(byte)0x2e,(byte)0x63,
+ (byte)0x6f,(byte)0x6d,(byte)0x80,(byte)0x01,
+ (byte)0x00,(byte)0x81,(byte)0x01,(byte)0x01,
+ (byte)0x30,(byte)0x16,(byte)0x86,(byte)0x0e,
+ (byte)0x66,(byte)0x69,(byte)0x6c,(byte)0x65,
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x62,
+ (byte)0x61,(byte)0x72,(byte)0x2e,(byte)0x63,
+ (byte)0x6f,(byte)0x6d,(byte)0x80,(byte)0x01,
+ (byte)0x00,(byte)0x81,(byte)0x01,(byte)0x01,
+ (byte)0x30,(byte)0x12,(byte)0x86,(byte)0x0a,
+ (byte)0x66,(byte)0x69,(byte)0x6c,(byte)0x65,
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x6d,
+ (byte)0x75,(byte)0x75,(byte)0x80,(byte)0x01,
+ (byte)0x00,(byte)0x81,(byte)0x01,(byte)0x01,
+ };
+ }
+
+ //
+ // NameConstraints encoding without permittedSubtrees
+ // (generated by own encoder class created durind test development)
+ //
+ // @return NameConstraints encoding with
+ // excludedSubtrees only; all OPTIONAL
+ // values in excludedSubtrees are presented.
+ //
+ private static final byte[] getEncodingESOnly() {
+ // DO NOT MODIFY!
+ return new byte[] {
+ (byte)0x30,(byte)0x46,(byte)0xa1,(byte)0x44,
+ (byte)0x30,(byte)0x16,(byte)0x86,(byte)0x0e,
+ (byte)0x68,(byte)0x74,(byte)0x74,(byte)0x70, // http
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x66, // ://f
+ (byte)0x6f,(byte)0x6f,(byte)0x2e,(byte)0x63, // oo.c
+ (byte)0x6f,(byte)0x6d,(byte)0x80,(byte)0x01, // om
+ (byte)0x00,(byte)0x81,(byte)0x01,(byte)0x01,
+ (byte)0x30,(byte)0x16,(byte)0x86,(byte)0x0e,
+ (byte)0x68,(byte)0x74,(byte)0x74,(byte)0x70,
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x62,
+ (byte)0x61,(byte)0x72,(byte)0x2e,(byte)0x63,
+ (byte)0x6f,(byte)0x6d,(byte)0x80,(byte)0x01,
+ (byte)0x00,(byte)0x81,(byte)0x01,(byte)0x01,
+ (byte)0x30,(byte)0x12,(byte)0x86,(byte)0x0a,
+ (byte)0x68,(byte)0x74,(byte)0x74,(byte)0x70,
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x6d,
+ (byte)0x75,(byte)0x75,(byte)0x80,(byte)0x01,
+ (byte)0x00,(byte)0x81,(byte)0x01,(byte)0x01,
+ };
+ }
+
+ //
+ // NameConstraints full encoding with all (OPTIONAL)
+ // minimum/maximum GeneralSubtree fields OMITTED
+ // (generated by own encoder class created durind test development)
+ //
+ // @return Full NameConstraints encoding
+ // with all (OPTIONAL) minimum/maximum
+ // GeneralSubtree fields OMITTED
+ //
+ private static final byte[] getEncodingNoMinMax() {
+ // DO NOT MODIFY!
+ return new byte[] {
+ (byte)0x30,(byte)0x68,(byte)0xa0,(byte)0x32,
+ (byte)0x30,(byte)0x10,(byte)0x86,(byte)0x0e,
+ (byte)0x66,(byte)0x69,(byte)0x6c,(byte)0x65,
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x66,
+ (byte)0x6f,(byte)0x6f,(byte)0x2e,(byte)0x63,
+ (byte)0x6f,(byte)0x6d,(byte)0x30,(byte)0x10,
+ (byte)0x86,(byte)0x0e,(byte)0x66,(byte)0x69,
+ (byte)0x6c,(byte)0x65,(byte)0x3a,(byte)0x2f,
+ (byte)0x2f,(byte)0x62,(byte)0x61,(byte)0x72,
+ (byte)0x2e,(byte)0x63,(byte)0x6f,(byte)0x6d,
+ (byte)0x30,(byte)0x0c,(byte)0x86,(byte)0x0a,
+ (byte)0x66,(byte)0x69,(byte)0x6c,(byte)0x65,
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x6d,
+ (byte)0x75,(byte)0x75,(byte)0xa1,(byte)0x32,
+ (byte)0x30,(byte)0x10,(byte)0x86,(byte)0x0e,
+ (byte)0x68,(byte)0x74,(byte)0x74,(byte)0x70,
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x66,
+ (byte)0x6f,(byte)0x6f,(byte)0x2e,(byte)0x63,
+ (byte)0x6f,(byte)0x6d,(byte)0x30,(byte)0x10,
+ (byte)0x86,(byte)0x0e,(byte)0x68,(byte)0x74,
+ (byte)0x74,(byte)0x70,(byte)0x3a,(byte)0x2f,
+ (byte)0x2f,(byte)0x62,(byte)0x61,(byte)0x72,
+ (byte)0x2e,(byte)0x63,(byte)0x6f,(byte)0x6d,
+ (byte)0x30,(byte)0x0c,(byte)0x86,(byte)0x0a,
+ (byte)0x68,(byte)0x74,(byte)0x74,(byte)0x70,
+ (byte)0x3a,(byte)0x2f,(byte)0x2f,(byte)0x6d,
+ (byte)0x75,(byte)0x75,
+ };
+ }
+
+ // Returns OID encoding
+ // (generated by own encoder class created durind test development)
+ private static final byte[] getEncodingOid() {
+ // DO NOT MODIFY!
+ return new byte[] {
+ (byte) 0x30, (byte) 0x09, (byte) 0xA0, (byte) 0x07,
+ (byte) 0x30, (byte) 0x05, (byte) 0x88, (byte) 0x03,
+ (byte) 0x2A, (byte) 0x03, (byte) 0x04
+ };
+ }
+}
Index: modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
===================================================================
--- modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java (revision 415258)
+++ modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java (working copy)
@@ -16,15 +16,12 @@
package tests.api.java.security;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
import java.net.URL;
import java.security.PermissionCollection;
import java.security.SecurityPermission;
-import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import tests.support.Support_Exec;
@@ -55,82 +52,63 @@
/**
* @tests java.security.PermissionCollection#implies(java.security.Permission)
*/
- public void test_impliesLjava_security_Permission() {
+ public void test_impliesLjava_security_Permission() throws Exception{
// Look for the tests classpath
URL classURL = this.getClass().getProtectionDomain().getCodeSource()
.getLocation();
assertNotNull("Could not get this class' location", classURL);
- File policyFile = null;
- try {
- policyFile = Support_GetLocal.createTempFile(".policy");
- } catch (IOException e) {
- fail("Unexpected IOException while creating policy file : " + e);
- }
+ File policyFile = Support_GetLocal.createTempFile(".policy");
URL signedBKS = getResourceURL("PermissionCollection/signedBKS.jar");
URL keystoreBKS = getResourceURL("PermissionCollection/keystore.bks");
-
+
// Create the policy file (and save the existing one if any)
- try {
- FileOutputStream fileOut = new FileOutputStream(policyFile);
- String linebreak = System.getProperty("line.separator");
- String towrite = "grant codeBase \""
- + signedBKS.toExternalForm()
- + "\" signedBy \"eleanor\" {"
- + linebreak
- + "permission java.io.FilePermission \"test1.txt\", \"write\";"
- + linebreak
- + "permission mypackage.MyPermission \"essai\", signedBy \"eleanor,dylan\";"
- + linebreak
- + "};"
- + linebreak
- + "grant codeBase \""
- + signedBKS.toExternalForm()
- + "\" signedBy \"eleanor\" {"
- + linebreak
- + "permission java.io.FilePermission \"test2.txt\", \"write\";"
- + linebreak + "};" + linebreak + "grant codeBase \"";
- towrite += classURL.toExternalForm();
- towrite += "\" {" + linebreak
- + "permission java.security.AllPermission;" + linebreak
- + "};" + linebreak + "keystore \""
- + keystoreBKS.toExternalForm()
- + "\",\"BKS\";";
- fileOut.write(towrite.getBytes());
- fileOut.flush();
- fileOut.close();
- } catch (Exception e) {
- fail("Exception while creating policy file : " + e);
- }
+ FileOutputStream fileOut = new FileOutputStream(policyFile);
+ String linebreak = System.getProperty("line.separator");
+ String towrite = "grant codeBase \""
+ + signedBKS.toExternalForm()
+ + "\" signedBy \"eleanor\" {"
+ + linebreak
+ + "permission java.io.FilePermission \"test1.txt\", \"write\";"
+ + linebreak
+ + "permission mypackage.MyPermission \"essai\", signedBy \"eleanor,dylan\";"
+ + linebreak
+ + "};"
+ + linebreak
+ + "grant codeBase \""
+ + signedBKS.toExternalForm()
+ + "\" signedBy \"eleanor\" {"
+ + linebreak
+ + "permission java.io.FilePermission \"test2.txt\", \"write\";"
+ + linebreak + "};" + linebreak + "grant codeBase \"";
+ towrite += classURL.toExternalForm();
+ towrite += "\" {" + linebreak
+ + "permission java.security.AllPermission;" + linebreak
+ + "};" + linebreak + "keystore \""
+ + keystoreBKS.toExternalForm()
+ + "\",\"BKS\";";
+ fileOut.write(towrite.getBytes());
+ fileOut.flush();
+ fileOut.close();
// Copy mypermissionBKS.jar to the user directory so that it can be put
- // in
- // the classpath
+ // in the classpath
File jarFile = null;
- try {
- InputStream jis = Support_Resources
- .getResourceStream("PermissionCollection/mypermissionBKS.jar");
- jarFile = Support_GetLocal.createTempFile(".jar");
- FileOutputStream fout = new FileOutputStream(jarFile);
- int c = jis.read();
- while (c != -1) {
- fout.write(c);
- c = jis.read();
- }
- fout.flush();
- fout.close();
- jis.close();
- } catch (MalformedURLException e) {
- fail("Unexpected MalformedURLException while creating jar file :"
- + e);
- } catch (FileNotFoundException e) {
- fail("Unexpected FileNotFoundException while creating jar file :"
- + e);
- } catch (IOException e) {
- fail("Unexpected IOException while creating jar file : " + e);
+
+ InputStream jis = Support_Resources
+ .getResourceStream("PermissionCollection/mypermissionBKS.jar");
+ jarFile = Support_GetLocal.createTempFile(".jar");
+ FileOutputStream fout = new FileOutputStream(jarFile);
+ int c = jis.read();
+ while (c != -1) {
+ fout.write(c);
+ c = jis.read();
}
+ fout.flush();
+ fout.close();
+ jis.close();
String classPath = new File(classURL.getFile()).getPath();
@@ -139,65 +117,45 @@
classPathArray[0] = classPath;
classPathArray[1] = jarFile.getPath();
String[] args = new String[3];
- try {
- args[0] = "-Djava.security.policy=" + policyFile.toURL();
- args[1] = "tests.support.Support_PermissionCollection";
- args[2] = signedBKS.toExternalForm();
- } catch (MalformedURLException e) {
- fail("Unexpected MalformedURLException while policy file to url : "
- + e);
+ args[0] = "-Djava.security.policy=" + policyFile.toURL();
+ args[1] = "tests.support.Support_PermissionCollection";
+ args[2] = signedBKS.toExternalForm();
+
+ String result = Support_Exec.execJava(args, classPathArray, true);
+ // Delete the Jar file copied in the user directory
+ if (!jarFile.delete()) {
+ throw new IOException("Could not delete temporary jar file : "
+ + jarFile.getPath());
}
- try {
- String result = Support_Exec.execJava(args, classPathArray, true);
- // Delete the Jar file copied in the user directory
- if (!jarFile.delete()) {
- throw new IOException("Could not delete temporary jar file : "
- + jarFile.getPath());
- }
+ // Delete the temporary policy file
+ if (!policyFile.delete()) {
+ throw new IOException("Could not delete temporary policy file : "
+ + policyFile.getPath());
+ }
- // Delete the temporary policy file
- if (!policyFile.delete()) {
- throw new IOException(
- "Could not delete temporary policy file : "
- + policyFile.getPath());
- }
+ StringTokenizer resultTokenizer = new StringTokenizer(result, ",");
- StringTokenizer resultTokenizer = new StringTokenizer(result, ",");
-
- // Check the test result from the new VM process
- assertEquals("Permission should be granted", "true",
- resultTokenizer.nextToken());
- assertEquals("signed Permission should be granted", "true",
- resultTokenizer.nextToken());
- assertEquals("Permission should not be granted", "false",
- resultTokenizer.nextToken());
- } catch (IOException e) {
- fail("IOException during test : " + e);
- } catch (InterruptedException e) {
- fail("InterruptedException during test : " + e);
- } catch (NoSuchElementException e) {
- fail("NoSuchElementException during test : " + e);
- } catch (Exception e) {
- fail("Exception during test : " + e);
- }
+ // Check the test result from the new VM process
+ assertEquals("Permission should be granted", "true", resultTokenizer
+ .nextToken());
+ assertEquals("signed Permission should be granted", "true",
+ resultTokenizer.nextToken());
+ assertEquals("Permission should not be granted", "false",
+ resultTokenizer.nextToken());
}
/**
* @tests java.security.PermissionCollection#PermissionCollection()
*/
- public void test_Constructor() {
+ public void test_Constructor() throws Exception {
// test java.security.permissionCollection.PermissionCollection()
- try {
- SecurityPermission permi = new SecurityPermission(
- "testing permissionCollection-isReadOnly");
- PermissionCollection permCollect = permi.newPermissionCollection();
- assertNotNull(
- "creat permissionCollection constructor returned a null",
- permCollect);
- } catch (Exception e) {
- fail("creating of permissionCollection constructor failed : " + e);
- }
+
+ SecurityPermission permi = new SecurityPermission(
+ "testing permissionCollection-isReadOnly");
+ PermissionCollection permCollect = permi.newPermissionCollection();
+ assertNotNull("creat permissionCollection constructor returned a null",
+ permCollect);
}
/**
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator4Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator4Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator4Test.java (working copy)
@@ -13,16 +13,19 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.math.BigInteger;
+import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.spec.DSAParameterSpec;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.DSAParams;
-public class KeyPairGeneratorTest extends junit.framework.TestCase {
+public class KeyPairGenerator4Test extends junit.framework.TestCase {
/**
* @tests java.security.KeyPairGenerator#genKeyPair()
@@ -97,14 +100,22 @@
keyPair.initialize(1024, new SecureRandom());
}
+
/**
* @tests java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec)
*/
public void test_initializeLjava_security_spec_AlgorithmParameterSpec()
throws Exception {
+ // create DSAParams
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
+ keyPairGenerator.initialize(1024);
+ DSAPublicKey key = (DSAPublicKey) keyPairGenerator.genKeyPair()
+ .getPublic();
+ DSAParams params = key.getParams();
+
KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
- keyPair.initialize(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE,
- BigInteger.ONE));
+ keyPair.initialize(new DSAParameterSpec(params.getP(), params.getQ(),
+ params.getG()));
}
/**
@@ -113,8 +124,15 @@
*/
public void test_initializeLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom()
throws Exception {
+ // create DSAParams
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
+ keyPairGenerator.initialize(1024);
+ DSAPublicKey key = (DSAPublicKey) keyPairGenerator.genKeyPair()
+ .getPublic();
+ DSAParams params = key.getParams();
+
KeyPairGenerator keyPair = KeyPairGenerator.getInstance("DSA");
- keyPair.initialize(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE,
- BigInteger.ONE), new SecureRandom());
+ keyPair.initialize(new DSAParameterSpec(params.getP(), params.getQ(),
+ params.getG()), new SecureRandom());
}
}
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.InvalidAlgorithmParameterException;
-public class InvalidAlgorithmParameterExceptionTest extends
+public class InvalidAlgorithmParameterException2Test extends
junit.framework.TestCase {
/**
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignatureException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignatureException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignatureException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.SignatureException;
-public class SignatureExceptionTest extends junit.framework.TestCase {
+public class SignatureException2Test extends junit.framework.TestCase {
/**
* @tests java.security.SignatureException#SignatureException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPublicKeyTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPublicKeyTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPublicKeyTest.java (working copy)
@@ -19,10 +19,11 @@
* @version $Revision$
*/
-package java.security.interfaces;
+package org.apache.harmony.security.tests.java.security.interfaces;
import java.math.BigInteger;
+import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPublicKey;
import junit.framework.TestCase;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPublicKeyTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPublicKeyTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPublicKeyTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.interfaces;
+package org.apache.harmony.security.tests.java.security.interfaces;
import java.security.spec.ECPoint;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateCrtKeyTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateCrtKeyTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateCrtKeyTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.interfaces;
+package org.apache.harmony.security.tests.java.security.interfaces;
import java.math.BigInteger;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateKeyTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateKeyTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPrivateKeyTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.interfaces;
+package org.apache.harmony.security.tests.java.security.interfaces;
import java.math.BigInteger;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.interfaces;
+package org.apache.harmony.security.tests.java.security.interfaces;
import java.math.BigInteger;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPrivateKeyTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPrivateKeyTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/DSAPrivateKeyTest.java (working copy)
@@ -19,10 +19,11 @@
* @version $Revision$
*/
-package java.security.interfaces;
+package org.apache.harmony.security.tests.java.security.interfaces;
import java.math.BigInteger;
+import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPrivateKey;
import junit.framework.TestCase;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPrivateKeyTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPrivateKeyTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/ECPrivateKeyTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.interfaces;
+package org.apache.harmony.security.tests.java.security.interfaces;
import java.math.BigInteger;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPublicKeyTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPublicKeyTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/interfaces/RSAPublicKeyTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.interfaces;
+package org.apache.harmony.security.tests.java.security.interfaces;
import java.math.BigInteger;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java (working copy)
@@ -13,13 +13,13 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.SecurityPermission;
-public class PermissionTest extends junit.framework.TestCase {
+public class Permission2Test extends junit.framework.TestCase {
static class ConcretePermission extends Permission {
public ConcretePermission() {
super("noname");
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyManagementException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyManagementException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyManagementException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.KeyManagementException;
-public class KeyManagementExceptionTest extends junit.framework.TestCase {
+public class KeyManagementException2Test extends junit.framework.TestCase {
/**
* @tests java.security.KeyManagementException#KeyManagementException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessController2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessController2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessController2Test.java (working copy)
@@ -13,13 +13,13 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.AccessController;
import java.security.AllPermission;
import java.security.PrivilegedAction;
-public class AccessControllerTest extends junit.framework.TestCase {
+public class AccessController2Test extends junit.framework.TestCase {
/**
* @tests java.security.AccessController#doPrivileged(java.security.PrivilegedAction)
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.KeyException;
-public class KeyExceptionTest extends junit.framework.TestCase {
+public class KeyException2Test extends junit.framework.TestCase {
/**
* @tests java.security.KeyException#KeyException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameters2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameters2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameters2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.IOException;
import java.math.BigInteger;
@@ -25,7 +25,7 @@
import java.security.spec.InvalidParameterSpecException;
import java.util.Arrays;
-public class AlgorithmParametersTest extends junit.framework.TestCase {
+public class AlgorithmParameters2Test extends junit.framework.TestCase {
/**
* @tests java.security.AlgorithmParameters#getAlgorithm()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidKeyException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidKeyException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidKeyException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.InvalidKeyException;
-public class InvalidKeyExceptionTest extends junit.framework.TestCase {
+public class InvalidKeyException2Test extends junit.framework.TestCase {
/**
* @tests java.security.InvalidKeyException#InvalidKeyException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermission2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermission2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermission2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.SecurityPermission;
-public class SecurityPermissionTest extends junit.framework.TestCase {
+public class SecurityPermission2Test extends junit.framework.TestCase {
/**
* @tests java.security.SecurityPermission#SecurityPermission(java.lang.String)
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlException2Test.java (working copy)
@@ -13,12 +13,12 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.FilePermission;
import java.security.AccessControlException;
-public class AccessControlExceptionTest extends junit.framework.TestCase {
+public class AccessControlException2Test extends junit.framework.TestCase {
FilePermission filePermission;
AccessControlException acException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GeneralSecurityException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GeneralSecurityException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GeneralSecurityException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.GeneralSecurityException;
-public class GeneralSecurityExceptionTest extends junit.framework.TestCase {
+public class GeneralSecurityException2Test extends junit.framework.TestCase {
/**
* @tests java.security.GeneralSecurityException#GeneralSecurityException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.UnrecoverableKeyException;
-public class UnrecoverableKeyExceptionTest extends junit.framework.TestCase {
+public class UnrecoverableKeyException2Test extends junit.framework.TestCase {
/**
* @tests java.security.UnrecoverableKeyException#UnrecoverableKeyException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.KeyStoreException;
-public class KeyStoreExceptionTest extends junit.framework.TestCase {
+public class KeyStoreException2Test extends junit.framework.TestCase {
/**
* @tests java.security.KeyStoreException#KeyStoreException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
@@ -21,7 +21,7 @@
import java.security.SecureRandom;
import java.security.Security;
-public class SecureRandomTest extends junit.framework.TestCase {
+public class SecureRandom2Test extends junit.framework.TestCase {
private static final byte[] SEED_BYTES = { (byte) 33, (byte) 15, (byte) -3,
(byte) 22, (byte) 77, (byte) -16, (byte) -33, (byte) 56 };
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/BasicPermission2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/BasicPermission2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/BasicPermission2Test.java (working copy)
@@ -13,12 +13,12 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.BasicPermission;
import java.security.PermissionCollection;
-public class BasicPermissionTest extends junit.framework.TestCase {
+public class BasicPermission2Test extends junit.framework.TestCase {
public static class BasicPermissionSubclass extends BasicPermission {
public BasicPermissionSubclass(String name) {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.Provider;
-public class ProviderTest extends junit.framework.TestCase {
+public class Provider2Test extends junit.framework.TestCase {
class TestProvider extends Provider {
TestProvider(String name, double version, String info) {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator3Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.math.BigInteger;
import java.security.AlgorithmParameterGenerator;
@@ -25,7 +25,7 @@
import java.security.Security;
import java.security.spec.DSAParameterSpec;
-public class AlgorithmParameterGeneratorTest extends junit.framework.TestCase {
+public class AlgorithmParameterGenerator3Test extends junit.framework.TestCase {
/**
* @tests java.security.AlgorithmParameterGenerator#generateParameters()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.File;
import java.io.IOException;
@@ -28,7 +28,7 @@
import tests.support.Support_GetLocal;
-public class SecureClassLoaderTest extends junit.framework.TestCase {
+public class SecureClassLoader2Test extends junit.framework.TestCase {
/**
* @tests java.security.SecureClassLoader#getPermissions(java.security.CodeSource)
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java (working copy)
@@ -13,12 +13,12 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.IOException;
import java.security.PrivilegedActionException;
-public class PrivilegedActionExceptionTest extends junit.framework.TestCase {
+public class PrivilegedActionException2Test extends junit.framework.TestCase {
/**
* @tests java.security.PrivilegedActionException#PrivilegedActionException(java.lang.Exception)
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -21,7 +21,7 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-public class DigestInputStreamTest extends junit.framework.TestCase {
+public class DigestInputStream2Test extends junit.framework.TestCase {
ByteArrayInputStream inStream;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
@@ -28,7 +28,7 @@
import java.util.Enumeration;
import java.util.Vector;
-public class MessageDigestTest extends junit.framework.TestCase {
+public class MessageDigest2Test extends junit.framework.TestCase {
private static final String MESSAGEDIGEST_ID = "MessageDigest.";
@@ -419,7 +419,7 @@
Enumeration e = provider.keys();
while (e.hasMoreElements()) {
String algorithm = (String) e.nextElement();
- if (algorithm.startsWith(MESSAGEDIGEST_ID)) {
+ if (algorithm.startsWith(MESSAGEDIGEST_ID) && !algorithm.contains(" ")) {
algs.addElement(algorithm.substring(MESSAGEDIGEST_ID.length()));
}
}// end while
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.NoSuchAlgorithmException;
-public class NoSuchAlgorithmExceptionTest extends junit.framework.TestCase {
+public class NoSuchAlgorithmException2Test extends junit.framework.TestCase {
/**
* @tests java.security.NoSuchAlgorithmException#NoSuchAlgorithmException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signer2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signer2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signer2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.IdentityScope;
import java.security.KeyManagementException;
@@ -21,9 +21,9 @@
import java.security.KeyPairGenerator;
import java.security.Signer;
-import tests.api.java.security.IdentityScopeTest.IdentityScopeSubclass;
+import org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass;
-public class SignerTest extends junit.framework.TestCase {
+public class Signer2Test extends junit.framework.TestCase {
public class SignerImpl extends Signer {
public SignerImpl() {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -27,9 +27,9 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
-import tests.api.java.security.IdentityScopeTest.IdentityScopeSubclass;
+import org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass;
-public class IdentityTest extends junit.framework.TestCase {
+public class Identity2Test extends junit.framework.TestCase {
static PublicKey pubKey;
static {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.NoSuchProviderException;
-public class NoSuchProviderExceptionTest extends junit.framework.TestCase {
+public class NoSuchProviderException2Test extends junit.framework.TestCase {
/**
* @tests java.security.NoSuchProviderException#NoSuchProviderException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java (working copy)
@@ -19,13 +19,12 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CRLException;
import junit.framework.TestCase;
-
/**
* Tests for CRLException class constructors and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderExceptionTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertPathBuilderException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExceptionTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertificateException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java (working copy)
@@ -19,20 +19,23 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
+import java.security.cert.CertPathBuilder;
+import java.security.cert.CertPathBuilderException;
+import java.security.cert.CertPathBuilderSpi;
+import java.security.cert.CertificateException;
import org.apache.harmony.security.tests.support.SpiEngUtils;
+import org.apache.harmony.security.tests.support.cert.MyCertPathBuilderSpi;
import junit.framework.TestCase;
-
-
/**
* Tests for CertPathBuilder class constructors and
* methods.
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator2Test.java (working copy)
@@ -19,19 +19,22 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
+import java.security.cert.CertPathValidator;
+import java.security.cert.CertPathValidatorException;
+import org.apache.harmony.security.tests.java.security.cert.CertPathValidator1Test;
import org.apache.harmony.security.tests.support.SpiEngUtils;
+import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
import junit.framework.TestCase;
-
/**
* Tests for CertPathValidator class constructors and methods
*
@@ -40,7 +43,7 @@
public class CertPathValidator2Test extends TestCase {
private static final String defaultAlg = "CertPB";
- public static final String CertPathValidatorProviderClass = "java.security.cert.MyCertPathValidatorSpi";
+ public static final String CertPathValidatorProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi";
private static final String[] invalidValues = SpiEngUtils.invalidValues;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java (working copy)
@@ -19,12 +19,13 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidParameterException;
import java.security.KeyStore;
-import java.security.KeyStoreException;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.PKIXParameters;
+import java.security.cert.X509CertSelector;
import java.util.HashSet;
import java.util.Set;
@@ -32,7 +33,6 @@
import junit.framework.TestCase;
-
/**
* Tests for PKIXBuilderParameters fields and methods
*
@@ -166,71 +166,6 @@
}
/**
- * Test #1 for PKIXBuilderParameters(KeyStore, CertSelector)
- * constructor
- * Assertion: creates an instance of PKIXBuilderParameters
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector01()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // both parameters are valid and non-null
- PKIXParameters p =
- new PKIXBuilderParameters(ks, new X509CertSelector());
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNotNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #2 for PKIXBuilderParameters(KeyStore, CertSelector)
- * constructor
- * Assertion: creates an instance of PKIXBuilderParameters
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector02()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // both parameters are valid but CertSelector is null
- PKIXParameters p =
- new PKIXBuilderParameters(ks, null);
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #3 for PKIXBuilderParameters(KeyStore, CertSelector)
- * constructor
- * Assertion: Only keystore entries that contain trusted
- * X509Certificates are considered; all other
- * certificate types are ignored
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector03()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // both parameters are valid but CertSelector is null
- PKIXParameters p =
- new PKIXBuilderParameters(ks, null);
- assertTrue("instanceof", p instanceof PKIXBuilderParameters);
- assertEquals("size", 1, p.getTrustAnchors().size());
- }
-
- /**
* Test #4 for PKIXBuilderParameters(KeyStore, CertSelector)
* constructor
* Assertion: NullPointerException -
@@ -245,131 +180,4 @@
}
}
- /**
- * Test #5 for PKIXBuilderParameters(KeyStore, CertSelector)
- * constructor
- * Assertion: KeyStoreException -
- * if the keystore has not been initialized
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector05() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(false, 0);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- // pass not initialized KeyStore
- new PKIXBuilderParameters(ks, null);
- fail("KeyStoreException expected");
- } catch (KeyStoreException e) {
- }
- }
-
- /**
- * Test #6 for PKIXBuilderParameters(KeyStore, CertSelector)
- * constructor
- * Assertion: InvalidAlgorithmParameterException -
- * if the keystore does not contain at least one
- * trusted certificate entry
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector06() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- return;
- }
-
- try {
- // pass KeyStore that does not contain trusted certificates
- new PKIXBuilderParameters(ks, null);
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
- * Test for getMaxPathLength() method
- * Assertion: The default maximum path length, if not specified, is 5
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- */
- public final void testGetMaxPathLength01()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
- assertEquals(DEFAULT_MAX_PATH_LEN, p.getMaxPathLength());
- }
-
- /**
- * Test #1 for setMaxPathLength(int) method
- * Assertion: sets the maximum number of non-self-signed certificates
- * in the cert path
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- */
- public final void testSetMaxPathLength01()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // all these VALID maxPathLength values must be
- // set (and get) without exceptions
- int[] testPathLength = new int[] {-1, 0, 1, 999, Integer.MAX_VALUE};
- for (int i=0; isetMaxPathLength(int) method
- * Assertion: throws InvalidParameterException if parameter is
- * less than -1
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testSetMaxPathLength02()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
-
- try {
- // pass parameter less than -1
- p.setMaxPathLength(Integer.MIN_VALUE);
- fail("InvalidParameterException expected");
- } catch (InvalidParameterException e) {
- }
- }
-
- /**
- * Test for toString() method
- * Assertion: returns string describing this object
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testToString()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true,TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- PKIXBuilderParameters p =
- new PKIXBuilderParameters(ks, new X509CertSelector());
- String rep = p.toString();
-
- assertNotNull(rep);
- }
-
}
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.math.BigInteger;
import java.security.InvalidKeyException;
@@ -29,7 +29,10 @@
import java.security.PublicKey;
import java.security.SignatureException;
import java.security.cert.CRLException;
+import java.security.cert.Certificate;
+import java.security.cert.X509CRL;
import java.security.cert.X509CRLEntry;
+import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.Set;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CollectionCertStoreParametersTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CollectionCertStoreParametersTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CollectionCertStoreParametersTest.java (working copy)
@@ -19,8 +19,10 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
+import java.security.cert.CertStoreParameters;
+import java.security.cert.CollectionCertStoreParameters;
import java.util.Collection;
import java.util.Vector;
@@ -28,7 +30,6 @@
import junit.framework.TestCase;
-
/**
* Tests for CollectionCertStoreParameters
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntry2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntry2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntry2Test.java (working copy)
@@ -13,10 +13,9 @@
* limitations under the License.
*/
-package tests.api.java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.InputStream;
-import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Iterator;
@@ -24,8 +23,10 @@
import tests.support.resource.Support_Resources;
-public class X509CRLEntryTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
+public class X509CRLEntry2Test extends junit.framework.TestCase {
+
private X509Certificate pemCert = null;
protected void setUp() throws Exception {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java (working copy)
@@ -19,17 +19,19 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
+import java.security.cert.PKIXCertPathValidatorResult;
+import java.security.cert.PolicyNode;
+import java.security.cert.TrustAnchor;
import java.security.spec.InvalidKeySpecException;
import org.apache.harmony.security.tests.support.cert.TestUtils;
import junit.framework.TestCase;
-
/**
* Tests for PKIXCertPathValidatorResult
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java (working copy)
@@ -19,10 +19,14 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
+import java.security.cert.CertPath;
+import java.security.cert.CertPathBuilderResult;
+import java.security.cert.PKIXCertPathBuilderResult;
+import java.security.cert.TrustAnchor;
import java.security.spec.InvalidKeySpecException;
import org.apache.harmony.security.tests.support.cert.MyCertPath;
@@ -30,7 +34,6 @@
import junit.framework.TestCase;
-
/**
* Tests for PKIXCertPathBuilderResult
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
+import java.security.cert.CRL;
+
import org.apache.harmony.security.tests.support.cert.MyCRL;
import junit.framework.TestCase;
-
/**
* Tests for java.security.cert.CRL fields and methods
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateTest.java (working copy)
@@ -19,18 +19,20 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SignatureException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
import org.apache.harmony.security.tests.support.cert.MyCertificate;
import junit.framework.TestCase;
-
/**
* Tests for Certificate fields and methods
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRL2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRL2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRL2Test.java (working copy)
@@ -13,10 +13,9 @@
* limitations under the License.
*/
-package tests.api.java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.InputStream;
-import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Iterator;
@@ -24,8 +23,10 @@
import tests.support.resource.Support_Resources;
-public class X509CRLTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
+public class X509CRL2Test extends junit.framework.TestCase {
+
private X509Certificate pemCert = null;
protected void setUp() throws Exception {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreExceptionTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreExceptionTest.java (working copy)
@@ -19,13 +19,12 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertStoreException;
import junit.framework.TestCase;
-
/**
* Tests for CertStoreException class constructors and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509Certificate2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509Certificate2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509Certificate2Test.java (working copy)
@@ -13,10 +13,9 @@
* limitations under the License.
*/
-package tests.api.java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.InputStream;
-import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Iterator;
@@ -24,7 +23,9 @@
import tests.support.resource.Support_Resources;
-public class X509CertificateTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
+
+public class X509Certificate2Test extends junit.framework.TestCase {
private X509Certificate pemCert = null;
protected void setUp() throws Exception {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStore1Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStore1Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStore1Test.java (working copy)
@@ -19,21 +19,27 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
+import java.security.cert.CertStore;
+import java.security.cert.CertStoreException;
+import java.security.cert.CertStoreParameters;
+import java.security.cert.CertStoreSpi;
+import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.LDAPCertStoreParameters;
import java.util.Collection;
import org.apache.harmony.security.tests.support.SpiEngUtils;
+import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters;
+import org.apache.harmony.security.tests.support.cert.MyCertStoreSpi;
import junit.framework.TestCase;
-
-
/**
* Tests for CertStore class constructors and
* methods.
@@ -205,37 +211,6 @@
}
}
}
- /**
- * Test for getInstance(String type, CertStoreParameters params) method
- * Assertion: throws InvalidAlgorithmParameterException when params is not LDAP
- * or null
- */
- public void testCertStore04() throws NoSuchAlgorithmException {
- if (!initParams()) {
- return;
- }
- CertStoreParameters paramsNull = null;
- CertStoreParameters paramsContr = null;
- if (CollectionSupport) {
- if (LDAPSupport) {
- paramsContr = new LDAPCertStoreParameters();
- }
- }
- for (int i = 0; i < dValid.length; i++ ) {
- try {
- CertStore.getInstance(dValid[i], paramsNull);
- fail("InvalidAlgorithmParameterException must be thrown when params null");
- } catch (InvalidAlgorithmParameterException e) {
- }
- if (paramsContr != null) {
- try {
- CertStore.getInstance(dValid[i], paramsContr);
- fail("InvalidAlgorithmParameterException must be thrown when params has incorrect type");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
- }
/**
* Test for getInstance(String type, CertStoreParameters params) method
@@ -327,41 +302,8 @@
} catch (NoSuchAlgorithmException e) {
}
}
+
/**
- * Test for method
- * getInstance(String type, CertStoreParameters params, String provider)
- * Assertion: throws InvalidAlgorithmParameterException when params is null
- * or has invalid value
- */
- public void testCertStore09()
- throws NoSuchProviderException, NoSuchAlgorithmException,
- InvalidAlgorithmParameterException {
- if (!initParams()) {
- return;
- }
- CertStoreParameters paramsNull = null;
- CertStoreParameters paramsContr = null;
- if (CollectionSupport) {
- if (LDAPSupport) {
- paramsContr = new LDAPCertStoreParameters();
- }
- }
- for (int i = 0; i < dValid.length; i++ ) {
- try {
- CertStore.getInstance(dValid[i], paramsNull, dName);
- fail("InvalidAlgorithmParameterException must be thrown when params null");
- } catch (InvalidAlgorithmParameterException e) {
- }
- if (paramsContr != null) {
- try {
- CertStore.getInstance(dValid[i], paramsContr, dName);
- fail("InvalidAlgorithmParameterException must be thrown when params has incorrect type");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
- }
- /**
* Test for method
* getInstance(String type, CertStoreParameters params, String provider)
* Assertion: return CertStore object
@@ -425,40 +367,8 @@
}
}
}
+
/**
- * Test for method
- * getInstance(String type, CertStoreParameters params, Provider provider)
- * Assertion: throws InvalidAlgorithmParameterExceptio when params is null
- * or has invalid value
- */
- public void testCertStore13()
- throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
- if (!initParams()) {
- return;
- }
- CertStoreParameters paramsNull = null;
- CertStoreParameters paramsContr = null;
- if (CollectionSupport) {
- if (LDAPSupport) {
- paramsContr = new LDAPCertStoreParameters();
- }
- }
- for (int i = 0; i < dValid.length; i++ ) {
- try {
- CertStore.getInstance(dValid[i], paramsNull, dProv);
- fail("InvalidAlgorithmParameterException must be thrown when params null");
- } catch (InvalidAlgorithmParameterException e) {
- }
- if (paramsContr != null) {
- try {
- CertStore.getInstance(dValid[i], paramsContr, dProv);
- fail("InvalidAlgorithmParameterException must be thrown when params has incorrect type");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
- }
- }
- /**
* Test for method
* getInstance(String type, CertStoreParameters params, Provider provider)
* Assertion: return CertStore object
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java (working copy)
@@ -18,7 +18,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -28,6 +28,13 @@
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
+import java.security.cert.CRL;
+import java.security.cert.CRLException;
+import java.security.cert.CertPath;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CertificateFactorySpi;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -36,10 +43,10 @@
import org.apache.harmony.security.tests.support.SpiEngUtils;
import org.apache.harmony.security.tests.support.cert.MyCertPath;
import org.apache.harmony.security.tests.support.cert.MyCertificate;
+import org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi;
import junit.framework.TestCase;
-
/**
* Tests for CertificateFactory class methods and constructor
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderSpiTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderSpiTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilderSpiTest.java (working copy)
@@ -19,11 +19,18 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
-import junit.framework.TestCase;
import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CertPathBuilderException;
+import java.security.cert.CertPathBuilderResult;
+import java.security.cert.CertPathBuilderSpi;
+import java.security.cert.CertPathParameters;
+import org.apache.harmony.security.tests.support.cert.MyCertPathBuilderSpi;
+
+import junit.framework.TestCase;
+
/**
* Tests for CertPathBuilderSpi class constructors and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.File;
import java.io.FileInputStream;
@@ -27,16 +27,20 @@
import java.io.IOException;
import java.security.NoSuchProviderException;
import java.security.Provider;
+import java.security.cert.CertPath;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-import junit.framework.TestCase;
-
+import org.apache.harmony.security.tests.java.security.cert.CertificateFactory1Test;
import org.apache.harmony.security.tests.support.SpiEngUtils;
import org.apache.harmony.security.tests.support.TestUtils;
+import junit.framework.TestCase;
/**
* Tests for CertificateFactory class methods
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorExceptionTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorExceptionTest.java (working copy)
@@ -19,10 +19,14 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertPath;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Vector;
import junit.framework.TestCase;
@@ -401,4 +405,38 @@
}
}
}
+
+ class myCertPath extends CertPath {
+
+ public List getCertificates() {
+ return new Vector();
+ }
+
+ public byte[] getEncoded() {
+ return new byte[0];
+ }
+
+ public byte[] getEncoded(String s) {
+ return new byte[0];
+ }
+
+ public Iterator getEncodings() {
+ return (Iterator) (new StringTokenizer("ss ss ss ss"));
+ }
+
+ protected myCertPath(String s) {
+ super(s);
+ }
+
+ public CertPath get(String s) {
+ return new myCertPath(s);
+ }
+
+ public myCertPath(String s, String s1) {
+ super(s);
+ }
+
+ }
}
+
+
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/LDAPCertStoreParametersTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/LDAPCertStoreParametersTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/LDAPCertStoreParametersTest.java (working copy)
@@ -19,8 +19,11 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
+import java.security.cert.CertStoreParameters;
+import java.security.cert.LDAPCertStoreParameters;
+
import junit.framework.TestCase;
/**
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java (working copy)
@@ -19,13 +19,20 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertPathParameters;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.CertStore;
+import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.PKIXCertPathChecker;
+import java.security.cert.PKIXParameters;
+import java.security.cert.X509CertSelector;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
@@ -36,7 +43,6 @@
import junit.framework.TestCase;
-
/**
* Tests for PKIXParameters fields and methods
*
@@ -153,46 +159,6 @@
}
/**
- * Test #1 for PKIXParameters(KeyStore) constructor
- * Assertion: Creates an instance of PKIXParameters
- * that populates the set of most-trusted CAs from the trusted
- * certificate entries contained in the specified KeyStore
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXParametersKeyStore01() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- // use valid parameter - KeyStore containing
- // only trusted X.509 certificates
- CertPathParameters cpp = new PKIXParameters(ks);
- assertTrue(cpp instanceof PKIXParameters);
- }
-
- /**
- * Test #2 for PKIXParameters(KeyStore) constructor
- * Assertion: Only keystore entries that contain trusted
- * X509Certificates are considered; all other
- * certificate types are ignored
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXParametersKeyStore02() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- // use valid parameter - KeyStore containing
- // both trusted and untrusted X.509 certificates
- PKIXParameters cpp = new PKIXParameters(ks);
- assertEquals("size", 1, cpp.getTrustAnchors().size());
- }
-
- /**
* Test #3 for PKIXParameters(KeyStore) constructor
* Assertion: NullPointerException -
* if the keystore is null
@@ -209,45 +175,6 @@
}
/**
- * Test #4 for PKIXParameters(KeyStore) constructor
- * Assertion: KeyStoreException -
- * if the keystore has not been initialized
- */
- public final void testPKIXParametersKeyStore04() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(false, 0);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- // pass not initialized KeyStore
- new PKIXParameters(ks);
- fail("KeyStoreException expected");
- } catch (KeyStoreException e) {
- }
- }
-
- /**
- * Test #5 for PKIXParameters(KeyStore) constructor
- * Assertion: InvalidAlgorithmParameterException -
- * if the keystore does not contain at least one
- * trusted certificate entry
- */
- public final void testPKIXParametersKeyStore05() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- // pass KeyStore that does not contain trusted certificates
- new PKIXParameters(ks);
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
* Test #1 for getPolicyQualifiersRejected() method
* Assertion: When a PKIXParameters object is created,
* this flag is set to true
@@ -1352,161 +1279,4 @@
}
}
- /**
- * Test #5 for setTrustAnchors(Set) method
- * Assertion: Set is copied to protect against
- * subsequent modifications
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testSetTrustAnchors05() throws Exception {
- // use several trusted certs in this test
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- PKIXParameters p = new PKIXParameters(ks);
- // prepare new Set
- HashSet newSet = new HashSet(p.getTrustAnchors());
- HashSet newSetCopy = (HashSet)newSet.clone();
- // set new Set
- p.setTrustAnchors(newSetCopy);
- // modify set - remove one element
- assertTrue("modified", newSetCopy.remove(newSetCopy.iterator().next()));
- // check that set maintained internally has
- // not been changed by the above modification
- assertEquals("isCopied", newSet, p.getTrustAnchors());
- }
-
- /**
- * Test #1 for clone() method
- * Assertion: Makes a copy of this PKIXParameters object
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- * @throws NoSuchAlgorithmException
- */
- public final void testClone01() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- PKIXParameters p1 = new PKIXParameters(ks);
- // set to some non-default values
- p1.setPolicyQualifiersRejected(false);
- p1.setAnyPolicyInhibited(true);
- p1.setExplicitPolicyRequired(true);
- p1.setPolicyMappingInhibited(true);
- p1.setRevocationEnabled(false);
-
- String sigProviderName = "Some Provider";
- p1.setSigProvider(sigProviderName);
-
- X509CertSelector x509cs = new X509CertSelector();
- p1.setTargetCertConstraints(x509cs);
-
- p1.setCertStores(TestUtils.getCollectionCertStoresList());
-
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p1.setCertPathCheckers(l);
-
- p1.setDate(new Date(555L));
-
- Set s = new HashSet();
- s.add("1.2.3.4.5.6.7");
- s.add("1.2.3.4.5.6.8");
- p1.setInitialPolicies(s);
-
- // TrustAnchors already set
-
- PKIXParameters p2 = (PKIXParameters)p1.clone();
-
- // check that objects match
- assertEquals("check1", p1.getPolicyQualifiersRejected(),
- p2.getPolicyQualifiersRejected());
- assertEquals("check2", p1.isAnyPolicyInhibited(),
- p2.isAnyPolicyInhibited());
- assertEquals("check3", p1.isExplicitPolicyRequired(),
- p2.isExplicitPolicyRequired());
- assertEquals("check4", p1.isPolicyMappingInhibited(),
- p2.isPolicyMappingInhibited());
- assertEquals("check5", p1.isRevocationEnabled(),
- p2.isRevocationEnabled());
- assertEquals("check6", p1.getSigProvider(), p2.getSigProvider());
-
- // just check that not null
- assertNotNull("check7", p2.getTargetCertConstraints());
-
- assertEquals("check8", p1.getCertStores(), p2.getCertStores());
-
- // just check that not empty
- assertFalse("check9", p2.getCertPathCheckers().isEmpty());
-
- assertEquals("check10", p1.getDate(), p2.getDate());
- assertEquals("check11", p1.getInitialPolicies(),
- p2.getInitialPolicies());
- assertEquals("check12", p1.getTrustAnchors(), p2.getTrustAnchors());
- }
-
- /**
- * Test #2 for clone() method
- * Assertion: Changes to the copy will not affect
- * the original and vice versa
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- * @throws NoSuchAlgorithmException
- */
- public final void testClone02() throws Exception {
- PKIXParameters[] p = new PKIXParameters[2];
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- for (int i = 0; itoString() method
- * Assertion: Returns a formatted string describing the parameters
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testToString() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- PKIXParameters p = new PKIXParameters(ks);
- assertNotNull(p.toString());
- }
-
}
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java (working copy)
@@ -19,22 +19,25 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
+import java.security.cert.CertPathParameters;
+import java.security.cert.CertPathValidator;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.CertPathValidatorSpi;
+import java.security.cert.CertificateException;
import org.apache.harmony.security.tests.support.SpiEngUtils;
import org.apache.harmony.security.tests.support.cert.MyCertPath;
+import org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi;
import junit.framework.TestCase;
-
-
-
/**
* Tests for CertPathValidator class constructors and
* methods.
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java (working copy)
@@ -19,19 +19,23 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
+import java.security.cert.CertPathBuilder;
+import java.security.cert.CertPathBuilderException;
+import java.security.cert.CertPathBuilderResult;
+import org.apache.harmony.security.tests.java.security.cert.CertPathBuilder1Test;
import org.apache.harmony.security.tests.support.SpiEngUtils;
+import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
import junit.framework.TestCase;
-
/**
* Tests for CertPathBuilder class constructors and methods
*
@@ -39,7 +43,7 @@
public class CertPathBuilder2Test extends TestCase {
private static final String defaultAlg = "CertPB";
- private static final String CertPathBuilderProviderClass = "java.security.cert.MyCertPathBuilderSpi";
+ private static final String CertPathBuilderProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertPathBuilderSpi";
private static final String[] invalidValues = SpiEngUtils.invalidValues;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator3Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator3Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator3Test.java (working copy)
@@ -19,14 +19,20 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
+import java.security.cert.CertPathParameters;
+import java.security.cert.CertPathValidator;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.PKIXParameters;
+import org.apache.harmony.security.tests.java.security.cert.CertPathBuilder1Test;
+import org.apache.harmony.security.tests.java.security.cert.CertPathValidator1Test;
import org.apache.harmony.security.tests.support.SpiEngUtils;
import org.apache.harmony.security.tests.support.cert.MyCertPath;
import org.apache.harmony.security.tests.support.cert.TestUtils;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingExceptionTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertificateEncodingException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactoryTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactoryTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactoryTest.java (working copy)
@@ -1,222 +0,0 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.
- */
-
-/**
- * @author Alexander Y. Kleymenov
- * @version $Revision$
- */
-
-package org.apache.harmony.security.tests.java.security.cert;
-
-import java.io.ByteArrayInputStream;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509CRL;
-import java.security.cert.X509Certificate;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.Collection;
-import java.util.Iterator;
-import org.apache.harmony.luni.util.Base64;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * X.509 CertificateFactory provider implementation test.
- * See RFC 3280 (http://www.ietf.org/rfc/rfc3280.txt) for
- * more information on X.509, and
- * http://www.rsasecurity.com/rsalabs/node.asp?id=2129
- * for more information on PKCS #7.
- * The testing data was generated by use of classes from
- * org.apache.harmony.security.x509 package.
- */
-public class CertificateFactoryTest extends TestCase {
-
- /**
- * Base64 encoded PKCS7 SignedObject containing two X.509 CRLs.
- */
- private static String pkcs7so =
- "MIIHBQYJKoZIhvcNAQcCoIIG9jCCBvICAQExADALBgkqhkiG9w0BBwGg"
- + "ggUkMIICjjCCAk6gAwIBAgICAiswCQYHKoZIzjgEAzAdMRswGQYDVQQK"
- + "ExJDZXJ0aWZpY2F0ZSBJc3N1ZXIwHhcNMDYwNTE4MDUxMzQzWhcNMzMx"
- + "MDA3MDQxNzM5WjAdMRswGQYDVQQKExJDZXJ0aWZpY2F0ZSBJc3N1ZXIw"
- + "ggG4MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11EilS30qcLuzk5/YR"
- + "t1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv"
- + "8mZgt2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7D"
- + "AjVUE1oWkTL2dfOuK2HXKu/yIgMZndFIAccCFQCXYFCPFSMLzLKSuYKi"
- + "64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o66oL5V0wLPQeC"
- + "Z1FZV4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjg"
- + "o64eK7OmdZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8Gkotm"
- + "XoB7VSVkAUw7/s9JKgOBhQACgYEA8EFZqbP1i1VG045DPX+glAxnOs3C"
- + "PKiX9vnqWbDh4EVANHgCq9fwsuFModO1OTc0tA7CY386PJKGppcELlva"
- + "foPw6Qsp59980E7mwa6deTmdwdjXH9uP7/niZ4hVA+xHiFXl4oJeroq/"
- + "/pcNOCjo7ZujYc954kDiyUsGBsP0uaejHjAcMBoGA1UdEQEB/wQQMA6B"
- + "DHJmY0A4MjIuTmFtZTAJBgcqhkjOOAQDAy8AMCwCFB5XdhSOXmUNJfRL"
- + "l5gYDo4XsZeJAhR6Yueam/MwyEcA8/SG1Xr1/WJnlDCCAo4wggJOoAMC"
- + "AQICAgIrMAkGByqGSM44BAMwHTEbMBkGA1UEChMSQ2VydGlmaWNhdGUg"
- + "SXNzdWVyMB4XDTA2MDUxODA1MTM0M1oXDTMzMTAwNzA0MTczOVowHTEb"
- + "MBkGA1UEChMSQ2VydGlmaWNhdGUgSXNzdWVyMIIBuDCCASwGByqGSM44"
- + "BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZp"
- + "RV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7"
- + "ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith"
- + "1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmCouuEC/BYHPUCgYEA9+Gg"
- + "hdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCB"
- + "gLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/oh"
- + "NWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoD"
- + "gYUAAoGBAPBBWamz9YtVRtOOQz1/oJQMZzrNwjyol/b56lmw4eBFQDR4"
- + "AqvX8LLhTKHTtTk3NLQOwmN/OjyShqaXBC5b2n6D8OkLKefffNBO5sGu"
- + "nXk5ncHY1x/bj+/54meIVQPsR4hV5eKCXq6Kv/6XDTgo6O2bo2HPeeJA"
- + "4slLBgbD9Lmnox4wHDAaBgNVHREBAf8EEDAOgQxyZmNAODIyLk5hbWUw"
- + "CQYHKoZIzjgEAwMvADAsAhQeV3YUjl5lDSX0S5eYGA6OF7GXiQIUemLn"
- + "mpvzMMhHAPP0htV69f1iZ5ShggGyMIHWMIGWAgEBMAkGByqGSM44BAMw"
- + "FTETMBEGA1UEChMKQ1JMIElzc3VlchcNMDYwNTE4MDUxMzQ0WhcNMDYw"
- + "NTE4MDUxNTI0WjBAMD4CAgIrFw0wNjA1MTgwNTEzNDVaMCkwCgYDVR0V"
- + "BAMKAQEwGwYDVR0YBBQYEjIwMDYwNTE4MDUxMzQ0Ljg5WqAPMA0wCwYD"
- + "VR0UBAQCAhFcMAkGByqGSM44BAMDMAAwLQIVAIkFZCysgzWYGxIXf+pc"
- + "jMDniwHyAhQfeuU5AQucvJKodpN+yfbQRoFEHTCB1jCBlgIBATAJBgcq"
- + "hkjOOAQDMBUxEzARBgNVBAoTCkNSTCBJc3N1ZXIXDTA2MDUxODA1MTM0"
- + "NFoXDTA2MDUxODA1MTUyNFowQDA+AgICKxcNMDYwNTE4MDUxMzQ1WjAp"
- + "MAoGA1UdFQQDCgEBMBsGA1UdGAQUGBIyMDA2MDUxODA1MTM0NC44OVqg"
- + "DzANMAsGA1UdFAQEAgIRXDAJBgcqhkjOOAQDAzAAMC0CFQCJBWQsrIM1"
- + "mBsSF3/qXIzA54sB8gIUH3rlOQELnLySqHaTfsn20EaBRB0xAA==";
-
- /**
- * Base64 encoded Public Key for signature verification.
- * Key corresponds to the CRLs and Certificates in PKCS7 SignedObject.
- */
- private static String b64PublicKeySpec =
- "MIIBuDCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2"
- + "EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00"
- + "b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208Ue"
- + "wwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmC"
- + "ouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0H"
- + "gmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o"
- + "4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKL"
- + "Zl6Ae1UlZAFMO/7PSSoDgYUAAoGBAPBBWamz9YtVRtOOQz1/oJQMZzrN"
- + "wjyol/b56lmw4eBFQDR4AqvX8LLhTKHTtTk3NLQOwmN/OjyShqaXBC5b"
- + "2n6D8OkLKefffNBO5sGunXk5ncHY1x/bj+/54meIVQPsR4hV5eKCXq6K"
- + "v/6XDTgo6O2bo2HPeeJA4slLBgbD9Lmn";
-
- /**
- * The name of the algorithm used for Certificate/CRL signing.
- */
- private static String publicKeyAlgorithm = "DSA";
-
- /**
- * The public key to verify generated Certificates and CRLs.
- */
- private static PublicKey publicKey;
-
- static {
- try {
- X509EncodedKeySpec publicKeySpec =
- new X509EncodedKeySpec(
- Base64.decode(b64PublicKeySpec.getBytes()));
- KeyFactory keyFactory =
- KeyFactory.getInstance(publicKeyAlgorithm);
- publicKey = keyFactory.generatePublic(publicKeySpec);
- } catch (NoSuchAlgorithmException e) {
- // provider is not installed, will not verify the generated data
- publicKey = null;
- } catch (Exception e) {
- // problems with a representation of the key
- e.printStackTrace();
- publicKey = null;
- }
- }
-
- /**
- * generateCRLs method testing.
- */
- public void testGenerateCRLs() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- // Testing the CRLs generation on the base of PKCS7 SignedData object
- ByteArrayInputStream bais = new ByteArrayInputStream(
- Base64.decode(pkcs7so.getBytes()));
-
- Collection crls = factory.generateCRLs(bais);
- assertNotNull("Factory returned null on correct PKCS7 data", crls);
- assertEquals("The size of collection differs from expected",
- 2, crls.size());
-
- if (publicKey != null) {
- // verify the signatures
- for (Iterator i = crls.iterator(); i.hasNext();) {
- ((X509CRL) i.next()).verify(publicKey);
- }
- }
- }
-
- /**
- * generateCertificates method testing.
- */
- public void testGenerateCertificates() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- // Testing the Certificates generation
- // on the base of PKCS7 SignedData object
- ByteArrayInputStream bais = new ByteArrayInputStream(
- Base64.decode(pkcs7so.getBytes()));
-
- Collection certs = factory.generateCertificates(bais);
- assertNotNull("Factory returned null on correct PKCS7 data", certs);
- assertEquals("The size of collection differs from expected",
- 2, certs.size());
-
- if (publicKey != null) {
- // verify the signatures
- for (Iterator i = certs.iterator(); i.hasNext();) {
- ((X509Certificate) i.next()).verify(publicKey);
- }
- }
- }
-
- /**
- * generateCertificates method testing.
- */
- public void testGenerateCertPath() throws Exception {
- CertificateFactory factory = CertificateFactory.getInstance("X.509");
-
- // Testing the CertPath generation
- // on the base of PKCS7 SignedData object
- ByteArrayInputStream bais = new ByteArrayInputStream(
- Base64.decode(pkcs7so.getBytes()));
-
- Collection certPath =
- factory.generateCertPath(bais, "PKCS7").getCertificates();
- assertEquals("The size of collection differs from expected",
- 2, certPath.size());
-
- if (publicKey != null) {
- // verify the signatures
- for (Iterator i = certPath.iterator(); i.hasNext();) {
- ((X509Certificate) i.next()).verify(publicKey);
- }
- }
- }
-
- public static Test suite() {
- return new TestSuite(CertificateFactoryTest.class);
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-}
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathTest.java (working copy)
@@ -19,13 +19,15 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
+import java.security.cert.CertPath;
+import java.security.cert.CertificateEncodingException;
+
import org.apache.harmony.security.tests.support.cert.MyCertPath;
import junit.framework.TestCase;
-
/**
* Tests for CertPath fields and methods
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchorTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchorTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/TrustAnchorTest.java (working copy)
@@ -19,11 +19,13 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.PublicKey;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509Certificate;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
@@ -34,7 +36,6 @@
import junit.framework.TestCase;
-
/**
* Unit tests for TrustAnchor
*/
@@ -50,353 +51,6 @@
"C=Testland";
/**
- * Constructor for TrustAnchorTest.
- * @param arg0
- */
- public TrustAnchorTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test #1 for TrustAnchor(X509Certificate, byte[]) constructor
- * Assertion: creates TrustAnchor instance
- * Test preconditions: valid parameters passed
- * Expected: must pass without any exceptions
- */
- public final void testTrustAnchorX509CertificatebyteArray01()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- // sub testcase 1
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- getFullEncoding());
- // sub testcase 2
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- getEncodingPSOnly());
- // sub testcase 3
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- getEncodingESOnly());
- // sub testcase 4
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- getEncodingNoMinMax());
- }
-
- /**
- * Test #2 for TrustAnchor(X509Certificate, byte[]) constructor
- * Assertion: creates TrustAnchor instance
- * Test preconditions: null as nameConstraints passed
- * Expected: must pass without any exceptions
- */
- public final void testTrustAnchorX509CertificatebyteArray02()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- null);
- }
-
- /**
- * Test #3 for TrustAnchor(X509Certificate, byte[]) constructor
- * Assertion: nameConstraints cloned by the constructor
- * Test preconditions: modify passed nameConstraints
- * Expected: modification must not change object internal state
- */
- public final void testTrustAnchorX509CertificatebyteArray03()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte[] nc = getEncodingPSOnly();
- byte[] ncCopy = nc.clone();
- // sub testcase 5 - nameConstraints can be null
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- ncCopy);
- // modify
- ncCopy[0]=(byte)0;
- // check that above modification did not change
- // object internal state
- assertTrue(Arrays.equals(nc, ta.getNameConstraints()));
- }
-
- /**
- * Test #4 for TrustAnchor(X509Certificate, byte[]) constructor
- * Assertion: NullPointerException if X509Certificate
- * parameter is null
- * Test preconditions: pass null as X509Certificate
- * Expected: NullPointerException
- */
- public final void testTrustAnchorX509CertificatebyteArray04()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- new TrustAnchor(null, getFullEncoding());
- fail("NullPointerException has not been thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #5 for TrustAnchor(X509Certificate, byte[]) constructor
- * Assertion: IllegalArgumentException if nameConstraints
- * parameter can not be decoded
- * Test preconditions: pass invalid nameConstraints encoding
- * Expected: IllegalArgumentException
- */
- public final void testTrustAnchorX509CertificatebyteArray05()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
-
- // sub testcase 1:
- byte [] nameConstraints = getFullEncoding();
- // corrupt encoding:
- // set wrong root seq length
- nameConstraints[2] = (byte)0x8d;
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 2:
- nameConstraints = getFullEncoding();
- // corrupt encoding:
- // set wrong root seq length
- nameConstraints[2] = (byte)0x8b;
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 3:
- nameConstraints = getFullEncoding();
- // corrupt encoding:
- // remove right class from seq tag
- nameConstraints[3] &= (byte)0x3f;
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 4:
- nameConstraints = getEncodingESOnly();
- // corrupt encoding:
- // set wrong tagged value (excludedSubtrees SEQ OF) tag [2]
- nameConstraints[2] = (byte)0xa2;
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 5:
- nameConstraints = getEncodingESOnly();
- // corrupt encoding:
- // remove CONSTRUCTED flag from tagged value (excludedSubtrees SEQ OF) tag
- nameConstraints[2] &= (byte)0xdf;
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 6:
- nameConstraints = getEncodingESOnly();
- // corrupt encoding:
- // set CONSTRUCTED flag for PROMITIVE tagged value tag
- // (generalSubtree's 'base' as IA5String)
- nameConstraints[5] |= (byte)0x20;
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
-
- // sub testcase 7:
- nameConstraints = getEncodingESOnly();
- // corrupt encoding:
- // remove scheme from URI
- // (generalSubtree's 'base' as IA5String (uniformResourceIdentifier))
- nameConstraints[12] = nameConstraints[13] = nameConstraints[14] =
- (byte)0x6f;
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #6 for TrustAnchor(X509Certificate, byte[]) constructor
- * Assertion: creates TrustAnchor instance
- * Test preconditions: valid parameters passed (base as OID)
- * Expected: must pass without any exceptions
- */
- public final void testTrustAnchorX509CertificatebyteArray06()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte [] nameConstraints = getEncodingOid();
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- nameConstraints);
- }
-
- /**
- * Test #7 for TrustAnchor(X509Certificate, byte[]) constructor
- * Assertion: IllegalArgumentException if nameConstraints
- * parameter can not be decoded
- * Test preconditions: pass invalid nameConstraints (OID) encoding
- * Expected: IllegalArgumentException
- */
- public final void testTrustAnchorX509CertificatebyteArray07()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte [] nameConstraints = getEncodingOid();
- //corrupt Oid
- nameConstraints[10]= (byte) 0xFF;
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- nameConstraints);
- fail("IllegalArgumentException has not been thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test #8 for TrustAnchor(X509Certificate, byte[]) constructor
- * Assertion: IllegalArgumentException if nameConstraints
- * parameter can not be decoded
- * Test preconditions: pass invalid nameConstraints encodings
- * Expected: IllegalArgumentException
- */
- public final void testTrustAnchorX509CertificatebyteArray08()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- // GeneralName tags for this test (1,2 and 3 are omitted)
- byte[] generalNameTag = new byte[] {
- (byte)0xa0,(byte)0xa4,(byte)0xa5,
- (byte)0x86,(byte)0x87,(byte)0x88
- };
- // wrong (for above tags) nameConstraints encoding
- byte[] wrongEncoding = new byte[] {
- (byte)0x30,(byte)0x0c, // sequence + length
- (byte)0xa1,(byte)0x0a, // excluded subtrees, tag, len
- (byte)0x30,(byte)0x08, // sequence of, tag, len
- (byte)0xa0, // element 6 - tag identifying GeneralName choice
- (byte)0x03, // GeneralName length
- (byte)0x01,(byte)0x01,(byte)0xff, // wrong GeneralName for any choice
- (byte)0x80,(byte)0x01,(byte)0x00 // minimum
- };
- for (int i=0; iTrustAnchor(X509Certificate, byte[]) constructor
- * Assertion: IllegalArgumentException if nameConstraints
- * parameter can not be decoded
- * Test preconditions: pass valid and then invalid nameConstraints encodings
- * (GeneralName choice is [0] OtherName)
- * Expected: no exception for valid encoding and IllegalArgumentException for invalid
- * @throws KeyStoreException
- */
- public final void testTrustAnchorX509CertificatebyteArray09()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte[] encoding = new byte[] {
- (byte)0x30,(byte)0x13,(byte)0xa1,(byte)0x11,
- (byte)0x30,(byte)0x0f,(byte)0xa0,(byte)0x0a,
- (byte)0x06,(byte)0x03,(byte)0x00,(byte)0x01,(byte)0x02,
- (byte)0xA0,(byte)0x03,1,1,(byte)0xff,
- (byte)0x80,(byte)0x01,(byte)0x00
- };
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias), encoding);
- } catch (IllegalArgumentException failed) {
- fail("valid encoding not accepted");
- }
- // now corrupt encoding: set OtherName value tag to 1 (must be 0)
- encoding[13] = 1;
- try {
- new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias), encoding);
- fail("invalid encoding accepted");
- } catch (IllegalArgumentException ok) {
- }
- }
- /**
* Test #1 for TrustAnchor(String, PublicKey, byte[]) constructor
* Assertion: creates TrustAnchor instance
* Test preconditions: valid parameters passed
@@ -608,35 +262,6 @@
}
/**
- * Test for getNameConstraints() method
- * Assertion: returns nameConstraints der encoding
- * Test preconditions: valid nameConstraints parameter passed (not null)
- * Expected: encoding passed to the ctor must match returned one
- * Assertion: returns new nameConstraints der encoding each time
- * Test preconditions: valid nameConstraints parameter passed (not null)
- * Expected: must return new reference each time called
- */
- public final void testGetNameConstraints()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "testca1";
- byte[] nc = getFullEncoding();
- // sub testcase 1
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias), nc);
- byte[] ncRet = ta.getNameConstraints();
- // assert 1
- assertTrue(Arrays.equals(nc, ncRet));
- assertNotSame(nc, ncRet);
- // assert 2
- assertNotSame(ncRet, ta.getNameConstraints());
- }
-
- /**
* Test #1 for getCAPublicKey() method
*
* Assertion: returns most trusted CA public key
@@ -658,30 +283,7 @@
assertEquals("equals2", pk, ta.getCAPublicKey());
}
- /**
- * Test #2 for getCAName() method
- *
- * Assertion: returns ... null if TrustAnchor
- * was not specified as public key and CA name or CA principal pair
- * Test preconditions: test object is not specified as public key
- * and CA name or CA principal pair
- * Expected: null as return value
- * @throws KeyStoreException
- *
- */
- public final void testGetCAPublicKey02()
- throws InvalidKeySpecException, KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate)ks.getCertificate("testca1"),
- null);
- assertNull(ta.getCAPublicKey());
- }
-
/**
* Test #1 for getCAName() method
*
@@ -708,51 +310,6 @@
* Test #2 for getCAName() method
*
* Assertion: returns ... null if TrustAnchor
- * was not specified as public key and CA name or CA principal pair
- * Test preconditions: test object is not specified as public key
- * and CA name or CA principal pair
- * Expected: null as return value
- * @throws KeyStoreException
- */
- public final void testGetCAName02()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate)ks.getCertificate("testca1"),
- null);
- assertNull(ta.getCAName());
- }
-
- /**
- * Test #1 for getCAName() method
- *
- * Assertion: returns most trusted CA certificate
- * Test preconditions: valid certificate passed to the constructor
- * Expected: the same certificate must be returned by the method
- * @throws KeyStoreException
- *
- */
- public final void testGetTrustedCert01()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- X509Certificate cert =
- (X509Certificate)ks.getCertificate("testca1");
- TrustAnchor ta = new TrustAnchor(cert, null);
- assertEquals(cert, ta.getTrustedCert());
- }
-
- /**
- * Test #2 for getCAName() method
- *
- * Assertion: returns ... null if TrustAnchor
* was not specified as trusted certificate
* Test preconditions: test object is not specified as trusted certificate
* Expected: null as return value
@@ -797,71 +354,6 @@
assertEquals("equals2", x500p, ta.getCA());
}
- /**
- * Test #2 for getCA() method
- *
- * Assertion: returns ... null if TrustAnchor
- * was not specified as public key and CA name or CA principal pair
- * Test preconditions: test object is not specified as public key
- * and CA name or CA principal pair
- * Expected: null as return value
- * @throws KeyStoreException
- */
- public final void testGetCA02()
- throws KeyStoreException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate)ks.getCertificate("testca1"),
- null);
- assertNull(ta.getCA());
- }
-
- /**
- * Test for toString() method
- *
- * Assertion: returns string representation of this TrustAnchor
- * Test preconditions: several valid test objects created
- * Expected: method returns not null in all cases
- */
- public final void testToString() throws Exception {
-
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- String certAlias = "test";
-
- // sub testcase 1
- TrustAnchor ta = new TrustAnchor(
- (X509Certificate)ks.getCertificate(certAlias),
- getFullEncoding());
-
- assertNotNull("#1", ta.toString());
-
- PublicKey pk = new TestKeyPair(keyAlg).getPublic();
-
-
- // sub testcase 2
- ta = new TrustAnchor(validCaNameRfc2253, pk, getEncodingESOnly());
-
- assertNotNull("#2", ta.toString());
-
- // sub testcase 3
- X500Principal x500p = new X500Principal(validCaNameRfc2253);
- ta = new TrustAnchor(x500p, pk, getEncodingNoMinMax());
-
- assertNotNull("#3", ta.toString());
-
- // sub testcase 4
- ta = new TrustAnchor(x500p, pk, null);
- assertNotNull("#4", ta.toString());
- }
-
//
// Private stuff
//
@@ -1053,14 +545,4 @@
};
}
- // Returns OID encoding
- // (generated by own encoder class created durind test development)
- private static final byte[] getEncodingOid() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte) 0x30, (byte) 0x09, (byte) 0xA0, (byte) 0x07,
- (byte) 0x30, (byte) 0x05, (byte) 0x88, (byte) 0x03,
- (byte) 0x2A, (byte) 0x03, (byte) 0x04
- };
- }
}
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java (working copy)
@@ -18,14 +18,14 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.IOException;
+import java.security.cert.PolicyQualifierInfo;
import java.util.Arrays;
import junit.framework.TestCase;
-
/**
* PolicyQualifierInfo test
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExpiredExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExpiredExceptionTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateExpiredExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertificateExpiredException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateException2Test.java (working copy)
@@ -13,12 +13,14 @@
* limitations under the License.
*/
-package tests.api.java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertificateException;
-public class CertificateExceptionTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
+public class CertificateException2Test extends junit.framework.TestCase {
+
/**
* @tests java.security.cert.CertificateException#CertificateException()
*/
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertificateNotYetValidException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertificateParsingException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java (working copy)
@@ -19,16 +19,23 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.InputStream;
+import java.security.cert.CRL;
+import java.security.cert.CRLException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactorySpi;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi;
+
import junit.framework.TestCase;
/**
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java (working copy)
@@ -19,13 +19,21 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CRL;
+import java.security.cert.CRLSelector;
+import java.security.cert.CertSelector;
+import java.security.cert.CertStoreException;
+import java.security.cert.CertStoreSpi;
+import java.security.cert.Certificate;
+import org.apache.harmony.security.tests.support.cert.MyCertStoreSpi;
+import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters;
+
import junit.framework.TestCase;
-
import junit.framework.Test;
import junit.framework.TestSuite;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.math.BigInteger;
import java.security.cert.CRLException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingException2Test.java (working copy)
@@ -13,12 +13,14 @@
* limitations under the License.
*/
-package tests.api.java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.security.cert.CertificateEncodingException;
-public class CertificateEncodingExceptionTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
+public class CertificateEncodingException2Test extends junit.framework.TestCase {
+
/**
* @tests java.security.cert.CertificateEncodingException#CertificateEncodingException()
*/
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java (working copy)
@@ -19,8 +19,10 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.PKIXCertPathChecker;
import java.util.HashSet;
import org.apache.harmony.security.tests.support.cert.MyCertificate;
@@ -28,7 +30,6 @@
import junit.framework.TestCase;
-
/**
* Tests for PKIXCertPathChecker
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorSpiTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorSpiTest.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidatorSpiTest.java (working copy)
@@ -19,11 +19,19 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
-import junit.framework.TestCase;
import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CertPath;
+import java.security.cert.CertPathParameters;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.CertPathValidatorResult;
+import java.security.cert.CertPathValidatorSpi;
+import org.apache.harmony.security.tests.support.cert.MyCertPathValidatorSpi;
+
+import junit.framework.TestCase;
+
/**
* Tests for CertPathValidatorSpi class constructors and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory2Test.java (working copy)
@@ -19,22 +19,29 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
+import java.security.cert.CRL;
+import java.security.cert.CRLException;
+import java.security.cert.CertPath;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.harmony.security.tests.support.SpiEngUtils;
+import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
+import org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi;
import junit.framework.TestCase;
-
/**
* Tests for CertificateFactory class constructors and methods
*
@@ -42,7 +49,7 @@
public class CertificateFactory2Test extends TestCase {
private static final String defaultAlg = "CertFac";
- private static final String CertificateFactoryProviderClass = "java.security.cert.MyCertificateFactorySpi";
+ private static final String CertificateFactoryProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi";
private static final String[] invalidValues = SpiEngUtils.invalidValues;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -32,8 +32,10 @@
import tests.support.Support_GetResource;
import tests.support.resource.Support_Resources;
-public class CertificateFactoryTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
+public class CertificateFactory4Test extends junit.framework.TestCase {
+
private static final String BASE_URL = Support_GetResource
.getResourceURL("/../internalres/");
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerException2Test.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerException2Test.java (working copy)
@@ -13,12 +13,14 @@
* limitations under the License.
*/
-package tests.api.java.security.acl;
+package org.apache.harmony.security.tests.java.security.acl;
import java.security.acl.LastOwnerException;
-public class LastOwnerExceptionTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
+public class LastOwnerException2Test extends junit.framework.TestCase {
+
/**
* @tests java.security.acl.LastOwnerException#LastOwnerException()
*/
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java (working copy)
@@ -19,12 +19,14 @@
* @version $Revision$
*/
-package java.security.acl;
+package org.apache.harmony.security.tests.java.security.acl;
+import java.security.acl.NotOwnerException;
+
import junit.framework.TestCase;
/**
- * TODO Put your class description here
+ * Unit test for NotOwnerException.
*
*/
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java (working copy)
@@ -19,12 +19,14 @@
* @version $Revision$
*/
-package java.security.acl;
+package org.apache.harmony.security.tests.java.security.acl;
+import java.security.acl.AclNotFoundException;
+
import junit.framework.TestCase;
/**
- * TODO Put your class description here
+ * Unit test for AclNotFoundException.
*
*/
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerException2Test.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerException2Test.java (working copy)
@@ -13,12 +13,14 @@
* limitations under the License.
*/
-package tests.api.java.security.acl;
+package org.apache.harmony.security.tests.java.security.acl;
import java.security.acl.NotOwnerException;
-public class NotOwnerExceptionTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
+public class NotOwnerException2Test extends junit.framework.TestCase {
+
/**
* @tests java.security.acl.NotOwnerException#NotOwnerException()
*/
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java (working copy)
@@ -19,12 +19,14 @@
* @version $Revision$
*/
-package java.security.acl;
+package org.apache.harmony.security.tests.java.security.acl;
+import java.security.acl.LastOwnerException;
+
import junit.framework.TestCase;
/**
- * TODO Put your class description here
+ * Unit test for LastOwnerException.
*
*/
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundException2Test.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundException2Test.java (working copy)
@@ -13,12 +13,14 @@
* limitations under the License.
*/
-package tests.api.java.security.acl;
+package org.apache.harmony.security.tests.java.security.acl;
import java.security.acl.AclNotFoundException;
-public class AclNotFoundExceptionTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
+public class AclNotFoundException2Test extends junit.framework.TestCase {
+
/**
* @tests java.security.acl.AclNotFoundException#AclNotFoundException()
*/
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.DigestException;
-public class DigestExceptionTest extends junit.framework.TestCase {
+public class DigestException2Test extends junit.framework.TestCase {
/**
* @tests java.security.DigestException#DigestException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Policy2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Policy2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Policy2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.AccessControlException;
import java.security.CodeSource;
@@ -21,7 +21,7 @@
import java.security.PermissionCollection;
import java.security.Policy;
-public class PolicyTest extends junit.framework.TestCase {
+public class Policy2Test extends junit.framework.TestCase {
static class TestPolicy extends Policy {
public PermissionCollection getPermissions(CodeSource cs) {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.math.BigInteger;
import java.security.InvalidParameterException;
@@ -24,7 +24,7 @@
import java.security.Signature;
import java.security.spec.DSAParameterSpec;
-public class SignatureTest extends junit.framework.TestCase {
+public class Signature2Test extends junit.framework.TestCase {
private static final String MESSAGE = "abc";
static KeyPair keys;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.InvalidParameterException;
import java.security.Provider;
@@ -28,7 +28,7 @@
import tests.support.Support_ProviderTrust;
import tests.support.Support_TestProvider;
-public class SecurityTest extends junit.framework.TestCase {
+public class Security2Test extends junit.framework.TestCase {
/**
* @tests java.security.Security#getProperty(java.lang.String)
@@ -149,27 +149,6 @@
}
/**
- * This test has been written with the default Harmony security
- * configuration in mind. Recode or else exclude from run if using a
- * different providers configuration. i.e.
- * security.provider.1=org.apache.harmony.security.provider.cert.DRLCertFactory
- * security.provider.2=org.bouncycastle.jce.provider.BouncyCastleProvider
- *
- * @tests java.security.Security#getProviders()
- */
- public void test_getProviders() {
- // Test for method java.security.Provider []
- // java.security.Security.getProviders()
- Provider provTest[] = Security.getProviders();
- assertEquals("the number of providers is not 2 it was: "
- + provTest.length, 2, provTest.length);
- assertEquals("the first provider should be DRLCertFactory", "DRLCertFactory", provTest[0]
- .getName());
- assertEquals("the second provider should be BC", "BC", provTest[1].getName()
- );
- }
-
- /**
* @tests java.security.Security#getProviders(java.lang.String)
*/
public void test_getProvidersLjava_lang_String() {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java (working copy)
@@ -13,14 +13,14 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.File;
import java.io.FilePermission;
import java.security.Permissions;
import java.util.Enumeration;
-public class PermissionsTest extends junit.framework.TestCase {
+public class Permissions2Test extends junit.framework.TestCase {
FilePermission readAllFiles = new FilePermission("<>", "read");
FilePermission alsoReadAllFiles = new FilePermission("<>",
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStream2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStream2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStream2Test.java (working copy)
@@ -13,13 +13,13 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.ByteArrayOutputStream;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
-public class DigestOutputStreamTest extends junit.framework.TestCase {
+public class DigestOutputStream2Test extends junit.framework.TestCase {
ByteArrayOutputStream output1;
ByteArrayOutputStream output2;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
@@ -34,7 +34,7 @@
import java.util.Enumeration;
import java.util.Vector;
-public class KeyFactoryTest extends junit.framework.TestCase {
+public class KeyFactory2Test extends junit.framework.TestCase {
private static final String KEYFACTORY_ID = "KeyFactory.";
@@ -366,7 +366,7 @@
Enumeration e = provider.keys();
while (e.hasMoreElements()) {
String algorithm = (String) e.nextElement();
- if (algorithm.startsWith(KEYFACTORY_ID)) {
+ if (algorithm.startsWith(KEYFACTORY_ID) && !algorithm.contains(" ")) {
algs.addElement(algorithm.substring(KEYFACTORY_ID.length()));
}
}
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AllPermission2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AllPermission2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AllPermission2Test.java (working copy)
@@ -13,12 +13,12 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.AllPermission;
import java.security.SecurityPermission;
-public class AllPermissionTest extends junit.framework.TestCase {
+public class AllPermission2Test extends junit.framework.TestCase {
/**
* @tests java.security.AllPermission#AllPermission()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScope2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScope2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScope2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.Identity;
import java.security.IdentityScope;
@@ -23,9 +23,9 @@
import java.util.Enumeration;
import java.util.Hashtable;
-import tests.api.java.security.IdentityTest.IdentitySubclass;
+import org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass;
-public class IdentityScopeTest extends junit.framework.TestCase {
+public class IdentityScope2Test extends junit.framework.TestCase {
static PublicKey pubKey;
static {
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2mTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2mTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2mTest.java (working copy)
@@ -19,14 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.ECFieldF2m;
import java.util.Arrays;
import junit.framework.TestCase;
-
/**
* Tests for ECFieldF2m class fields and methods.
*
@@ -160,127 +160,6 @@
* Set of parameters used for ECFieldF2m(int, BigInteger)
* constructor tests.
*/
- private final ECFieldF2mDomainParams[] intBigIntegerCtorTestParameters =
- new ECFieldF2mDomainParams[] {
- // set 0: valid m and rp - trinomial basis params
- new ECFieldF2mDomainParams(
- 1999,
- BigInteger.valueOf(0L).setBit(0).setBit(367).setBit(1999),
- null,
- null),
- // set 1: valid m and rp - pentanomial basis params
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(981).setBit(2000),
- null,
- null),
- // set 2: valid m, invalid (null) rp
- new ECFieldF2mDomainParams(
- 1963,
- (BigInteger)null,
- null,
- ECFieldF2mDomainParams.NPE),
- // set 3: valid m, invalid rp - bit 0 not set
- new ECFieldF2mDomainParams(
- 1999,
- BigInteger.valueOf(0L).setBit(1).setBit(367).setBit(1999),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 4: valid m, invalid rp - bit m not set
- new ECFieldF2mDomainParams(
- 1999,
- BigInteger.valueOf(0L).setBit(0).setBit(367).setBit(1998),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 5: valid m, invalid rp - bit k improperly set
- new ECFieldF2mDomainParams(
- 1999,
- BigInteger.valueOf(0L).setBit(0).setBit(2367).setBit(1999),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 6: valid m, invalid rp - k1 k2 k3
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(2001).setBit(2002).setBit(2003).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 7: valid m, invalid rp - number of bits set
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 8: valid m, invalid rp - number of bits set
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 9: valid m, invalid rp - number of bits set
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).
- setBit(981).setBit(985).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 10: valid m, invalid rp
- new ECFieldF2mDomainParams(
- 2000,
- BigInteger.valueOf(0L),
- null,
- ECFieldF2mDomainParams.IArgE),
- // set 11: invalid m
- new ECFieldF2mDomainParams(
- -2000,
- BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).
- setBit(981).setBit(2000),
- null,
- ECFieldF2mDomainParams.IArgE),
- };
-
- /**
- * Tests for constructor ECFieldF2m(int, BigInteger)
- *
- * Assertion: constructs new ECFieldF2m object
- * using valid parameters m and rp. rp represents trinomial basis.
- *
- * Assertion: constructs new ECFieldF2m object
- * using valid parameters m and rp. rp represents pentanomial basis.
- *
- * Assertion: IllegalArgumentException if m is not positive.
- *
- * Assertion: NullPointerException if rp is null.
- *
- * Assertion: IllegalArgumentException if rp is invalid.
- */
- public final void testECFieldF2mintBigInteger() {
- for(int i=0; iECFieldF2m(int, BigInteger)
- * constructor tests.
- */
private final ECFieldF2mDomainParams[] intIntArrayCtorTestParameters =
new ECFieldF2mDomainParams[] {
// set 0: valid m and ks - trinomial basis params
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAOtherPrimeInfoTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAOtherPrimeInfoTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAOtherPrimeInfoTest.java (working copy)
@@ -19,13 +19,13 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.RSAOtherPrimeInfo;
import junit.framework.TestCase;
-
/**
* Tests for RSAOtherPrimeInfo class fields and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECPointTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECPointTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECPointTest.java (working copy)
@@ -19,13 +19,13 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.ECPoint;
import junit.framework.TestCase;
-
/**
* Tests for ECPoint class fields and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAKeyGenParameterSpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAKeyGenParameterSpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAKeyGenParameterSpecTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.RSAKeyGenParameterSpec;
import junit.framework.TestCase;
-
/**
* Tests for RSAKeyGenParameterSpec class fields and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateKeySpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateKeySpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateKeySpecTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.KeySpec;
+import java.security.spec.RSAPrivateKeySpec;
import junit.framework.TestCase;
-
/**
* Tests for RSAPrivateKeySpec class fields and methods
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/MGF1ParameterSpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/MGF1ParameterSpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/MGF1ParameterSpecTest.java (working copy)
@@ -19,8 +19,10 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
+import java.security.spec.MGF1ParameterSpec;
+
import junit.framework.TestCase;
/**
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.security.Key;
import java.security.KeyFactory;
@@ -26,7 +26,7 @@
import junit.framework.TestCase;
-public class EncodedKeySpecTest extends TestCase {
+public class EncodedKeySpec2Test extends TestCase {
/**
* @tests java.security.spec.EncodedKeySpec#getEncoded()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPublicKeySpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPublicKeySpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPublicKeySpecTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.KeySpec;
+import java.security.spec.RSAPublicKeySpec;
import junit.framework.TestCase;
-
/**
* Tests for RSAPublicKeySpec class fields and methods
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java (working copy)
@@ -19,14 +19,17 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.ECField;
+import java.security.spec.ECFieldF2m;
+import java.security.spec.ECFieldFp;
+import java.security.spec.EllipticCurve;
import java.util.Arrays;
import junit.framework.TestCase;
-
/**
* Tests for EllipticCurve class fields and methods.
*
@@ -631,81 +634,6 @@
}
/**
- * Test #2 for equals(Object other) method
- * Assertion: return false if this and other objects are not equal
- * Test preconditions: see test comments
- * Expected: all objects in this test must be NOT equal
- */
- public final void testEqualsObject02() {
- // test case 1: must not be equal to null
- EllipticCurve c2=null, c1 =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L));
- assertFalse(c1.equals(c2));
-
- // test case 2: not equal objects - field
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L));
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(31L)),
- BigInteger.valueOf(1L),
- BigInteger.valueOf(19L));
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 3: not equal objects - a
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L));
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ZERO,
- BigInteger.valueOf(19L));
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 4: not equal objects - b
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L));
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(17L));
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 5: not equal objects - both seed not null
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L),
- new byte[24]);
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.valueOf(1L),
- BigInteger.valueOf(19L),
- new byte[25]);
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 6: not equal objects - one seed is null
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L),
- null);
- c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.valueOf(1L),
- BigInteger.valueOf(19L),
- new byte[24]);
- assertFalse(c1.equals(c2) || c2.equals(c1));
-
- // test case 7: not equal objects - field class
- c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
- BigInteger.ONE,
- BigInteger.valueOf(19L),
- new byte[24]);
- c2 = new EllipticCurve(new ECFieldF2m(5),
- BigInteger.ONE,
- BigInteger.valueOf(19L),
- new byte[24]);
- assertFalse(c1.equals(c2) || c2.equals(c1));
- }
-
- /**
* Test #1 for hashCode() method.
*
* Assertion: must return the same value if invoked
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/X509EncodedKeySpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/X509EncodedKeySpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/X509EncodedKeySpecTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
+import java.security.spec.EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
import java.util.Arrays;
import junit.framework.TestCase;
-
/**
* Tests for X509EncodedKeySpec class fields and methods
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateCrtKeySpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateCrtKeySpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAPrivateCrtKeySpecTest.java (working copy)
@@ -19,13 +19,15 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.KeySpec;
+import java.security.spec.RSAPrivateCrtKeySpec;
+import java.security.spec.RSAPrivateKeySpec;
import junit.framework.TestCase;
-
/**
* Tests for RSAPrivateCrtKeySpec class fields and methods
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PSSParameterSpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PSSParameterSpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PSSParameterSpecTest.java (working copy)
@@ -19,8 +19,12 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.MGF1ParameterSpec;
+import java.security.spec.PSSParameterSpec;
+
import junit.framework.TestCase;
/**
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidParameterSpecExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidParameterSpecExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidParameterSpecExceptionTest.java (working copy)
@@ -19,13 +19,12 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.security.spec.InvalidParameterSpecException;
import junit.framework.TestCase;
-
/**
* Tests for InvalidParameterSpecException class constructors and
* methods.
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldFpTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldFpTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECFieldFpTest.java (working copy)
@@ -19,13 +19,13 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.ECFieldFp;
import junit.framework.TestCase;
-
/**
* Tests for ECFieldFp class fields and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAParameterSpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAParameterSpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAParameterSpecTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.DSAParameterSpec;
import junit.framework.TestCase;
-
/**
* Tests for DSAParameterSpec
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java (working copy)
@@ -19,13 +19,16 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.KeySpec;
+import java.security.spec.RSAMultiPrimePrivateCrtKeySpec;
+import java.security.spec.RSAOtherPrimeInfo;
+import java.security.spec.RSAPrivateKeySpec;
import junit.framework.TestCase;
-
/**
* Tests for RSAMultiPrimePrivateCrtKeySpec class fields and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
+import java.security.spec.EncodedKeySpec;
+
import org.apache.harmony.security.tests.support.spec.MyEncodedKeySpec;
import junit.framework.TestCase;
-
/**
* Tests for EncodedKeySpec class fields and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPrivateKeySpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPrivateKeySpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPrivateKeySpecTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.DSAPrivateKeySpec;
+import java.security.spec.KeySpec;
import junit.framework.TestCase;
-
/**
* Tests for DSAPrivateKeySpec
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java (working copy)
@@ -19,13 +19,12 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.security.spec.InvalidKeySpecException;
import junit.framework.TestCase;
-
/**
* Tests for InvalidKeySpecException class constructors and
* methods.
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPublicKeySpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPublicKeySpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/DSAPublicKeySpecTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
import java.math.BigInteger;
+import java.security.spec.DSAPublicKeySpec;
+import java.security.spec.KeySpec;
import junit.framework.TestCase;
-
/**
* Tests for DSAPublicKeySpec
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECGenParameterSpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECGenParameterSpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/ECGenParameterSpecTest.java (working copy)
@@ -19,8 +19,10 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
+import java.security.spec.ECGenParameterSpec;
+
import junit.framework.TestCase;
/**
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PKCS8EncodedKeySpecTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PKCS8EncodedKeySpecTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/PKCS8EncodedKeySpecTest.java (working copy)
@@ -19,13 +19,14 @@
* @version $Revision$
*/
-package java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
+import java.security.spec.EncodedKeySpec;
+import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Arrays;
import junit.framework.TestCase;
-
/**
* Tests for PKCS8EncodedKeySpec class fields and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java (working copy)
@@ -13,13 +13,13 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.net.URL;
import java.security.CodeSource;
import java.security.cert.Certificate;
-public class CodeSourceTest extends junit.framework.TestCase {
+public class CodeSource2Test extends junit.framework.TestCase {
/**
* @throws Exception
@@ -99,14 +99,4 @@
assertTrue("host should not imply null host", !cs2.implies(cs1));
}
- /**
- * @tests java.security.CodeSource#toString()
- */
- public void test_toString() throws Exception {
- // Test for method java.lang.String java.security.CodeSource.toString()
- CodeSource cs = new CodeSource(new java.net.URL("file:///test"),
- (Certificate[]) null);
- assertEquals("toString did not return expected value.",
- "CodeSource, url=file:/test, ", cs.toString());
- }
}
\ No newline at end of file
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java (working copy)
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -37,8 +37,22 @@
import tests.support.Support_TestProvider;
import tests.support.resource.Support_Resources;
-public class KeyStoreTest extends junit.framework.TestCase {
+public class KeyStore2Test extends junit.framework.TestCase {
+ static PrivateKey privateKey;
+ static {
+ try {
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator
+ .getInstance("DSA");
+ SecureRandom secureRandom = new SecureRandom();
+ keyPairGenerator.initialize(1024, secureRandom);
+ KeyPair keyPair = keyPairGenerator.genKeyPair();
+ privateKey = keyPair.getPrivate();
+ } catch (Exception e) {
+ fail("initialization failed: " + e);
+ }
+ }
+
final char[] pssWord = { 'a', 'b', 'c' };
private Provider support_TestProvider;
@@ -115,12 +129,10 @@
KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
keyTest.load(null, null);
// alias 1
- PublicKey pub = cert[0].getPublicKey();
keyTest.setCertificateEntry("alias1", cert[0]);
// alias 2
- keyTest.setCertificateEntry("alias2", cert[0]);
- keyTest.setKeyEntry("alias2", pub, pssWord, cert);
+ keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
// alias 3
keyTest.setCertificateEntry("alias3", cert[1]);
@@ -248,11 +260,8 @@
+ "certificate was wrong", alias.equals("alias1"));
// key entry
- PublicKey pub = cert[0].getPublicKey();
- // If next line throws a NPE check that a full math implementation
- // is being used.
- keyTest.setKeyEntry("alias2", pub, pssWord, cert);
+ keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
alias = keyTest.getCertificateAlias(cert[0]);
assertTrue("key entry - the alias returned for this "
+ "certificate was wrong", alias.equals("alias2"));
@@ -280,12 +289,10 @@
keyTest.load(null, null);
// alias 1
- PublicKey pub = cert[0].getPublicKey();
keyTest.setCertificateEntry("alias1", cert[0]);
// alias 2
- keyTest.setCertificateEntry("alias2", cert[0]);
- keyTest.setKeyEntry("alias2", pub, pssWord, cert);
+ keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
java.security.cert.Certificate[] certRes = keyTest
.getCertificateChain("alias2");
@@ -344,11 +351,7 @@
cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
keyTest.load(null, null);
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
- SecureRandom secureRandom = new SecureRandom();
- keyPairGenerator.initialize(1024, secureRandom);
- KeyPair keyPair = keyPairGenerator.genKeyPair();
- PrivateKey privateKey = keyPair.getPrivate();
+
keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
PrivateKey returnedKey = (PrivateKey) keyTest.getKey("alias2", pssWord);
byte[] retB = returnedKey.getEncoded();
@@ -411,12 +414,10 @@
KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
keyTest.load(null, null);
// alias 1
- PublicKey pub = cert[0].getPublicKey();
keyTest.setCertificateEntry("alias1", cert[0]);
// alias 2
- keyTest.setCertificateEntry("alias2", cert[0]);
- keyTest.setKeyEntry("alias2", pub, pssWord, cert);
+ keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
assertTrue("isCertificateEntry method returns false for a certificate",
keyTest.isCertificateEntry("alias1") == true);
@@ -437,12 +438,10 @@
KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
keyTest.load(null, null);
// alias 1
- PublicKey pub = cert[0].getPublicKey();
keyTest.setCertificateEntry("alias1", cert[0]);
// alias 2
- keyTest.setCertificateEntry("alias2", cert[0]);
- keyTest.setKeyEntry("alias2", pub, pssWord, cert);
+ keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
assertTrue("isKeyEntry method returns false for a certificate", keyTest
.isKeyEntry("alias2") == true);
@@ -522,7 +521,7 @@
public void test_setKeyEntryLjava_lang_String$B$Ljava_security_cert_Certificate()
throws Exception {
- fail("Test hangs - requires a full math implementation ??");
+// fail("Test hangs - requires a full math implementation ??");
// Test for method void
// java.security.KeyStore.setKeyEntry(java.lang.String, byte [],
@@ -534,13 +533,9 @@
cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
keyTest.load(null, null);
- // generator
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
- SecureRandom secureRandom = new SecureRandom();
- keyPairGenerator.initialize(1024, secureRandom);
- KeyPair keyPair = keyPairGenerator.genKeyPair();
+
// set the same alias as keyEntry
- keyTest.setKeyEntry("alias2", keyPair.getPrivate().getEncoded(), cert);
+ keyTest.setKeyEntry("alias2", privateKey.getEncoded(), cert);
assertTrue("the entry specified by the alias alias2 is not a keyEntry",
keyTest.isKeyEntry("alias2"));
}
@@ -562,12 +557,7 @@
cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
keyTest.load(null, null);
- // generator
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
- SecureRandom secureRandom = new SecureRandom();
- keyPairGenerator.initialize(1024, secureRandom);
- KeyPair keyPair = keyPairGenerator.genKeyPair();
- PrivateKey privateKey = keyPair.getPrivate();
+
keyTest.setKeyEntry("alias3", privateKey, pssWord, cert);
assertTrue("the entry specified by the alias alias3 is not a keyEntry",
keyTest.isKeyEntry("alias3"));
@@ -586,12 +576,10 @@
KeyStore keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
keyTest.load(null, null);
// alias 1
- PublicKey pub = cert[0].getPublicKey();
keyTest.setCertificateEntry("alias1", cert[0]);
// alias 2
- keyTest.setCertificateEntry("alias2", cert[0]);
- keyTest.setKeyEntry("alias2", pub, pssWord, cert);
+ keyTest.setKeyEntry("alias2", privateKey, pssWord, cert);
// alias 3
keyTest.setCertificateEntry("alias3", cert[1]);
@@ -604,13 +592,13 @@
* is called before a test is executed.
*/
protected void setUp() throws Exception {
- super.setUp();
- Security.addProvider(new Support_TestProvider());
- }
+ super.setUp();
+ support_TestProvider = new Support_TestProvider();
+ Security.addProvider(support_TestProvider);
+ }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- Security.removeProvider(support_TestProvider.getName());
- }
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Security.removeProvider(support_TestProvider.getName());
+ }
}
\ No newline at end of file
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidParameterException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidParameterException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/InvalidParameterException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.InvalidParameterException;
-public class InvalidParameterExceptionTest extends junit.framework.TestCase {
+public class InvalidParameterException2Test extends junit.framework.TestCase {
/**
* @tests java.security.InvalidParameterException#InvalidParameterException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java (revision 415258)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java (working copy)
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-package tests.api.java.security;
+package org.apache.harmony.security.tests.java.security;
import java.security.ProviderException;
-public class ProviderExceptionTest extends junit.framework.TestCase {
+public class ProviderException2Test extends junit.framework.TestCase {
/**
* @tests java.security.ProviderException#ProviderException()
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package javax.security.cert;
+package org.apache.harmony.security.tests.javax.security.cert;
import javax.security.cert.CertificateException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExpiredExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExpiredExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateExpiredExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package javax.security.cert;
+package org.apache.harmony.security.tests.javax.security.cert;
import javax.security.cert.CertificateExpiredException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java (working copy)
@@ -19,13 +19,15 @@
* @version $Revision$
*/
-package javax.security.cert;
+package org.apache.harmony.security.tests.javax.security.cert;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PublicKey;
import java.security.SignatureException;
+
+import javax.security.cert.Certificate;
import javax.security.cert.CertificateEncodingException;
import javax.security.cert.CertificateException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateNotYetValidExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateNotYetValidExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateNotYetValidExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package javax.security.cert;
+package org.apache.harmony.security.tests.javax.security.cert;
import javax.security.cert.CertificateNotYetValidException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateParsingExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateParsingExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateParsingExceptionTest.java (working copy)
@@ -19,7 +19,7 @@
* @version $Revision$
*/
-package javax.security.cert;
+package org.apache.harmony.security.tests.javax.security.cert;
import javax.security.cert.CertificateParsingException;
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateEncodingExceptionTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateEncodingExceptionTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateEncodingExceptionTest.java (working copy)
@@ -19,13 +19,12 @@
* @version $Revision$
*/
-package javax.security.cert;
+package org.apache.harmony.security.tests.javax.security.cert;
import javax.security.cert.CertificateEncodingException;
import junit.framework.TestCase;
-
/**
* Tests for DigestException class constructors and methods.
*
Index: modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java
===================================================================
--- modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java (revision 0)
+++ modules/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java (working copy)
@@ -19,21 +19,26 @@
* @version $Revision$
*/
-package javax.security.cert;
+package org.apache.harmony.security.tests.javax.security.cert;
import java.io.ByteArrayInputStream;
import java.security.cert.CertificateFactory;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
+
import javax.security.cert.CertificateEncodingException;
import javax.security.cert.CertificateException;
+import javax.security.cert.CertificateExpiredException;
+import javax.security.cert.CertificateNotYetValidException;
import javax.security.cert.X509Certificate;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+
+
/**
*/
Index: modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java
===================================================================
--- modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java (revision 415258)
+++ modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java (working copy)
@@ -19,9 +19,14 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.support.cert;
import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CertPath;
+import java.security.cert.CertPathParameters;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.CertPathValidatorResult;
+import java.security.cert.CertPathValidatorSpi;
/**
* Additional class for verification of CertPathValidatorSpi
Index: modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java
===================================================================
--- modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java (revision 415258)
+++ modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java (working copy)
@@ -19,9 +19,13 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.support.cert;
import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CertPathBuilderException;
+import java.security.cert.CertPathBuilderResult;
+import java.security.cert.CertPathBuilderSpi;
+import java.security.cert.CertPathParameters;
/**
* Additional class for verification CertPathBuilderSpi
Index: modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java
===================================================================
--- modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java (revision 415258)
+++ modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java (working copy)
@@ -19,8 +19,10 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.support.cert;
+import java.security.cert.CertStoreParameters;
+
/**
* Class for verification of CertStore and CertStoreSpi
*
Index: modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java
===================================================================
--- modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java (revision 415258)
+++ modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java (working copy)
@@ -19,9 +19,14 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.support.cert;
import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CRLSelector;
+import java.security.cert.CertSelector;
+import java.security.cert.CertStoreException;
+import java.security.cert.CertStoreParameters;
+import java.security.cert.CertStoreSpi;
import java.util.Collection;
/**
Index: modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificateFactorySpi.java
===================================================================
--- modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificateFactorySpi.java (revision 415258)
+++ modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertificateFactorySpi.java (working copy)
@@ -19,15 +19,21 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.support.cert;
+import java.io.DataInputStream;
import java.io.InputStream;
-import java.io.DataInputStream;
+import java.security.cert.CRL;
+import java.security.cert.CRLException;
+import java.security.cert.CertPath;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactorySpi;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.HashSet;
/**
* Additional class for verification CertificateFactorySpi and
Index: modules/security/make/common/build.xml
===================================================================
--- modules/security/make/common/build.xml (revision 415258)
+++ modules/security/make/common/build.xml (working copy)
@@ -73,7 +73,7 @@
-
+
@@ -111,15 +111,18 @@
-
+
+
+
+
+
-
-
-
-
+
+
+