Merged V3.2 to HEAD

16092: ETHREEOH-2800: org.alfresco.repo.jscript.People should use AuthenticationService rather than the MutableAuthenticationDAO or otherwise it won't work in an authentication chain.
   16094: ETHREEOH-2800: The same for org.alfresco.repo.template.People


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16095 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2009-09-04 12:32:18 +00:00
parent 034027961d
commit 9fc993a852
4 changed files with 29 additions and 52 deletions

View File

@@ -132,8 +132,8 @@
<property name="personService"> <property name="personService">
<ref bean="PersonService"/> <ref bean="PersonService"/>
</property> </property>
<property name="mutableAuthenticationDao"> <property name="authenticationService">
<ref bean="authenticationDao"/> <ref bean="AuthenticationService"/>
</property> </property>
<property name="contentUsageService"> <property name="contentUsageService">
<ref bean="ContentUsageService"/> <ref bean="ContentUsageService"/>
@@ -144,9 +144,6 @@
<property name="userNameGenerator"> <property name="userNameGenerator">
<ref bean="userNameGenerator"/> <ref bean="userNameGenerator"/>
</property> </property>
<property name="passwordGenerator">
<ref bean="passwordGenerator"/>
</property>
</bean> </bean>
<bean id="sessionScript" parent="baseJavaScriptExtension" class="org.alfresco.repo.jscript.Session"> <bean id="sessionScript" parent="baseJavaScriptExtension" class="org.alfresco.repo.jscript.Session">

View File

@@ -97,8 +97,8 @@
<property name="personService"> <property name="personService">
<ref bean="PersonService"/> <ref bean="PersonService"/>
</property> </property>
<property name="mutableAuthenticationDao"> <property name="authenticationService">
<ref bean="authenticationDao"/> <ref bean="AuthenticationService"/>
</property> </property>
</bean> </bean>

View File

@@ -31,8 +31,6 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.authentication.PasswordGenerator;
import org.alfresco.repo.security.authentication.UserNameGenerator; import org.alfresco.repo.security.authentication.UserNameGenerator;
import org.alfresco.repo.security.authority.AuthorityDAO; import org.alfresco.repo.security.authority.AuthorityDAO;
import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantService;
@@ -71,11 +69,10 @@ public final class People extends BaseScopableProcessorExtension
private AuthorityDAO authorityDAO; private AuthorityDAO authorityDAO;
private AuthorityService authorityService; private AuthorityService authorityService;
private PersonService personService; private PersonService personService;
private MutableAuthenticationDao mutableAuthenticationDao; private AuthenticationService authenticationService;
private ContentUsageService contentUsageService; private ContentUsageService contentUsageService;
private TenantService tenantService; private TenantService tenantService;
private UserNameGenerator usernameGenerator; private UserNameGenerator usernameGenerator;
private PasswordGenerator passwordGenerator;
private StoreRef storeRef; private StoreRef storeRef;
private int numRetries = 10; private int numRetries = 10;
@@ -93,16 +90,17 @@ public final class People extends BaseScopableProcessorExtension
throw new IllegalStateException("Default store URL can only be set once."); throw new IllegalStateException("Default store URL can only be set once.");
} }
this.storeRef = new StoreRef(storeRef); this.storeRef = new StoreRef(storeRef);
} }
/** /**
* Set the mutable authentication dao * Sets the authentication service.
* *
* @param mutableAuthenticationDao Mutable Authentication DAO * @param authenticationService
* the authentication service
*/ */
public void setMutableAuthenticationDao(MutableAuthenticationDao mutableAuthenticationDao) public void setAuthenticationService(AuthenticationService authenticationService)
{ {
this.mutableAuthenticationDao = mutableAuthenticationDao; this.authenticationService = authenticationService;
} }
/** /**
@@ -170,17 +168,7 @@ public final class People extends BaseScopableProcessorExtension
{ {
this.usernameGenerator = userNameGenerator; this.usernameGenerator = userNameGenerator;
} }
/**
* Set the password generator service
*
* @param passwordGenerator the password generator
*/
public void setPasswordGenerator(PasswordGenerator passwordGenerator)
{
this.passwordGenerator = passwordGenerator;
}
/** /**
* Delete a Person with the given username * Delete a Person with the given username
* *
@@ -189,14 +177,6 @@ public final class People extends BaseScopableProcessorExtension
public void deletePerson(String username) public void deletePerson(String username)
{ {
personService.deletePerson(username); personService.deletePerson(username);
try
{
mutableAuthenticationDao.deleteUser(username);
}
catch (AuthenticationException e)
{
// Let's not worry if authentication details don't exist
}
} }
/** /**
@@ -268,8 +248,8 @@ public final class People extends BaseScopableProcessorExtension
if (person != null && password != null) if (person != null && password != null)
{ {
// create account for person with the userName and password // create account for person with the userName and password
mutableAuthenticationDao.createUser(userName, password.toCharArray()); authenticationService.createAuthentication(userName, password.toCharArray());
mutableAuthenticationDao.setEnabled(userName, setAccountEnabled); authenticationService.setAuthenticationEnabled(userName, setAccountEnabled);
person.save(); person.save();
} }
@@ -287,7 +267,7 @@ public final class People extends BaseScopableProcessorExtension
{ {
if (this.authorityService.isAdminAuthority(AuthenticationUtil.getFullyAuthenticatedUser())) if (this.authorityService.isAdminAuthority(AuthenticationUtil.getFullyAuthenticatedUser()))
{ {
this.mutableAuthenticationDao.setEnabled(userName, true); this.authenticationService.setAuthenticationEnabled(userName, true);
} }
} }
@@ -300,7 +280,7 @@ public final class People extends BaseScopableProcessorExtension
{ {
if (this.authorityService.isAdminAuthority(AuthenticationUtil.getFullyAuthenticatedUser())) if (this.authorityService.isAdminAuthority(AuthenticationUtil.getFullyAuthenticatedUser()))
{ {
this.mutableAuthenticationDao.setEnabled(userName, false); this.authenticationService.setAuthenticationEnabled(userName, false);
} }
} }
@@ -313,7 +293,7 @@ public final class People extends BaseScopableProcessorExtension
*/ */
public boolean isAccountEnabled(String userName) public boolean isAccountEnabled(String userName)
{ {
return this.mutableAuthenticationDao.getEnabled(userName); return this.authenticationService.getAuthenticationEnabled(userName);
} }
/** /**

View File

@@ -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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -30,11 +30,11 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.authority.AuthorityDAO; import org.alfresco.repo.security.authority.AuthorityDAO;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.security.PersonService;
@@ -51,7 +51,7 @@ public class People extends BaseTemplateProcessorExtension
private ServiceRegistry services; private ServiceRegistry services;
private AuthorityDAO authorityDAO; private AuthorityDAO authorityDAO;
private AuthorityService authorityService; private AuthorityService authorityService;
private MutableAuthenticationDao mutableAuthenticationDao; private AuthenticationService authenticationService;
private PersonService personService; private PersonService personService;
private StoreRef storeRef; private StoreRef storeRef;
@@ -112,15 +112,16 @@ public class People extends BaseTemplateProcessorExtension
} }
/** /**
* Set the mutable authentication dao * Sets the authentication service.
* *
* @param mutableAuthenticationDao Mutable Authentication DAO * @param authenticationService
* the new authentication service
*/ */
public void setMutableAuthenticationDao(MutableAuthenticationDao mutableAuthenticationDao) public void setAuthenticationService(AuthenticationService authenticationService)
{ {
this.mutableAuthenticationDao = mutableAuthenticationDao; this.authenticationService = authenticationService;
} }
/** /**
* Gets the Person given the username * Gets the Person given the username
* *
@@ -234,7 +235,7 @@ public class People extends BaseTemplateProcessorExtension
*/ */
public boolean isAccountEnabled(TemplateNode person) public boolean isAccountEnabled(TemplateNode person)
{ {
return this.mutableAuthenticationDao.getEnabled((String)person.getProperties().get(ContentModel.PROP_USERNAME)); return this.authenticationService.getAuthenticationEnabled((String)person.getProperties().get(ContentModel.PROP_USERNAME));
} }
/** /**
@@ -255,7 +256,6 @@ public class People extends BaseTemplateProcessorExtension
String groupName = (String)container.getProperties().get(ContentModel.PROP_AUTHORITY_NAME); String groupName = (String)container.getProperties().get(ContentModel.PROP_AUTHORITY_NAME);
Set<String> authorities = authorityService.getContainedAuthorities(type, groupName, !recurse); Set<String> authorities = authorityService.getContainedAuthorities(type, groupName, !recurse);
members = new ArrayList<TemplateNode>(authorities.size()); members = new ArrayList<TemplateNode>(authorities.size());
int i = 0;
for (String authority : authorities) for (String authority : authorities)
{ {
AuthorityType authorityType = AuthorityType.getAuthorityType(authority); AuthorityType authorityType = AuthorityType.getAuthorityType(authority);
@@ -278,6 +278,6 @@ public class People extends BaseTemplateProcessorExtension
} }
} }
return members != null ? members : (List)Collections.emptyList(); return members != null ? members : Collections.<TemplateNode>emptyList();
} }
} }