diff --git a/config/alfresco/authentication-services-context.xml b/config/alfresco/authentication-services-context.xml
index 0504dfc5e4..e1c71a6898 100644
--- a/config/alfresco/authentication-services-context.xml
+++ b/config/alfresco/authentication-services-context.xml
@@ -95,6 +95,9 @@
+
+
+
diff --git a/config/alfresco/authority-services-context.xml b/config/alfresco/authority-services-context.xml
index f4880d53ce..c6af6b9f48 100644
--- a/config/alfresco/authority-services-context.xml
+++ b/config/alfresco/authority-services-context.xml
@@ -72,6 +72,9 @@
+
+
+
diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml
index 989ed85871..5b13075c2c 100644
--- a/config/alfresco/bootstrap-context.xml
+++ b/config/alfresco/bootstrap-context.xml
@@ -274,6 +274,13 @@
+
+
+
+
+
+
+
@@ -300,7 +307,7 @@
-
+
diff --git a/config/alfresco/hibernate-context.xml b/config/alfresco/hibernate-context.xml
index 7c417efaa2..b12c77277d 100644
--- a/config/alfresco/hibernate-context.xml
+++ b/config/alfresco/hibernate-context.xml
@@ -46,7 +46,8 @@
org/alfresco/repo/domain/hibernate/AppliedPatch.hbm.xml
org/alfresco/repo/domain/hibernate/Permission.hbm.xml
org/alfresco/repo/avm/hibernate/AVM.hbm.xml
- org/alfresco/repo/attributes/hibernate/Attributes.hbm.xml
+ org/alfresco/repo/attributes/hibernate/Attributes.hbm.xml
+ org/alfresco/repo/simple/permission/AuthorityCapability.hbm.xml
diff --git a/config/alfresco/simple-permissions-context.xml b/config/alfresco/simple-permissions-context.xml
index 7b24feb515..6956ab4675 100644
--- a/config/alfresco/simple-permissions-context.xml
+++ b/config/alfresco/simple-permissions-context.xml
@@ -1,7 +1,26 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
read
@@ -11,5 +30,12 @@
shake
+
+
+
+
+
+
+
diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties
index ebff9289bb..c0f6811559 100644
--- a/config/alfresco/version.properties
+++ b/config/alfresco/version.properties
@@ -19,4 +19,4 @@ version.build=@build-number@
# Schema number
-version.schema=106
+version.schema=107
diff --git a/source/java/org/alfresco/repo/avm/util/RawServices.java b/source/java/org/alfresco/repo/avm/util/RawServices.java
index 1f3f1c1629..44ab0ac473 100644
--- a/source/java/org/alfresco/repo/avm/util/RawServices.java
+++ b/source/java/org/alfresco/repo/avm/util/RawServices.java
@@ -10,7 +10,7 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.security.AuthorityService;
-import org.alfresco.service.simple.permission.CapabilityRegistry;
+import org.alfresco.service.simple.permission.AuthorityCapabilityRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -68,7 +68,7 @@ public class RawServices implements ApplicationContextAware
/**
* The CapabilityRegistry.
*/
- private CapabilityRegistry fCapabilityRegistry;
+ private AuthorityCapabilityRegistry fCapabilityRegistry;
/**
* Default constructor.
@@ -157,11 +157,11 @@ public class RawServices implements ApplicationContextAware
return fAuthorityService;
}
- public CapabilityRegistry getCapabilityRegistry()
+ public AuthorityCapabilityRegistry getAuthorityCapabilityRegistry()
{
if (fCapabilityRegistry == null)
{
- fCapabilityRegistry = (CapabilityRegistry)fContext.getBean("capabilityRegistry");
+ fCapabilityRegistry = (AuthorityCapabilityRegistry)fContext.getBean("authorityCapabilityRegistry");
}
return fCapabilityRegistry;
}
diff --git a/source/java/org/alfresco/repo/model/filefolder/loader/FileFolderRemoteLoader.java b/source/java/org/alfresco/repo/model/filefolder/loader/FileFolderRemoteLoader.java
index 760ccb6427..89bc63b20c 100644
--- a/source/java/org/alfresco/repo/model/filefolder/loader/FileFolderRemoteLoader.java
+++ b/source/java/org/alfresco/repo/model/filefolder/loader/FileFolderRemoteLoader.java
@@ -211,8 +211,9 @@ public class FileFolderRemoteLoader
{
ArrayList threads = new ArrayList(3);
// Iterate over the properties and pick out the thread descriptors
- for (String propertyName : properties.stringPropertyNames())
+ for (Object o : properties.keySet())
{
+ String propertyName = (String)o;
if (!propertyName.startsWith("test.load."))
{
continue;
diff --git a/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java b/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java
index 7e28fa99aa..179d470718 100644
--- a/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java
+++ b/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java
@@ -61,6 +61,7 @@ import org.alfresco.service.namespace.DynamicNamespacePrefixResolver;
import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
+import org.alfresco.service.simple.permission.AuthorityCapabilityRegistry;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
@@ -108,6 +109,8 @@ public class AuthenticationTest extends TestCase
private AuthenticationComponent authenticationComponentImpl;
+ private AuthorityCapabilityRegistry authorityCapabilityRegistry;
+
public AuthenticationTest()
{
super();
@@ -131,6 +134,7 @@ public class AuthenticationTest extends TestCase
pubAuthenticationService = (AuthenticationService) ctx.getBean("AuthenticationService");
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
authenticationComponentImpl = (AuthenticationComponent) ctx.getBean("authenticationComponent");
+ authorityCapabilityRegistry = (AuthorityCapabilityRegistry) ctx.getBean("authorityCapabilityRegistry");
// permissionServiceSPI = (PermissionServiceSPI)
// ctx.getBean("permissionService");
ticketsCache = (SimpleCache) ctx.getBean("ticketsCache");
@@ -291,7 +295,7 @@ public class AuthenticationTest extends TestCase
dao.setDictionaryService(dictionaryService);
dao.setNamespaceService(getNamespacePrefixReolsver(""));
dao.setPasswordEncoder(passwordEncoder);
-
+ dao.setAuthorityCapabilityRegistry(authorityCapabilityRegistry);
dao.createUser("Andy", "cabbage".toCharArray());
assertNotNull(dao.getUserOrNull("Andy"));
diff --git a/source/java/org/alfresco/repo/security/authentication/RepositoryAuthenticationDao.java b/source/java/org/alfresco/repo/security/authentication/RepositoryAuthenticationDao.java
index d15726c165..6f8d0f87c4 100644
--- a/source/java/org/alfresco/repo/security/authentication/RepositoryAuthenticationDao.java
+++ b/source/java/org/alfresco/repo/security/authentication/RepositoryAuthenticationDao.java
@@ -53,6 +53,7 @@ import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
+import org.alfresco.service.simple.permission.AuthorityCapabilityRegistry;
import org.springframework.dao.DataAccessException;
public class RepositoryAuthenticationDao implements MutableAuthenticationDao
@@ -70,6 +71,8 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
private SearchService searchService;
private PasswordEncoder passwordEncoder;
+
+ private AuthorityCapabilityRegistry authorityCapabilityRegistry;
private boolean userNamesAreCaseSensitive;
@@ -112,6 +115,11 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
{
this.searchService = searchService;
}
+
+ public void setAuthorityCapabilityRegistry(AuthorityCapabilityRegistry registry)
+ {
+ this.authorityCapabilityRegistry = registry;
+ }
public UserDetails loadUserByUsername(String incomingUserName) throws UsernameNotFoundException,
DataAccessException
@@ -244,7 +252,7 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
properties.put(ContentModel.PROP_ACCOUNT_LOCKED, Boolean.valueOf(false));
nodeService.createNode(typesNode, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_USER, ContentModel.TYPE_USER,
properties);
-
+ authorityCapabilityRegistry.addAuthority(caseSensitiveUserName, null);
}
private NodeRef getUserFolderLocation(String caseSensitiveUserName)
@@ -304,6 +312,7 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
throw new AuthenticationException("User name does not exist: " + userName);
}
nodeService.deleteNode(userRef);
+ authorityCapabilityRegistry.removeAuthority(userName);
}
public Object getSalt(UserDetails userDetails)
diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java b/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java
index 368a8fbcdb..a0a3317d82 100644
--- a/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java
+++ b/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java
@@ -51,6 +51,7 @@ import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
+import org.alfresco.service.simple.permission.AuthorityCapabilityRegistry;
import org.alfresco.util.ISO9075;
public class AuthorityDAOImpl implements AuthorityDAO
@@ -70,6 +71,8 @@ public class AuthorityDAOImpl implements AuthorityDAO
private DictionaryService dictionaryService;
private SimpleCache> userToAuthorityCache;
+
+ private AuthorityCapabilityRegistry authorityCapabilityRegistry;
public AuthorityDAOImpl()
{
@@ -103,6 +106,11 @@ public class AuthorityDAOImpl implements AuthorityDAO
this.userToAuthorityCache = userToAuthorityCache;
}
+ public void setAuthorityCapabilityRegistry(AuthorityCapabilityRegistry registry)
+ {
+ this.authorityCapabilityRegistry = registry;
+ }
+
public boolean authorityExists(String name)
{
NodeRef ref = getAuthorityOrNull(name);
@@ -142,7 +150,7 @@ public class AuthorityDAOImpl implements AuthorityDAO
throw new AlfrescoRuntimeException("Authorities of the type "
+ AuthorityType.getAuthorityType(childName) + " may not be added to other authorities");
}
-
+ authorityCapabilityRegistry.addAuthority(childName, parentName);
}
public void createAuthority(String parentName, String name)
@@ -165,6 +173,7 @@ public class AuthorityDAOImpl implements AuthorityDAO
nodeService.createNode(authorityContainerRef, ContentModel.ASSOC_CHILDREN, QName.createQName("usr", name,
namespacePrefixResolver), ContentModel.TYPE_AUTHORITY_CONTAINER, props);
}
+ authorityCapabilityRegistry.addAuthority(name, parentName);
}
public void deleteAuthority(String name)
@@ -176,6 +185,7 @@ public class AuthorityDAOImpl implements AuthorityDAO
}
nodeService.deleteNode(nodeRef);
userToAuthorityCache.clear();
+ authorityCapabilityRegistry.removeAuthority(name);
}
public Set getAllRootAuthorities(AuthorityType type)
@@ -246,7 +256,7 @@ public class AuthorityDAOImpl implements AuthorityDAO
nodeService.removeChild(parentRef, childRef);
userToAuthorityCache.clear();
}
-
+ authorityCapabilityRegistry.removeAuthorityChild(parentName, childName);
}
public Set getContainingAuthorities(AuthorityType type, String name, boolean immediate)
diff --git a/source/java/org/alfresco/repo/simple/permission/ACLImpl.java b/source/java/org/alfresco/repo/simple/permission/ACLImpl.java
index 4cd732e4dd..ca51b5ba37 100644
--- a/source/java/org/alfresco/repo/simple/permission/ACLImpl.java
+++ b/source/java/org/alfresco/repo/simple/permission/ACLImpl.java
@@ -31,10 +31,9 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.repo.avm.util.RawServices;
-import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.simple.permission.ACL;
-import org.alfresco.service.simple.permission.CapabilityRegistry;
+import org.alfresco.service.simple.permission.AuthorityCapabilityRegistry;
/**
* Basic implementation of a simple ACL.
@@ -64,15 +63,10 @@ public class ACLImpl implements ACL
*/
private String fStringRep;
- /**
- * Reference to the authority service.
- */
- private transient AuthorityService fAuthorityService;
-
/**
* Reference to the capability registry.
*/
- private transient CapabilityRegistry fCapabilityRegistry;
+ private transient AuthorityCapabilityRegistry fCapabilityRegistry;
/**
* Initialize a brand new one.
@@ -81,8 +75,7 @@ public class ACLImpl implements ACL
public ACLImpl(boolean inherit)
{
fInherit = inherit;
- fAuthorityService = RawServices.Instance().getAuthorityService();
- fCapabilityRegistry = RawServices.Instance().getCapabilityRegistry();
+ fCapabilityRegistry = RawServices.Instance().getAuthorityCapabilityRegistry();
fAllowed = new HashMap>();
fDenied = new HashMap>();
fStringRep = null;
@@ -164,12 +157,21 @@ public class ACLImpl implements ACL
for (String entryRep : segments)
{
String[] entryRegs = entryRep.split(";");
- String capability = fCapabilityRegistry.getCapabilityName(Integer.parseInt(entryRegs[0], 16));
+ String capability = fCapabilityRegistry.getCapabilityName(Integer.parseInt(entryRegs[0], 32));
+ if (capability == null)
+ {
+ continue;
+ }
Set authorities = new HashSet();
map.put(capability, authorities);
for (int i = 1; i < entryRegs.length; ++i)
{
- authorities.add(entryRegs[i]);
+ String authority = fCapabilityRegistry.getAuthorityName(Integer.parseInt(entryRegs[i], 32));
+ if (authority == null)
+ {
+ continue;
+ }
+ authorities.add(authority);
}
}
}
@@ -196,7 +198,7 @@ public class ACLImpl implements ACL
}
for (String auth : denied)
{
- if (fAuthorityService.getContainedAuthorities(null, auth, false).contains(authority))
+ if (fCapabilityRegistry.getContainedAuthorities(auth).contains(authority))
{
return false;
}
@@ -212,7 +214,7 @@ public class ACLImpl implements ACL
}
for (String auth : allowed)
{
- if (fAuthorityService.getContainedAuthorities(null, auth, false).contains(authority))
+ if (fCapabilityRegistry.getContainedAuthorities(auth).contains(authority))
{
return true;
}
@@ -270,7 +272,7 @@ public class ACLImpl implements ACL
allowed.addAll(expAllowed);
for (String authority : expAllowed)
{
- allowed.addAll(fAuthorityService.getContainedAuthorities(null, authority, false));
+ allowed.addAll(fCapabilityRegistry.getContainedAuthorities(authority));
}
// Now remove based on denials.
Set denied = fDenied.get(capability);
@@ -282,7 +284,7 @@ public class ACLImpl implements ACL
// Now those that are indirectly denied.
for (String authority : denied)
{
- allowed.removeAll(fAuthorityService.getContainedAuthorities(null, authority, false));
+ allowed.removeAll(fCapabilityRegistry.getContainedAuthorities(authority));
}
return allowed;
}
@@ -296,7 +298,7 @@ public class ACLImpl implements ACL
AuthorityType type = AuthorityType.getAuthorityType(authority);
if (type == AuthorityType.ADMIN)
{
- return fCapabilityRegistry.getAll();
+ return fCapabilityRegistry.getAllCapabilities();
}
Set capabilities = new HashSet();
// First run through the allowed entries.
@@ -310,7 +312,7 @@ public class ACLImpl implements ACL
}
if (containers == null)
{
- containers = fAuthorityService.getContainingAuthorities(null, authority, false);
+ containers = fCapabilityRegistry.getContainerAuthorities(authority);
}
for (String auth : containers)
{
@@ -336,7 +338,7 @@ public class ACLImpl implements ACL
}
if (containers == null)
{
- containers = fAuthorityService.getContainingAuthorities(null, authority, false);
+ containers = fCapabilityRegistry.getContainerAuthorities(authority);
}
for (String auth : containers)
{
@@ -365,11 +367,11 @@ public class ACLImpl implements ACL
int count = 0;
for (Map.Entry> entry : fAllowed.entrySet())
{
- builder.append(Integer.toString(fCapabilityRegistry.getCapabilityID(entry.getKey()), 16));
+ builder.append(Integer.toString(fCapabilityRegistry.getCapabilityID(entry.getKey()), 32));
for (String authority : entry.getValue())
{
builder.append(';');
- builder.append(authority);
+ builder.append(Integer.toString(fCapabilityRegistry.getAuthorityID(authority), 32));
}
if (count++ < fAllowed.size() - 1)
{
@@ -380,11 +382,11 @@ public class ACLImpl implements ACL
count = 0;
for (Map.Entry> entry : fDenied.entrySet())
{
- builder.append(Integer.toString(fCapabilityRegistry.getCapabilityID(entry.getKey()), 16));
+ builder.append(Integer.toString(fCapabilityRegistry.getCapabilityID(entry.getKey()), 32));
for (String authority : entry.getValue())
{
builder.append(';');
- builder.append(authority);
+ builder.append(Integer.toString(fCapabilityRegistry.getAuthorityID(authority), 32));
}
if (count++ < fDenied.size() - 1)
{
diff --git a/source/java/org/alfresco/repo/simple/permission/ACLTest.java b/source/java/org/alfresco/repo/simple/permission/ACLTest.java
index d27cf93a37..944820bd69 100644
--- a/source/java/org/alfresco/repo/simple/permission/ACLTest.java
+++ b/source/java/org/alfresco/repo/simple/permission/ACLTest.java
@@ -25,13 +25,16 @@
package org.alfresco.repo.simple.permission;
+import java.util.HashSet;
+import java.util.Set;
+
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.simple.permission.ACL;
-import org.alfresco.service.simple.permission.CapabilityRegistry;
+import org.alfresco.service.simple.permission.AuthorityCapabilityRegistry;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import junit.framework.TestCase;
@@ -52,7 +55,7 @@ public class ACLTest extends TestCase
private static AuthenticationComponent fAuthenticationComponent;
- private static CapabilityRegistry fCapabilityRegistry;
+ private static AuthorityCapabilityRegistry fCapabilityRegistry;
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
@@ -67,7 +70,7 @@ public class ACLTest extends TestCase
fAuthenticationService = (AuthenticationService)fContext.getBean("AuthenticationService");
fAuthenticationComponent = (AuthenticationComponent)fContext.getBean("AuthenticationComponent");
fAuthenticationComponent.setSystemUserAsCurrentUser();
- fCapabilityRegistry = (CapabilityRegistry)fContext.getBean("capabilityRegistry");
+ fCapabilityRegistry = (AuthorityCapabilityRegistry)fContext.getBean("authorityCapabilityRegistry");
}
// Set up sample users groups and roles.
fAuthenticationService.createAuthentication("Buffy", "Buffy".toCharArray());
@@ -114,7 +117,9 @@ public class ACLTest extends TestCase
{
try
{
- System.out.println(fCapabilityRegistry.getAll());
+ Set allCaps = fCapabilityRegistry.getAllCapabilities();
+ System.out.println(allCaps);
+ System.out.println(fCapabilityRegistry.getAllAuthorities());
ACL acl = new ACLImpl(true);
acl.allow("read", "GROUP_Scoobies", "GROUP_vampires");
acl.allow("write", "GROUP_Scoobies", "GROUP_vampires");
@@ -123,18 +128,18 @@ public class ACLTest extends TestCase
acl.allow("shake", "GROUP_vampires", "Tara");
acl.deny("delete", "Xander", "GROUP_soulless");
acl.deny("shake", "Spike");
- System.out.println(acl.getCapabilities("Spike", false));
- System.out.println(acl.getCapabilities("Tara", false));
- System.out.println(acl.getCapabilities("Xander", false));
- System.out.println(acl.getCapabilities("Buffy", false));
+ checkEvaluation(allCaps, acl, "Spike");
+ checkEvaluation(allCaps, acl, "Tara");
+ checkEvaluation(allCaps, acl, "Xander");
+ checkEvaluation(allCaps, acl, "Buffy");
String stringRep = acl.getStringRepresentation();
System.out.println(stringRep);
ACL acl2 = new ACLImpl(stringRep);
System.out.println(acl2.getStringRepresentation());
- System.out.println(acl2.getCapabilities("Spike", false));
- System.out.println(acl2.getCapabilities("Tara", false));
- System.out.println(acl2.getCapabilities("Xander", false));
- System.out.println(acl2.getCapabilities("Buffy", false));
+ checkEvaluation(allCaps, acl2, "Spike");
+ checkEvaluation(allCaps, acl2, "Tara");
+ checkEvaluation(allCaps, acl2, "Xander");
+ checkEvaluation(allCaps, acl2, "Buffy");
System.out.println(acl2.getStringRepresentation());
}
catch (Exception e)
@@ -143,4 +148,20 @@ public class ACLTest extends TestCase
fail();
}
}
+
+ private void checkEvaluation(Set allCaps, ACL acl, String authority)
+ {
+ Set caps = acl.getCapabilities(authority, false);
+ System.out.println(caps);
+ for (String cap : caps)
+ {
+ assertTrue(acl.can(authority, false, cap));
+ }
+ Set inverse = new HashSet(allCaps);
+ inverse.removeAll(caps);
+ for (String cap : inverse)
+ {
+ assertFalse(acl.can(authority, false, cap));
+ }
+ }
}
diff --git a/source/java/org/alfresco/repo/simple/permission/AuthorityCapability.hbm.xml b/source/java/org/alfresco/repo/simple/permission/AuthorityCapability.hbm.xml
new file mode 100644
index 0000000000..5a731883c1
--- /dev/null
+++ b/source/java/org/alfresco/repo/simple/permission/AuthorityCapability.hbm.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/java/org/alfresco/repo/simple/permission/AuthorityCapabilityBootstrap.java b/source/java/org/alfresco/repo/simple/permission/AuthorityCapabilityBootstrap.java
new file mode 100644
index 0000000000..1ec03921c3
--- /dev/null
+++ b/source/java/org/alfresco/repo/simple/permission/AuthorityCapabilityBootstrap.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2005-2007 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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:
+ * http://www.alfresco.com/legal/licensing
+ */
+
+package org.alfresco.repo.simple.permission;
+
+import org.alfresco.util.AbstractLifecycleBean;
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * Bootstrapping for the AuthorityCapabilityRegistry.
+ * @author britt
+ */
+public class AuthorityCapabilityBootstrap extends AbstractLifecycleBean
+{
+ private AuthorityCapabilityRegistryImpl fRegistry;
+
+ public AuthorityCapabilityBootstrap()
+ {
+ }
+
+ public void setAuthorityCapabilityRegistry(AuthorityCapabilityRegistryImpl registry)
+ {
+ fRegistry = registry;
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent)
+ */
+ @Override
+ protected void onBootstrap(ApplicationEvent event)
+ {
+ fRegistry.bootstrap();
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent)
+ */
+ @Override
+ protected void onShutdown(ApplicationEvent event)
+ {
+ }
+}
diff --git a/source/java/org/alfresco/repo/simple/permission/AuthorityCapabilityRegistryImpl.java b/source/java/org/alfresco/repo/simple/permission/AuthorityCapabilityRegistryImpl.java
new file mode 100644
index 0000000000..fd09dac9a3
--- /dev/null
+++ b/source/java/org/alfresco/repo/simple/permission/AuthorityCapabilityRegistryImpl.java
@@ -0,0 +1,506 @@
+/*
+ * Copyright (C) 2005-2007 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * 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:
+ * http://www.alfresco.com/legal/licensing
+ */
+
+package org.alfresco.repo.simple.permission;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
+import org.alfresco.repo.transaction.RetryingTransactionHelper;
+import org.alfresco.repo.transaction.TransactionListener;
+import org.alfresco.service.cmr.security.AuthorityService;
+import org.alfresco.service.cmr.security.AuthorityType;
+import org.alfresco.service.simple.permission.AuthorityCapabilityRegistry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Implementation of a registry for Authorities and Capabilities.
+ * @author britt
+ */
+public class AuthorityCapabilityRegistryImpl implements
+ AuthorityCapabilityRegistry, TransactionListener
+{
+ private static Log fgLogger = LogFactory.getLog(AuthorityCapabilityRegistryImpl.class);
+
+ private Map fAuthorityToID;
+
+ private Map fIDToAuthority;
+
+ private Map> fAuthorityToChild;
+
+ private Map> fChildToAuthority;
+
+ private Map fCapabilityToID;
+
+ private Map fIDToCapability;
+
+ private AuthorityEntryDAO fAuthorityEntryDAO;
+
+ private CapabilityEntryDAO fCapabilityEntryDAO;
+
+ private Set fInitialCapabilities;
+
+ private RetryingTransactionHelper fTransactionHelper;
+
+ private AuthorityService fAuthorityService;
+
+ public AuthorityCapabilityRegistryImpl()
+ {
+ fAuthorityToID = new HashMap();
+ fIDToAuthority = new HashMap();
+ fAuthorityToChild = new HashMap>();
+ fChildToAuthority = new HashMap>();
+ fCapabilityToID = new HashMap();
+ fIDToCapability = new HashMap();
+ }
+
+ public void setAuthorityEntryDAO(AuthorityEntryDAO dao)
+ {
+ fAuthorityEntryDAO = dao;
+ }
+
+ public void setCapabilityEntryDAO(CapabilityEntryDAO dao)
+ {
+ fCapabilityEntryDAO = dao;
+ }
+
+ public void setCapabilities(Set capabilities)
+ {
+ fInitialCapabilities = capabilities;
+ }
+
+ public void setRetryingTransactionHelper(RetryingTransactionHelper helper)
+ {
+ fTransactionHelper = helper;
+ }
+
+ public void setAuthorityService(AuthorityService service)
+ {
+ fAuthorityService = service;
+ }
+
+ public void bootstrap()
+ {
+ fTransactionHelper.doInTransaction(
+ new RetryingTransactionHelper.RetryingTransactionCallback