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

com.firefly.net.tcp.secure.openssl.SelfSignedCertificateOpenSSLSecureSessionFactory Maven / Gradle / Ivy

There is a newer version: 5.0.0-dev6
Show newest version
package com.firefly.net.tcp.secure.openssl;

import com.firefly.net.tcp.secure.openssl.nativelib.SelfSignedCertificate;
import com.firefly.utils.exception.CommonRuntimeException;

import java.io.File;
import java.security.cert.CertificateException;
import java.util.List;

/**
 * @author Pengtao Qiu
 */
public class SelfSignedCertificateOpenSSLSecureSessionFactory extends AbstractOpenSSLSecureSessionFactory {

    private SelfSignedCertificate selfSignedCertificate;

    public SelfSignedCertificateOpenSSLSecureSessionFactory() {
        this(DEFAULT_SUPPORTED_PROTOCOLS);
    }

    public SelfSignedCertificateOpenSSLSecureSessionFactory(List supportedProtocols) {
        super(supportedProtocols);
        try {
            selfSignedCertificate = new SelfSignedCertificate("www.fireflysource.com");
        } catch (CertificateException e) {
            log.error("create certificate exception", e);
            throw new CommonRuntimeException(e);
        }
    }

    public SelfSignedCertificate getSelfSignedCertificate() {
        return selfSignedCertificate;
    }

    public void setSelfSignedCertificate(SelfSignedCertificate selfSignedCertificate) {
        this.selfSignedCertificate = selfSignedCertificate;
    }

    @Override
    public File getCertificate() {
        return selfSignedCertificate.certificate();
    }

    @Override
    public File getPrivateKey() {
        return selfSignedCertificate.privateKey();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy