use of com.notnoop.exceptions.InvalidSSLConfig in project java-apns by notnoop.
the class SSLContextBuilder method withTrustKeyStore.
public SSLContextBuilder withTrustKeyStore(KeyStore keyStore, String keyStorePassword) throws InvalidSSLConfig {
try {
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
trustManagerFactory.init(keyStore);
trustManagers = trustManagerFactory.getTrustManagers();
return this;
} catch (GeneralSecurityException e) {
throw new InvalidSSLConfig(e);
}
}
use of com.notnoop.exceptions.InvalidSSLConfig in project java-apns by notnoop.
the class SSLContextBuilder method withCertificateKeyStore.
public SSLContextBuilder withCertificateKeyStore(KeyStore keyStore, String keyStorePassword) throws InvalidSSLConfig {
try {
keyManagerFactory = KeyManagerFactory.getInstance(algorithm);
keyManagerFactory.init(keyStore, keyStorePassword.toCharArray());
return this;
} catch (GeneralSecurityException e) {
throw new InvalidSSLConfig(e);
}
}
use of com.notnoop.exceptions.InvalidSSLConfig in project java-apns by notnoop.
the class SSLContextBuilder method build.
public SSLContext build() throws InvalidSSLConfig {
if (keyManagerFactory == null) {
throw new InvalidSSLConfig("Missing KeyManagerFactory");
}
if (trustManagers == null) {
throw new InvalidSSLConfig("Missing TrustManagers");
}
try {
final SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagerFactory.getKeyManagers(), trustManagers, null);
return sslContext;
} catch (GeneralSecurityException e) {
throw new InvalidSSLConfig(e);
}
}
use of com.notnoop.exceptions.InvalidSSLConfig in project java-apns by notnoop.
the class SSLContextBuilder method withDefaultTrustKeyStore.
public SSLContextBuilder withDefaultTrustKeyStore() throws InvalidSSLConfig {
try {
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
trustManagerFactory.init((KeyStore) null);
trustManagers = trustManagerFactory.getTrustManagers();
return this;
} catch (GeneralSecurityException e) {
throw new InvalidSSLConfig(e);
}
}
use of com.notnoop.exceptions.InvalidSSLConfig in project java-apns by notnoop.
the class SSLContextBuilder method withCertificateKeyStore.
public SSLContextBuilder withCertificateKeyStore(InputStream keyStoreStream, String keyStorePassword, String keyStoreType, String keyAlias) throws InvalidSSLConfig {
try {
final KeyStore ks = KeyStore.getInstance(keyStoreType);
ks.load(keyStoreStream, keyStorePassword.toCharArray());
return withCertificateKeyStore(ks, keyStorePassword, keyAlias);
} catch (GeneralSecurityException e) {
throw new InvalidSSLConfig(e);
} catch (IOException e) {
throw new InvalidSSLConfig(e);
}
}
Aggregations