Package java.security.cert

Examples of java.security.cert.CertificateException


      {
    DERInputStream derInStream = new DERInputStream(inStream);
    DERObject derObject = derInStream.readObject();
    if ( derObject == null || ! ( derObject instanceof ASN1Sequence ) )
    {
        throw new CertificateException("input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath" );
    }
    Enumeration enumx = ((ASN1Sequence)derObject).getObjects();
    InputStream certInStream;
    ByteArrayOutputStream outStream;
    DEROutputStream derOutStream;
    certificates = new ArrayList();
    CertificateFactory certFactory= CertificateFactory.getInstance( "X.509", "BC" );
    while ( enumx.hasMoreElements() ) {
        outStream = new ByteArrayOutputStream();
        derOutStream = new DEROutputStream(outStream);
   
              derOutStream.writeObject(enumx.nextElement());
              derOutStream.close();

        certInStream = new ByteArrayInputStream(outStream.toByteArray());
        certificates.add(0,certFactory.generateCertificate(certInStream));
    }
      }
      else
      {
    throw new CertificateException( "unsupported 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() );
  }
    }
View Full Code Here


   * @param authType The authentication type based on the client certificate.
   * @throws CertificateException Always.
   */
  public void checkClientTrusted(X509Certificate[] chain, String authType)
  throws CertificateException {
    throw new CertificateException("This trust manager _is_ for clients. "+
        "What other client should be trusted?");
  }
View Full Code Here

   * @throws CertificateException If the server is not trusted.
   */
  public void checkServerTrusted(X509Certificate[] chain, String authType)
  throws CertificateException {
    if (!trustManager.isTrusted(chain)) {
      throw new CertificateException("The certificate chain is not "+
          "trusted!");
    }
  }
View Full Code Here

                return readDERCertificate(in);
            }
        }
        catch (IOException e)
        {
            throw new CertificateException(e.toString());
        }
    }
View Full Code Here

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

    {
        Signature   signature = null;

        if (!c.getSignatureAlgorithm().equals(c.getTBSCertificate().getSignature()))
        {
            throw new CertificateException("signature algorithm in TBS cert not same as outer cert");
        }

        try
        {
            signature = Signature.getInstance(c.getSignatureAlgorithm().getObjectId().getId(), "BC");
View Full Code Here

    public static TrustManager[] getTrustManagerArray() {
        return new TrustManager[] { getInstance() };
    }

    public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
        throw new CertificateException("Client certs are not trusted by the custom SSL trust manager.");
    }
View Full Code Here

                if (log.isInfoEnabled())
                    log.info("Failed to validate certificate path", e);
            }
        }

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

          
        }
    }

    public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
        throw new CertificateException("Client certs are not trusted by the custom SSL trust manager.");
    }
View Full Code Here

         * 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

TOP

Related Classes of java.security.cert.CertificateException

Copyright © 2018 www.massapicom. 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.