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

org.kiwiproject.security.KeyAndTrustStoreConfigProvider Maven / Gradle / Ivy

Go to download

Kiwi is a utility library. We really like Google's Guava, and also use Apache Commons. But if they don't have something we need, and we think it is useful, this is where we put it.

There is a newer version: 4.5.2
Show newest version
package org.kiwiproject.security;

import javax.net.ssl.SSLContext;

/**
 * Defines a configuration interface for properties needed to create key and trust stores, and a contract to
 * be able to create an {@link SSLContext} and {@link javax.net.ssl.SSLSocketFactory} from this configuration.
 */
public interface KeyAndTrustStoreConfigProvider extends TrustStoreConfigProvider {

    /**
     * The path to the key store.
     *
     * @return key store path
     */
    String getKeyStorePath();

    /**
     * The key store password (plain text).
     *
     * @return key store password
     */
    String getKeyStorePassword();

    /**
     * Key store type. Default is JKS.
     *
     * @return key store type
     * @see KeyStoreType#JKS
     */
    default String getKeyStoreType() {
        return KeyStoreType.JKS.value;
    }

    /**
     * Convert this configuration into a {@link SSLContext}.
     *
     * @return a new SSLContext instance
     * @see KiwiSecurity#createSslContext(String, String, String, String, String, String, String)
     */
    @Override
    default SSLContext toSSLContext() {
        return KiwiSecurity.createSslContext(
                getKeyStorePath(), getKeyStorePassword(), getKeyStoreType(),
                getTrustStorePath(), getTrustStorePassword(), getTrustStoreType(),
                getProtocol()
        );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy