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

public class InMemoryAclService extends Object implements 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.acls.model.MutableAcl
    createAcl(org.springframework.security.acls.model.ObjectIdentity objectIdentity)
     
    void
    deleteAcl(org.springframework.security.acls.model.ObjectIdentity objectIdentity, boolean deleteChildren)
     
    void
    deleteSid(org.springframework.security.acls.model.Sid sid)
     
    org.springframework.security.acls.model.MutableAcl
    Create-or-get the ACL for entity without 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.MutableAcl
    grantToAuthority(Securable entity, String authority, org.springframework.security.acls.model.Permission permission)
    Same as grantToPrincipal(Securable, String, Permission) but grants to a granted-authority Sid (group / role).
    org.springframework.security.acls.model.MutableAcl
    grantToPrincipal(Securable entity, String principal, org.springframework.security.acls.model.Permission permission)
    Create-or-get the ACL for entity and grant permission to a principal Sid (the kind you get from a logged-in user).
     
    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.
    org.springframework.security.acls.model.Acl
    readAclById(org.springframework.security.acls.model.ObjectIdentity object)
     
    org.springframework.security.acls.model.Acl
    readAclById(org.springframework.security.acls.model.ObjectIdentity object, List<org.springframework.security.acls.model.Sid> sids)
     
    org.springframework.security.acls.model.Acl
    readAclById(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)
     
    int
    Snapshot of currently-stored ACL count, for size assertions.
    org.springframework.security.acls.model.MutableAcl
    updateAcl(org.springframework.security.acls.model.MutableAcl acl)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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:
      createAcl in interface org.springframework.security.acls.model.MutableAclService
    • deleteAcl

      public void deleteAcl(org.springframework.security.acls.model.ObjectIdentity objectIdentity, boolean deleteChildren)
      Specified by:
      deleteAcl in interface org.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:
      updateAcl in interface org.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:
      findChildren in interface org.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:
      readAclById in interface org.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:
      readAclById in interface org.springframework.security.acls.model.AclService
    • readAclsById

      public Map<org.springframework.security.acls.model.ObjectIdentity, org.springframework.security.acls.model.Acl> readAclsById(List<org.springframework.security.acls.model.ObjectIdentity> objects)
      Specified by:
      readAclsById in interface org.springframework.security.acls.model.AclService
    • 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:
      readAclsById in interface org.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:
      readAclById in interface AclService
    • openSession

      public Session openSession()
      Specified by:
      openSession in interface AclService
    • deleteSid

      public void deleteSid(org.springframework.security.acls.model.Sid sid)
      Specified by:
      deleteSid in interface AclService
    • 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 for entity and grant permission to 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, write acls.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 as grantToPrincipal(Securable, String, Permission) but grants to a granted-authority Sid (group / role).
    • ensureAcl

      public org.springframework.security.acls.model.MutableAcl ensureAcl(Securable entity)
      Create-or-get the ACL for entity without 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.