All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vtence.molecule.ssl.SecureProtocol Maven / Gradle / Ivy

There is a newer version: 0.15.0
Show newest version
package com.vtence.molecule.ssl;

import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import java.security.GeneralSecurityException;

public enum SecureProtocol {
    SSL("SSL"),
    TLS("TLS");

    private final String protocol;

    SecureProtocol(String protocol) {
            this.protocol = protocol;
        }

    public SSLContext initialize(KeyManager[] keys) throws GeneralSecurityException {
        return initialize(keys, null);
    }

    public SSLContext initialize(KeyManager[] keys, TrustManager[] trusts) throws GeneralSecurityException {
        SSLContext context = SSLContext.getInstance(protocol);
        context.init(keys, trusts, null);
        return context;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy