Skip to content

Commit

Permalink
Apply code cleanup rules to projects
Browse files Browse the repository at this point in the history
Apply automated cleanup rules to add `@Override` and `@Deprecated`
annotations and to fix class references used with static methods.

Issue spring-projectsgh-8945
  • Loading branch information
philwebb authored and rwinch committed Aug 24, 2020
1 parent 8866fa6 commit 9e08b51
Show file tree
Hide file tree
Showing 558 changed files with 1,418 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ public void setSidRetrievalStrategy(SidRetrievalStrategy sidRetrievalStrategy) {
this.sidRetrievalStrategy = sidRetrievalStrategy;
}

@Override
public boolean supports(ConfigAttribute attribute) {
return (attribute.getAttribute() != null) && attribute.getAttribute().equals(getProcessConfigAttribute());
}

@Override
public int vote(Authentication authentication, MethodInvocation object, Collection<ConfigAttribute> attributes) {

for (ConfigAttribute attr : attributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public AclPermissionCacheOptimizer(AclService aclService) {
this.aclService = aclService;
}

@Override
public void cachePermissionsFor(Authentication authentication, Collection<?> objects) {
if (objects.isEmpty()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public AclPermissionEvaluator(AclService aclService) {
* the ACL configuration. If the domain object is null, returns false (this can always
* be overridden using a null check in the expression itself).
*/
@Override
public boolean hasPermission(Authentication authentication, Object domainObject, Object permission) {
if (domainObject == null) {
return false;
Expand All @@ -80,6 +81,7 @@ public boolean hasPermission(Authentication authentication, Object domainObject,
return checkPermission(authentication, objectIdentity, permission);
}

@Override
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
Object permission) {
ObjectIdentity objectIdentity = this.objectIdentityGenerator.createObjectIdentity(targetId, targetType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void setSidRetrievalStrategy(SidRetrievalStrategy sidRetrievalStrategy) {
this.sidRetrievalStrategy = sidRetrievalStrategy;
}

@Override
public boolean supports(ConfigAttribute attribute) {
return this.processConfigAttribute.equals(attribute.getAttribute());
}
Expand All @@ -119,6 +120,7 @@ public boolean supports(ConfigAttribute attribute) {
* @param clazz the secure object
* @return always <code>true</code>
*/
@Override
public boolean supports(Class<?> clazz) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public AclEntryAfterInvocationCollectionFilteringProvider(AclService aclService,
super(aclService, "AFTER_ACL_COLLECTION_READ", requirePermission);
}

@Override
@SuppressWarnings("unchecked")
public Object decide(Authentication authentication, Object object, Collection<ConfigAttribute> config,
Object returnedObject) throws AccessDeniedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public AclEntryAfterInvocationProvider(AclService aclService, String processConf
super(aclService, processConfigAttribute, requirePermission);
}

@Override
public Object decide(Authentication authentication, Object object, Collection<ConfigAttribute> config,
Object returnedObject) throws AccessDeniedException {

Expand Down Expand Up @@ -111,6 +112,7 @@ public Object decide(Authentication authentication, Object object, Collection<Co
return returnedObject;
}

@Override
public void setMessageSource(MessageSource messageSource) {
this.messages = new MessageSourceAccessor(messageSource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ArrayFilterer<T> implements Filterer<T> {
*
* @see org.springframework.security.acls.afterinvocation.Filterer#getFilteredObject()
*/
@Override
@SuppressWarnings("unchecked")
public T[] getFilteredObject() {
// Recreate an array of same type and filter the removed objects.
Expand Down Expand Up @@ -80,21 +81,25 @@ public T[] getFilteredObject() {
*
* @see org.springframework.security.acls.afterinvocation.Filterer#iterator()
*/
@Override
public Iterator<T> iterator() {
return new Iterator<T>() {
private int index = 0;

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

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

@Override
public void remove() {
throw new UnsupportedOperationException();
}
Expand All @@ -105,6 +110,7 @@ public void remove() {
*
* @see org.springframework.security.acls.afterinvocation.Filterer#remove(java.lang.Object)
*/
@Override
public void remove(T object) {
this.removeList.add(object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class CollectionFilterer<T> implements Filterer<T> {
*
* @see org.springframework.security.acls.afterinvocation.Filterer#getFilteredObject()
*/
@Override
public Object getFilteredObject() {
// Now the Iterator has ended, remove Objects from Collection
Iterator<T> removeIter = this.removeList.iterator();
Expand All @@ -77,6 +78,7 @@ public Object getFilteredObject() {
*
* @see org.springframework.security.acls.afterinvocation.Filterer#iterator()
*/
@Override
public Iterator<T> iterator() {
return this.collection.iterator();
}
Expand All @@ -85,6 +87,7 @@ public Iterator<T> iterator() {
*
* @see org.springframework.security.acls.afterinvocation.Filterer#remove(java.lang.Object)
*/
@Override
public void remove(T object) {
this.removeList.add(object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface Filterer<T> extends Iterable<T> {
* Returns an iterator over the filtered collection or array.
* @return an Iterator
*/
@Override
Iterator<T> iterator();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected AbstractPermission(int mask, char code) {
this.code = code;
}

@Override
public final boolean equals(Object arg0) {
if (arg0 == null) {
return false;
Expand All @@ -64,18 +65,22 @@ public final boolean equals(Object arg0) {
return (this.mask == rhs.getMask());
}

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

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

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

@Override
public final int hashCode() {
return this.mask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public AclAuthorizationStrategyImpl(GrantedAuthority... auths) {
}
}

@Override
public void securityCheck(Acl acl, int changeType) {
if ((SecurityContextHolder.getContext() == null)
|| (SecurityContextHolder.getContext().getAuthentication() == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
public class ConsoleAuditLogger implements AuditLogger {

@Override
public void logIfNeeded(boolean granted, AccessControlEntry ace) {
Assert.notNull(ace, "AccessControlEntry required");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public CumulativePermission set(Permission permission) {
return this;
}

@Override
public String getPattern() {
return this.pattern;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ protected void registerPermission(Permission perm, String permissionName) {
this.registeredPermissionsByName.put(permissionName, perm);
}

@Override
public Permission buildFromMask(int mask) {
if (this.registeredPermissionsByInteger.containsKey(mask)) {
// The requested mask has an exact match against a statically-defined
Expand Down Expand Up @@ -140,6 +141,7 @@ public Permission buildFromMask(int mask) {
return permission;
}

@Override
public Permission buildFromName(String name) {
Permission p = this.registeredPermissionsByName.get(name);

Expand All @@ -150,6 +152,7 @@ public Permission buildFromName(String name) {
return p;
}

@Override
public List<Permission> buildFromNames(List<String> names) {
if ((names == null) || (names.size() == 0)) {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public DefaultPermissionGrantingStrategy(AuditLogger auditLogger) {
* @throws NotFoundException if an exact ACE for one of the permission bit masks and
* SID combination could not be found
*/
@Override
public boolean isGranted(Acl acl, List<Permission> permission, List<Sid> sids, boolean administrativeMode)
throws NotFoundException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public EhCacheBasedAclCache(Ehcache cache, PermissionGrantingStrategy permission
this.aclAuthorizationStrategy = aclAuthorizationStrategy;
}

@Override
public void evictFromCache(Serializable pk) {
Assert.notNull(pk, "Primary key (identifier) required");

Expand All @@ -66,6 +67,7 @@ public void evictFromCache(Serializable pk) {
}
}

@Override
public void evictFromCache(ObjectIdentity objectIdentity) {
Assert.notNull(objectIdentity, "ObjectIdentity required");

Expand All @@ -77,6 +79,7 @@ public void evictFromCache(ObjectIdentity objectIdentity) {
}
}

@Override
public MutableAcl getFromCache(ObjectIdentity objectIdentity) {
Assert.notNull(objectIdentity, "ObjectIdentity required");

Expand All @@ -95,6 +98,7 @@ public MutableAcl getFromCache(ObjectIdentity objectIdentity) {
return initializeTransientFields((MutableAcl) element.getValue());
}

@Override
public MutableAcl getFromCache(Serializable pk) {
Assert.notNull(pk, "Primary key (identifier) required");

Expand All @@ -113,6 +117,7 @@ public MutableAcl getFromCache(Serializable pk) {
return initializeTransientFields((MutableAcl) element.getValue());
}

@Override
public void putInCache(MutableAcl acl) {
Assert.notNull(acl, "Acl required");
Assert.notNull(acl.getObjectIdentity(), "ObjectIdentity required");
Expand Down Expand Up @@ -147,6 +152,7 @@ private MutableAcl initializeTransientFields(MutableAcl value) {
return value;
}

@Override
public void clearCache() {
this.cache.removeAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
*/
public class ObjectIdentityRetrievalStrategyImpl implements ObjectIdentityRetrievalStrategy, ObjectIdentityGenerator {

@Override
public ObjectIdentity getObjectIdentity(Object domainObject) {
return new ObjectIdentityImpl(domainObject);
}

@Override
public ObjectIdentity createObjectIdentity(Serializable id, String type) {
return new ObjectIdentityImpl(type, id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public SidRetrievalStrategyImpl(RoleHierarchy roleHierarchy) {
this.roleHierarchy = roleHierarchy;
}

@Override
public List<Sid> getSids(Authentication authentication) {
Collection<? extends GrantedAuthority> authorities = this.roleHierarchy
.getReachableGrantedAuthorities(authentication.getAuthorities());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public SpringCacheBasedAclCache(Cache cache, PermissionGrantingStrategy permissi
this.aclAuthorizationStrategy = aclAuthorizationStrategy;
}

@Override
public void evictFromCache(Serializable pk) {
Assert.notNull(pk, "Primary key (identifier) required");

Expand All @@ -67,6 +68,7 @@ public void evictFromCache(Serializable pk) {
}
}

@Override
public void evictFromCache(ObjectIdentity objectIdentity) {
Assert.notNull(objectIdentity, "ObjectIdentity required");

Expand All @@ -78,16 +80,19 @@ public void evictFromCache(ObjectIdentity objectIdentity) {
}
}

@Override
public MutableAcl getFromCache(ObjectIdentity objectIdentity) {
Assert.notNull(objectIdentity, "ObjectIdentity required");
return getFromCache((Object) objectIdentity);
}

@Override
public MutableAcl getFromCache(Serializable pk) {
Assert.notNull(pk, "Primary key (identifier) required");
return getFromCache((Object) pk);
}

@Override
public void putInCache(MutableAcl acl) {
Assert.notNull(acl, "Acl required");
Assert.notNull(acl.getObjectIdentity(), "ObjectIdentity required");
Expand Down Expand Up @@ -123,6 +128,7 @@ private MutableAcl initializeTransientFields(MutableAcl value) {
return value;
}

@Override
public void clearCache() {
this.cache.clear();
}
Expand Down
Loading

0 comments on commit 9e08b51

Please sign in to comment.