mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merge V1.2.0 BRANCH to HEAD
svn merge -r 2519:2565 svn://www.alfresco.org/alfresco/BRANCHES/V1.2.0/root HEAD/root git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2566 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -80,16 +80,6 @@ public class DefaultMutableAuthenticationDao implements MutableAuthenticationDao
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the store ref where user objects are persisted.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public StoreRef getUserStoreRef()
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable a user.
|
||||
*
|
||||
|
@@ -21,8 +21,6 @@ import java.util.Date;
|
||||
import net.sf.acegisecurity.providers.dao.AuthenticationDao;
|
||||
import net.sf.acegisecurity.providers.dao.SaltSource;
|
||||
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
|
||||
/**
|
||||
* A service provider interface to provide both acegi integration via AuthenticationDao and SaltSource
|
||||
* and mutability support for user definitions.
|
||||
@@ -65,14 +63,6 @@ public interface MutableAuthenticationDao extends AuthenticationDao, SaltSource
|
||||
*/
|
||||
public boolean userExists(String userName);
|
||||
|
||||
|
||||
/**
|
||||
* Get the store ref where user objects are persisted.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public StoreRef getUserStoreRef();
|
||||
|
||||
/**
|
||||
* Enable/disable a user.
|
||||
*
|
||||
|
@@ -29,16 +29,14 @@ import net.sf.acegisecurity.providers.dao.User;
|
||||
import net.sf.acegisecurity.providers.dao.UsernameNotFoundException;
|
||||
import net.sf.acegisecurity.providers.encoding.PasswordEncoder;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.search.QueryParameterDefImpl;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.search.QueryParameterDefinition;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
@@ -50,10 +48,7 @@ import org.springframework.dao.DataAccessException;
|
||||
|
||||
public class RepositoryAuthenticationDao implements MutableAuthenticationDao
|
||||
{
|
||||
|
||||
private static final String SYSTEM_FOLDER = "/sys:system";
|
||||
|
||||
private static final String PEOPLE_FOLDER = SYSTEM_FOLDER + "/sys:people";
|
||||
private static final StoreRef STOREREF_USERS = new StoreRef("user", "alfrescoUserStore");
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
@@ -65,8 +60,6 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
|
||||
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
private StoreRef userStoreRef;
|
||||
|
||||
private boolean userNamesAreCaseSensitive;
|
||||
|
||||
public boolean getUserNamesAreCaseSensitive()
|
||||
@@ -132,7 +125,7 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
|
||||
SearchParameters sp = new SearchParameters();
|
||||
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
sp.setQuery("@usr\\:username:" + userName);
|
||||
sp.addStore(getUserStoreRef());
|
||||
sp.addStore(STOREREF_USERS);
|
||||
sp.excludeDataInTheCurrentTransaction(false);
|
||||
|
||||
ResultSet rs = null;
|
||||
@@ -175,7 +168,7 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
|
||||
{
|
||||
throw new AuthenticationException("User already exists: " + userName);
|
||||
}
|
||||
NodeRef typesNode = getOrCreateTypeLocation();
|
||||
NodeRef typesNode = getUserFolderLocation();
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
properties.put(ContentModel.PROP_USER_USERNAME, userName);
|
||||
String salt = null; // GUID.generate();
|
||||
@@ -185,41 +178,47 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
|
||||
properties.put(ContentModel.PROP_CREDENTIALS_EXPIRE, Boolean.valueOf(false));
|
||||
properties.put(ContentModel.PROP_ENABLED, Boolean.valueOf(true));
|
||||
properties.put(ContentModel.PROP_ACCOUNT_LOCKED, Boolean.valueOf(false));
|
||||
nodeService.createNode(typesNode, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_USER, ContentModel.TYPE_USER,
|
||||
nodeService.createNode(
|
||||
typesNode,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
ContentModel.TYPE_USER,
|
||||
ContentModel.TYPE_USER,
|
||||
properties);
|
||||
|
||||
}
|
||||
|
||||
private NodeRef getOrCreateTypeLocation()
|
||||
private NodeRef getUserFolderLocation()
|
||||
{
|
||||
NodeRef rootNode = nodeService.getRootNode(getUserStoreRef());
|
||||
List<ChildAssociationRef> results = nodeService.getChildAssocs(rootNode, RegexQNamePattern.MATCH_ALL, QName
|
||||
.createQName("sys", "system", namespacePrefixResolver));
|
||||
NodeRef sysNode = null;
|
||||
QName qnameAssocSystem = QName.createQName("sys", "system", namespacePrefixResolver);
|
||||
QName qnameAssocUsers = QName.createQName("sys", "people", namespacePrefixResolver); // see AR-527
|
||||
NodeRef rootNode = nodeService.getRootNode(STOREREF_USERS);
|
||||
List<ChildAssociationRef> results = nodeService.getChildAssocs(
|
||||
rootNode,
|
||||
RegexQNamePattern.MATCH_ALL,
|
||||
qnameAssocSystem);
|
||||
NodeRef sysNodeRef = null;
|
||||
if (results.size() == 0)
|
||||
{
|
||||
sysNode = nodeService.createNode(rootNode, ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("sys", "system", namespacePrefixResolver), ContentModel.TYPE_CONTAINER)
|
||||
.getChildRef();
|
||||
throw new AlfrescoRuntimeException("Required authority system folder path not found: " + qnameAssocSystem);
|
||||
}
|
||||
else
|
||||
{
|
||||
sysNode = results.get(0).getChildRef();
|
||||
sysNodeRef = results.get(0).getChildRef();
|
||||
}
|
||||
results = nodeService.getChildAssocs(sysNode, RegexQNamePattern.MATCH_ALL, QName.createQName("sys", "people",
|
||||
namespacePrefixResolver));
|
||||
NodeRef typesNode = null;
|
||||
results = nodeService.getChildAssocs(
|
||||
sysNodeRef,
|
||||
RegexQNamePattern.MATCH_ALL,
|
||||
qnameAssocUsers);
|
||||
NodeRef userNodeRef = null;
|
||||
if (results.size() == 0)
|
||||
{
|
||||
typesNode = nodeService.createNode(sysNode, ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("sys", "people", namespacePrefixResolver), ContentModel.TYPE_CONTAINER)
|
||||
.getChildRef();
|
||||
throw new AlfrescoRuntimeException("Required user folder path not found: " + qnameAssocUsers);
|
||||
}
|
||||
else
|
||||
{
|
||||
typesNode = results.get(0).getChildRef();
|
||||
userNodeRef = results.get(0).getChildRef();
|
||||
}
|
||||
return typesNode;
|
||||
return userNodeRef;
|
||||
}
|
||||
|
||||
public void updateUser(String userName, char[] rawPassword) throws AuthenticationException
|
||||
@@ -248,20 +247,6 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
|
||||
nodeService.deleteNode(userRef);
|
||||
}
|
||||
|
||||
public synchronized StoreRef getUserStoreRef()
|
||||
{
|
||||
if (userStoreRef == null)
|
||||
{
|
||||
userStoreRef = new StoreRef("user", "alfrescoUserStore");
|
||||
}
|
||||
if (!nodeService.exists(userStoreRef))
|
||||
{
|
||||
nodeService.createStore(userStoreRef.getProtocol(), userStoreRef.getIdentifier());
|
||||
}
|
||||
|
||||
return userStoreRef;
|
||||
}
|
||||
|
||||
public Object getSalt(UserDetails userDetails)
|
||||
{
|
||||
// NodeRef userRef = getUserOrNull(userDetails.getUsername());
|
||||
|
@@ -26,7 +26,7 @@ import org.alfresco.service.namespace.QName;
|
||||
|
||||
public class PermissionModelTest extends AbstractPermissionTest
|
||||
{
|
||||
|
||||
|
||||
public PermissionModelTest()
|
||||
{
|
||||
super();
|
||||
@@ -40,6 +40,30 @@ public class PermissionModelTest extends AbstractPermissionTest
|
||||
assertEquals(5, grantees.size());
|
||||
}
|
||||
|
||||
public void testIncludePermissionGroups2()
|
||||
{
|
||||
Set<PermissionReference> grantees = permissionModelDAO.getGranteePermissions(new SimplePermissionReference(QName.createQName("cm", "cmobject",
|
||||
namespacePrefixResolver), "Contributor"));
|
||||
|
||||
assertEquals(11, grantees.size());
|
||||
}
|
||||
|
||||
public void testIncludePermissionGroups3()
|
||||
{
|
||||
Set<PermissionReference> grantees = permissionModelDAO.getGranteePermissions(new SimplePermissionReference(QName.createQName("cm", "cmobject",
|
||||
namespacePrefixResolver), "Editor"));
|
||||
|
||||
assertEquals(11, grantees.size());
|
||||
}
|
||||
|
||||
public void testIncludePermissionGroups4()
|
||||
{
|
||||
Set<PermissionReference> grantees = permissionModelDAO.getGranteePermissions(new SimplePermissionReference(QName.createQName("cm", "cmobject",
|
||||
namespacePrefixResolver), "Collaborator"));
|
||||
|
||||
assertEquals(16, grantees.size());
|
||||
}
|
||||
|
||||
public void testGetGrantingPermissions()
|
||||
{
|
||||
Set<PermissionReference> granters = permissionModelDAO.getGrantingPermissions(new SimplePermissionReference(QName.createQName("sys", "base",
|
||||
|
@@ -25,9 +25,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.permissions.PermissionServiceSPI;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
@@ -41,7 +41,6 @@ import org.alfresco.service.cmr.security.NoSuchPersonException;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
|
||||
public class PersonServiceImpl implements PersonService
|
||||
{
|
||||
@@ -148,8 +147,9 @@ public class PersonServiceImpl implements PersonService
|
||||
NodeRef nodeRef = row.getNodeRef();
|
||||
if (nodeService.exists(nodeRef))
|
||||
{
|
||||
String realUserName = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(
|
||||
nodeRef, ContentModel.PROP_USERNAME));
|
||||
String realUserName = DefaultTypeConverter.INSTANCE.convert(
|
||||
String.class,
|
||||
nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME));
|
||||
realUserName = userNamesAreCaseSensitive ? realUserName : realUserName.toLowerCase();
|
||||
if (realUserName.equals(userName))
|
||||
{
|
||||
@@ -235,47 +235,26 @@ public class PersonServiceImpl implements PersonService
|
||||
.get(ContentModel.PROP_USERNAME));
|
||||
String userName = userNamesAreCaseSensitive ? caseSensitiveUserName : caseSensitiveUserName.toLowerCase();
|
||||
properties.put(ContentModel.PROP_USERNAME, userName);
|
||||
return nodeService.createNode(getPeopleContainer(), ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_PERSON,
|
||||
ContentModel.TYPE_PERSON, properties).getChildRef();
|
||||
return nodeService.createNode(
|
||||
getPeopleContainer(),
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
ContentModel.TYPE_PERSON,
|
||||
ContentModel.TYPE_PERSON,
|
||||
properties).getChildRef();
|
||||
}
|
||||
|
||||
public NodeRef getPeopleContainer()
|
||||
{
|
||||
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
|
||||
List<NodeRef> results = searchService.selectNodes(rootNodeRef, PEOPLE_FOLDER, null, namespacePrefixResolver,
|
||||
List<NodeRef> results = searchService.selectNodes(
|
||||
rootNodeRef,
|
||||
PEOPLE_FOLDER,
|
||||
null,
|
||||
namespacePrefixResolver,
|
||||
false);
|
||||
NodeRef typesNode = null;
|
||||
if (results.size() == 0)
|
||||
{
|
||||
|
||||
List<ChildAssociationRef> result = nodeService.getChildAssocs(rootNodeRef, RegexQNamePattern.MATCH_ALL,
|
||||
QName.createQName("sys", "system", namespacePrefixResolver));
|
||||
NodeRef sysNode = null;
|
||||
if (result.size() == 0)
|
||||
{
|
||||
sysNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("sys", "system", namespacePrefixResolver), ContentModel.TYPE_CONTAINER)
|
||||
.getChildRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
sysNode = result.get(0).getChildRef();
|
||||
}
|
||||
result = nodeService.getChildAssocs(sysNode, RegexQNamePattern.MATCH_ALL, QName.createQName("sys",
|
||||
"people", namespacePrefixResolver));
|
||||
|
||||
if (result.size() == 0)
|
||||
{
|
||||
typesNode = nodeService.createNode(sysNode, ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("sys", "people", namespacePrefixResolver), ContentModel.TYPE_CONTAINER)
|
||||
.getChildRef();
|
||||
return typesNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result.get(0).getChildRef();
|
||||
}
|
||||
|
||||
throw new AlfrescoRuntimeException("Required people system path not found: " + PEOPLE_FOLDER);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user