Class InMemoryAclService
java.lang.Object
ubic.gemma.core.security.acl.InMemoryAclService
- All Implemented Interfaces:
org.springframework.security.acls.model.AclService, org.springframework.security.acls.model.MutableAclService, AclService
Test-only
AclService that stores ACLs in an in-memory Map using real Spring
Security AclImpl instances. Lets unit tests for AclEventListener and
BaseAclAdvice run without Spring, Hibernate, JDBC, or a database while still
exercising the same MutableAcl.setParent(Acl), MutableAcl.setEntriesInheriting(boolean)
and ACE-list semantics that production code depends on.
Equality with both ObjectIdentityImpl (Spring's canonical) and gsec's
AclObjectIdentity is handled by normalizing every incoming OID through
normalize(ObjectIdentity) before map lookups — same shape as
GsecAclServiceAdapter in production.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.acls.model.MutableAclcreateAcl(org.springframework.security.acls.model.ObjectIdentity objectIdentity) voiddeleteAcl(org.springframework.security.acls.model.ObjectIdentity objectIdentity, boolean deleteChildren) voiddeleteSid(org.springframework.security.acls.model.Sid sid) org.springframework.security.acls.model.MutableAclCreate-or-get the ACL forentitywithout granting anything — useful when a test needs the entity to be ACL-known but with no permissions for the test principal.List<org.springframework.security.acls.model.ObjectIdentity> findChildren(org.springframework.security.acls.model.ObjectIdentity parentIdentity) org.springframework.security.acls.model.MutableAclgrantToAuthority(Securable entity, String authority, org.springframework.security.acls.model.Permission permission) Same asgrantToPrincipal(Securable, String, Permission)but grants to a granted-authority Sid (group / role).org.springframework.security.acls.model.MutableAclgrantToPrincipal(Securable entity, String principal, org.springframework.security.acls.model.Permission permission) Create-or-get the ACL forentityand grantpermissionto a principal Sid (the kind you get from a logged-in user).org.springframework.security.acls.domain.AclImplpeek(org.springframework.security.acls.model.ObjectIdentity oid) Direct map-style access to the stored ACL by entity OID, bypassing the NotFoundException contract — useful in assertions that want a nullable view.org.springframework.security.acls.model.AclreadAclById(org.springframework.security.acls.model.ObjectIdentity object) org.springframework.security.acls.model.AclreadAclById(org.springframework.security.acls.model.ObjectIdentity object, List<org.springframework.security.acls.model.Sid> sids) org.springframework.security.acls.model.AclreadAclById(org.springframework.security.acls.model.ObjectIdentity oid, Session session) Map<org.springframework.security.acls.model.ObjectIdentity, org.springframework.security.acls.model.Acl> readAclsById(List<org.springframework.security.acls.model.ObjectIdentity> objects) Map<org.springframework.security.acls.model.ObjectIdentity, org.springframework.security.acls.model.Acl> readAclsById(List<org.springframework.security.acls.model.ObjectIdentity> objects, List<org.springframework.security.acls.model.Sid> sids) intsize()Snapshot of currently-stored ACL count, for size assertions.org.springframework.security.acls.model.MutableAclupdateAcl(org.springframework.security.acls.model.MutableAcl acl)
-
Constructor Details
-
InMemoryAclService
public InMemoryAclService()
-
-
Method Details
-
createAcl
public org.springframework.security.acls.model.MutableAcl createAcl(org.springframework.security.acls.model.ObjectIdentity objectIdentity) - Specified by:
createAclin interfaceorg.springframework.security.acls.model.MutableAclService
-
deleteAcl
public void deleteAcl(org.springframework.security.acls.model.ObjectIdentity objectIdentity, boolean deleteChildren) - Specified by:
deleteAclin interfaceorg.springframework.security.acls.model.MutableAclService
-
updateAcl
public org.springframework.security.acls.model.MutableAcl updateAcl(org.springframework.security.acls.model.MutableAcl acl) throws org.springframework.security.acls.model.NotFoundException - Specified by:
updateAclin interfaceorg.springframework.security.acls.model.MutableAclService- Throws:
org.springframework.security.acls.model.NotFoundException
-
findChildren
public List<org.springframework.security.acls.model.ObjectIdentity> findChildren(org.springframework.security.acls.model.ObjectIdentity parentIdentity) - Specified by:
findChildrenin interfaceorg.springframework.security.acls.model.AclService
-
readAclById
public org.springframework.security.acls.model.Acl readAclById(org.springframework.security.acls.model.ObjectIdentity object) throws org.springframework.security.acls.model.NotFoundException - Specified by:
readAclByIdin interfaceorg.springframework.security.acls.model.AclService- Throws:
org.springframework.security.acls.model.NotFoundException
-
readAclById
public org.springframework.security.acls.model.Acl readAclById(org.springframework.security.acls.model.ObjectIdentity object, List<org.springframework.security.acls.model.Sid> sids) - Specified by:
readAclByIdin interfaceorg.springframework.security.acls.model.AclService
-
readAclsById
-
readAclsById
public Map<org.springframework.security.acls.model.ObjectIdentity, org.springframework.security.acls.model.Acl> readAclsById(List<org.springframework.security.acls.model.ObjectIdentity> objects, @Nullable List<org.springframework.security.acls.model.Sid> sids) - Specified by:
readAclsByIdin interfaceorg.springframework.security.acls.model.AclService
-
readAclById
public org.springframework.security.acls.model.Acl readAclById(org.springframework.security.acls.model.ObjectIdentity oid, Session session) - Specified by:
readAclByIdin interfaceAclService
-
openSession
- Specified by:
openSessionin interfaceAclService
-
deleteSid
public void deleteSid(org.springframework.security.acls.model.Sid sid) - Specified by:
deleteSidin interfaceAclService
-
size
public int size()Snapshot of currently-stored ACL count, for size assertions. -
grantToPrincipal
public org.springframework.security.acls.model.MutableAcl grantToPrincipal(Securable entity, String principal, org.springframework.security.acls.model.Permission permission) Create-or-get the ACL forentityand grantpermissionto a principal Sid (the kind you get from a logged-in user). Convenience for after-invocation provider tests: instead of constructing AclImpl + insertAce + updateAcl by hand, writeacls.grantToPrincipal(entity, "alice", BasePermission.READ). -
grantToAuthority
public org.springframework.security.acls.model.MutableAcl grantToAuthority(Securable entity, String authority, org.springframework.security.acls.model.Permission permission) Same asgrantToPrincipal(Securable, String, Permission)but grants to a granted-authority Sid (group / role). -
ensureAcl
Create-or-get the ACL forentitywithout granting anything — useful when a test needs the entity to be ACL-known but with no permissions for the test principal. -
peek
@Nullable public org.springframework.security.acls.domain.AclImpl peek(org.springframework.security.acls.model.ObjectIdentity oid) Direct map-style access to the stored ACL by entity OID, bypassing the NotFoundException contract — useful in assertions that want a nullable view.
-