Example usage for java.security InvalidAlgorithmParameterException InvalidAlgorithmParameterException

List of usage examples for java.security InvalidAlgorithmParameterException InvalidAlgorithmParameterException

Introduction

In this page you can find the example usage for java.security InvalidAlgorithmParameterException InvalidAlgorithmParameterException.

Prototype

public InvalidAlgorithmParameterException(String message, Throwable cause) 

Source Link

Document

Creates an InvalidAlgorithmParameterException with the specified detail message and cause.

Usage

From source file:net.vexelon.myglob.utils.TrustAllSocketFactory.java

public TrustAllSocketFactory() throws InvalidAlgorithmParameterException {
    super();//from w w w .ja  va 2  s  . c o m

    TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
        @Override
        public X509Certificate[] getAcceptedIssuers() {
            return new X509Certificate[] {};
        }

        @Override
        public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {

        }

        @Override
        public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {

        }
    } };

    SecureRandom secureRND = new SecureRandom();

    try {
        sslContext = SSLContext.getInstance(org.apache.http.conn.ssl.SSLSocketFactory.TLS);
        sslContext.init(null, trustAllCerts, secureRND);
    } catch (NoSuchAlgorithmException e) {
        throw new InvalidAlgorithmParameterException("Failed to initlize TLS context!", e);
    } catch (KeyManagementException e) {
        throw new InvalidAlgorithmParameterException("Failed to init SSL context!", e);
    }

    socketFactory = sslContext.getSocketFactory();
}