java.rmi.server.ServerNotActiveException Java Examples

The following examples show how to use java.rmi.server.ServerNotActiveException. 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: UnicastServerRef.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the details of an incoming call.  The method parameter is either of
 * type java.lang.reflect.Method or java.rmi.server.Operation.
 */
private void logCall(Remote obj, Object method) {
    if (callLog.isLoggable(Log.VERBOSE)) {
        String clientHost;
        try {
            clientHost = getClientHost();
        } catch (ServerNotActiveException snae) {
            clientHost = "(local)"; // shouldn't happen
        }
        callLog.log(Log.VERBOSE, "[" + clientHost + ": " +
                          obj.getClass().getName() +
                          ref.getObjID().toString() + ": " +
                          method + "]");
    }
}
 
Example #2
Source File: RMIServerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #3
Source File: TCPTransport.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}
 
Example #4
Source File: UnicastServerRef.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the details of an incoming call.  The method parameter is either of
 * type java.lang.reflect.Method or java.rmi.server.Operation.
 */
private void logCall(Remote obj, Object method) {
    if (callLog.isLoggable(Log.VERBOSE)) {
        String clientHost;
        try {
            clientHost = getClientHost();
        } catch (ServerNotActiveException snae) {
            clientHost = "(local)"; // shouldn't happen
        }
        callLog.log(Log.VERBOSE, "[" + clientHost + ": " +
                          obj.getClass().getName() +
                          ref.getObjID().toString() + ": " +
                          method + "]");
    }
}
 
Example #5
Source File: RMIServerImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #6
Source File: RMIServerImpl.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #7
Source File: TCPTransport.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}
 
Example #8
Source File: UnicastServerRef.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the details of an incoming call.  The method parameter is either of
 * type java.lang.reflect.Method or java.rmi.server.Operation.
 */
private void logCall(Remote obj, Object method) {
    if (callLog.isLoggable(Log.VERBOSE)) {
        String clientHost;
        try {
            clientHost = getClientHost();
        } catch (ServerNotActiveException snae) {
            clientHost = "(local)"; // shouldn't happen
        }
        callLog.log(Log.VERBOSE, "[" + clientHost + ": " +
                          obj.getClass().getName() +
                          ref.getObjID().toString() + ": " +
                          method + "]");
    }
}
 
Example #9
Source File: RMIServerImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #10
Source File: TCPTransport.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}
 
Example #11
Source File: UnicastServerRef.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the details of an incoming call.  The method parameter is either of
 * type java.lang.reflect.Method or java.rmi.server.Operation.
 */
private void logCall(Remote obj, Object method) {
    if (callLog.isLoggable(Log.VERBOSE)) {
        String clientHost;
        try {
            clientHost = getClientHost();
        } catch (ServerNotActiveException snae) {
            clientHost = "(local)"; // shouldn't happen
        }
        callLog.log(Log.VERBOSE, "[" + clientHost + ": " +
                          obj.getClass().getName() +
                          ref.getObjID().toString() + ": " +
                          method + "]");
    }
}
 
Example #12
Source File: RMIServerImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #13
Source File: TCPTransport.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}
 
Example #14
Source File: TCPTransport.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}
 
Example #15
Source File: RMIServerImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #16
Source File: TCPTransport.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}
 
Example #17
Source File: UnicastServerRef.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the details of an incoming call.  The method parameter is either of
 * type java.lang.reflect.Method or java.rmi.server.Operation.
 */
private void logCall(Remote obj, Object method) {
    if (callLog.isLoggable(Log.VERBOSE)) {
        String clientHost;
        try {
            clientHost = getClientHost();
        } catch (ServerNotActiveException snae) {
            clientHost = "(local)"; // shouldn't happen
        }
        callLog.log(Log.VERBOSE, "[" + clientHost + ": " +
                          obj.getClass().getName() +
                          ref.getObjID().toString() + ": " +
                          method + "]");
    }
}
 
Example #18
Source File: RMIServerImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #19
Source File: TCPTransport.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}
 
Example #20
Source File: UnicastServerRef.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the details of an incoming call.  The method parameter is either of
 * type java.lang.reflect.Method or java.rmi.server.Operation.
 */
private void logCall(Remote obj, Object method) {
    if (callLog.isLoggable(Log.VERBOSE)) {
        String clientHost;
        try {
            clientHost = getClientHost();
        } catch (ServerNotActiveException snae) {
            clientHost = "(local)"; // shouldn't happen
        }
        callLog.log(Log.VERBOSE, "[" + clientHost + ": " +
                          obj.getClass().getName() +
                          ref.getObjID().toString() + ": " +
                          method + "]");
    }
}
 
Example #21
Source File: RMIServerImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #22
Source File: TCPTransport.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}
 
Example #23
Source File: UnicastServerRef.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the details of an incoming call.  The method parameter is either of
 * type java.lang.reflect.Method or java.rmi.server.Operation.
 */
private void logCall(Remote obj, Object method) {
    if (callLog.isLoggable(Log.VERBOSE)) {
        String clientHost;
        try {
            clientHost = getClientHost();
        } catch (ServerNotActiveException snae) {
            clientHost = "(local)"; // shouldn't happen
        }
        callLog.log(Log.VERBOSE, "[" + clientHost + ": " +
                          obj.getClass().getName() +
                          ref.getObjID().toString() + ": " +
                          method + "]");
    }
}
 
Example #24
Source File: RMIServerImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #25
Source File: MementoService.java    From Fourinone with Apache License 2.0 5 votes vote down vote up
String getClientHost(){
	String clienthost=null;
	try{
		clienthost = RemoteServer.getClientHost();
	}catch(ServerNotActiveException ex){
		LogUtil.fine("[MementoService]", "[getClientHost]", ex);
	}
	//System.out.println("clienthost:"+clienthost);
	return clienthost;
}
 
Example #26
Source File: RMIServerImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #27
Source File: UnicastServerRef.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the details of an incoming call.  The method parameter is either of
 * type java.lang.reflect.Method or java.rmi.server.Operation.
 */
private void logCall(Remote obj, Object method) {
    if (callLog.isLoggable(Log.VERBOSE)) {
        String clientHost;
        try {
            clientHost = getClientHost();
        } catch (ServerNotActiveException snae) {
            clientHost = "(local)"; // shouldn't happen
        }
        callLog.log(Log.VERBOSE, "[" + clientHost + ": " +
                          obj.getClass().getName() +
                          ref.getObjID().toString() + ": " +
                          method + "]");
    }
}
 
Example #28
Source File: RMIServerImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
        /*
         * According to the rules specified in the javax.management.remote
         * package description, a numeric IPv6 address (detected by the
         * presence of otherwise forbidden ":" character) forming a part
         * of the connection id must be enclosed in square brackets.
         */
        if (clientHost.contains(":")) {
            clientHost = "[" + clientHost + "]";
        }
    } catch (ServerNotActiveException e) {
        logger.trace("makeConnectionId", "getClientHost", e);
    }

    final StringBuilder buf = new StringBuilder();
    buf.append(protocol).append(":");
    if (clientHost.length() > 0)
        buf.append("//").append(clientHost);
    buf.append(" ");
    if (subject != null) {
        Set<Principal> principals = subject.getPrincipals();
        String sep = "";
        for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
            Principal p = it.next();
            String name = p.getName().replace(' ', '_').replace(';', ':');
            buf.append(sep).append(name);
            sep = ";";
        }
    }
    buf.append(" ").append(connectionIdNumber);
    if (logger.traceOn())
        logger.trace("newConnectionId","connectionId="+buf);
    return buf.toString();
}
 
Example #29
Source File: TCPTransport.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}
 
Example #30
Source File: TCPTransport.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the client host for the current thread's connection.  Throws
 * ServerNotActiveException if no connection is active for this thread.
 */
public static String getClientHost() throws ServerNotActiveException {
    ConnectionHandler h = threadConnectionHandler.get();
    if (h != null) {
        return h.getClientHost();
    } else {
        throw new ServerNotActiveException("not in a remote call");
    }
}