Examples of CertificateException


Examples of java.security.cert.CertificateException

         * If we got this far then the certificate was not in our trust store so
         * lets check the java cacerts store.
         */

        if (trustcacerts == null) {
          throw new CertificateException("No trust store found!");
        } else {
            try {
                CertificateFactory certFact = CertificateFactory.getInstance("X.509");
                CertPath path = certFact.generateCertPath(Arrays.asList(chain));
                PKIXParameters params = new PKIXParameters(trustcacerts);
                params.setRevocationEnabled(false);
                CertPathValidator certPathValidator = CertPathValidator.getInstance(CertPathValidator.getDefaultType());
                CertPathValidatorResult result = certPathValidator.validate(path, params);
                PKIXCertPathValidatorResult pkixResult = (PKIXCertPathValidatorResult) result;
                TrustAnchor ta = pkixResult.getTrustAnchor();
                X509Certificate cert = ta.getTrustedCert();
                return;
            } catch (Exception e) {
            }
        }

        throw new CertificateException("Certificate chain is not trusted");
    }
View Full Code Here

Examples of java.security.cert.CertificateException

       
       
    private void reinit() throws CertificateException {
        log.entering("GECATrustManager", "reinit");
        if(caTop == null) {
            throw new CertificateException("caTop not set");
        }
        File caCertFile = new File(caTop, "cacert.pem");
        File caCrlFile = new File(caTop, "ca-crl.pem");

        if (trustManager == null || lastUpdate < caCertFile.lastModified() || lastUpdate < caCrlFile.lastModified()) {
View Full Code Here

Examples of java.security.cert.CertificateException

                }
            }

            if (trustManager == null) {
                // This should never happen since we handle only X509 certificates
                throw new CertificateException("Found no X509TrustManager");
            }



        } catch (NoSuchAlgorithmException ex) {
            CertificateException cae = new CertificateException("Certificate algorithm is unknown", ex);
            log.throwing("GECATrustManager", "init", cae);
            throw cae;
        } catch (InvalidAlgorithmParameterException ex) {
            CertificateException cae = new CertificateException("Invalid parameters for crypte algorithms", ex);
            log.throwing("GECATrustManager", "init", cae);
            throw cae;
        } catch(KeyStoreException ex) {
            CertificateException cae = new CertificateException("Cannot create keystore for ca certificate", ex);
            log.throwing("GECATrustManager", "init", cae);
            throw cae;
        } catch(IOException ex) {
            CertificateException cae = new CertificateException("I/O error while initializing the ca certificate", ex);
            log.throwing("GECATrustManager", "init", cae);
            throw cae;
        } catch(CRLException ex) {
            CertificateException cae = new CertificateException("Error in crl file", ex);
            log.throwing("SgeCATrustManager", "init", ex);
            throw cae;
        }
        log.exiting("GECATrustManager", "init");
    }
View Full Code Here

Examples of java.security.cert.CertificateException

            obj = iter.next();
            if (obj != null)
            {
                if (!(obj instanceof X509Certificate))
                {
                    throw new CertificateException("list contains non X509Certificate object while creating CertPath\n" + obj.toString());
                }
            }
        }
        return new PKIXCertPath(certificates);
    }
View Full Code Here

Examples of java.security.cert.CertificateException

            return new byte[0];
        }

        public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
        {
            throw new CertificateException();
        }
View Full Code Here

Examples of java.security.cert.CertificateException

            throw new CertificateException();
        }

        public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
        {
            throw new CertificateException();
        }
View Full Code Here

Examples of java.security.cert.CertificateException

        throws CertificateException, NoSuchAlgorithmException,
            SignatureException, InvalidKeyException
    {
        if (!isAlgIdEqual(c.getSignatureAlgorithm(), c.getTBSCertificate().getSignature()))
        {
            throw new CertificateException("signature algorithm in TBS cert not same as outer cert");
        }

        ASN1Encodable params = c.getSignatureAlgorithm().getParameters();

        // TODO This should go after the initVerify?
View Full Code Here

Examples of java.security.cert.CertificateException

            {
                ASN1InputStream derInStream = new ASN1InputStream(inStream);
                ASN1Primitive derObject = derInStream.readObject();
                if (!(derObject instanceof ASN1Sequence))
                {
                    throw new CertificateException("input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath");
                }
                Enumeration e = ((ASN1Sequence)derObject).getObjects();
                certificates = new ArrayList();
                CertificateFactory certFactory = CertificateFactory.getInstance("X.509", BouncyCastleProvider.PROVIDER_NAME);
                while (e.hasMoreElements())
                {
                    ASN1Encodable element = (ASN1Encodable)e.nextElement();
                    byte[] encoded = element.toASN1Primitive().getEncoded(ASN1Encoding.DER);
                    certificates.add(0, certFactory.generateCertificate(
                        new ByteArrayInputStream(encoded)));
                }
            }
            else if (encoding.equalsIgnoreCase("PKCS7") || encoding.equalsIgnoreCase("PEM"))
            {
                inStream = new BufferedInputStream(inStream);
                certificates = new ArrayList();
                CertificateFactory certFactory= CertificateFactory.getInstance("X.509", BouncyCastleProvider.PROVIDER_NAME);
                Certificate cert;
                while ((cert = certFactory.generateCertificate(inStream)) != null)
                {
                    certificates.add(cert);
                }
            }
            else
            {
                throw new CertificateException("unsupported encoding: " + encoding);
            }
        }
        catch (IOException ex)
        {
            throw new CertificateException("IOException throw while decoding CertPath:\n" + ex.toString());
        }
        catch (NoSuchProviderException ex)
        {
            throw new CertificateException("BouncyCastle provider not found while trying to get a CertificateFactory:\n" + ex.toString());
        }
       
        this.certificates = sortCerts(certificates);
    }
View Full Code Here

Examples of java.security.cert.CertificateException

        throws CertificateException, NoSuchAlgorithmException,
            SignatureException, InvalidKeyException
    {
        if (!isAlgIdEqual(c.getSignatureAlgorithm(), c.getTBSCertificate().getSignature()))
        {
            throw new CertificateException("signature algorithm in TBS cert not same as outer cert");
        }

        ASN1Encodable params = c.getSignatureAlgorithm().getParameters();

        // TODO This should go after the initVerify?
View Full Code Here

Examples of java.security.cert.CertificateException

    {
        Signature   signature = null;

        if (!cert.getSignatureAlgorithm().equals(cert.getAcinfo().getSignature()))
        {
            throw new CertificateException("Signature algorithm in certificate info not same as outer certificate");
        }

        signature = Signature.getInstance(cert.getSignatureAlgorithm().getObjectId().getId(), provider);

        signature.initVerify(key);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.