Java Code Examples for java.security.cert.CertStoreException

Following code examples demonstrate how to use java.security.cert.CertStoreExceptionfrom java. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use java.security.cert.CertStoreExceptionand various code implementation of this class.

    static boolean isCausedByNetworkIssue(java.lang.String r1, java.security.cert.CertStoreException r2) {
        
        throw new UnsupportedOperationException("Method not decompiled: sun.security.provider.certpath.CertStoreHelper.isCausedByNetworkIssue(java.lang.String, java.security.cert.CertStoreException):boolean");
    } 


    @Category(Draft.class)
    public void create_CertStoreException()
    throws Exception {
        @SuppressWarnings("unused")
        final CertStoreException sut = new CertStoreException();
    } 

    
    public AdvancedX509TrustManager(KeyStore knownServersKeyStore)
            throws NoSuchAlgorithmException, KeyStoreException, CertStoreException {
        super();
        TrustManagerFactory factory = TrustManagerFactory
                .getInstance(TrustManagerFactory.getDefaultAlgorithm());
        factory.init((KeyStore)null);
        mStandardTrustManager = findX509TrustManager(factory);

        mKnownServersKeyStore = knownServersKeyStore;
    } 

    private X509TrustManager findX509TrustManager(TrustManagerFactory factory) throws CertStoreException {
        TrustManager tms[] = factory.getTrustManagers();
        for (int i = 0; i < tms.length; i++) {
            if (tms[i] instanceof X509TrustManager) {
                return (X509TrustManager) tms[i];
            }
        }
        return null;
    } 

    private final Collection findCRLs(PKIXCRLStoreSelector crlSelect, List crlStores) throws AnnotatedException {
        Set crls = new HashSet();
        AnnotatedException lastException = null;
        boolean foundValidStore = false;
        for (CertStore store : crlStores) {
            try {
                crls.addAll(PKIXCRLStoreSelector.getCRLs(crlSelect, store));
                foundValidStore = true;
            } catch (CertStoreException e) {
                lastException = new AnnotatedException("Exception searching in X.509 CRL store.", e);
            }
        }
        if (foundValidStore || lastException == null) {
            return crls;
        }
        throw lastException;
    } 

    
    public Collection<? extends CRL> engineGetCRLs(CRLSelector selector)
            throws CertStoreException {

        if (selector == null) {
            return this.crl;
        }

        List<X509CRL> crlList = new Vector<X509CRL>();
        for (X509CRL aCrl : this.crl) {
            if (selector.match(aCrl)) {
                crlList.add(aCrl);
            }
        }
        return crlList;
    } 

    
    public Collection<? extends Certificate> engineGetCertificates(
            CertSelector selector) throws CertStoreException {

        throw new UnsupportedOperationException();
    } 

    }

    public static Collection<? extends Certificate> getCertificates(final PKIXCertStoreSelector selector, CertStore certStore)
        throws CertStoreException
    {
        return certStore.getCertificates(new CertSelector()
        {
            public boolean match(Certificate certificate)
            {
                return (selector == null) ? true : selector.match(certificate);
            }

            public Object clone()
            {
                return this;
            }
        });
    } 

    @Test
    public default void verifyGenericType()
    throws Exception {
        final Class<SUT> sut = createNewSUT();
        assertTrue("This j8unit test interface is used with a generic type that is illegaly not assignable to CertStoreException.class!",
                   CertStoreException.class.isAssignableFrom(sut));
    } 

Advertisement
Javadoc
An exception indicating one of a variety of problems retrieving certificates and CRLs from a CertSto

re.

A CertStoreException provides support for wrapping exceptions. The #getCause getCause method returns the throwable, if any, that caused this exception to be thrown.

Concurrent Access

Unless otherwise specified, the methods defined in this class are not thread-safe. Multiple threads that need to access a single object concurrently should synchronize amongst themselves and provide the necessary locking. Multiple threads each manipulating separate objects need not synchronize. @see CertStore @since 1.4 @author Sean Mullan

Read More
Advertisement