mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.2 to HEAD
15888: ETHREEOH-2617: CIFS Authenticators should not try to initialize when disabled - removed init-method declaration from cifsAuthenticatorBase 15731: ENH-524: Use JobLockService to ensure that it is only possible for LDAP sync to run on one node at a time in a cluster - Ensures that if schedule is identical on all nodes, the LDAP sync will only be run on one 15694: Fix TransactionServiceImplTest broken by 15685 15685: ETHREEOH-983: Move RepoServerMgmt JMX editable capabilities into a sysAdmin subsystem for more consistent control and cluster support - New SysAdminParams interface exported by sysAdmin subsystem through which AuthenticationService and TransactionService get at the configured parameters - The repository read only flag does not apply to the system user so that we can still persist changes to that flag through JMX! - Removed sysAdminCache and supporting configuration. 15684: Improvements to cluster support for subsystems - When a subsystem is stopped on a node for editing it is completely destroyed and deregistered from JMX on other nodes - Should the subsystem be reactivated on those other nodes (e.g. called into by code) it will be reinitialized from persisted properties and thus stay in sync with the node being edited! 15683: Fixed potential concurrency issues in HeartBeat and LicenseComponent - Discovered during cluster testing - Because these components schedule triggers in a retrying transaction, they need to unschedule the triggers beforehand, just in case a retry has happened 15617: MOB-646: JMX edits now synchronized across cluster via JGroups - When you stop a component or subsystem, it is stopped across the entire cluster - When you restart it after editing properties, the component is reinitialized from the persisted properties across the cluster git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16873 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -15,17 +15,15 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
@@ -34,29 +32,19 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.linkvalidation.LinkValidationService;
|
||||
import org.alfresco.repo.security.authentication.AbstractAuthenticationService;
|
||||
import org.alfresco.repo.transaction.TransactionServiceImpl;
|
||||
import org.alfresco.service.license.LicenseService;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
public class RepoServerMgmt implements RepoServerMgmtMBean, ApplicationContextAware, InitializingBean
|
||||
public class RepoServerMgmt implements RepoServerMgmtMBean
|
||||
{
|
||||
private static final Log log = LogFactory.getLog(RepoServerMgmt.class);
|
||||
|
||||
private ApplicationContext ctx; // to get license component, if installed
|
||||
|
||||
private TransactionServiceImpl transactionService;
|
||||
|
||||
private AbstractAuthenticationService authenticationService;
|
||||
|
||||
private LinkValidationService linkValidationService;
|
||||
|
||||
private boolean initialised = false;
|
||||
|
||||
public void setTransactionService(TransactionServiceImpl transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
@@ -73,50 +61,6 @@ public class RepoServerMgmt implements RepoServerMgmtMBean, ApplicationContextAw
|
||||
this.linkValidationService = linkValidationService;
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly)
|
||||
{
|
||||
if (readOnly && isReadOnly())
|
||||
{
|
||||
log.warn("Alfresco is already read-only");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!readOnly && !isReadOnly())
|
||||
{
|
||||
log.warn("Alfresco is already read-write");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!readOnly)
|
||||
{
|
||||
LicenseService licenseService = null;
|
||||
try
|
||||
{
|
||||
licenseService = (LicenseService) ctx.getBean("org.alfresco.enterprise.license.LicenseComponent");
|
||||
readOnly = !licenseService.isLicenseValid();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
transactionService.setAllowWrite(!readOnly);
|
||||
|
||||
if (readOnly)
|
||||
{
|
||||
log.warn("Alfresco set to be read-only");
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("Alfresco set to be read-write");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReadOnly()
|
||||
{
|
||||
return transactionService.isReadOnly();
|
||||
@@ -182,130 +126,11 @@ public class RepoServerMgmt implements RepoServerMgmtMBean, ApplicationContextAw
|
||||
log.info("User invalidated: " + username);
|
||||
}
|
||||
|
||||
public void setSingleUserOnly(String allowedUsername)
|
||||
{
|
||||
|
||||
List<String> allowedUsers = null;
|
||||
if (PropertyCheck.isValidPropertyString(allowedUsername))
|
||||
{
|
||||
allowedUsers = new ArrayList<String>(0);
|
||||
allowedUsers.add(allowedUsername);
|
||||
|
||||
if (initialised)
|
||||
{
|
||||
int maxUsers = getMaxUsers();
|
||||
invalidateTicketsAll();
|
||||
|
||||
if (maxUsers != 0)
|
||||
{
|
||||
log.warn("Alfresco set to allow single-user (" + allowedUsername + ") logins only");
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn("Alfresco set to allow single-user (" + allowedUsername + ") logins - although further logins are currently prevented (limit = 0)");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (initialised)
|
||||
{
|
||||
int maxUsers = getMaxUsers();
|
||||
if (maxUsers == -1)
|
||||
{
|
||||
log.info("Alfresco set to allow logins (no limit set)");
|
||||
}
|
||||
else if (maxUsers == 0)
|
||||
{
|
||||
log.warn("Alfresco set to allow logins - although further logins are currently prevented (limit = 0)");
|
||||
}
|
||||
else if (maxUsers != 0)
|
||||
{
|
||||
log.info("Alfresco set to allow logins (limit = " + maxUsers + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
authenticationService.setAllowedUsers(allowedUsers);
|
||||
}
|
||||
|
||||
public String getSingleUserOnly()
|
||||
{
|
||||
List<String> allowedUsers = authenticationService.getAllowedUsers();
|
||||
if (allowedUsers != null)
|
||||
{
|
||||
if (allowedUsers.size() > 1)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unexpected: more than one user allowed");
|
||||
}
|
||||
if (allowedUsers.size() == 1)
|
||||
{
|
||||
return allowedUsers.get(0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMaxUsers(int maxUsers)
|
||||
{
|
||||
authenticationService.setMaxUsers(maxUsers);
|
||||
|
||||
if (initialised)
|
||||
{
|
||||
String singleUserOnlyName = getSingleUserOnly();
|
||||
if (maxUsers == -1)
|
||||
{
|
||||
if ((singleUserOnlyName != null) && (!singleUserOnlyName.equals("")))
|
||||
{
|
||||
log.info("Alfresco set to allow logins (no limit set) - although currently restricted to single-user (" + singleUserOnlyName + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("Alfresco set to allow logins (no limit set)");
|
||||
}
|
||||
}
|
||||
else if (maxUsers == 0)
|
||||
{
|
||||
log.warn("Alfresco set to prevent further logins (limit = 0)");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((singleUserOnlyName != null) && (!singleUserOnlyName.equals("")))
|
||||
{
|
||||
log.info("Alfresco set to allow logins (limit = " + maxUsers + ") - although currently restricted to single-user (" + singleUserOnlyName + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("Alfresco set to allow logins (limit = " + maxUsers + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxUsers()
|
||||
{
|
||||
return authenticationService.getMaxUsers();
|
||||
}
|
||||
|
||||
public void setLinkValidationDisabled(boolean disable)
|
||||
{
|
||||
if (linkValidationService == null)
|
||||
{
|
||||
log.error("LinkValidationService not registered");
|
||||
throw new AlfrescoRuntimeException("LinkValidationService not registered");
|
||||
}
|
||||
|
||||
linkValidationService.setLinkValidationDisabled(disable);
|
||||
if (disable)
|
||||
{
|
||||
log.warn("Link validation disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("Link validation enabled");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLinkValidationDisabled()
|
||||
{
|
||||
if (linkValidationService == null)
|
||||
@@ -316,9 +141,4 @@ public class RepoServerMgmt implements RepoServerMgmtMBean, ApplicationContextAw
|
||||
|
||||
return linkValidationService.isLinkValidationDisabled();
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
initialised = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user