Java 类java.rmi.server.RemoteServer 实例源码

项目:openNaEF    文件:JournalDistributor.java   
public void addDistributee
        (JournalMirroringClient distributee, TransactionDigest synchronizationBase)
        throws NegotiationException {
    try {
        String distributeeHost = RemoteServer.getClientHost();
        if (!authenticate(InetAddress.getByName(distributeeHost))) {
            logMessage("unauthorized access, " + distributeeHost);
            throw new NegotiationException("authentication failed.");
        }

        ClientAgent agent
                = new ClientAgent(JournalDistributor.this, distributee, synchronizationBase);
        agent.logMessage(distributeeHost);
    } catch (NegotiationException ne) {
        throw ne;
    } catch (Exception e) {
        tefService_.logError("", e);
        throw new NegotiationException(e);
    }
}
项目:GameServerFramework    文件:MasterRMIServerInterfaceImpl.java   
@Override
public boolean registerServer(String key, RMIServiceInterface service) throws RemoteException {
    for (ManagedServerInformationNode node
            : getServer().getServerConfig().getManagedServers().values()) {
        if (node.getServerKey().equals(key)) {
            try {
                // 注册服务
                node.setRemoteService(service);
                node.setServerRMIAddress(service.getServerRMIAddress());
                // 输出日志
                logger.info(
                        String.format("服务节点 [%s] 上线.服务地址为 [%s] .",
                                node.getServerType(),
                                RemoteServer.getClientHost()));
                return true;
            } catch (ServerNotActiveException ex) {
                logger.error("尝试注册服务失败:", ex);
            }
        }
    }
    return false;
}
项目:freeVM    文件:RegistryImpl.java   
/**
 * Checks if the current client has privilegies to modify the contents of
 * the registry. All non-local clients should be rejected.
 * 
 * @throws AccessException
 *             if registry denies the caller access to perform this
 *             operation
 */
private final void checkAccessPrivilegies() throws AccessException {
    String hostName;
    try {
        hostName = RemoteServer.getClientHost();
    } catch (ServerNotActiveException e) {
        // if no remote host is currently executing this method,
        // then is localhost, and the access should be granted.
        return;
    }
    if (hostName == null) {
        throw new AccessException("Can not get remote host address.");
    }
    if (!localIPs.contains(hostName)) {
        throw new AccessException(
                "Registry can not be modified by this host.");
    }
}
项目:freeVM    文件:RegistryImpl.java   
/**
 * Checks if the current client has privilegies to modify the contents of
 * the registry. All non-local clients should be rejected.
 * 
 * @throws AccessException
 *             if registry denies the caller access to perform this
 *             operation
 */
private final void checkAccessPrivilegies() throws AccessException {
    String hostName;
    try {
        hostName = RemoteServer.getClientHost();
    } catch (ServerNotActiveException e) {
        // if no remote host is currently executing this method,
        // then is localhost, and the access should be granted.
        return;
    }
    if (hostName == null) {
        throw new AccessException("Can not get remote host address.");
    }
    if (!localIPs.contains(hostName)) {
        throw new AccessException(
                "Registry can not be modified by this host.");
    }
}
项目:freeVM    文件:RemoteServerTest.java   
public void testLog() {
    SecurityManager sm = new SecurityManager() {
        @Override
        public void checkPermission(Permission perm) {
            return;
        }
    };
    SecurityManager previous = System.getSecurityManager();
    System.setSecurityManager(sm);
    try {
        RemoteServer.setLog(null);
        assertNull(RemoteServer.getLog());
    } finally {
        System.setSecurityManager(previous);
    }
}
项目:OpenJSharp    文件:RMIServerImpl.java   
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();
}
项目:jdk8u-jdk    文件:RMIServerImpl.java   
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();
}
项目:jdk8u-jdk    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:openjdk-jdk10    文件:RMIServerImpl.java   
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();
}
项目:openjdk-jdk10    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:openjdk9    文件:RMIServerImpl.java   
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();
}
项目:openjdk9    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:Java8CN    文件:RMIServerImpl.java   
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();
}
项目:jdk8u_jdk    文件:RMIServerImpl.java   
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();
}
项目:jdk8u_jdk    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:RMIServerImpl.java   
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();
}
项目:lookaside_java-1.8.0-openjdk    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:VS    文件:Main.java   
static public void main(String[] args) throws RemoteException{
        System.out.println("hello i am the server");

        LocateRegistry.createRegistry(Registry.REGISTRY_PORT);

        DiceRMI diceRMI = new DiceRMIImpl();
        //DiceRMI stub = (DiceRMI) UnicastRemoteObject.exportObject(diceRMI, 0);
        RemoteServer.setLog(System.out);

        Registry registry = LocateRegistry.getRegistry();
        registry.rebind( "DiceRMI", diceRMI );
//        registry.rebind( "192.168.99.101:1234/DiceRMI", stub );
        System.out.println( "DiceRMI angemeldet" );
    }
项目:infobip-open-jdk-8    文件:RMIServerImpl.java   
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();
}
项目:infobip-open-jdk-8    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:jdk8u-dev-jdk    文件:RMIServerImpl.java   
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();
}
项目:jdk8u-dev-jdk    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:jdk7-jdk    文件:RMIServerImpl.java   
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
    } 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();
}
项目:jdk7-jdk    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:fourinone    文件:MementoService.java   
String getClientHost(){
    String clienthost=null;
    try{
        clienthost = RemoteServer.getClientHost();
    }catch(ServerNotActiveException ex){
        LogUtil.fine("[MementoService]", "[getClientHost]", ex);
    }
    //System.out.println("clienthost:"+clienthost);
    return clienthost;
}
项目:openjdk-source-code-learn    文件:RMIServerImpl.java   
private static synchronized String makeConnectionId(String protocol,
                                                    Subject subject) {
    connectionIdNumber++;

    String clientHost = "";
    try {
        clientHost = RemoteServer.getClientHost();
    } 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();
}
项目:openjdk-source-code-learn    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:OLD-OpenJDK8    文件:RMIServerImpl.java   
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();
}
项目:OLD-OpenJDK8    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:JAVA_UNIT    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:openjdk-jdk7u-jdk    文件:RMIServerImpl.java   
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();
}
项目:openjdk-jdk7u-jdk    文件:CheckLogging.java   
private static void checkPermissions() {
    SecurityException ex = null;
    try {
        // should fail for lack of LoggingPermission "control"
        RemoteServer.setLog(System.err);
    } catch (SecurityException e) {
        System.err.println("security excepton caught correctly");
        ex = e;
    }
    if (ex == null) {
        TestLibrary.bomb("able to set log without permission");
    }
}
项目:JServer    文件:JServerRmiAdapter.java   
/**
 * Method for logging of a method call.
 * 
 * @param origin the log origin.
 * @param methodName the name of the method to create a log entry for.
 */
public static final void logMethodCall(final String origin, final String methodName)
{
    if( isRmiMethodCallLoggingEnabled() )
    {
        try{
        JServerUtilities.logDebug(origin, "Method " + methodName + " called by " + RemoteServer.getClientHost() + ".");
        }catch(Exception e){}
    }
}
项目:freeVM    文件:UnicastServerRefImpl.java   
/**
 * Sends call information to the logger.
 * 
 * @param msg
 *            The message to be logged
 */
private void logCall(String msg) {
    Logger logger = Logger.getLogger("org.apache.harmony.rmi.internal.server");
    try {
        logger.log(Level.FINER, "RMI "
                + TransportManager.getTransportManager()
                        .getClientConnection() + " ["
                + RemoteServer.getClientHost() + " : " + msg + "]");
    } catch (ServerNotActiveException e) {
        logger.log(Level.FINER, "RMI (No Connection Info) [" + " : " + msg
                + "]");
    }
}
项目:freeVM    文件:UnicastServerRefImpl.java   
/**
 * Sends exception or error information to the logger.
 * 
 * @param e
 *            The exception or error to be logged
 */
private void logException(Throwable e) {
    Logger logger = Logger.getLogger("org.apache.harmony.rmi.internal.server");
    try {
        logger.log(Level.FINE, "RMI "
                + TransportManager.getTransportManager()
                        .getClientConnection() + " ["
                + RemoteServer.getClientHost() + "] exception: " + e);
    } catch (ServerNotActiveException e1) {
        logger.log(Level.FINE, "RMI (No Connection Info) ["
                + "] exception: " + e);
    }

}
项目:freeVM    文件:UnicastServerRefImpl.java   
/**
 * Sends call information to the logger.
 * 
 * @param msg
 *            The message to be logged
 */
private void logCall(String msg) {
    Logger logger = Logger.getLogger("ar.org.fitc.rmi.server");
    try {
        logger.log(Level.FINER, "RMI "
                + TransportManager.getTransportManager()
                        .getClientConnection() + " ["
                + RemoteServer.getClientHost() + " : " + msg + "]");
    } catch (ServerNotActiveException e) {
        logger.log(Level.FINER, "RMI (No Connection Info) [" + " : " + msg
                + "]");
    }
}
项目:freeVM    文件:UnicastServerRefImpl.java   
/**
 * Sends exception or error information to the logger.
 * 
 * @param e
 *            The exception or error to be logged
 */
private void logException(Throwable e) {
    Logger logger = Logger.getLogger("ar.org.fitc.rmi.server");
    try {
        logger.log(Level.FINE, "RMI "
                + TransportManager.getTransportManager()
                        .getClientConnection() + " ["
                + RemoteServer.getClientHost() + "] exception: " + e);
    } catch (ServerNotActiveException e1) {
        logger.log(Level.FINE, "RMI (No Connection Info) ["
                + "] exception: " + e);
    }

}
项目:freeVM    文件:TestRemoteServer.java   
public void testGetLog001() {
    try {
        RemoteServer.getLog();
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }

}
项目:freeVM    文件:TestRemoteServer.java   
public void testSetLog001() {
    try {
        RemoteServer.setLog(null);
        assertNull("Not logger is set", RemoteServer.getLog());
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
项目:freeVM    文件:TestRemoteServer.java   
public void testSetLog002() {
    try {
        RemoteServer.setLog(new ByteArrayOutputStream());
        assertNotNull("One logger is set", RemoteServer.getLog());
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}