Package java.security

Examples of java.security.KeyStore.containsAlias()


                        || command == Command.CERTREQ
                        || command == Command.KEYPASSWD
                        || command == Command.SELFCERT
                // if keystore contains alias, import of a certificate reply
                // is considered, otherwise password is unnecessary.
                || (command == Command.IMPORT && keyStore.containsAlias(alias)))) {
            param.setKeyPass(tryStorePassAsKeyPass(keyStore, alias, param
                    .getStorePass()));
        }
       
        switch (command) {
View Full Code Here


        // if the generated certificate shouldn't be self-signed
        // but should be signed with a chain.
        boolean selfSigned = (param.getIssuerAlias() == null);
        if (!selfSigned) {
            String issuerAlias = param.getIssuerAlias();
            if (!keyStore.containsAlias(issuerAlias)) {
                throw new KeytoolException("Certificate issuer alias <"
                        + issuerAlias + "> does not exist.");
            }

            if (!keyStore.entryInstanceOf(issuerAlias,
View Full Code Here

      if(ks == null){
        LOG.error("Null keystore");
      }
      else {
        try {
          if(ks.containsAlias(ALIAS)) {
            ks.deleteEntry(ALIAS);
          }
         
          keyStoreService.saveKeyStore(ks);
        }
View Full Code Here

        LOG.error("KeyStoreService did not give me my keystore!");
        throw new RuntimeException("KeyStoreService did not give me my keystore!");
      }
     
      try {
        if(ks.containsAlias(ALIAS)) {
          ks.deleteEntry(ALIAS);
        }
       
        ks.setKeyEntry(ALIAS, jkey, keyStoreKeyPassword.toCharArray(), (java.security.cert.Certificate[]) Arrays.asList(jcert).toArray());
       
View Full Code Here

      ks = loadKeyStore(passphrase);
    } catch (KeyStoreException e) { // Problem loading keystore
      log4j.error(e.getMessage(), e);
    }
    // check if the Certificate for alias is installed. If not, install it.
    if (ks != null && !ks.containsAlias(alias)) {
      installCert(url, alias, passphrase);
      ks = loadKeyStore(passphrase);
    }
    // Now try and establish the secure connection
    try {
View Full Code Here

    private void ensureKeyPairForInstanceAlias() throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, UnrecoverableKeyException, ProcessManagerException {
        /*
         * No need to add glassfish-instance to the keystore if it already exists.
         */
        final KeyStore ks = sslUtils().getKeyStore();
        if (ks.containsAlias(SecureAdmin.Duck.DEFAULT_INSTANCE_ALIAS)) {
            return;
        }
       
        /*
         * This is ugly but effective.  We need to add a new private key to
View Full Code Here

        // if the generated certificate shouldn't be self-signed
        // but should be signed with a chain.
        boolean selfSigned = (param.getIssuerAlias() == null);
        if (!selfSigned) {
            String issuerAlias = param.getIssuerAlias();
            if (!keyStore.containsAlias(issuerAlias)) {
                throw new KeytoolException("Certificate issuer alias <"
                        + issuerAlias + "> does not exist.");
            }

            if (!keyStore.entryInstanceOf(issuerAlias,
View Full Code Here

    {
      if (!containsCertificate(chain[i], k))
      {
        String alias = chain[i].getSubjectDN().getName();
        int j = 1;
        while (k.containsAlias(alias))
        {
          alias = chain[i].getSubjectDN().getName()+ "-" + j;
          j++;
        }
        k.setCertificateEntry(alias, chain[i]);
View Full Code Here

      if (!lock.tryLock(10, TimeUnit.MINUTES)) {
         throw CertificateMgmtException.ACQUIRE_TRUST_LOCK_TIMEOUT();
      }
      try {
         store = JksKeyStoreUtil.loadKeyStore(cmsKeyStorePath, keyStorePswd);
         if (store.containsAlias(alias)) {
            store.deleteEntry(alias);
            JksKeyStoreUtil.serializeKeyStore(cmsKeyStorePath, store, keyStorePswd);
         }
      } finally {
         lock.unlock();
View Full Code Here

    private void ensureKeyPairForInstanceAlias() throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, UnrecoverableKeyException, ProcessManagerException {
        /*
         * No need to add glassfish-instance to the keystore if it already exists.
         */
        final KeyStore ks = sslUtils().getKeyStore();
        if (ks.containsAlias(SecureAdmin.Duck.DEFAULT_INSTANCE_ALIAS)) {
            return;
        }
       
        /*
         * This is ugly but effective.  We need to add a new private key to
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.