001 /* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2006-2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.protocols.jmx; 028 029 import java.io.IOException; 030 import java.rmi.server.RMIClientSocketFactory; 031 import java.rmi.server.RMIServerSocketFactory; 032 import java.util.Map; 033 import java.util.Set; 034 035 import javax.management.remote.rmi.RMIJRMPServerImpl; 036 import javax.management.remote.rmi.RMIConnection; 037 import javax.security.auth.Subject; 038 039 /** 040 * An <code>OpendsRMIJRMPServerImpl</code> object that is exported 041 * through JRMP and that creates client connections as RMI objects exported 042 * through JRMP. 043 */ 044 public class OpendsRMIJRMPServerImpl 045 extends RMIJRMPServerImpl 046 { 047 /** 048 * Creates a new RMIServer object that will be exported on the given port 049 * using the given socket factories. 050 * 051 * @param port 052 * the port on which this object and the RMIConnectionImpl objects 053 * it creates will be exported. Can be zero, to indicate any 054 * available port 055 * @param csf 056 * the client socket factory for the created RMI objects. Can be 057 * null. 058 * @param ssf 059 * the server socket factory for the created RMI objects. Can be 060 * null. 061 * @param env 062 * the environment map. Can be null. 063 * @throws IOException 064 * if the RMIServer object cannot be created. 065 */ 066 public OpendsRMIJRMPServerImpl(int port, RMIClientSocketFactory csf, 067 RMIServerSocketFactory ssf, Map<String, ?> env) throws IOException 068 { 069 super(port, csf, ssf, env); 070 } 071 072 /** 073 * {@inheritDoc} 074 */ 075 @Override 076 protected RMIConnection makeClient(String connectionId, Subject subject) 077 throws IOException 078 { 079 if (subject != null) 080 { 081 Set<Credential> privateCreds = subject 082 .getPrivateCredentials(Credential.class); 083 JmxClientConnection jmxClientConnection = 084 (JmxClientConnection) 085 privateCreds.iterator().next().getClientConnection(); 086 jmxClientConnection.jmxConnectionID = connectionId; 087 } 088 089 return super.makeClient(connectionId, subject); 090 } 091 092 }