Java Code Examples for javax.net.ssl.SSLSocket#setNeedClientAuth()
The following examples show how to use
javax.net.ssl.SSLSocket#setNeedClientAuth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectorBootstrap.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public Socket accept() throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; }
Example 2
Source File: SslRMIServerSocketFactorySecure.java From hbase with Apache License 2.0 | 6 votes |
@Override public ServerSocket createServerSocket(int port) throws IOException { return new ServerSocket(port) { @Override public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); sslSocket.setNeedClientAuth(false); ArrayList<String> secureProtocols = new ArrayList<>(); for (String p : sslSocket.getEnabledProtocols()) { if (!p.contains("SSLv3")) { secureProtocols.add(p); } } sslSocket.setEnabledProtocols(secureProtocols.toArray(new String[secureProtocols.size()])); return sslSocket; } }; }
Example 3
Source File: SslContextFactory.java From cloudhopper-commons with Apache License 2.0 | 6 votes |
/** * Get an SSLSocket from this context. * {@link SSLContext#getSocketFactory()} */ public SSLSocket newSslSocket() throws IOException { SSLSocketFactory factory = sslContext.getSocketFactory(); SSLSocket socket = (SSLSocket)factory.createSocket(); if (sslConfig.getWantClientAuth()) socket.setWantClientAuth(sslConfig.getWantClientAuth()); if (sslConfig.getNeedClientAuth()) socket.setNeedClientAuth(sslConfig.getNeedClientAuth()); socket.setEnabledCipherSuites(selectCipherSuites(socket.getEnabledCipherSuites(), socket.getSupportedCipherSuites())); socket.setEnabledProtocols(selectProtocols(socket.getEnabledProtocols(),socket.getSupportedProtocols())); return socket; }
Example 4
Source File: SslRMIServerSocketFactory.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * <p>Creates a server socket that accepts SSL connections * configured according to this factory's SSL socket configuration * parameters.</p> */ public ServerSocket createServerSocket(int port) throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); return new ServerSocket(port) { public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; } }; }
Example 5
Source File: FTPSClient.java From Aria with Apache License 2.0 | 6 votes |
/** * Returns a socket of the data connection. * Wrapped as an {@link SSLSocket}, which carries out handshake processing. * * @param command The textual representation of the FTP command to send. * @param arg The arguments to the FTP command. * If this parameter is set to null, then the command is sent with * no arguments. * @return corresponding to the established data connection. * Null is returned if an FTP protocol error is reported at any point * during the establishment and initialization of the connection. * @throws IOException If there is any problem with the connection. * @see FTPClient#_openDataConnection_(int, String) * @since 3.2 */ @Override protected Socket _openDataConnection_(String command, String arg) throws IOException { Socket socket = super._openDataConnection_(command, arg); _prepareDataSocket_(socket); if (socket instanceof SSLSocket) { SSLSocket sslSocket = (SSLSocket) socket; sslSocket.setUseClientMode(isClientMode); sslSocket.setEnableSessionCreation(isCreation); // server mode if (!isClientMode) { sslSocket.setNeedClientAuth(isNeedClientAuth); sslSocket.setWantClientAuth(isWantClientAuth); } if (suites != null) { sslSocket.setEnabledCipherSuites(suites); } if (protocols != null) { sslSocket.setEnabledProtocols(protocols); } sslSocket.startHandshake(); } return socket; }
Example 6
Source File: SslRMIServerSocketFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * <p>Creates a server socket that accepts SSL connections * configured according to this factory's SSL socket configuration * parameters.</p> */ public ServerSocket createServerSocket(int port) throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); return new ServerSocket(port) { public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; } }; }
Example 7
Source File: ConnectorBootstrap.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public Socket accept() throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; }
Example 8
Source File: SslRMIServerSocketFactory.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * <p>Creates a server socket that accepts SSL connections * configured according to this factory's SSL socket configuration * parameters.</p> */ public ServerSocket createServerSocket(int port) throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); return new ServerSocket(port) { public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; } }; }
Example 9
Source File: SslContextFactory.java From IoTgo_Android_App with MIT License | 6 votes |
public SSLSocket newSslSocket() throws IOException { SSLSocketFactory factory = _context.getSocketFactory(); SSLSocket socket = (SSLSocket)factory.createSocket(); if (getWantClientAuth()) socket.setWantClientAuth(getWantClientAuth()); if (getNeedClientAuth()) socket.setNeedClientAuth(getNeedClientAuth()); socket.setEnabledCipherSuites(selectCipherSuites( socket.getEnabledCipherSuites(), socket.getSupportedCipherSuites())); socket.setEnabledProtocols(selectProtocols(socket.getEnabledProtocols(),socket.getSupportedProtocols())); return socket; }
Example 10
Source File: SslRMIServerSocketFactory.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * <p>Creates a server socket that accepts SSL connections * configured according to this factory's SSL socket configuration * parameters.</p> */ public ServerSocket createServerSocket(int port) throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); return new ServerSocket(port) { public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; } }; }
Example 11
Source File: SslRMIServerSocketFactory.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * <p>Creates a server socket that accepts SSL connections * configured according to this factory's SSL socket configuration * parameters.</p> */ public ServerSocket createServerSocket(int port) throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); return new ServerSocket(port) { public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; } }; }
Example 12
Source File: ConnectorBootstrap.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override public Socket accept() throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; }
Example 13
Source File: SslRMIServerSocketFactory.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * <p>Creates a server socket that accepts SSL connections * configured according to this factory's SSL socket configuration * parameters.</p> */ public ServerSocket createServerSocket(int port) throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); return new ServerSocket(port) { public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; } }; }
Example 14
Source File: ConnectorBootstrap.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public Socket accept() throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; }
Example 15
Source File: ConnectorBootstrap.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public Socket accept() throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; }
Example 16
Source File: SslRMIServerSocketFactory.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * <p>Creates a server socket that accepts SSL connections * configured according to this factory's SSL socket configuration * parameters.</p> */ public ServerSocket createServerSocket(int port) throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); return new ServerSocket(port) { public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; } }; }
Example 17
Source File: SslRMIServerSocketFactory.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * <p>Creates a server socket that accepts SSL connections * configured according to this factory's SSL socket configuration * parameters.</p> */ public ServerSocket createServerSocket(int port) throws IOException { final SSLSocketFactory sslSocketFactory = context == null ? getDefaultSSLSocketFactory() : context.getSocketFactory(); return new ServerSocket(port) { public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); if (enabledCipherSuites != null) { sslSocket.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sslSocket.setEnabledProtocols(enabledProtocols); } sslSocket.setNeedClientAuth(needClientAuth); return sslSocket; } }; }
Example 18
Source File: HandshakeHashCloneExhaustion.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override protected void runServerApplication(SSLSocket socket) throws Exception { socket.setNeedClientAuth(true); socket.setEnabledProtocols(protocol); socket.setEnabledCipherSuites(ciphersuite); // here comes the test logic InputStream sslIS = socket.getInputStream(); OutputStream sslOS = socket.getOutputStream(); sslIS.read(); sslOS.write(85); sslOS.flush(); }
Example 19
Source File: HandshakeHashCloneExhaustion.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override protected void runServerApplication(SSLSocket socket) throws Exception { socket.setNeedClientAuth(true); socket.setEnabledProtocols(protocol); socket.setEnabledCipherSuites(ciphersuite); // here comes the test logic InputStream sslIS = socket.getInputStream(); OutputStream sslOS = socket.getOutputStream(); sslIS.read(); sslOS.write(85); sslOS.flush(); }
Example 20
Source File: ListenSMTP.java From localization_nifi with Apache License 2.0 | 4 votes |
private SMTPServer prepareServer(final ProcessContext context, final ProcessSessionFactory sessionFactory) { final int port = context.getProperty(SMTP_PORT).asInteger(); final String host = context.getProperty(SMTP_HOSTNAME).getValue(); final ComponentLog log = getLogger(); final int maxMessageSize = context.getProperty(SMTP_MAXIMUM_MSG_SIZE).asDataSize(DataUnit.B).intValue(); //create message handler factory final MessageHandlerFactory messageHandlerFactory = (final MessageContext mc) -> { return new SmtpConsumer(mc, sessionFactory, port, host, log, maxMessageSize); }; //create smtp server final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); final SMTPServer smtpServer = sslContextService == null ? new SMTPServer(messageHandlerFactory) : new SMTPServer(messageHandlerFactory) { @Override public SSLSocket createSSLSocket(Socket socket) throws IOException { InetSocketAddress remoteAddress = (InetSocketAddress) socket.getRemoteSocketAddress(); String clientAuth = context.getProperty(CLIENT_AUTH).getValue(); SSLContext sslContext = sslContextService.createSSLContext(SSLContextService.ClientAuth.valueOf(clientAuth)); SSLSocketFactory socketFactory = sslContext.getSocketFactory(); SSLSocket sslSocket = (SSLSocket) (socketFactory.createSocket(socket, remoteAddress.getHostName(), socket.getPort(), true)); sslSocket.setUseClientMode(false); if (SSLContextService.ClientAuth.REQUIRED.toString().equals(clientAuth)) { this.setRequireTLS(true); sslSocket.setNeedClientAuth(true); } return sslSocket; } }; if (sslContextService != null) { smtpServer.setEnableTLS(true); } else { smtpServer.setHideTLS(true); } smtpServer.setSoftwareName("Apache NiFi SMTP"); smtpServer.setPort(port); smtpServer.setMaxConnections(context.getProperty(SMTP_MAXIMUM_CONNECTIONS).asInteger()); smtpServer.setMaxMessageSize(maxMessageSize); smtpServer.setConnectionTimeout(context.getProperty(SMTP_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()); if (context.getProperty(SMTP_HOSTNAME).isSet()) { smtpServer.setHostName(context.getProperty(SMTP_HOSTNAME).getValue()); } return smtpServer; }