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 legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2006-2008 Sun Microsystems, Inc. 025 * Portions Copyright 2015 ForgeRock AS. 026 */ 027package org.opends.server.protocols.jmx; 028 029import java.io.IOException; 030import java.rmi.server.RMIClientSocketFactory; 031import java.rmi.server.RMIServerSocketFactory; 032import java.util.Map; 033import java.util.Set; 034 035import javax.management.remote.rmi.RMIJRMPServerImpl; 036import javax.management.remote.rmi.RMIConnection; 037import 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 */ 044public 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 /** {@inheritDoc} */ 073 @Override 074 protected RMIConnection makeClient(String connectionId, Subject subject) 075 throws IOException 076 { 077 if (subject != null) 078 { 079 Set<Credential> privateCreds = subject 080 .getPrivateCredentials(Credential.class); 081 JmxClientConnection jmxClientConnection = 082 (JmxClientConnection) 083 privateCreds.iterator().next().getClientConnection(); 084 jmxClientConnection.jmxConnectionID = connectionId; 085 } 086 087 return super.makeClient(connectionId, subject); 088 } 089 090}