Package java.security

Examples of java.security.KeyManagementException


    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

                        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

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

public class MySSLContextSpi extends SSLContextSpi {
    private boolean init = false;
    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

public class MySSLContextSpi extends SSLContextSpi {
    private boolean init = false;
    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

            "New message",
            "Long message for Exception. Long message for Exception. Long message for Exception." };

    protected Object[] getData() {
        Exception cause = new Exception(msgs[1]);
        KeyManagementException dExc = new KeyManagementException(msgs[0], cause);
        String msg = null;
        Throwable th = null;
        return new Object[] { new KeyManagementException(), new KeyManagementException(msg),
                new KeyManagementException(msgs[1]),
                new KeyManagementException(new Throwable()), new KeyManagementException(th),
                new KeyManagementException(msgs[1], dExc) };
    }
View Full Code Here

      return identities.elements();
    }

    public void addIdentity(Identity id) throws KeyManagementException {
      if (identities.containsKey(id))
        throw new KeyManagementException(
            "This Identity is already contained in the scope");
      if (getIdentity(id.getPublicKey()) != null)
        throw new KeyManagementException(
            "This Identity's public key already exists in the scope");
      identities.put(id, id);
    }
View Full Code Here

      identities.put(id, id);
    }

    public void removeIdentity(Identity id) throws KeyManagementException {
      if (!identities.containsKey(id))
        throw new KeyManagementException(
            "This Identity is not contained in the scope");
      identities.remove(id);
    }
View Full Code Here

    /**
     * Test for <code>KeyManagementException()</code> constructor Assertion:
     * constructs KeyManagementException with no detail message
     */
    public void testKeyManagementException01() {
        KeyManagementException tE = new KeyManagementException();
        assertNull("getMessage() must return null.", tE.getMessage());
        assertNull("getCause() must return null", tE.getCause());
    }
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.