Refine search
private void processHandshakeFailure(Socket raw) throws Exception { SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new TrustManager[] {UNTRUSTED_TRUST_MANAGER}, new SecureRandom()); SSLSocketFactory sslSocketFactory = context.getSocketFactory(); SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket( raw, raw.getInetAddress().getHostAddress(), raw.getPort(), true); try { socket.startHandshake(); // we're testing a handshake failure throw new AssertionError(); } catch (IOException expected) { } socket.close(); }
/** * Returns the endpoint in the format of "address:port" */ private String endpoint() { return sock.getInetAddress() + ":" + sock.getPort(); }
String host = (_hostname_ != null) ? _hostname_ : getRemoteAddress().getHostAddress(); int port = _socket_.getPort(); SSLSocket socket = (SSLSocket) ssf.createSocket(_socket_, host, port, false);
protected String getSockAddress() { StringBuilder sb=new StringBuilder(); if(sock != null) { sb.append(sock.getLocalAddress().getHostAddress()).append(':').append(sock.getLocalPort()); sb.append(" - ").append(sock.getInetAddress().getHostAddress()).append(':').append(sock.getPort()); } return sb.toString(); }
/** * @return pretty print of 'this' */ @Override public String toString() { return "ssl://" + socket.getInetAddress() + ":" + socket.getPort(); } }
public FrontendConnection(SocketChannel channel) { super(channel); Socket socket = channel.socket(); this.host = socket.getInetAddress().getHostAddress(); this.port = socket.getPort(); this.localPort = socket.getLocalPort(); this.handler = new FrontendAuthenticator(this); }
/** * Returns the remote address and port of this socket as a {@code * SocketAddress} or null if the socket is not connected. * * @return the remote socket address and port. */ public SocketAddress getRemoteSocketAddress() { if (!isConnected()) { return null; } return new InetSocketAddress(getInetAddress(), getPort()); }
@Override public ArrayList<String> getClusterServers() { ArrayList<String> serverList = new ArrayList<>(); for (Transfer transfer : transferList) { serverList.add(transfer.getSocket().getInetAddress(). getHostAddress() + ":" + transfer.getSocket().getPort()); } return serverList; }
/** * @return pretty print of 'this' */ @Override public String toString() { return "" + (socket.isConnected() ? "tcp://" + socket.getInetAddress() + ":" + socket.getPort() + "@" + socket.getLocalPort() : (localLocation != null ? localLocation : remoteLocation)) ; }
@Override public Socket createSocket(Socket socket, String host, int port, String clientCertificateAlias) throws NoSuchAlgorithmException, KeyManagementException, MessagingException, IOException { TrustManager[] trustManagers = new TrustManager[] { new VeryTrustingTrustManager(serverCertificate) }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, trustManagers, null); SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); return sslSocketFactory.createSocket( socket, socket.getInetAddress().getHostAddress(), socket.getPort(), true); } }
public String getSocketString() { try { return String.valueOf(theSocket.getInetAddress()) + ':' + theSocket.getPort() + " timeout: " + theSocket.getSoTimeout(); } catch (Exception e) { return String.format("Error in getSocketString: %s", e.getLocalizedMessage()); } }
@Override public void onConnectionEstablished(SocketChannel socketChannel) throws IOException { this.myNext = new HandshakeReceiver( myContext, socketChannel.socket().getInetAddress().getHostAddress(), socketChannel.socket().getPort(), false); }
protected TransportLayer buildTransportLayer(String id, SelectionKey key, SocketChannel socketChannel) throws IOException { if (this.securityProtocol == SecurityProtocol.SASL_SSL) { return SslTransportLayer.create(id, key, sslFactory.createSslEngine(socketChannel.socket().getInetAddress().getHostName(), socketChannel.socket().getPort())); } else { return new PlaintextTransportLayer(key); } }
public SimpleServerRpcConnection(SimpleRpcServer rpcServer, SocketChannel channel, long lastContact) { super(rpcServer); this.channel = channel; this.lastContact = lastContact; this.data = null; this.dataLengthBuffer = ByteBuffer.allocate(4); this.socket = channel.socket(); this.addr = socket.getInetAddress(); if (addr == null) { this.hostAddress = "*Unknown*"; } else { this.hostAddress = addr.getHostAddress(); } this.remotePort = socket.getPort(); if (rpcServer.socketSendBufferSize != 0) { try { socket.setSendBufferSize(rpcServer.socketSendBufferSize); } catch (IOException e) { SimpleRpcServer.LOG.warn( "Connection: unable to set socket send buffer size to " + rpcServer.socketSendBufferSize); } } this.responder = rpcServer.responder; }
public SocketAddress getPeerAddress() { final Socket socket = conduit.getSocketChannel().socket(); return new InetSocketAddress(socket.getInetAddress(), socket.getPort()); }
/** * @param sock Socket. * @param clientNodeId Node ID. * @param log Logger. */ private ClientMessageWorker(Socket sock, UUID clientNodeId, IgniteLogger log) { super("tcp-disco-client-message-worker-[" + U.id8(clientNodeId) + ' ' + sock.getInetAddress().getHostAddress() + ":" + sock.getPort() + ']', log, Math.max(spi.metricsUpdateFreq, 10), null); this.sock = sock; this.clientNodeId = clientNodeId; lastMetricsUpdateMsgTime = U.currentTimeMillis(); }
/** * Return fake, temporary DistributedMember to represent the other vm this vm is connecting to * * @param sock the socket this handshake is operating on * @return temporary id to reprent the other vm */ private InternalDistributedMember getIDForSocket(Socket sock) { return new InternalDistributedMember(sock.getInetAddress(), sock.getPort(), false); }
public synchronized SSLSocket wrapSocket(Socket socket) throws IOException { // ssl socket factory javax.net.ssl.SSLSocketFactory sslSocketFactory = keyStoreFactory().sslContext().getSocketFactory(); // ssl socket SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, socket.getInetAddress().getHostAddress(), socket.getPort(), true); sslSocket.setUseClientMode(true); sslSocket.startHandshake(); return sslSocket; } }
@Override public SSLSocket createSocket(Socket socket) throws SocketException { SSLContext sc; try { sc = SSLContext.getInstance(this.protocol); initSSLContext(sc); } catch (GeneralSecurityException e) { throw new SocketException(e.getMessage()); } try { return (SSLSocket) sc.getSocketFactory() .createSocket(socket, socket.getInetAddress().getHostName(), socket.getPort(), true); } catch (IOException e) { throw new SocketException(e.getMessage()); } }
public Connection(SocketChannel channel, long lastContact) { this.channel = channel; this.lastContact = lastContact; this.data = null; // the buffer is initialized to read the "hrpc" and after that to read // the length of the Rpc-packet (i.e 4 bytes) this.dataLengthBuffer = ByteBuffer.allocate(4); this.unwrappedData = null; this.unwrappedDataLengthBuffer = ByteBuffer.allocate(4); this.socket = channel.socket(); this.addr = socket.getInetAddress(); if (addr == null) { this.hostAddress = "*Unknown*"; } else { this.hostAddress = addr.getHostAddress(); } this.remotePort = socket.getPort(); this.responseQueue = new LinkedList<RpcCall>(); if (socketSendBufferSize != 0) { try { socket.setSendBufferSize(socketSendBufferSize); } catch (IOException e) { LOG.warn("Connection: unable to set socket send buffer size to " + socketSendBufferSize); } } }