if (keyStore != null && keyInstance == null) { logger.info( "Keystore {} not found", keyStore ); } else if (keyStore != null && keyInstance.isKeystoreLocked()) { logger.info( "Keystore {} locked", keyStore ); } else if (keyStore != null && keyAlias != null && keyInstance.isKeyLocked(keyAlias)) { } else if (trustStore != null && trustInstance == null) { logger.info( "Truststore {} not found", trustStore ); } else if (trustStore != null && trustInstance.isKeystoreLocked()) { logger.info( "Truststore {} locked", keyStore ); } else {
if (keyStore != null && keyInstance == null) { logger.info( "Keystore {} not found", keyStore ); } else if (keyStore != null && keyInstance.isKeystoreLocked()) { logger.info( "Keystore {} locked", keyStore ); } else if (keyStore != null && keyAlias != null && keyInstance.isKeyLocked(keyAlias)) { } else if (trustStore != null && trustInstance == null) { logger.info( "Truststore {} not found", trustStore ); } else if (trustStore != null && trustInstance.isKeystoreLocked()) { logger.info( "Truststore {} locked", keyStore ); } else {
public SSLContext createSSLContext(String provider, String protocol, String algorithm, String keyStore, String keyAlias, String trustStore, long timeout) throws GeneralSecurityException { if (!this.checkForKeystoresAvailability(keyStore, keyAlias, trustStore, timeout)) { throw new GeneralSecurityException("Unable to lookup configured keystore and/or truststore"); } KeystoreInstance keyInstance = getKeystore(keyStore); if (keyInstance != null && keyInstance.isKeystoreLocked()) { throw new KeystoreIsLocked("Keystore '" + keyStore + "' is locked"); } if (keyInstance != null && keyInstance.isKeyLocked(keyAlias)) { throw new KeystoreIsLocked("Key '" + keyAlias + "' in keystore '" + keyStore + "' is locked"); } KeystoreInstance trustInstance = trustStore == null ? null : getKeystore(trustStore); if (trustInstance != null && trustInstance.isKeystoreLocked()) { throw new KeystoreIsLocked("Keystore '" + trustStore + "' is locked"); } SSLContext context; if (provider == null) { context = SSLContext.getInstance(protocol); } else { context = SSLContext.getInstance(protocol, provider); } context.init(keyInstance == null ? null : keyInstance.getKeyManager(algorithm, keyAlias), trustInstance == null ? null : trustInstance.getTrustManager(algorithm), new SecureRandom()); return context; }
public SSLContext createSSLContext(String provider, String protocol, String algorithm, String keyStore, String keyAlias, String trustStore, long timeout) throws GeneralSecurityException { if (!this.checkForKeystoresAvailability(keyStore, keyAlias, trustStore, timeout)) { throw new GeneralSecurityException("Unable to lookup configured keystore and/or truststore"); } KeystoreInstance keyInstance = getKeystore(keyStore); if (keyInstance != null && keyInstance.isKeystoreLocked()) { throw new KeystoreIsLocked("Keystore '" + keyStore + "' is locked"); } if (keyInstance != null && keyInstance.isKeyLocked(keyAlias)) { throw new KeystoreIsLocked("Key '" + keyAlias + "' in keystore '" + keyStore + "' is locked"); } KeystoreInstance trustInstance = trustStore == null ? null : getKeystore(trustStore); if (trustInstance != null && trustInstance.isKeystoreLocked()) { throw new KeystoreIsLocked("Keystore '" + trustStore + "' is locked"); } SSLContext context; if (provider == null) { context = SSLContext.getInstance(protocol); } else { context = SSLContext.getInstance(protocol, provider); } context.init(keyInstance == null ? null : keyInstance.getKeyManager(algorithm, keyAlias), trustInstance == null ? null : trustInstance.getTrustManager(algorithm), new SecureRandom()); return context; }