mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-09 11:53:30 +00:00
Reformat code.
This commit is contained in:
parent
e675c89e28
commit
449e395181
@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -159,27 +159,25 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* The {@link BasicAclEntry}s returned by this method will have
|
* The {@link BasicAclEntry}s returned by this method will have
|
||||||
* <code>String</code>-based recipients. This will not be a problem if
|
* <code>String</code>-based recipients. This will not be a problem if you
|
||||||
* you are using the
|
* are using the <code>GrantedAuthorityEffectiveAclsResolver</code>, which
|
||||||
* <code>GrantedAuthorityEffectiveAclsResolver</code>, which is the
|
* is the default configured against <code>BasicAclProvider</code>.
|
||||||
* default configured against <code>BasicAclProvider</code>.
|
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* This method will only return ACLs for requests where the
|
* This method will only return ACLs for requests where the
|
||||||
* <code>AclObjectIdentity</code> is of type {@link
|
* <code>AclObjectIdentity</code> is of type {@link
|
||||||
* NamedEntityObjectIdentity}. Of course, you can subclass or replace
|
* NamedEntityObjectIdentity}. Of course, you can subclass or replace this
|
||||||
* this class and support your own custom
|
* class and support your own custom <code>AclObjectIdentity</code> types.
|
||||||
* <code>AclObjectIdentity</code> types.
|
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param aclObjectIdentity for which ACL information is required
|
* @param aclObjectIdentity for which ACL information is required (cannot
|
||||||
* (cannot be <code>null</code> and must be an instance of
|
* be <code>null</code> and must be an instance of
|
||||||
* <code>NamedEntityObjectIdentity</code>)
|
* <code>NamedEntityObjectIdentity</code>)
|
||||||
*
|
*
|
||||||
* @return the ACLs that apply (without any <code>null</code>s inside
|
* @return the ACLs that apply (without any <code>null</code>s inside the
|
||||||
* the array), or <code>null</code> if not found or if an
|
* array), or <code>null</code> if not found or if an incompatible
|
||||||
* incompatible <code>AclObjectIdentity</code> was requested
|
* <code>AclObjectIdentity</code> was requested
|
||||||
*/
|
*/
|
||||||
public BasicAclEntry[] getAcls(AclObjectIdentity aclObjectIdentity) {
|
public BasicAclEntry[] getAcls(AclObjectIdentity aclObjectIdentity) {
|
||||||
String aclObjectIdentityString;
|
String aclObjectIdentityString;
|
||||||
@ -199,8 +197,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cast to an object properties holder (there should only be one record)
|
// Cast to an object properties holder (there should only be one record)
|
||||||
AclDetailsHolder propertiesInformation = (AclDetailsHolder) objects
|
AclDetailsHolder propertiesInformation = (AclDetailsHolder) objects.get(0);
|
||||||
.get(0);
|
|
||||||
|
|
||||||
// Lookup the object's ACLs from RDBMS (guaranteed no nulls)
|
// Lookup the object's ACLs from RDBMS (guaranteed no nulls)
|
||||||
List acls = aclsByObjectIdentity.execute(propertiesInformation
|
List acls = aclsByObjectIdentity.execute(propertiesInformation
|
||||||
@ -212,13 +209,12 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
null)};
|
null)};
|
||||||
} else {
|
} else {
|
||||||
// return the individual ACL instances
|
// return the individual ACL instances
|
||||||
AclDetailsHolder[] aclHolders = (AclDetailsHolder[]) acls
|
AclDetailsHolder[] aclHolders = (AclDetailsHolder[]) acls.toArray(new AclDetailsHolder[] {});
|
||||||
.toArray(new AclDetailsHolder[] {});
|
|
||||||
List toReturnAcls = new Vector();
|
List toReturnAcls = new Vector();
|
||||||
|
|
||||||
for (int i = 0; i < aclHolders.length; i++) {
|
for (int i = 0; i < aclHolders.length; i++) {
|
||||||
toReturnAcls.add(createBasicAclEntry(
|
toReturnAcls.add(createBasicAclEntry(propertiesInformation,
|
||||||
propertiesInformation, aclHolders[i]));
|
aclHolders[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (BasicAclEntry[]) toReturnAcls.toArray(new BasicAclEntry[] {});
|
return (BasicAclEntry[]) toReturnAcls.toArray(new BasicAclEntry[] {});
|
||||||
@ -242,14 +238,12 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension point to allow other MappingSqlQuery objects to be
|
* Extension point to allow other MappingSqlQuery objects to be substituted
|
||||||
* substituted in a subclass
|
* in a subclass
|
||||||
*/
|
*/
|
||||||
protected void initMappingSqlQueries() {
|
protected void initMappingSqlQueries() {
|
||||||
setAclsByObjectIdentity(new AclsByObjectIdentityMapping(
|
setAclsByObjectIdentity(new AclsByObjectIdentityMapping(getDataSource()));
|
||||||
getDataSource()));
|
setObjectProperties(new ObjectPropertiesMapping(getDataSource()));
|
||||||
setObjectProperties(new ObjectPropertiesMapping(
|
|
||||||
getDataSource()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAclsByObjectIdentity(
|
public void setAclsByObjectIdentity(
|
||||||
@ -258,12 +252,12 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the default query string used to retrieve ACLs based
|
* Allows the default query string used to retrieve ACLs based on object
|
||||||
* on object identity to be overriden, if default table or
|
* identity to be overriden, if default table or column names need to be
|
||||||
* column names need to be changed. The default query is
|
* changed. The default query is {@link
|
||||||
* {@link #DEF_ACLS_BY_OBJECT_IDENTITY_QUERY}; when modifying
|
* #DEF_ACLS_BY_OBJECT_IDENTITY_QUERY}; when modifying this query, ensure
|
||||||
* this query, ensure that all returned columns are mapped
|
* that all returned columns are mapped back to the same column names as
|
||||||
* back to the same column names as in the default query.
|
* in the default query.
|
||||||
*
|
*
|
||||||
* @param queryString The query string to set
|
* @param queryString The query string to set
|
||||||
*/
|
*/
|
||||||
@ -271,8 +265,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
aclsByObjectIdentityQuery = queryString;
|
aclsByObjectIdentityQuery = queryString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setObjectProperties(
|
public void setObjectProperties(MappingSqlQuery objectPropertiesQuery) {
|
||||||
MappingSqlQuery objectPropertiesQuery) {
|
|
||||||
this.objectProperties = objectPropertiesQuery;
|
this.objectProperties = objectPropertiesQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,20 +276,18 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
//~ Inner Classes ==========================================================
|
//~ Inner Classes ==========================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to hold details of a domain object instance's
|
* Used to hold details of a domain object instance's properties, or an
|
||||||
* properties, or an individual ACL entry.
|
* individual ACL entry.
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* Not all properties will be set. The actual properties set
|
* Not all properties will be set. The actual properties set will depend on
|
||||||
* will depend on which <code>MappingSqlQuery</code> creates
|
* which <code>MappingSqlQuery</code> creates the object.
|
||||||
* the object.
|
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* Does not enforce <code>null</code>s or empty
|
* Does not enforce <code>null</code>s or empty <code>String</code>s as
|
||||||
* <code>String</code>s as this is performed by the
|
* this is performed by the <code>MappingSqlQuery</code> objects (or
|
||||||
* <code>MappingSqlQuery</code> objects (or preferably the
|
* preferably the backend RDBMS via schema constraints).
|
||||||
* backend RDBMS via schema constraints).
|
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
protected final class AclDetailsHolder {
|
protected final class AclDetailsHolder {
|
||||||
@ -308,8 +299,8 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
private long foreignKeyId;
|
private long foreignKeyId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record details of an individual ACL entry (usually from
|
* Record details of an individual ACL entry (usually from the
|
||||||
* the ACL_PERMISSION table)
|
* ACL_PERMISSION table)
|
||||||
*
|
*
|
||||||
* @param recipient the recipient
|
* @param recipient the recipient
|
||||||
* @param mask the integer to be masked
|
* @param mask the integer to be masked
|
||||||
@ -320,25 +311,23 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record details of a domain object instance's properties
|
* Record details of a domain object instance's properties (usually
|
||||||
* (usually from the ACL_OBJECT_IDENTITY table)
|
* from the ACL_OBJECT_IDENTITY table)
|
||||||
*
|
*
|
||||||
* @param foreignKeyId used by the
|
* @param foreignKeyId used by the
|
||||||
* <code>AclsByObjectIdentityMapping</code> to
|
* <code>AclsByObjectIdentityMapping</code> to locate the
|
||||||
* locate the individual ACL entries
|
* individual ACL entries
|
||||||
* @param aclObjectIdentity the object identity of the
|
* @param aclObjectIdentity the object identity of the domain object
|
||||||
* domain object instance
|
* instance
|
||||||
* @param aclObjectParentIdentity the object identity of
|
* @param aclObjectParentIdentity the object identity of the domain
|
||||||
* the domain object instance's parent
|
* object instance's parent
|
||||||
* @param aclClass the class of which a new instance which
|
* @param aclClass the class of which a new instance which should be
|
||||||
* should be created for each individual ACL entry
|
* created for each individual ACL entry (or an inheritence
|
||||||
* (or an inheritence "holder" class if there are
|
* "holder" class if there are no ACL entries)
|
||||||
* no ACL entries)
|
|
||||||
*/
|
*/
|
||||||
public AclDetailsHolder(long foreignKeyId,
|
public AclDetailsHolder(long foreignKeyId,
|
||||||
AclObjectIdentity aclObjectIdentity,
|
AclObjectIdentity aclObjectIdentity,
|
||||||
AclObjectIdentity aclObjectParentIdentity,
|
AclObjectIdentity aclObjectParentIdentity, Class aclClass) {
|
||||||
Class aclClass) {
|
|
||||||
this.foreignKeyId = foreignKeyId;
|
this.foreignKeyId = foreignKeyId;
|
||||||
this.aclObjectIdentity = aclObjectIdentity;
|
this.aclObjectIdentity = aclObjectIdentity;
|
||||||
this.aclObjectParentIdentity = aclObjectParentIdentity;
|
this.aclObjectParentIdentity = aclObjectParentIdentity;
|
||||||
@ -378,18 +367,16 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* Guarantees to never return <code>null</code> (exceptions are
|
* Guarantees to never return <code>null</code> (exceptions are thrown in
|
||||||
* thrown in the event of any issues).
|
* the event of any issues).
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* The executed SQL requires the following information be made
|
* The executed SQL requires the following information be made available
|
||||||
* available from the indicated placeholders: 1. RECIPIENT, 2.
|
* from the indicated placeholders: 1. RECIPIENT, 2. MASK.
|
||||||
* MASK.
|
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
protected class AclsByObjectIdentityMapping
|
protected class AclsByObjectIdentityMapping extends MappingSqlQuery {
|
||||||
extends MappingSqlQuery {
|
|
||||||
protected AclsByObjectIdentityMapping(DataSource ds) {
|
protected AclsByObjectIdentityMapping(DataSource ds) {
|
||||||
super(ds, aclsByObjectIdentityQuery);
|
super(ds, aclsByObjectIdentityQuery);
|
||||||
declareParameter(new SqlParameter(Types.BIGINT));
|
declareParameter(new SqlParameter(Types.BIGINT));
|
||||||
@ -414,15 +401,14 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* Guarantees to never return <code>null</code> (exceptions are
|
* Guarantees to never return <code>null</code> (exceptions are thrown in
|
||||||
* thrown in the event of any issues).
|
* the event of any issues).
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <P>
|
* <P>
|
||||||
* The executed SQL requires the following information be made
|
* The executed SQL requires the following information be made available
|
||||||
* available from the indicated placeholders: 1. ID, 2.
|
* from the indicated placeholders: 1. ID, 2. OBJECT_IDENTITY, 3.
|
||||||
* OBJECT_IDENTITY, 3. ACL_CLASS and 4.
|
* ACL_CLASS and 4. PARENT_OBJECT_IDENTITY.
|
||||||
* PARENT_OBJECT_IDENTITY.
|
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
protected class ObjectPropertiesMapping extends MappingSqlQuery {
|
protected class ObjectPropertiesMapping extends MappingSqlQuery {
|
||||||
@ -459,15 +445,13 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements BasicAclDao {
|
|||||||
Class aclClazz;
|
Class aclClazz;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
aclClazz = this.getClass().getClassLoader()
|
aclClazz = this.getClass().getClassLoader().loadClass(aclClass);
|
||||||
.loadClass(aclClass);
|
|
||||||
} catch (ClassNotFoundException cnf) {
|
} catch (ClassNotFoundException cnf) {
|
||||||
throw new IllegalArgumentException(cnf.getMessage());
|
throw new IllegalArgumentException(cnf.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AclDetailsHolder(id,
|
return new AclDetailsHolder(id, buildIdentity(objectIdentity),
|
||||||
buildIdentity(objectIdentity),
|
|
||||||
buildIdentity(parentObjectIdentity), aclClazz);
|
buildIdentity(parentObjectIdentity), aclClazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user