Example usage for javax.net.ssl SSLSocketFactory getDefault

List of usage examples for javax.net.ssl SSLSocketFactory getDefault

Introduction

In this page you can find the example usage for javax.net.ssl SSLSocketFactory getDefault.

Prototype

public static SocketFactory getDefault() 

Source Link

Document

Returns the default SSL socket factory.

Usage

From source file:org.alfresco.repo.security.authentication.ldap.AlfrescoLdapSSLSocketFactory.java

@Override
public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
    SSLSocket sslSocket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(host, port);
    addHostNameVerification(sslSocket);//w w  w.j  a v  a 2 s.c  o  m
    return sslSocket;
}

From source file:org.alfresco.repo.security.authentication.ldap.AlfrescoLdapSSLSocketFactory.java

@Override
public Socket createSocket(InetAddress host, int port) throws IOException {
    SSLSocket sslSocket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(host, port);
    addHostNameVerification(sslSocket);/*www .  j ava  2 s . co  m*/
    return sslSocket;
}

From source file:org.lizardirc.beancounter.security.VerifyingSslSocketFactory.java

public VerifyingSslSocketFactory(String hostname) {
    this.hostname = hostname;
    underlyingFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
}

From source file:org.lizardirc.beancounter.security.FingerprintingSslSocketFactory.java

public FingerprintingSslSocketFactory(Collection<String> c) {
    this(c, (SSLSocketFactory) SSLSocketFactory.getDefault());
}

From source file:org.alfresco.repo.security.authentication.ldap.AlfrescoLdapSSLSocketFactory.java

@Override
public Socket createSocket(String address, int port, InetAddress localAddress, int localPort)
        throws IOException, UnknownHostException {
    SSLSocket sslSocket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(address, port, localAddress,
            localPort);//from  w  ww .j  ava 2 s  . c o  m
    addHostNameVerification(sslSocket);
    return sslSocket;
}

From source file:org.jgentleframework.integration.remoting.rmi.customsocket.SSLSocket_RMIClientSocketFactory.java

public Socket createSocket(String host, int port) {

    try {/*  www  .j ava  2 s. c om*/
        java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
        SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket returnValue = (SSLSocket) socketFactory.createSocket(host, port);
        returnValue.setEnabledCipherSuites(Ciphers);
        return returnValue;
    } catch (Exception ignored) {
        if (log.isFatalEnabled()) {
            log.fatal("Could not create SSL Socket !! ", ignored);
        }
    }
    return null;
}

From source file:IMAPService.java

public IMAPService(String _server, int _port) {
    File mailboxRootDir = new File(mailboxRootDirectory);
    mailboxRootDir.mkdir();//from  w w w. j  a v  a  2 s .co  m

    this.server = _server;
    this.port = _port;
    this.emailFolders = new ArrayList<EmailFolder>();
    this.deleteAfterDownload = false;
    // TODO Auto-generated constructor stub
    try {
        SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
        this.socket = (SSLSocket) sslSocketFactory.createSocket(this.server, this.port);

        this.reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        this.output = new PrintWriter(socket.getOutputStream());
        System.out.println(parseServerResponse());

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.wso2.carbon.databridge.agent.endpoint.binary.BinarySecureClientPoolFactory.java

@Override
public Object createClient(String protocol, String hostName, int port)
        throws DataEndpointException, DataEndpointSecurityException, DataEndpointAgentConfigurationException {
    if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.SSL.toString())) {
        int timeout = AgentHolder.getInstance()
                .getDataEndpointAgent(DataEndpointConstants.BINARY_DATA_AGENT_TYPE).getAgentConfiguration()
                .getSocketTimeoutMS();//from ww  w.jav a2 s.c  o m
        String sslProtocols = AgentHolder.getInstance()
                .getDataEndpointAgent(DataEndpointConstants.BINARY_DATA_AGENT_TYPE).getAgentConfiguration()
                .getSslEnabledProtocols();
        String ciphers = AgentHolder.getInstance()
                .getDataEndpointAgent(DataEndpointConstants.BINARY_DATA_AGENT_TYPE).getAgentConfiguration()
                .getCiphers();

        try {
            SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
            SSLSocket sslSocket = (SSLSocket) sslsocketfactory.createSocket(hostName, port);
            sslSocket.setSoTimeout(timeout);

            if (sslProtocols != null && sslProtocols.length() != 0) {
                String[] sslProtocolsArray = sslProtocols.split(",");
                sslSocket.setEnabledProtocols(sslProtocolsArray);
            }

            if (ciphers != null && ciphers.length() != 0) {
                String[] ciphersArray = ciphers.split(",");
                sslSocket.setEnabledCipherSuites(ciphersArray);
            } else {
                sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites());
            }
            return sslSocket;
        } catch (IOException e) {
            throw new DataEndpointException(
                    "Error while opening socket to " + hostName + ":" + port + ". " + e.getMessage(), e);
        }
    } else {
        throw new DataEndpointException("Unsupported protocol: " + protocol + ". Currently only "
                + DataEndpointConfiguration.Protocol.SSL.toString() + " supported.");
    }
}

From source file:cz.jirutka.spring.unboundid.LdapConnectionFactoryBean.java

public LDAPConnection getObject() throws GeneralSecurityException, LDAPException {
    SocketFactory socketFactory;//ww w  . j ava 2  s. c om

    if (ssl && sslTrustAll) {
        sslTrustManager = new TrustAllTrustManager();
    }

    if (sslTrustManager != null) {
        socketFactory = new SSLUtil(sslTrustManager).createSSLSocketFactory();
    } else if (ssl) {
        socketFactory = SSLSocketFactory.getDefault();
    } else {
        socketFactory = SocketFactory.getDefault();
    }

    connection = new LDAPConnection(socketFactory, host, port);

    if (hasText(bindDN) && hasText(password)) {
        connection.bind(bindDN, password);
    }

    return connection;
}

From source file:org.alfresco.repo.security.authentication.ldap.AlfrescoLdapSSLSocketFactory.java

@Override
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
        throws IOException {
    SSLSocket sslSocket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(address, port, localAddress,
            localPort);/*ww w.java 2s. c  om*/
    addHostNameVerification(sslSocket);
    return sslSocket;
}