List of usage examples for java.net SocketAddress toString
public String toString()
From source file:org.apache.sshd.common.util.net.SshdSocketAddress.java
public static String toAddressString(SocketAddress addr) { if (addr == null) { return null; } else if (addr instanceof InetSocketAddress) { return ((InetSocketAddress) addr).getHostString(); } else if (addr instanceof SshdSocketAddress) { return ((SshdSocketAddress) addr).getHostName(); } else {// w w w . j a v a2s .co m return addr.toString(); } }
From source file:org.apache.synapse.transport.nhttp.HttpCoreNIOSSLSender.java
private SSLSetupHandler createSSLSetupHandler(final String hostnameVerifier, final CertificateVerificationConfig cvConfig) throws AxisFault { return new SSLSetupHandler() { public void initalize(SSLEngine sslengine) { }/* www. jav a2 s . c o m*/ public void verify(IOSession ioSession, SSLSession session) throws SSLException { SocketAddress remoteAddress = ioSession.getRemoteAddress(); String address; if (remoteAddress instanceof InetSocketAddress) { address = ((InetSocketAddress) remoteAddress).getHostName(); } else { address = remoteAddress.toString(); } boolean valid = false; //Do HostName verification. if (hostnameVerifier != null) { if ("Strict".equals(hostnameVerifier)) { valid = HostnameVerifier.STRICT.verify(address, session); } else if ("AllowAll".equals(hostnameVerifier)) { valid = HostnameVerifier.ALLOW_ALL.verify(address, session); } else if ("DefaultAndLocalhost".equals(hostnameVerifier)) { valid = HostnameVerifier.DEFAULT_AND_LOCALHOST.verify(address, session); } } else { valid = HostnameVerifier.DEFAULT.verify(address, session); } if (!valid) { throw new SSLException("Host name verification failed for host : " + address); } if (cvConfig != null) { try { ocspCrl.verifyRevocationStatus(session.getPeerCertificateChain(), cvConfig.getCacheSize(), cvConfig.getCacheDuration()); } catch (CertificateVerificationException e) { throw new SSLException("Certificate chain validation failed for host : " + address, e); } } } }; }
From source file:org.dragonet.net.inf.mcpe.NetworkHandler.java
public void remove(SocketAddress sockAddr) { clients.remove(sockAddr.toString()); }
From source file:org.dragonet.net.inf.mcpe.NetworkHandler.java
private String getClientKey(SocketAddress addr) { return "MCPE-" + addr.toString(); }
From source file:org.drools.services.RegisterTaskTest.java
@Before public void setUp() throws InterruptedException, IOException { //Task Related Stuff // Use persistence.xml configuration this.emf = Persistence.createEntityManagerFactory("org.drools.task"); this.taskService = new TaskService(this.emf, SystemEventListenerFactory.getSystemEventListener()); this.taskSession = this.taskService.createSession(); MockUserInfo userInfo = new MockUserInfo(); this.taskService.setUserinfo(userInfo); Map vars = new HashedMap(); Reader reader = null;//from w w w . jav a 2 s . c om try { reader = new InputStreamReader( new ClassPathResource("org/drools/task/LoadUsers.mvel").getInputStream()); this.users = (Map<String, User>) eval(reader, vars); for (User user : this.users.values()) { this.taskSession.addUser(user); } } finally { if (reader != null) { reader.close(); } reader = null; } try { reader = new InputStreamReader( new ClassPathResource("org/drools/task/LoadGroups.mvel").getInputStream()); this.groups = (Map<String, Group>) eval(reader, vars); for (Group group : this.groups.values()) { this.taskSession.addGroup(group); } } finally { if (reader != null) { reader.close(); } } // Human task Server configuration SocketAddress htAddress = new InetSocketAddress("127.0.0.1", 9123); SocketAcceptor htAcceptor = new NioSocketAcceptor(); htAcceptor.setHandler(new MinaIoHandler(SystemEventListenerFactory.getSystemEventListener(), new TaskServerMessageHandlerImpl(this.taskService, SystemEventListenerFactory.getSystemEventListener()))); this.serverTask = new MinaAcceptor(htAcceptor, htAddress); this.serverTask.start(); Thread.sleep(5000); // End Execution Server //Execution Node related stuff System.out.println("Server 1 Starting!"); // the servers should be started in a different machine (jvm or physical) or in another thread SocketAddress address = new InetSocketAddress("127.0.0.1", 9124); NodeData nodeData = new NodeData(); // setup Server SocketAcceptor acceptor = new NioSocketAcceptor(); acceptor.setHandler(new MinaIoHandler(SystemEventListenerFactory.getSystemEventListener(), new GenericMessageHandlerImpl(nodeData, SystemEventListenerFactory.getSystemEventListener()))); this.serverNode = new MinaAcceptor(acceptor, address); this.serverNode.start(); System.out.println("Server 1 Started! at = " + address.toString()); Thread.sleep(5000); }
From source file:org.eclipse.gyrex.cloud.internal.zk.ZooKeeperGate.java
/** * Returns more information about the server this node is connected to. * <p>//from ww w . j a v a 2 s.co m * This method is used for debugging purposes and may not be referenced * elsewhere. * </p> * * @return the server info * @noreference This method is not intended to be referenced by clients. */ public String getConnectedServerInfo() { final SocketAddress socketAddress = zooKeeper.testableRemoteSocketAddress(); if (socketAddress instanceof InetSocketAddress) return String.format("%s:%d", ((InetSocketAddress) socketAddress).getHostName(), ((InetSocketAddress) socketAddress).getPort()); if (null != socketAddress) return socketAddress.toString(); return null; }
From source file:org.limewire.mojito.util.ContactUtils.java
/** * Returns the nodeId and address as a formatted String. *///from w w w.ja v a 2 s . com public static String toString(KUID nodeId, SocketAddress address) { if (nodeId != null) { if (address != null) { return nodeId + " (" + address + ")"; } else { return nodeId.toString(); } } else if (address != null) { return address.toString(); } else { return "null"; } }
From source file:org.mule.transport.http.HttpServerConnection.java
public String getRemoteClientAddress() { final SocketAddress clientAddress = socket.getRemoteSocketAddress(); if (clientAddress != null) { return clientAddress.toString(); }/*from w w w . java 2 s . c om*/ return null; }
From source file:org.opendaylight.ovsdb.lib.jsonrpc.NettyBootStrapper.java
public int getServerPort() { SocketAddress socketAddress = channelFuture.channel().localAddress(); if (socketAddress instanceof InetSocketAddress) { InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; return inetSocketAddress.getPort(); } else {//w w w. ja va 2 s .co m throw new NotImplementedException( "Please implement how to obtain port from a " + socketAddress.toString()); } }
From source file:org.red5.server.net.rtmp.RTMPMinaConnection.java
/** * Setter for MINA I/O session (connection) * * @param protocolSession Protocol session *///from w ww .j ava2 s .c om void setIoSession(IoSession protocolSession) { SocketAddress remote = protocolSession.getRemoteAddress(); if (remote instanceof InetSocketAddress) { remoteAddress = ((InetSocketAddress) remote).getAddress().getHostAddress(); remotePort = ((InetSocketAddress) remote).getPort(); } else { remoteAddress = remote.toString(); remotePort = -1; } remoteAddresses = new ArrayList<String>(); remoteAddresses.add(remoteAddress); remoteAddresses = Collections.unmodifiableList(remoteAddresses); this.ioSession = protocolSession; }