@Override public boolean engineIsKeyEntry(String alias) { try { return getKeyStore().isKeyEntry(alias); } catch (KeyStoreException e) { throw new IllegalStateException(e); } }
@Override public Map<String, byte[]> getAllEncodedKeys() { Map<String, byte[]> ret = new HashMap<>(); try { Enumeration<String> aliases = ks.aliases(); while (aliases.hasMoreElements()) { String key = aliases.nextElement(); try { if (ks.isKeyEntry(key)) { ret.put(key, getEncodedKey(key)); } } catch (KeyStoreException e) { log.warn("Error trying to decode key id " + key + ", not returning in list", e); } } } catch (KeyStoreException e) { log.warn("Error retrieving all aliases in keystore; treating as empty", e); return ret; } return ret; }
trustMgrMap.put(alias, fact); if (ks.isKeyEntry(alias) && cert instanceof X509Certificate) { X509Certificate x509Cert = (X509Certificate) cert; Collection<List<?>> ans = x509Cert.getSubjectAlternativeNames();
private static void validateCertificates(KeyStore keyStore) throws GeneralSecurityException { for (String alias : list(keyStore.aliases())) { if (!keyStore.isKeyEntry(alias)) { continue; } Certificate certificate = keyStore.getCertificate(alias); if (!(certificate instanceof X509Certificate)) { continue; } try { ((X509Certificate) certificate).checkValidity(); } catch (CertificateExpiredException e) { throw new CertificateExpiredException("KeyStore certificate is expired: " + e.getMessage()); } catch (CertificateNotYetValidException e) { throw new CertificateNotYetValidException("KeyStore certificate is not yet valid: " + e.getMessage()); } } }
private static void validateCertificates(KeyStore keyStore) throws GeneralSecurityException { for (String alias : list(keyStore.aliases())) { if (!keyStore.isKeyEntry(alias)) { continue; } Certificate certificate = keyStore.getCertificate(alias); if (!(certificate instanceof X509Certificate)) { continue; } try { ((X509Certificate) certificate).checkValidity(); } catch (CertificateExpiredException e) { throw new CertificateExpiredException("KeyStore certificate is expired: " + e.getMessage()); } catch (CertificateNotYetValidException e) { throw new CertificateNotYetValidException("KeyStore certificate is not yet valid: " + e.getMessage()); } } }
private static String findAlias(KeyStore ks) throws KeyStoreException { Enumeration<String> e = ks.aliases(); while(e.hasMoreElements()) { String entry = e.nextElement(); if (ks.isKeyEntry(entry)) { return entry; } } throw new KeyStoreException("Cannot find a private key entry"); }
/** * Gets the initialized key managers. */ protected KeyManager[] getKeyManagers(String algorithm, String keyAlias) throws Exception { KeyManager[] kms; String keystorePass = getKeystorePassword(); KeyStore ks = getKeystore(keystorePass); if (keyAlias != null && !ks.isKeyEntry(keyAlias)) { throw new IOException(sm.getString("jsse.alias_no_key_entry", keyAlias)); } KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); kmf.init(ks, keystorePass.toCharArray()); kms = kmf.getKeyManagers(); if (keyAlias != null) { for (int i = 0; i < kms.length; i++) { kms[i] = new JSSEKeyManager((X509KeyManager) kms[i], keyAlias); } } return kms; }
trustMgrMap.put(alias, fact); if (ks.isKeyEntry(alias) && cert instanceof X509Certificate) { X509Certificate x509Cert = (X509Certificate) cert; Collection<List<?>> ans = x509Cert.getSubjectAlternativeNames();
for(Enumeration<String> e = ks.aliases(); e.hasMoreElements();) { String alias = e.nextElement(); if (ks.isKeyEntry(alias)) { Certificate[] cs; try {
private static String getAlias(final KeyStore ks) throws KeyStoreException { final Enumeration<String> aliasesEnum = ks.aliases(); while (aliasesEnum.hasMoreElements()) { final String alias = aliasesEnum.nextElement(); if (ks.isKeyEntry(alias)) { return alias; } } throw new KeyStoreException("Nenhum alias encontrado no certificado"); } }
@Override public boolean engineIsKeyEntry(String alias) { try { return getKeyStore().isKeyEntry(alias); } catch (KeyStoreException e) { throw new IllegalStateException(e); } }
private static void validateAlias(KeyStore store, String alias) throws IllegalArgumentException, KeyStoreException { if (!store.containsAlias(alias)) { throw new IllegalArgumentException("The alias '" + alias + "' doesn't exist in the key store"); } if (!store.isKeyEntry(alias)) { throw new IllegalArgumentException("The alias '" + alias + "' in the keystore doesn't represent a key entry"); } }
private static void validateAlias(KeyStore store, String alias) throws IllegalArgumentException, KeyStoreException { if (!store.containsAlias(alias)) { throw new IllegalArgumentException("The alias '" + alias + "' doesn't exist in the key store"); } if (!store.isKeyEntry(alias)) { throw new IllegalArgumentException("The alias '" + alias + "' in the keystore doesn't represent a key entry"); } }
private static String findAlias(KeyStore ks) throws KeyStoreException { Enumeration<String> e = ks.aliases(); while (e.hasMoreElements()) { String entry = e.nextElement(); if (ks.isKeyEntry(entry)) { return entry; } } throw new KeyStoreException("Cannot find a private key entry"); }
@Override public boolean engineIsKeyEntry(String alias) { try { return getKeyStore().isKeyEntry(alias); } catch (KeyStoreException e) { throw new IllegalStateException(e); } }
private void assertContainsKey(final KeyStore keyStore) throws StartException, KeyStoreException { Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { if (keyStore.isKeyEntry(aliases.nextElement())) { return; } } throw DomainManagementLogger.ROOT_LOGGER.noKey(path); }
Key GetKey() throws Exception { Key secretKey; if (!_keystore.isKeyEntry(KEY_NAME)) { CreateKey(); } secretKey = _keystore.getKey(KEY_NAME, null); return secretKey; }
Key GetKey() throws Exception { Key secretKey; if(!_keystore.isKeyEntry(KEY_NAME)) { CreateKey(); } secretKey = _keystore.getKey(KEY_NAME, null); return secretKey; }
private void assertContainsKey(final KeyStore keyStore) throws StartException, KeyStoreException { Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { if (keyStore.isKeyEntry(aliases.nextElement())) { return; } } throw DomainManagementLogger.ROOT_LOGGER.noKey(path); }
private static void validateAlias(KeyStore store, String alias) throws IllegalArgumentException, KeyStoreException { if (!store.containsAlias(alias)) { throw new IllegalArgumentException("The alias '" + alias + "' doesn't exist in the key store"); } if (!store.isKeyEntry(alias)) { throw new IllegalArgumentException("The alias '" + alias + "' in the keystore doesn't represent a key entry"); } }