List of usage examples for java.security.cert CertificateException CertificateException
public CertificateException(String message, Throwable cause)
From source file:org.wso2.carbon.identity.core.util.ClientAuthX509TrustManager.java
@Override public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { try {// www. j a v a 2s. c o m //if changes were made to the trust store, reload the trust store and initialize the trustManager instance. if (Boolean.parseBoolean(System.getProperty(PROP_TRUST_STORE_UPDATE_REQUIRED))) { setupTrustManager(); } trustManager.checkClientTrusted(x509Certificates, s); } catch (Exception e) { throw new CertificateException("Error occurred while setting up trust manager." + e.getCause(), e); } }
From source file:org.globus.gsi.trustmanager.PKITrustManager.java
/** * Test if the client is trusted based on the certificate chain. Does not currently support anonymous clients. * * @param x509Certificates The certificate chain to test for validity. * @param authType The authentication type based on the client certificate. * @throws CertificateException If the path validation fails. *///from w w w . jav a 2 s .com public void checkClientTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException { // JGLOBUS-97 : anonymous clients? CertPath certPath = CertificateUtil.getCertPath(x509Certificates); try { this.result = this.validator.engineValidate(certPath, parameters); } catch (CertPathValidatorException exception) { throw new CertificateException("Path validation failed: " + exception.getMessage(), exception); } catch (InvalidAlgorithmParameterException exception) { throw new CertificateException("Path validation failed: " + exception.getMessage(), exception); } }
From source file:org.wso2.carbon.identity.core.util.DynamicX509TrustManager.java
/** * Checks the validity of passed x509Certificate certificate chain * * @param x509Certificates//from ww w .j a v a2s . co m * @param s * @throws CertificateException */ @Override public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { try { //if changes were made to the trust store, reload the trust store and initialize the trustManager instance. if (Boolean.parseBoolean(System.getProperty(PROP_TRUST_STORE_UPDATE_REQUIRED))) { setupTrustManager(); } trustManager.checkServerTrusted(x509Certificates, s); } catch (CertificateException e) { // Reload the truststore once if SSL validation fails. try { setupTrustManager(); trustManager.checkServerTrusted(x509Certificates, s); } catch (Exception e1) { throw new CertificateException("Certificate validation failed due to " + e1.getCause(), e1); } } catch (Exception e) { throw new CertificateException("Certificate validation failed due to " + e.getCause(), e); } }
From source file:org.apache.directory.studio.connection.core.StudioKeyStoreManager.java
/** * Gets the memory key store.//ww w . j a v a 2 s. c o m * * @return the memory key store */ private KeyStore getMemoryKeyStore() throws CertificateException { if (memoryKeyStore == null) { try { memoryKeyStore = KeyStore.getInstance("JKS"); //$NON-NLS-1$ memoryKeyStore.load(null, null); } catch (Exception e) { throw new CertificateException(Messages.StudioKeyStoreManager_CantReadTrustStore, e); } } return memoryKeyStore; }
From source file:org.globus.gsi.trustmanager.PKITrustManager.java
/** * Test if the server is trusted based on the certificate chain. * * @param x509Certificates The certificate chain to test for validity. * @param authType The authentication type based on the server certificate. * @throws CertificateException If the path validation fails. *///from w ww.j ava 2s. co m public void checkServerTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException { CertPath certPath = CertificateUtil.getCertPath(x509Certificates); try { this.result = this.validator.engineValidate(certPath, parameters); } catch (CertPathValidatorException exception) { throw new CertificateException("Path validation failed. " + exception.getMessage(), exception); } catch (InvalidAlgorithmParameterException exception) { throw new CertificateException("Path validation failed. " + exception.getMessage(), exception); } }
From source file:org.apache.directory.studio.connection.core.StudioKeyStoreManager.java
/** * Loads the file key store.//from w w w . ja va 2 s .c o m * * @return the file key store */ private KeyStore getFileKeyStore() throws CertificateException { try { KeyStore fileKeyStore = KeyStore.getInstance("JKS"); //$NON-NLS-1$ File file = ConnectionCorePlugin.getDefault().getStateLocation().append(filename).toFile(); if (file.exists() && file.isFile() && file.canRead()) { fileKeyStore.load(new FileInputStream(file), password.toCharArray()); } else { fileKeyStore.load(null, null); } return fileKeyStore; } catch (Exception e) { throw new CertificateException(Messages.StudioKeyStoreManager_CantReadTrustStore, e); } }
From source file:org.apache.directory.studio.connection.core.StudioKeyStoreManager.java
/** * Adds the certificate to the memory key store. * /* w w w . ja va 2 s . co m*/ * @param certificate the certificate */ private void addToMemoryKeyStore(X509Certificate certificate) throws CertificateException { try { KeyStore memoryKeyStore = getMemoryKeyStore(); addToKeyStore(certificate, memoryKeyStore); } catch (Exception e) { throw new CertificateException(Messages.StudioKeyStoreManager_CantAddCertificateToTrustStore, e); } }
From source file:org.apache.directory.studio.connection.core.StudioKeyStoreManager.java
/** * Adds the certificate to the file key store. * //from www . j ava 2 s . co m * @param certificate the certificate */ private void addToFileKeyStore(X509Certificate certificate) throws CertificateException { try { KeyStore fileKeyStore = getFileKeyStore(); addToKeyStore(certificate, fileKeyStore); File file = ConnectionCorePlugin.getDefault().getStateLocation().append(filename).toFile(); fileKeyStore.store(new FileOutputStream(file), password.toCharArray()); } catch (Exception e) { throw new CertificateException(Messages.StudioKeyStoreManager_CantAddCertificateToTrustStore, e); } }
From source file:org.apache.directory.studio.connection.core.StudioKeyStoreManager.java
/** * Gets the certificates contained in the key store. * //from ww w . ja va2 s .com * @return the certificates */ public X509Certificate[] getCertificates() throws CertificateException { try { List<X509Certificate> certificateList = new ArrayList<X509Certificate>(); KeyStore keyStore = getKeyStore(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); Certificate certificate = keyStore.getCertificate(alias); if (certificate instanceof X509Certificate) { certificateList.add((X509Certificate) certificate); } } return certificateList.toArray(new X509Certificate[0]); } catch (KeyStoreException e) { throw new CertificateException(Messages.StudioKeyStoreManager_CantReadTrustStore, e); } }
From source file:org.apache.directory.studio.connection.core.StudioKeyStoreManager.java
/** * Removes the certificate from the memory key store. * //from www . ja va 2 s . c o m * @param certificate the certificate */ private void removeFromMemoryKeyStore(X509Certificate certificate) throws CertificateException { try { KeyStore memoryKeyStore = getMemoryKeyStore(); removeFromKeyStore(certificate, memoryKeyStore); } catch (Exception e) { throw new CertificateException(Messages.StudioKeyStoreManager_CantRemoveCertificateFromTrustStore, e); } }