Package java.security

Examples of java.security.KeyManagementException


                chain1 = new X509Certificate[] { key.getCertificate() };
            }
            keystore.setKeyEntry(alias, key.getPrivateKey(), keyPassword.toCharArray(), chain1);       
        }
        catch(KeyStoreException e) {
            throw new KeyManagementException("Cannot add credential", e);
        }
    }
View Full Code Here


                if (tm instanceof X509TrustManager) {
                    return (X509TrustManager) tm;
                }
            }
        } catch (NoSuchAlgorithmException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        } catch (IOException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        } catch (CertificateException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        } catch (UnrecoverableEntryException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        } catch (KeyStoreException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        }
        throw new IllegalArgumentException("TrustManagerFactory did not return an X509TrustManager instance");
    }
View Full Code Here

                if (tm instanceof X509TrustManager) {
                    return (X509TrustManager) tm;
                }
            }
        } catch (NoSuchAlgorithmException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        } catch (IOException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        } catch (CertificateException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        } catch (UnrecoverableEntryException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        } catch (KeyStoreException e) {
            throw new KeyManagementException("Cannot create X509TrustManager", e);
        }
        throw new IllegalArgumentException("TrustManagerFactory did not return an X509TrustManager instance");
    }
View Full Code Here

        try {
            log.debug("Saving keystore");
            keystore.save();
        }
        catch(KeyStoreException e) {
            throw new KeyManagementException("Cannot add certificate to keystore: "+e.toString(), e);
        }
        catch(IOException e) {
            throw new KeyManagementException("Cannot add certificate to keystore: "+e.toString(), e);
        }
        catch(NoSuchAlgorithmException e) {
            throw new KeyManagementException("Cannot add certificate to keystore: "+e.toString(), e);
        }
        catch(CertificateException e) {
            throw new KeyManagementException("Cannot add certificate to keystore: "+e.toString(), e);
        }
        hashCode = null; // signal to recalculate the hashcode due to changed contents
    }
View Full Code Here

                        keyManager = (X509KeyManager)kms[i];
                        break;
                    }
                }
                if (keyManager == null) {
                    throw new KeyManagementException("No X509KeyManager found");
                }
                if (initialize_default) {
                    // found keyManager is default key manager
                    defaultKeyManager = keyManager;
                }
            }
           
            // initialize trust manager
            initialize_default = false;
            if ((tms == null) || (tms.length == 0)) {
                if (defaultTrustManager == null) {
                    TrustManagerFactory tmf = TrustManagerFactory
                        .getInstance(TrustManagerFactory.getDefaultAlgorithm());
                    tmf.init((KeyStore)null);
                    tms = tmf.getTrustManagers();
                    initialize_default = true;
                } else {
                    trustManager = defaultTrustManager;
                }
            }
            if (trustManager == null) { // was not initialized by default
                for (int i = 0; i < tms.length; i++) {
                    if (tms[i] instanceof X509TrustManager) {
                        trustManager = (X509TrustManager)tms[i];
                        break;
                    }
                }
                if (trustManager == null) {
                    throw new KeyManagementException("No X509TrustManager found");
                }
                if (initialize_default) {
                    // found trustManager is default trust manager
                    defaultTrustManager = trustManager;
                }
            }
        } catch (NoSuchAlgorithmException e) {
            throw new KeyManagementException(e);
        } catch (KeyStoreException e) {
            throw new KeyManagementException(e);
        } catch (UnrecoverableKeyException e) {
            throw new KeyManagementException(e);         
        }
        // initialize secure random
        if (sr == null) {
            if (defaultSecureRandom == null) {
              defaultSecureRandom = new SecureRandom();
View Full Code Here

            throw new NullPointerException(Messages.getString("security.92")); //$NON-NLS-1$
        }

        String name = identity.getName();
        if (names.containsKey(name)) {
            throw new KeyManagementException(Messages.getString("security.93", name)); //$NON-NLS-1$
        }

        PublicKey key = identity.getPublicKey();
        if (key != null && keys.containsKey(key)) {
            throw new KeyManagementException(Messages.getString("security.94", key)); //$NON-NLS-1$
        }

        names.put(name, identity);
        if (key != null) {
            keys.put(key, identity);
View Full Code Here

            contains = contains || keys.containsKey(key);
            keys.remove(key);
        }
       
        if (!contains) {
            throw new KeyManagementException(Messages.getString("security.96")); //$NON-NLS-1$
        }
    }
View Full Code Here

    private boolean init = false;
    @Override
    protected void engineInit(KeyManager[] km, TrustManager[] tm,
            SecureRandom sr) throws KeyManagementException {
        if (sr == null) {
            throw new KeyManagementException(
                    "secureRandom is null");
        }
        init = true;
    }
View Full Code Here

    private boolean init = false;
    @Override
    protected void engineInit(KeyManager[] km, TrustManager[] tm,
            SecureRandom sr) throws KeyManagementException {
        if (sr == null) {
            throw new KeyManagementException(
                    "secureRandom is null");
        }
        init = true;
    }
View Full Code Here

                        } else if ("Hello Exception".equals(s)) {
                            throw new CamelExchangeException("Forced for testing", exchange);
                        } else if ("Hello business".equals(s)) {
                            throw new MyBusinessException();
                        } else if ("I am not allowed to do this".equals(s)) {
                            throw new KeyManagementException();
                        } else if ("I am not allowed to access this".equals(s)) {
                            throw new IllegalAccessException();
                        }
                        exchange.getOut().setBody("Hello World");
                    }
View Full Code Here

TOP

Related Classes of java.security.KeyManagementException

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.