PKIXCertPathCheckerTest.java revision 8d8858e39800de641b50f6e8e864af9cf68bedea
131c24bf5b39cc8391d4cfdbf8cf5163975fdb81eJim Grosbach/* 2334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * Licensed to the Apache Software Foundation (ASF) under one or more 3334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * contributor license agreements. See the NOTICE file distributed with 4334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * this work for additional information regarding copyright ownership. 5334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * The ASF licenses this file to You under the Apache License, Version 2.0 6334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * (the "License"); you may not use this file except in compliance with 7334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * the License. You may obtain a copy of the License at 8334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * 9334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * http://www.apache.org/licenses/LICENSE-2.0 10334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * 11334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * Unless required by applicable law or agreed to in writing, software 12334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * distributed under the License is distributed on an "AS IS" BASIS, 13334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * See the License for the specific language governing permissions and 15334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * limitations under the License. 16334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin */ 17d457e6e9a5cd975baf4d1f0578382ab8373e6153Evan Cheng 18334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin/** 19f95215f551949d5e5adfbf4753aa833b9009b77aAnton Korobeynikov * @author Vladimir N. Molotkov 204dbbe3433f7339ed277af55037ff6847f484e5abChris Lattner */ 21fdc834046efd427d474e3b899ec69354c05071e0Evan Cheng 22fdc834046efd427d474e3b899ec69354c05071e0Evan Chengpackage org.apache.harmony.security.tests.java.security.cert; 23fdc834046efd427d474e3b899ec69354c05071e0Evan Cheng 24334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwinimport java.security.cert.CertPathValidatorException; 25334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwinimport java.security.cert.PKIXCertPathChecker; 26d457e6e9a5cd975baf4d1f0578382ab8373e6153Evan Chengimport java.util.HashSet; 27334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 28334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwinimport org.apache.harmony.security.tests.support.cert.MyCertificate; 29334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwinimport org.apache.harmony.security.tests.support.cert.TestUtils; 30249fb339ad9d4b921a04de738b9c67d27e328bb7Anton Korobeynikov 312457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Chengimport junit.framework.TestCase; 32249fb339ad9d4b921a04de738b9c67d27e328bb7Anton Korobeynikov 33af76e592c7f9deff0e55c13dbb4a34f07f1c7f64Chris Lattner/** 34334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * Tests for <code>PKIXCertPathChecker</code> 35f95215f551949d5e5adfbf4753aa833b9009b77aAnton Korobeynikov */ 36c25e7581b9b8088910da31702d4ca21c4734c6d7Torok Edwinpublic class PKIXCertPathCheckerTest extends TestCase { 37334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 38334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin /** 39334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * Constructor for PKIXCertPathCheckerTest. 40334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * 41334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin * @param name 42334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin */ 43f95215f551949d5e5adfbf4753aa833b9009b77aAnton Korobeynikov public PKIXCertPathCheckerTest(String name) { 44f95215f551949d5e5adfbf4753aa833b9009b77aAnton Korobeynikov super(name); 45f95215f551949d5e5adfbf4753aa833b9009b77aAnton Korobeynikov } 46334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 47334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin // 48334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin // Tests 49334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin // 50334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 51334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin public final void testClone() { 5278703ddafe3d037f75d8ca188e4829d238289ac3Evan Cheng PKIXCertPathChecker pc1 = TestUtils.getTestCertPathChecker(); 5378703ddafe3d037f75d8ca188e4829d238289ac3Evan Cheng PKIXCertPathChecker pc2 = (PKIXCertPathChecker) pc1.clone(); 54334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin assertNotSame("notSame", pc1, pc2); 55334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin } 56334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 57334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin // 58334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin // the following tests just call methods 5999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes // that are abstract in <code>PKIXCertPathChecker</code> 60334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin // (So they just like signature tests) 61334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin // 62334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 63334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin public final void testIsForwardCheckingSupported() { 64334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker(); 65334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin pc.isForwardCheckingSupported(); 66334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin } 67334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 68334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin public final void testInit() 69334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin throws CertPathValidatorException { 70334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker(); 71334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin pc.init(true); 72334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin } 73334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 74334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin public final void testGetSupportedExtensions() { 75334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker(); 76334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin pc.getSupportedExtensions(); 77334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin } 78334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 79334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin public final void testCheck() 80334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin throws CertPathValidatorException { 81334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker(); 82334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin pc.check(new MyCertificate("", null), new HashSet()); 83334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin } 84334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin 85334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin} 86334c26473bba3ad8b88341bb0d25d0ac2008bb8dDavid Goodwin