public class JdbcMutableAclService extends JdbcAclService implements MutableAclService
MutableAclService
.
The default settings are for HSQLDB. If you are using a different database you will
probably need to set the sidIdentityQuery
and
classIdentityQuery
properties appropriately. The
other queries, SQL inserts and updates can also be customized to accomodate schema
variations, but must produce results consistent with those expected by the defaults.
See the appendix of the Spring Security reference manual for more information on the expected schema and how it is used. Information on using PostgreSQL is also included.
jdbcTemplate, log
Constructor and Description |
---|
JdbcMutableAclService(javax.sql.DataSource dataSource,
LookupStrategy lookupStrategy,
AclCache aclCache) |
Modifier and Type | Method and Description |
---|---|
MutableAcl |
createAcl(ObjectIdentity objectIdentity)
Creates an empty
Acl object in the database. |
protected void |
createEntries(MutableAcl acl)
Creates a new row in acl_entry for every ACE defined in the passed MutableAcl
object.
|
protected void |
createObjectIdentity(ObjectIdentity object,
Sid owner)
Creates an entry in the acl_object_identity table for the passed ObjectIdentity.
|
protected java.lang.Long |
createOrRetrieveClassPrimaryKey(java.lang.String type,
boolean allowCreate,
java.lang.Class idType)
Retrieves the primary key from
acl_class , creating a new row if needed and
the allowCreate property is true . |
protected java.lang.Long |
createOrRetrieveSidPrimaryKey(Sid sid,
boolean allowCreate)
Retrieves the primary key from acl_sid, creating a new row if needed and the
allowCreate property is true.
|
protected java.lang.Long |
createOrRetrieveSidPrimaryKey(java.lang.String sidName,
boolean sidIsPrincipal,
boolean allowCreate)
Retrieves the primary key from acl_sid, creating a new row if needed and the
allowCreate property is true.
|
void |
deleteAcl(ObjectIdentity objectIdentity,
boolean deleteChildren)
Removes the specified entry from the database.
|
protected void |
deleteEntries(java.lang.Long oidPrimaryKey)
Deletes all ACEs defined in the acl_entry table belonging to the presented
ObjectIdentity primary key.
|
protected void |
deleteObjectIdentity(java.lang.Long oidPrimaryKey)
Deletes a single row from acl_object_identity that is associated with the presented
ObjectIdentity primary key.
|
protected java.lang.Long |
retrieveObjectIdentityPrimaryKey(ObjectIdentity oid)
Retrieves the primary key from the acl_object_identity table for the passed
ObjectIdentity.
|
void |
setAclClassIdSupported(boolean aclClassIdSupported) |
void |
setClassIdentityQuery(java.lang.String classIdentityQuery)
Sets the query that will be used to retrieve the identity of a newly created row in
the acl_class table.
|
void |
setClassPrimaryKeyQuery(java.lang.String selectClassPrimaryKey) |
void |
setDeleteEntryByObjectIdentityForeignKeySql(java.lang.String deleteEntryByObjectIdentityForeignKey) |
void |
setDeleteObjectIdentityByPrimaryKeySql(java.lang.String deleteObjectIdentityByPrimaryKey) |
void |
setForeignKeysInDatabase(boolean foreignKeysInDatabase) |
void |
setInsertClassSql(java.lang.String insertClass) |
void |
setInsertEntrySql(java.lang.String insertEntry) |
void |
setInsertObjectIdentitySql(java.lang.String insertObjectIdentity) |
void |
setInsertSidSql(java.lang.String insertSid) |
void |
setObjectIdentityPrimaryKeyQuery(java.lang.String selectObjectIdentityPrimaryKey) |
void |
setSidIdentityQuery(java.lang.String sidIdentityQuery)
Sets the query that will be used to retrieve the identity of a newly created row in
the acl_sid table.
|
void |
setSidPrimaryKeyQuery(java.lang.String selectSidPrimaryKey) |
void |
setUpdateObjectIdentity(java.lang.String updateObjectIdentity) |
MutableAcl |
updateAcl(MutableAcl acl)
This implementation will simply delete all ACEs in the database and recreate them
on each invocation of this method.
|
protected void |
updateObjectIdentity(MutableAcl acl)
Updates an existing acl_object_identity row, with new information presented in the
passed MutableAcl object.
|
findChildren, isAclClassIdSupported, readAclById, readAclById, readAclsById, readAclsById, setAclClassIdUtils, setFindChildrenQuery
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
findChildren, readAclById, readAclById, readAclsById, readAclsById
public JdbcMutableAclService(javax.sql.DataSource dataSource, LookupStrategy lookupStrategy, AclCache aclCache)
public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException
MutableAclService
Acl
object in the database. It will have no entries.
The returned object will then be used to add entries.createAcl
in interface MutableAclService
objectIdentity
- the object identity to createAlreadyExistsException
- if the passed object identity already has a recordprotected void createEntries(MutableAcl acl)
acl
- containing the ACEs to insertprotected void createObjectIdentity(ObjectIdentity object, Sid owner)
object
- to represent an acl_object_identity forowner
- for the SID column (will be created if there is no acl_sid entry for
this particular Sid already)protected java.lang.Long createOrRetrieveClassPrimaryKey(java.lang.String type, boolean allowCreate, java.lang.Class idType)
acl_class
, creating a new row if needed and
the allowCreate
property is true
.type
- to find or create an entry for (often the fully-qualified class name)allowCreate
- true if creation is permitted if not foundprotected java.lang.Long createOrRetrieveSidPrimaryKey(Sid sid, boolean allowCreate)
sid
- to find or createallowCreate
- true if creation is permitted if not foundjava.lang.IllegalArgumentException
- if the Sid is not a recognized
implementation.protected java.lang.Long createOrRetrieveSidPrimaryKey(java.lang.String sidName, boolean sidIsPrincipal, boolean allowCreate)
sidName
- name of Sid to find or to createsidIsPrincipal
- whether it's a user or granted authority like roleallowCreate
- true if creation is permitted if not foundpublic void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren) throws ChildrenExistException
MutableAclService
deleteAcl
in interface MutableAclService
objectIdentity
- the object identity to removedeleteChildren
- whether to cascade the delete to childrenChildrenExistException
- if the deleteChildren argument was
false
but children existprotected void deleteEntries(java.lang.Long oidPrimaryKey)
oidPrimaryKey
- the rows in acl_entry to deleteprotected void deleteObjectIdentity(java.lang.Long oidPrimaryKey)
We do not delete any entries from acl_class, even if no classes are using that class any longer. This is a deadlock avoidance approach.
oidPrimaryKey
- to delete the acl_object_identityprotected java.lang.Long retrieveObjectIdentityPrimaryKey(ObjectIdentity oid)
createObjectIdentity(ObjectIdentity, Sid)
instead).oid
- to findpublic MutableAcl updateAcl(MutableAcl acl) throws NotFoundException
MutableAcl
.updateAcl
in interface MutableAclService
acl
- to modifyNotFoundException
- if the relevant record could not be found (did you
remember to use MutableAclService.createAcl(ObjectIdentity)
to create the object, rather
than creating it with the new
keyword?)protected void updateObjectIdentity(MutableAcl acl)
acl
- to modify (a row must already exist in acl_object_identity)NotFoundException
- if the ACL could not be found to update.public void setClassIdentityQuery(java.lang.String classIdentityQuery)
classIdentityQuery
- the query, which should return the identifier. Defaults
to call identity()public void setSidIdentityQuery(java.lang.String sidIdentityQuery)
sidIdentityQuery
- the query, which should return the identifier. Defaults to
call identity()public void setDeleteEntryByObjectIdentityForeignKeySql(java.lang.String deleteEntryByObjectIdentityForeignKey)
public void setDeleteObjectIdentityByPrimaryKeySql(java.lang.String deleteObjectIdentityByPrimaryKey)
public void setInsertClassSql(java.lang.String insertClass)
public void setInsertEntrySql(java.lang.String insertEntry)
public void setInsertObjectIdentitySql(java.lang.String insertObjectIdentity)
public void setInsertSidSql(java.lang.String insertSid)
public void setClassPrimaryKeyQuery(java.lang.String selectClassPrimaryKey)
public void setObjectIdentityPrimaryKeyQuery(java.lang.String selectObjectIdentityPrimaryKey)
public void setSidPrimaryKeyQuery(java.lang.String selectSidPrimaryKey)
public void setUpdateObjectIdentity(java.lang.String updateObjectIdentity)
public void setForeignKeysInDatabase(boolean foreignKeysInDatabase)
foreignKeysInDatabase
- if false this class will perform additional FK
constrain checking, which may cause deadlocks (the default is true, so deadlocks
are avoided but the database is expected to enforce FKs)public void setAclClassIdSupported(boolean aclClassIdSupported)
setAclClassIdSupported
in class JdbcAclService