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:
Dave Ward
2009-03-23 15:58:56 +00:00
parent 5fa1ffcff6
commit cc6116e682
5 changed files with 37 additions and 12 deletions

View File

@@ -40,8 +40,8 @@
<property name="authorityService">
<ref bean="AuthorityService" />
</property>
<property name="authenticationService">
<ref bean="AuthenticationService" />
<property name="authenticationContext">
<ref bean="authenticationContext" />
</property>
<property name="viewParser">
<ref bean="viewParser" />
@@ -81,8 +81,8 @@
<property name="authorityService">
<ref bean="AuthorityService" />
</property>
<property name="authenticationService">
<ref bean="AuthenticationService" />
<property name="authenticationContext">
<ref bean="authenticationContext" />
</property>
<property name="viewParser">
<ref bean="viewParser" />

View File

@@ -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)

View File

@@ -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
*

View File

@@ -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

View File

@@ -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);