mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-03-01 10:59:16 +00:00
Tidying.
This commit is contained in:
parent
b42fc7221f
commit
04e2fc7daf
@ -40,7 +40,7 @@ import org.springframework.util.Assert;
|
|||||||
*/
|
*/
|
||||||
public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
||||||
//~ Instance fields ================================================================================================
|
//~ Instance fields ================================================================================================
|
||||||
|
|
||||||
private Acl parentAcl;
|
private Acl parentAcl;
|
||||||
private transient AclAuthorizationStrategy aclAuthorizationStrategy;
|
private transient AclAuthorizationStrategy aclAuthorizationStrategy;
|
||||||
private transient AuditLogger auditLogger;
|
private transient AuditLogger auditLogger;
|
||||||
@ -53,7 +53,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
|
|
||||||
//~ Constructors ===================================================================================================
|
//~ Constructors ===================================================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal constructor, which should be used {@link
|
* Minimal constructor, which should be used {@link
|
||||||
* org.springframework.security.acls.MutableAclService#createAcl(ObjectIdentity)}.
|
* org.springframework.security.acls.MutableAclService#createAcl(ObjectIdentity)}.
|
||||||
*
|
*
|
||||||
@ -63,7 +63,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
* @param auditLogger audit logger (required)
|
* @param auditLogger audit logger (required)
|
||||||
*/
|
*/
|
||||||
public AclImpl(ObjectIdentity objectIdentity, Serializable id, AclAuthorizationStrategy aclAuthorizationStrategy,
|
public AclImpl(ObjectIdentity objectIdentity, Serializable id, AclAuthorizationStrategy aclAuthorizationStrategy,
|
||||||
AuditLogger auditLogger) {
|
AuditLogger auditLogger) {
|
||||||
Assert.notNull(objectIdentity, "Object Identity required");
|
Assert.notNull(objectIdentity, "Object Identity required");
|
||||||
Assert.notNull(id, "Id required");
|
Assert.notNull(id, "Id required");
|
||||||
Assert.notNull(aclAuthorizationStrategy, "AclAuthorizationStrategy required");
|
Assert.notNull(aclAuthorizationStrategy, "AclAuthorizationStrategy required");
|
||||||
@ -74,7 +74,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
this.auditLogger = auditLogger;
|
this.auditLogger = auditLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full constructor, which should be used by persistence tools that do not
|
* Full constructor, which should be used by persistence tools that do not
|
||||||
* provide field-level access features.
|
* provide field-level access features.
|
||||||
*
|
*
|
||||||
@ -90,7 +90,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
* @param owner the owner (required)
|
* @param owner the owner (required)
|
||||||
*/
|
*/
|
||||||
public AclImpl(ObjectIdentity objectIdentity, Serializable id, AclAuthorizationStrategy aclAuthorizationStrategy,
|
public AclImpl(ObjectIdentity objectIdentity, Serializable id, AclAuthorizationStrategy aclAuthorizationStrategy,
|
||||||
AuditLogger auditLogger, Acl parentAcl, Sid[] loadedSids, boolean entriesInheriting, Sid owner) {
|
AuditLogger auditLogger, Acl parentAcl, Sid[] loadedSids, boolean entriesInheriting, Sid owner) {
|
||||||
Assert.notNull(objectIdentity, "Object Identity required");
|
Assert.notNull(objectIdentity, "Object Identity required");
|
||||||
Assert.notNull(id, "Id required");
|
Assert.notNull(id, "Id required");
|
||||||
Assert.notNull(aclAuthorizationStrategy, "AclAuthorizationStrategy required");
|
Assert.notNull(aclAuthorizationStrategy, "AclAuthorizationStrategy required");
|
||||||
@ -106,7 +106,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private no-argument constructor for use by reflection-based persistence
|
* Private no-argument constructor for use by reflection-based persistence
|
||||||
* tools along with field-level access.
|
* tools along with field-level access.
|
||||||
*/
|
*/
|
||||||
@ -116,17 +116,17 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
|
|
||||||
private void verifyAceIndexExists(int aceIndex) {
|
private void verifyAceIndexExists(int aceIndex) {
|
||||||
if (aceIndex < 0) {
|
if (aceIndex < 0) {
|
||||||
throw new NotFoundException("aceIndex must be greater than or equal to zero");
|
throw new NotFoundException("aceIndex must be greater than or equal to zero");
|
||||||
}
|
}
|
||||||
if (aceIndex > this.aces.size()) {
|
if (aceIndex > this.aces.size()) {
|
||||||
throw new NotFoundException("aceIndex must correctly refer to an index of the AccessControlEntry collection");
|
throw new NotFoundException("aceIndex must correctly refer to an index of the AccessControlEntry collection");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAce(int aceIndex) throws NotFoundException {
|
public void deleteAce(int aceIndex) throws NotFoundException {
|
||||||
aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_GENERAL);
|
aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_GENERAL);
|
||||||
verifyAceIndexExists(aceIndex);
|
verifyAceIndexExists(aceIndex);
|
||||||
|
|
||||||
synchronized (aces) {
|
synchronized (aces) {
|
||||||
this.aces.remove(aceIndex);
|
this.aces.remove(aceIndex);
|
||||||
}
|
}
|
||||||
@ -153,16 +153,15 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
return parentAcl;
|
return parentAcl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertAce(int atIndexLocation, Permission permission, Sid sid, boolean granting)
|
public void insertAce(int atIndexLocation, Permission permission, Sid sid, boolean granting) throws NotFoundException {
|
||||||
throws NotFoundException {
|
|
||||||
aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_GENERAL);
|
aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_GENERAL);
|
||||||
Assert.notNull(permission, "Permission required");
|
Assert.notNull(permission, "Permission required");
|
||||||
Assert.notNull(sid, "Sid required");
|
Assert.notNull(sid, "Sid required");
|
||||||
if (atIndexLocation < 0) {
|
if (atIndexLocation < 0) {
|
||||||
throw new NotFoundException("atIndexLocation must be greater than or equal to zero");
|
throw new NotFoundException("atIndexLocation must be greater than or equal to zero");
|
||||||
}
|
}
|
||||||
if (atIndexLocation > this.aces.size()) {
|
if (atIndexLocation > this.aces.size()) {
|
||||||
throw new NotFoundException("atIndexLocation must be less than or equal to the size of the AccessControlEntry collection");
|
throw new NotFoundException("atIndexLocation must be less than or equal to the size of the AccessControlEntry collection");
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessControlEntryImpl ace = new AccessControlEntryImpl(null, this, sid, permission, granting, false, false);
|
AccessControlEntryImpl ace = new AccessControlEntryImpl(null, this, sid, permission, granting, false, false);
|
||||||
@ -208,7 +207,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
* subset of SIDs
|
* subset of SIDs
|
||||||
*/
|
*/
|
||||||
public boolean isGranted(Permission[] permission, Sid[] sids, boolean administrativeMode)
|
public boolean isGranted(Permission[] permission, Sid[] sids, boolean administrativeMode)
|
||||||
throws NotFoundException, UnloadedSidException {
|
throws NotFoundException, UnloadedSidException {
|
||||||
Assert.notEmpty(permission, "Permissions required");
|
Assert.notEmpty(permission, "Permissions required");
|
||||||
Assert.notEmpty(sids, "SIDs required");
|
Assert.notEmpty(sids, "SIDs required");
|
||||||
|
|
||||||
@ -360,7 +359,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_GENERAL);
|
aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_GENERAL);
|
||||||
verifyAceIndexExists(aceIndex);
|
verifyAceIndexExists(aceIndex);
|
||||||
|
|
||||||
synchronized (aces) {
|
synchronized (aces) {
|
||||||
AccessControlEntryImpl ace = (AccessControlEntryImpl) aces.get(aceIndex);
|
AccessControlEntryImpl ace = (AccessControlEntryImpl) aces.get(aceIndex);
|
||||||
ace.setPermission(permission);
|
ace.setPermission(permission);
|
||||||
@ -370,42 +369,42 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
|||||||
public void updateAuditing(int aceIndex, boolean auditSuccess, boolean auditFailure) {
|
public void updateAuditing(int aceIndex, boolean auditSuccess, boolean auditFailure) {
|
||||||
aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_AUDITING);
|
aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_AUDITING);
|
||||||
verifyAceIndexExists(aceIndex);
|
verifyAceIndexExists(aceIndex);
|
||||||
|
|
||||||
synchronized (aces) {
|
synchronized (aces) {
|
||||||
AccessControlEntryImpl ace = (AccessControlEntryImpl) aces.get(aceIndex);
|
AccessControlEntryImpl ace = (AccessControlEntryImpl) aces.get(aceIndex);
|
||||||
ace.setAuditSuccess(auditSuccess);
|
ace.setAuditSuccess(auditSuccess);
|
||||||
ace.setAuditFailure(auditFailure);
|
ace.setAuditFailure(auditFailure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof AclImpl) {
|
if (obj instanceof AclImpl) {
|
||||||
AclImpl rhs = (AclImpl) obj;
|
AclImpl rhs = (AclImpl) obj;
|
||||||
if (this.aces.equals(rhs.aces)) {
|
if (this.aces.equals(rhs.aces)) {
|
||||||
if ((this.parentAcl == null && rhs.parentAcl == null) || (this.parentAcl.equals(rhs.parentAcl))) {
|
if ((this.parentAcl == null && rhs.parentAcl == null) || (this.parentAcl.equals(rhs.parentAcl))) {
|
||||||
if ((this.objectIdentity == null && rhs.objectIdentity == null) || (this.objectIdentity.equals(rhs.objectIdentity))) {
|
if ((this.objectIdentity == null && rhs.objectIdentity == null) || (this.objectIdentity.equals(rhs.objectIdentity))) {
|
||||||
if ((this.id == null && rhs.id == null) || (this.id.equals(rhs.id))) {
|
if ((this.id == null && rhs.id == null) || (this.id.equals(rhs.id))) {
|
||||||
if ((this.owner == null && rhs.owner == null) || this.owner.equals(rhs.owner)) {
|
if ((this.owner == null && rhs.owner == null) || this.owner.equals(rhs.owner)) {
|
||||||
if (this.entriesInheriting == rhs.entriesInheriting) {
|
if (this.entriesInheriting == rhs.entriesInheriting) {
|
||||||
if ((this.loadedSids == null && rhs.loadedSids == null)) {
|
if ((this.loadedSids == null && rhs.loadedSids == null)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this.loadedSids.length == rhs.loadedSids.length) {
|
if (this.loadedSids.length == rhs.loadedSids.length) {
|
||||||
for (int i = 0; i < this.loadedSids.length; i++) {
|
for (int i = 0; i < this.loadedSids.length; i++) {
|
||||||
if (!this.loadedSids[i].equals(rhs.loadedSids[i])) {
|
if (!this.loadedSids[i].equals(rhs.loadedSids[i])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user