Package java.security

Examples of java.security.KeyStoreException


    * @throws NoSuchAlgorithmException
    */
   public void initializeKeyManagerFactory(KeyManagerFactory delegate) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException
   {
      if (keyStore == null)
         throw new KeyStoreException("Global keystore is not correctly initialized");
      if (log.isTraceEnabled())
         log.trace("Using global keystore configuration");
      delegate.init(keyStore, keyStorePass);
   }
View Full Code Here


        {
            if(keyStore.containsAlias(alias))
            {
                return (X509Certificate)keyStore.getCertificate(alias);
            }
            throw new KeyStoreException("the keystore does not contain the given alias");
        }
    }
View Full Code Here

            {
                if(keyStore.containsAlias(alias))
                {
                    return keyStore.getKey(alias, password.toCharArray());
                }
                throw new KeyStoreException("the keystore does not contain the given alias");
            }
        }
        catch(UnrecoverableKeyException ex)
        {
            throw new KeyStoreException("the private key is not recoverable");
        }
        catch(NoSuchAlgorithmException ex)
        {
            throw new KeyStoreException("the algorithm necessary to recover the key is not available");
        }
    }
View Full Code Here

  public void addPrivateKey(String alias, Key privateKey, char[] passphrase, String type) throws GeneralSecurityException {
    EncryptionKeyManager currentMgr = getKeyMgr(type);
    if (currentMgr != null) {
      currentMgr.setPrivateKeyEntry(alias, privateKey, passphrase);
    } else {
      throw new KeyStoreException(type + " KeyStore not initialized.");
    }
  }
View Full Code Here

   
    EncryptionKeyManager currentMgr = getKeyMgr(type);
    if (currentMgr != null) {
      currentMgr.setPublicKeyEntry(alias, publicKey);
    } else {
      throw new KeyStoreException(type + " KeyStore not initialized.");
    }
  }
View Full Code Here

    Key cachedKey = (Key) cachedPrivateKeys.get(alias);
    if (cachedKey != null){
      return cachedKey;
  }
   
    KeyStoreException caughtException = null;
    if (pgpKeyMgr != null || smimeKeyMgr != null) {
      // check to see if this exists anywhere.
      if (pgpKeyMgr != null && EncryptionManager.PGP.equalsIgnoreCase(type)) {
    try {
      if (pgpKeyMgr.containsPrivateKeyAlias(alias)) {
View Full Code Here

    if (algorithm == null) {
      algorithm = DEFAULT_ALGORITHM;
    }

    if (keyStore.size() == 0) {
      throw new KeyStoreException("Keystore is empty; while this is legal for keystores in general, APNs clients must have at least one key.");
    }

    final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
    trustManagerFactory.init((KeyStore) null);
View Full Code Here

    {
        StoreEntry  entry = (StoreEntry)table.get(alias);

        if (entry != null && entry.getType() != CERTIFICATE)
        {
            throw new KeyStoreException("key store already has a key entry with alias " + alias);
        }

        table.put(alias, new StoreEntry(alias, cert));
    }
View Full Code Here

        Certificate[]   chain)
        throws KeyStoreException
    {
        if ((key instanceof PrivateKey) && (chain == null))
        {
            throw new KeyStoreException("no certificate chain for private key");
        }

        try
        {
            table.put(alias, new StoreEntry(alias, key, password, chain));
        }
        catch (Exception e)
        {
            throw new KeyStoreException(e.toString());
        }
    }
View Full Code Here

        Certificate cert)
        throws KeyStoreException
    {
        if (keys.get(alias) != null)
        {
            throw new KeyStoreException("There is a key entry with the name " + alias + ".");
        }

        certs.put(alias, cert);
        chainCerts.put(new CertId(cert.getPublicKey()), cert);
    }
View Full Code Here

TOP

Related Classes of java.security.KeyStoreException

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.