mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.1.N (5.1.1) to HEAD (5.1)
121275 amukha: Merged 5.0.N (5.0.4) to 5.1.N (5.1.1) 121273 amukha: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.4) (PARTIAL MERGE) 121272 amukha: Merged V4.1-BUG-FIX (4.1.11) to V4.2-BUG-FIX (4.2.6) 121271 amukha: MNT-15543: CLONE - Remote access via JMX should be disabled by default - Added additional bean configuration to fully disable RMI by default. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@121291 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2016 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.util.remote.server;
|
||||
|
||||
import org.springframework.remoting.rmi.RmiRegistryFactoryBean;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.registry.Registry;
|
||||
import java.rmi.server.RMIClientSocketFactory;
|
||||
import java.rmi.server.RMIServerSocketFactory;
|
||||
|
||||
/**
|
||||
* This class controls the RMI connectivity via <code>alfresco.jmx.connector.enabled</code> property
|
||||
*
|
||||
* @author alex.mukha
|
||||
*/
|
||||
public class AlfrescoRmiRegistryFactoryBean extends RmiRegistryFactoryBean
|
||||
{
|
||||
private static final String ERR_MSG_NOT_ENABLED = "The RMI registry factory is disabled.";
|
||||
|
||||
private boolean enabled = true;
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
super.afterPropertiesSet();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Registry getRegistry(
|
||||
String registryHost,
|
||||
int registryPort,
|
||||
RMIClientSocketFactory clientSocketFactory,
|
||||
RMIServerSocketFactory serverSocketFactory) throws RemoteException
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
return super.getRegistry(registryHost, registryPort, clientSocketFactory, serverSocketFactory);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RemoteException(ERR_MSG_NOT_ENABLED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Registry getRegistry(
|
||||
int registryPort,
|
||||
RMIClientSocketFactory clientSocketFactory,
|
||||
RMIServerSocketFactory serverSocketFactory) throws RemoteException
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
return super.getRegistry(registryPort, clientSocketFactory, serverSocketFactory);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RemoteException(ERR_MSG_NOT_ENABLED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Registry getRegistry(int registryPort) throws RemoteException
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
return super.getRegistry(registryPort);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RemoteException(ERR_MSG_NOT_ENABLED);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user