Path: blob/master/test/jdk/javax/crypto/JceSecurity/MyCertificateFactory.java
41149 views
/*1* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* test25* @bug 637705826* @summary SunJCE depends on sun.security.provider.SignatureImpl27* behaviour, BC can't load into 1st slot.28* @author Brad R. Wetmore29*/3031import java.io.*;32import java.util.*;33import java.security.cert.*;34import java.security.cert.CertificateException;3536public class MyCertificateFactory extends CertificateFactorySpi {3738CertificateFactory cf;3940public MyCertificateFactory() {41try {42cf = CertificateFactory.getInstance("X.509", "SUN");43} catch (Exception e) {44throw new RuntimeException(45"Couldn't create the Sun X.509 CertificateFactory");46}47}4849public Certificate engineGenerateCertificate(InputStream inStream)50throws CertificateException {5152Certificate cert = cf.generateCertificate(inStream);53if (!(cert instanceof X509Certificate)) {54throw new RuntimeException("Not an X509Certificate");55}56return new MyX509CertImpl((X509Certificate)cert);57}5859public CertPath engineGenerateCertPath(InputStream inStream)60throws CertificateException {61return cf.generateCertPath(inStream);62}6364public CertPath engineGenerateCertPath(InputStream inStream,65String encoding)66throws CertificateException {67return cf.generateCertPath(inStream, encoding);68}6970public CertPath71engineGenerateCertPath(List<? extends Certificate> certificates)72throws CertificateException {73return cf.generateCertPath(certificates);74}7576public Iterator<String> engineGetCertPathEncodings() {77return cf.getCertPathEncodings();78}7980public Collection<? extends Certificate>81engineGenerateCertificates(InputStream inStream)82throws CertificateException {83return cf.generateCertificates(inStream);84}8586public CRL engineGenerateCRL(InputStream inStream)87throws CRLException {88return cf.generateCRL(inStream);89}9091public Collection<? extends CRL> engineGenerateCRLs92(InputStream inStream) throws CRLException {93return cf.generateCRLs(inStream);94}95}969798