mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Enable cold bootstrap without waking up authentication component. Made ImporterComponent use AuthenticationContext rather than AuthenticationService. Was then able to roll back temporary fix to AuthenticationFilter (from 13673).
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13727 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -40,6 +40,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.importer.view.NodeContext;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationContext;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
@@ -59,7 +60,6 @@ import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.OwnableService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
@@ -107,7 +107,7 @@ public class ImporterComponent
|
||||
private RuleService ruleService;
|
||||
private PermissionService permissionService;
|
||||
private AuthorityService authorityService;
|
||||
private AuthenticationService authenticationService;
|
||||
private AuthenticationContext authenticationContext;
|
||||
private OwnableService ownableService;
|
||||
|
||||
// binding markers
|
||||
@@ -198,11 +198,11 @@ public class ImporterComponent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authenticationService authenticationService
|
||||
* @param authenticationContext authenticationContext
|
||||
*/
|
||||
public void setAuthenticationService(AuthenticationService authenticationService)
|
||||
public void setAuthenticationContext(AuthenticationContext authenticationContext)
|
||||
{
|
||||
this.authenticationService = authenticationService;
|
||||
this.authenticationContext = authenticationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,6 +536,7 @@ public class ImporterComponent
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.importer.Importer#importNode(org.alfresco.repo.importer.ImportNode)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public NodeRef importNode(ImportNode context)
|
||||
{
|
||||
// import node
|
||||
@@ -714,6 +715,7 @@ public class ImporterComponent
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.importer.Importer#end()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void end()
|
||||
{
|
||||
// Bind all node references to destination space
|
||||
@@ -917,6 +919,7 @@ public class ImporterComponent
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<QName, Serializable> bindProperties(ImportNode context)
|
||||
{
|
||||
Map<QName, Serializable> properties = context.getProperties();
|
||||
@@ -1261,7 +1264,7 @@ public class ImporterComponent
|
||||
NodeRef nodeRef = assocRef.getChildRef();
|
||||
|
||||
// Note: non-admin authorities take ownership of new nodes
|
||||
if (!(authorityService.hasAdminAuthority() || authenticationService.isCurrentUserTheSystemUser()))
|
||||
if (!(authenticationContext.isCurrentUserTheSystemUser() || authorityService.hasAdminAuthority()))
|
||||
{
|
||||
ownableService.takeOwnership(nodeRef);
|
||||
}
|
||||
@@ -1269,7 +1272,7 @@ public class ImporterComponent
|
||||
// apply permissions
|
||||
List<AccessPermission> permissions = null;
|
||||
AccessStatus writePermission = permissionService.hasPermission(nodeRef, PermissionService.CHANGE_PERMISSIONS);
|
||||
if (authenticationService.isCurrentUserTheSystemUser() || writePermission.equals(AccessStatus.ALLOWED))
|
||||
if (authenticationContext.isCurrentUserTheSystemUser() || writePermission.equals(AccessStatus.ALLOWED))
|
||||
{
|
||||
permissions = bindPermissions(node.getAccessControlEntries());
|
||||
|
||||
@@ -1449,7 +1452,7 @@ public class ImporterComponent
|
||||
// Apply permissions
|
||||
List<AccessPermission> permissions = null;
|
||||
AccessStatus writePermission = permissionService.hasPermission(existingNodeRef, PermissionService.CHANGE_PERMISSIONS);
|
||||
if (authenticationService.isCurrentUserTheSystemUser() || writePermission.equals(AccessStatus.ALLOWED))
|
||||
if (authenticationContext.isCurrentUserTheSystemUser() || writePermission.equals(AccessStatus.ALLOWED))
|
||||
{
|
||||
boolean inheritPermissions = node.getInheritPermissions();
|
||||
if (!inheritPermissions)
|
||||
|
@@ -320,6 +320,16 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
|
||||
return authenticationContext.isSystemUserName(userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the current user the system user?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isCurrentUserTheSystemUser()
|
||||
{
|
||||
return authenticationContext.isCurrentUserTheSystemUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the Guest User note: for MT, will get guest for default domain only
|
||||
*
|
||||
|
@@ -24,6 +24,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.security.authentication;
|
||||
|
||||
import org.alfresco.service.Auditable;
|
||||
|
||||
import net.sf.acegisecurity.Authentication;
|
||||
import net.sf.acegisecurity.UserDetails;
|
||||
|
||||
@@ -87,6 +89,11 @@ public interface AuthenticationContext
|
||||
* True if this is the System user ?
|
||||
*/
|
||||
public boolean isSystemUserName(String userName);
|
||||
|
||||
/**
|
||||
* Is the current user the system user?
|
||||
*/
|
||||
public boolean isCurrentUserTheSystemUser();
|
||||
|
||||
/**
|
||||
* Get the name of the Guest User. Note: for MT, will get guest for default domain only
|
||||
|
@@ -102,6 +102,11 @@ public class AuthenticationContextImpl implements AuthenticationContext
|
||||
return getSystemUserName().equals(this.tenantService.getBaseNameUser(userName));
|
||||
}
|
||||
|
||||
public boolean isCurrentUserTheSystemUser()
|
||||
{
|
||||
return isSystemUserName(getCurrentUserName());
|
||||
}
|
||||
|
||||
public String getGuestUserName(String tenantDomain)
|
||||
{
|
||||
return this.tenantService.getDomainUser(getGuestUserName(), tenantDomain);
|
||||
|
Reference in New Issue
Block a user