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

com.fireflysource.net.tcp.secure.utils.SecureUtils Maven / Gradle / Ivy

There is a newer version: 5.0.2
Show newest version
package com.fireflysource.net.tcp.secure.utils;

import javax.net.ssl.X509TrustManager;
import java.io.InputStream;
import java.security.cert.X509Certificate;

/**
 * @author Pengtao Qiu
 */
abstract public class SecureUtils {

    public static final String SELF_SIGNED_KEY_STORE_TYPE = "jks";
    public static final String SELF_SIGNED_KEY_STORE_PASSWORD = "123456";
    public static final String SELF_SIGNED_KEY_PASSWORD = "654321";
    public static final String KEY_MANAGER_FACTORY_TYPE = "SunX509"; // // PKIX, SunX509
    public static final String TRUST_MANAGER_FACTORY_TYPE = "SunX509";

    public static InputStream getSelfSignedCertificate() {
        return SecureUtils.class.getClassLoader().getResourceAsStream("fireflyKeystore.jks");
    }

    public static X509TrustManager createX509TrustManagerNoCheck() {
        return new X509TrustManager() {
            @Override
            public void checkClientTrusted(X509Certificate[] chain, String authType) {
            }

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

            @Override
            public X509Certificate[] getAcceptedIssuers() {
                return null;
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy