Skip to content

Commit

Permalink
Always use 'this.' when accessing fields
Browse files Browse the repository at this point in the history
Apply an Eclipse cleanup rules to ensure that fields are always accessed
using `this.`. This aligns with the style used by Spring Framework and
helps users quickly see the difference between a local and member
variable.

Issue spring-projectsgh-8945
  • Loading branch information
philwebb authored and rwinch committed Aug 24, 2020
1 parent 6894ff5 commit 8866fa6
Show file tree
Hide file tree
Showing 793 changed files with 8,706 additions and 8,476 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ public AclEntryVoter(AclService aclService, String processConfigAttribute, Permi
* which will be the domain object used for ACL evaluation
*/
protected String getInternalMethod() {
return internalMethod;
return this.internalMethod;
}

public void setInternalMethod(String internalMethod) {
this.internalMethod = internalMethod;
}

protected String getProcessConfigAttribute() {
return processConfigAttribute;
return this.processConfigAttribute;
}

public void setObjectIdentityRetrievalStrategy(ObjectIdentityRetrievalStrategy objectIdentityRetrievalStrategy) {
Expand Down Expand Up @@ -181,41 +181,41 @@ public int vote(Authentication authentication, MethodInvocation object, Collecti
}

// Evaluate if we are required to use an inner domain object
if (StringUtils.hasText(internalMethod)) {
if (StringUtils.hasText(this.internalMethod)) {
try {
Class<?> clazz = domainObject.getClass();
Method method = clazz.getMethod(internalMethod, new Class[0]);
Method method = clazz.getMethod(this.internalMethod, new Class[0]);
domainObject = method.invoke(domainObject);
}
catch (NoSuchMethodException nsme) {
throw new AuthorizationServiceException("Object of class '" + domainObject.getClass()
+ "' does not provide the requested internalMethod: " + internalMethod);
+ "' does not provide the requested internalMethod: " + this.internalMethod);
}
catch (IllegalAccessException iae) {
logger.debug("IllegalAccessException", iae);

throw new AuthorizationServiceException(
"Problem invoking internalMethod: " + internalMethod + " for object: " + domainObject);
"Problem invoking internalMethod: " + this.internalMethod + " for object: " + domainObject);
}
catch (InvocationTargetException ite) {
logger.debug("InvocationTargetException", ite);

throw new AuthorizationServiceException(
"Problem invoking internalMethod: " + internalMethod + " for object: " + domainObject);
"Problem invoking internalMethod: " + this.internalMethod + " for object: " + domainObject);
}
}

// Obtain the OID applicable to the domain object
ObjectIdentity objectIdentity = objectIdentityRetrievalStrategy.getObjectIdentity(domainObject);
ObjectIdentity objectIdentity = this.objectIdentityRetrievalStrategy.getObjectIdentity(domainObject);

// Obtain the SIDs applicable to the principal
List<Sid> sids = sidRetrievalStrategy.getSids(authentication);
List<Sid> sids = this.sidRetrievalStrategy.getSids(authentication);

Acl acl;

try {
// Lookup only ACLs for SIDs we're interested in
acl = aclService.readAclById(objectIdentity, sids);
acl = this.aclService.readAclById(objectIdentity, sids);
}
catch (NotFoundException nfe) {
if (logger.isDebugEnabled()) {
Expand All @@ -226,7 +226,7 @@ public int vote(Authentication authentication, MethodInvocation object, Collecti
}

try {
if (acl.isGranted(requirePermission, sids, false)) {
if (acl.isGranted(this.requirePermission, sids, false)) {
if (logger.isDebugEnabled()) {
logger.debug("Voting to grant access");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ public void cachePermissionsFor(Authentication authentication, Collection<?> obj
if (domainObject == null) {
continue;
}
ObjectIdentity oid = oidRetrievalStrategy.getObjectIdentity(domainObject);
ObjectIdentity oid = this.oidRetrievalStrategy.getObjectIdentity(domainObject);
oidsToCache.add(oid);
}

List<Sid> sids = sidRetrievalStrategy.getSids(authentication);
List<Sid> sids = this.sidRetrievalStrategy.getSids(authentication);

if (logger.isDebugEnabled()) {
logger.debug("Eagerly loading Acls for " + oidsToCache.size() + " objects");
if (this.logger.isDebugEnabled()) {
this.logger.debug("Eagerly loading Acls for " + oidsToCache.size() + " objects");
}

aclService.readAclsById(oidsToCache, sids);
this.aclService.readAclsById(oidsToCache, sids);
}

public void setObjectIdentityRetrievalStrategy(ObjectIdentityRetrievalStrategy objectIdentityRetrievalStrategy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,49 +75,49 @@ public boolean hasPermission(Authentication authentication, Object domainObject,
return false;
}

ObjectIdentity objectIdentity = objectIdentityRetrievalStrategy.getObjectIdentity(domainObject);
ObjectIdentity objectIdentity = this.objectIdentityRetrievalStrategy.getObjectIdentity(domainObject);

return checkPermission(authentication, objectIdentity, permission);
}

public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
Object permission) {
ObjectIdentity objectIdentity = objectIdentityGenerator.createObjectIdentity(targetId, targetType);
ObjectIdentity objectIdentity = this.objectIdentityGenerator.createObjectIdentity(targetId, targetType);

return checkPermission(authentication, objectIdentity, permission);
}

private boolean checkPermission(Authentication authentication, ObjectIdentity oid, Object permission) {
// Obtain the SIDs applicable to the principal
List<Sid> sids = sidRetrievalStrategy.getSids(authentication);
List<Sid> sids = this.sidRetrievalStrategy.getSids(authentication);
List<Permission> requiredPermission = resolvePermission(permission);

final boolean debug = logger.isDebugEnabled();
final boolean debug = this.logger.isDebugEnabled();

if (debug) {
logger.debug("Checking permission '" + permission + "' for object '" + oid + "'");
this.logger.debug("Checking permission '" + permission + "' for object '" + oid + "'");
}

try {
// Lookup only ACLs for SIDs we're interested in
Acl acl = aclService.readAclById(oid, sids);
Acl acl = this.aclService.readAclById(oid, sids);

if (acl.isGranted(requiredPermission, sids, false)) {
if (debug) {
logger.debug("Access is granted");
this.logger.debug("Access is granted");
}

return true;
}

if (debug) {
logger.debug("Returning false - ACLs returned, but insufficient permissions for this principal");
this.logger.debug("Returning false - ACLs returned, but insufficient permissions for this principal");
}

}
catch (NotFoundException nfe) {
if (debug) {
logger.debug("Returning false - no ACLs apply for this principal");
this.logger.debug("Returning false - no ACLs apply for this principal");
}
}

Expand All @@ -127,7 +127,7 @@ private boolean checkPermission(Authentication authentication, ObjectIdentity oi

List<Permission> resolvePermission(Object permission) {
if (permission instanceof Integer) {
return Arrays.asList(permissionFactory.buildFromMask((Integer) permission));
return Arrays.asList(this.permissionFactory.buildFromMask((Integer) permission));
}

if (permission instanceof Permission) {
Expand All @@ -143,10 +143,10 @@ List<Permission> resolvePermission(Object permission) {
Permission p;

try {
p = permissionFactory.buildFromName(permString);
p = this.permissionFactory.buildFromName(permString);
}
catch (IllegalArgumentException notfound) {
p = permissionFactory.buildFromName(permString.toUpperCase(Locale.ENGLISH));
p = this.permissionFactory.buildFromName(permString.toUpperCase(Locale.ENGLISH));
}

if (p != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ public AbstractAclProvider(AclService aclService, String processConfigAttribute,
}

protected Class<?> getProcessDomainObjectClass() {
return processDomainObjectClass;
return this.processDomainObjectClass;
}

protected boolean hasPermission(Authentication authentication, Object domainObject) {
// Obtain the OID applicable to the domain object
ObjectIdentity objectIdentity = objectIdentityRetrievalStrategy.getObjectIdentity(domainObject);
ObjectIdentity objectIdentity = this.objectIdentityRetrievalStrategy.getObjectIdentity(domainObject);

// Obtain the SIDs applicable to the principal
List<Sid> sids = sidRetrievalStrategy.getSids(authentication);
List<Sid> sids = this.sidRetrievalStrategy.getSids(authentication);

try {
// Lookup only ACLs for SIDs we're interested in
Acl acl = aclService.readAclById(objectIdentity, sids);
Acl acl = this.aclService.readAclById(objectIdentity, sids);

return acl.isGranted(requirePermission, sids, false);
return acl.isGranted(this.requirePermission, sids, false);
}
catch (NotFoundException ignore) {
return false;
Expand Down Expand Up @@ -110,7 +110,7 @@ public void setSidRetrievalStrategy(SidRetrievalStrategy sidRetrievalStrategy) {
}

public boolean supports(ConfigAttribute attribute) {
return processConfigAttribute.equals(attribute.getAttribute());
return this.processConfigAttribute.equals(attribute.getAttribute());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Object decide(Authentication authentication, Object object, Collection<Co

logger.debug("Denying access");

throw new AccessDeniedException(messages.getMessage("AclEntryAfterInvocationProvider.noPermission",
throw new AccessDeniedException(this.messages.getMessage("AclEntryAfterInvocationProvider.noPermission",
new Object[] { authentication.getName(), returnedObject },
"Authentication {0} has NO permissions to the domain object {1}"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ArrayFilterer<T> implements Filterer<T> {
// Collect the removed objects to a HashSet so that
// it is fast to lookup them when a filtered array
// is constructed.
removeList = new HashSet<>();
this.removeList = new HashSet<>();
}

/**
Expand All @@ -55,14 +55,14 @@ class ArrayFilterer<T> implements Filterer<T> {
@SuppressWarnings("unchecked")
public T[] getFilteredObject() {
// Recreate an array of same type and filter the removed objects.
int originalSize = list.length;
int sizeOfResultingList = originalSize - removeList.size();
T[] filtered = (T[]) Array.newInstance(list.getClass().getComponentType(), sizeOfResultingList);
int originalSize = this.list.length;
int sizeOfResultingList = originalSize - this.removeList.size();
T[] filtered = (T[]) Array.newInstance(this.list.getClass().getComponentType(), sizeOfResultingList);

for (int i = 0, j = 0; i < list.length; i++) {
T object = list[i];
for (int i = 0, j = 0; i < this.list.length; i++) {
T object = this.list[i];

if (!removeList.contains(object)) {
if (!this.removeList.contains(object)) {
filtered[j] = object;
j++;
}
Expand All @@ -85,14 +85,14 @@ public Iterator<T> iterator() {
private int index = 0;

public boolean hasNext() {
return index < list.length;
return this.index < ArrayFilterer.this.list.length;
}

public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
return list[index++];
return ArrayFilterer.this.list[this.index++];
}

public void remove() {
Expand All @@ -106,7 +106,7 @@ public void remove() {
* @see org.springframework.security.acls.afterinvocation.Filterer#remove(java.lang.Object)
*/
public void remove(T object) {
removeList.add(object);
this.removeList.add(object);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CollectionFilterer<T> implements Filterer<T> {
// to the method may not necessarily be re-constructable (as
// the Collection(collection) constructor is not guaranteed and
// manually adding may lose sort order or other capabilities)
removeList = new HashSet<>();
this.removeList = new HashSet<>();
}

/**
Expand All @@ -57,36 +57,36 @@ class CollectionFilterer<T> implements Filterer<T> {
*/
public Object getFilteredObject() {
// Now the Iterator has ended, remove Objects from Collection
Iterator<T> removeIter = removeList.iterator();
Iterator<T> removeIter = this.removeList.iterator();

int originalSize = collection.size();
int originalSize = this.collection.size();

while (removeIter.hasNext()) {
collection.remove(removeIter.next());
this.collection.remove(removeIter.next());
}

if (logger.isDebugEnabled()) {
logger.debug("Original collection contained " + originalSize + " elements; now contains "
+ collection.size() + " elements");
+ this.collection.size() + " elements");
}

return collection;
return this.collection;
}

/**
*
* @see org.springframework.security.acls.afterinvocation.Filterer#iterator()
*/
public Iterator<T> iterator() {
return collection.iterator();
return this.collection.iterator();
}

/**
*
* @see org.springframework.security.acls.afterinvocation.Filterer#remove(java.lang.Object)
*/
public void remove(T object) {
removeList.add(object);
this.removeList.add(object);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public final boolean equals(Object arg0) {
}

public final int getMask() {
return mask;
return this.mask;
}

public String getPattern() {
return AclFormattingUtils.printBinary(mask, code);
return AclFormattingUtils.printBinary(this.mask, this.code);
}

public final String toString() {
return this.getClass().getSimpleName() + "[" + getPattern() + "=" + mask + "]";
return this.getClass().getSimpleName() + "[" + getPattern() + "=" + this.mask + "]";
}

public final int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,37 +134,37 @@ public int hashCode() {

@Override
public Acl getAcl() {
return acl;
return this.acl;
}

@Override
public Serializable getId() {
return id;
return this.id;
}

@Override
public Permission getPermission() {
return permission;
return this.permission;
}

@Override
public Sid getSid() {
return sid;
return this.sid;
}

@Override
public boolean isAuditFailure() {
return auditFailure;
return this.auditFailure;
}

@Override
public boolean isAuditSuccess() {
return auditSuccess;
return this.auditSuccess;
}

@Override
public boolean isGranting() {
return granting;
return this.granting;
}

void setAuditFailure(boolean auditFailure) {
Expand Down
Loading

0 comments on commit 8866fa6

Please sign in to comment.