Examples of KeyStoreException


Examples of org.apache.geronimo.management.geronimo.KeystoreException

     * @throws KeystoreException
     */
    public void changeKeyPassword(String alias, char[] storePassword, char[] keyPassword, char[] newKeyPassword) throws KeystoreException {
        ensureLoaded(storePassword);
        if(!privateKeys.contains(alias)) {
            throw new KeystoreException("No private key entry "+alias+" exists in the keystore "+keystoreName);
        }
        if(keyPasswords.containsKey(alias)) {
            if(!Arrays.equals(keyPasswords.get(alias), keyPassword)) {
                throw new KeystoreException("Incorrect password provided for private key entry "+alias);
            }
            keyPasswords.put(alias, newKeyPassword);
        }
        PrivateKey key = getPrivateKey(alias, storePassword, keyPassword);
        Certificate[] chain = getCertificateChain(alias, storePassword);
        try {
            keystore.setKeyEntry(alias, key, newKeyPassword, chain);
            saveKeystore(storePassword);
            log.info("Password changed for private key entry "+alias+" in keystore "+keystoreName+".");
            if(keyPasswords.containsKey(alias)) {
                storePasswords();
            }
        } catch(KeyStoreException e) {
            throw new KeystoreException("Could not change password for private key entry "+alias, e);
        }
    }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.KeystoreException

                } else if(keystore.isCertificateEntry(alias)) {
                    trustCerts.add(alias);
                }
            }
        } catch (KeyStoreException e) {
            throw new KeystoreException("Unable to open keystore with provided password", e);
        } catch (IOException e) {
            throw new KeystoreException("Unable to open keystore with provided password", e);
        } catch (NoSuchAlgorithmException e) {
            throw new KeystoreException("Unable to open keystore with provided password", e);
        } catch (CertificateException e) {
            throw new KeystoreException("Unable to open keystore with provided password", e);
        } finally {
            if(in != null) {
                try {
                    in.close();
                } catch (IOException e) {
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.KeystoreException

            keystore.store(out, password);
            out.flush();
            out.close();
            keystoreReadDate = System.currentTimeMillis();
        } catch (KeyStoreException e) {
            throw new KeystoreException("Unable to save keystore '" + keystoreName + "'", e);
        } catch (FileNotFoundException e) {
            throw new KeystoreException("Unable to save keystore '" + keystoreName + "'", e);
        } catch (IOException e) {
            throw new KeystoreException("Unable to save keystore '" + keystoreName + "'", e);
        } catch (NoSuchAlgorithmException e) {
            throw new KeystoreException("Unable to save keystore '" + keystoreName + "'", e);
        } catch (CertificateException e) {
            throw new KeystoreException("Unable to save keystore '" + keystoreName + "'", e);
        }
    }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.KeystoreException

            keystore.store(out, password);
            out.flush();
            out.close();
            return getKeystore(name, keystoreType);
        } catch (KeyStoreException e) {
            throw new KeystoreException("Unable to create keystore", e);
        } catch (IOException e) {
            throw new KeystoreException("Unable to create keystore", e);
        } catch (NoSuchAlgorithmException e) {
            throw new KeystoreException("Unable to create keystore", e);
        } catch (CertificateException e) {
            throw new KeystoreException("Unable to create keystore", e);
        }
    }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.KeystoreException

                                                                            trustInstance == null ? null : trustInstance.getTrustManager(algorithm, null),
                                                                            new java.security.SecureRandom()});
            Object result = cls.getMethod("getSocketFactory", new Class[0]).invoke(ctx, new Object[0]);
            return (SSLSocketFactory) result;
        } catch (Exception e) {
            throw new KeystoreException("Unable to create SSL Factory", e);
        }
    }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.KeystoreException

        // OMG this hurts, but it causes ClassCastExceptions elsewhere unless done this way!
        try {
            Object result = sslContext.getClass().getMethod("getServerSocketFactory", new Class[0]).invoke(sslContext, new Object[0]);
            return (SSLServerSocketFactory) result;
        } catch (Exception e) {
            throw new KeystoreException("Unable to create SSL Server Factory", e);
        }
    }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.KeystoreException

            cls.getMethod("init", new Class[]{kmc, tmc, src}).invoke(ctx, new Object[]{keyInstance.getKeyManager(algorithm, keyAlias, null),
                                                                            trustInstance == null ? null : trustInstance.getTrustManager(algorithm, null),
                                                                            new java.security.SecureRandom()});
            return (SSLContext) ctx;
        } catch (Exception e) {
            throw new KeystoreException("Unable to create SSL Context", e);
        }
    }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.KeystoreException

                    fingerprints.put(alias, CertificateUtil.generateFingerprint(instance.getCertificate(alias, password), "MD5"));
                }
            } catch (KeystoreException e) {
                throw e;
            } catch (Exception e) {
                throw new KeystoreException("Unable to import trust certificate", e);
            }
        }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.KeystoreException

                    fingerprints.put(alias, CertificateUtil.generateFingerprint(instance.getCertificate(alias, password), "MD5"));
                }
            } catch (KeystoreException e) {
                throw e;
            } catch (Exception e) {
                throw new KeystoreException("Unable to create key pair", e);
            }
        }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.KeystoreException

        instance.importPKCS7Certificate(alias, pkcs7cert, password);
        fingerprints.put(alias, CertificateUtil.generateFingerprint(instance.getCertificate(alias, password), "MD5"));
            } catch (KeystoreException e) {
                throw e;
            } catch (Exception e) {
                throw new KeystoreException("Unable to import PKCS7 certificate", e);
      }
    }
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.