Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Code Style Issues #7238

Merged
merged 11 commits into from
Aug 12, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
private final LinkedHashMap<Class<? extends SecurityConfigurer<O, B>>, List<SecurityConfigurer<O, B>>> configurers = new LinkedHashMap<>();
private final List<SecurityConfigurer<O, B>> configurersAddedInInitializing = new ArrayList<>();

private final Map<Class<? extends Object>, Object> sharedObjects = new HashMap<>();
private final Map<Class<?>, Object> sharedObjects = new HashMap<>();

private final boolean allowConfigurersOfSameType;

Expand Down Expand Up @@ -174,7 +174,7 @@ public <C> C getSharedObject(Class<C> sharedType) {
* Gets the shared objects
* @return the shared Objects
*/
public Map<Class<? extends Object>, Object> getSharedObjects() {
public Map<Class<?>, Object> getSharedObjects() {
return Collections.unmodifiableMap(this.sharedObjects);
}

Expand Down Expand Up @@ -409,7 +409,7 @@ private boolean isUnbuilt() {
* @author Rob Winch
* @since 3.2
*/
private static enum BuildState {
private enum BuildState {
/**
* This is the state before the {@link Builder#build()} is invoked
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void setBuilder(B builder) {
*/
private static final class CompositeObjectPostProcessor implements
ObjectPostProcessor<Object> {
private List<ObjectPostProcessor<? extends Object>> postProcessors = new ArrayList<>();
private List<ObjectPostProcessor<?>> postProcessors = new ArrayList<>();

@SuppressWarnings({ "rawtypes", "unchecked" })
public Object postProcess(Object object) {
Expand All @@ -132,7 +132,7 @@ public Object postProcess(Object object) {
* @return true if the {@link ObjectPostProcessor} was added, else false
*/
private boolean addObjectPostProcessor(
ObjectPostProcessor<? extends Object> objectPostProcessor) {
ObjectPostProcessor<?> objectPostProcessor) {
boolean result = this.postProcessors.add(objectPostProcessor);
Collections.sort(postProcessors, AnnotationAwareOrderComparator.INSTANCE);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ protected RunAsManager runAsManager() {
* @return the {@link AccessDecisionManager} to use
*/
protected AccessDecisionManager accessDecisionManager() {
List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<>();
List<AccessDecisionVoter<?>> decisionVoters = new ArrayList<>();
ExpressionBasedPreInvocationAdvice expressionAdvice = new ExpressionBasedPreInvocationAdvice();
expressionAdvice.setExpressionHandler(getExpressionHandler());
if (prePostEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ public final class HttpSecurity extends
@SuppressWarnings("unchecked")
public HttpSecurity(ObjectPostProcessor<Object> objectPostProcessor,
AuthenticationManagerBuilder authenticationBuilder,
Map<Class<? extends Object>, Object> sharedObjects) {
Map<Class<?>, Object> sharedObjects) {
super(objectPostProcessor);
Assert.notNull(authenticationBuilder, "authenticationBuilder cannot be null");
setSharedObject(AuthenticationManagerBuilder.class, authenticationBuilder);
for (Map.Entry<Class<? extends Object>, Object> entry : sharedObjects
for (Map.Entry<Class<?>, Object> entry : sharedObjects
.entrySet()) {
setSharedObject((Class<Object>) entry.getKey(), entry.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ protected final HttpSecurity getHttp() throws Exception {
AuthenticationManager authenticationManager = authenticationManager();
authenticationBuilder.parentAuthenticationManager(authenticationManager);
authenticationBuilder.authenticationEventPublisher(eventPublisher);
Map<Class<? extends Object>, Object> sharedObjects = createSharedObjects();
Map<Class<?>, Object> sharedObjects = createSharedObjects();

http = new HttpSecurity(objectPostProcessor, authenticationBuilder,
sharedObjects);
Expand Down Expand Up @@ -412,8 +412,8 @@ public void setAuthenticationConfiguration(
*
* @return the shared Objects
*/
private Map<Class<? extends Object>, Object> createSharedObjects() {
Map<Class<? extends Object>, Object> sharedObjects = new HashMap<>();
private Map<Class<?>, Object> createSharedObjects() {
Map<Class<?>, Object> sharedObjects = new HashMap<>();
sharedObjects.putAll(localConfigureAuthenticationBldr.getSharedObjects());
sharedObjects.put(UserDetailsService.class, userDetailsService());
sharedObjects.put(ApplicationContext.class, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void configure(H http) throws Exception {
* @return the {@link AccessDecisionVoter} instances used to create the default
* {@link AccessDecisionManager}
*/
abstract List<AccessDecisionVoter<? extends Object>> getDecisionVoters(H http);
abstract List<AccessDecisionVoter<?>> getDecisionVoters(H http);

abstract class AbstractInterceptUrlRegistry<R extends AbstractInterceptUrlRegistry<R, T>, T>
extends AbstractConfigAttributeRequestMatcherRegistry<T> {
Expand Down Expand Up @@ -195,4 +195,4 @@ private FilterSecurityInterceptor createFilterSecurityInterceptor(H http,
securityInterceptor.afterPropertiesSet();
return securityInterceptor;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ private void interceptUrl(Iterable<? extends RequestMatcher> requestMatchers,

@Override
@SuppressWarnings("rawtypes")
final List<AccessDecisionVoter<? extends Object>> getDecisionVoters(H http) {
List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<>();
final List<AccessDecisionVoter<?>> getDecisionVoters(H http) {
List<AccessDecisionVoter<?>> decisionVoters = new ArrayList<>();
WebExpressionVoter expressionVoter = new WebExpressionVoter();
expressionVoter.setExpressionHandler(getExpressionHandler(http));
decisionVoters.add(expressionVoter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ public H and() {
*/
@Override
@SuppressWarnings("rawtypes")
final List<AccessDecisionVoter<? extends Object>> getDecisionVoters(H http) {
List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<>();
final List<AccessDecisionVoter<?>> getDecisionVoters(H http) {
List<AccessDecisionVoter<?>> decisionVoters = new ArrayList<>();
decisionVoters.add(new RoleVoter());
decisionVoters.add(new AuthenticatedVoter());
return decisionVoters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public ChannelSecurityInterceptor inboundChannelSecurity(MessageSecurityMetadata
MessageExpressionVoter<Object> voter = new MessageExpressionVoter<>();
voter.setExpressionHandler(getMessageExpressionHandler());

List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<>();
List<AccessDecisionVoter<?>> voters = new ArrayList<>();
voters.add(voter);

AffirmativeBased manager = new AffirmativeBased(voters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ enum SecurityFilters {
private static final int INTERVAL = 100;
private final int order;

private SecurityFilters() {
SecurityFilters() {
order = ordinal() * INTERVAL;
}

private SecurityFilters(int order) {
SecurityFilters(int order) {
this.order = order;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public enum SecurityWebFiltersOrder {

private final int order;

private SecurityWebFiltersOrder() {
SecurityWebFiltersOrder() {
this.order = ordinal() * INTERVAL;
}

private SecurityWebFiltersOrder(int order) {
SecurityWebFiltersOrder(int order) {
this.order = order;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@
*
* @return String[] The secure method attributes
*/
public String[] value();
String[] value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface RoleHierarchy {
* @param authorities - List of the directly assigned authorities.
* @return List of all reachable authorities given the assigned authorities.
*/
public Collection<? extends GrantedAuthority> getReachableGrantedAuthorities(
Collection<? extends GrantedAuthority> getReachableGrantedAuthorities(
Collection<? extends GrantedAuthority> authorities);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
* @author Ben Alex
*/
public interface MethodSecurityMetadataSource extends SecurityMetadataSource {
public Collection<ConfigAttribute> getAttributes(Method method, Class<?> targetClass);
Collection<ConfigAttribute> getAttributes(Method method, Class<?> targetClass);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
* @return the Spring-EL expression to be evaluated after invoking the protected
* method
*/
public String value();
String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
* @return the Spring-EL expression to be evaluated after invoking the protected
* method
*/
public String value();
String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
* @return the Spring-EL expression to be evaluated before invoking the protected
* method
*/
public String value();
String value();

/**
* @return the name of the parameter which should be filtered (must be a non-null
* collection instance) If the method contains a single collection argument, then this
* attribute can be omitted.
*/
public String filterTarget() default "";
String filterTarget() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public abstract class AbstractAccessDecisionManager implements AccessDecisionMan
// ================================================================================================
protected final Log logger = LogFactory.getLog(getClass());

private List<AccessDecisionVoter<? extends Object>> decisionVoters;
private List<AccessDecisionVoter<?>> decisionVoters;

protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();

private boolean allowIfAllAbstainDecisions = false;

protected AbstractAccessDecisionManager(
List<AccessDecisionVoter<? extends Object>> decisionVoters) {
List<AccessDecisionVoter<?>> decisionVoters) {
Assert.notEmpty(decisionVoters, "A list of AccessDecisionVoters is required");
this.decisionVoters = decisionVoters;
}
Expand All @@ -72,7 +72,7 @@ protected final void checkAllowIfAllAbstainDecisions() {
}
}

public List<AccessDecisionVoter<? extends Object>> getDecisionVoters() {
public List<AccessDecisionVoter<?>> getDecisionVoters() {
return this.decisionVoters;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public class AffirmativeBased extends AbstractAccessDecisionManager {

public AffirmativeBased(List<AccessDecisionVoter<? extends Object>> decisionVoters) {
public AffirmativeBased(List<AccessDecisionVoter<?>> decisionVoters) {
super(decisionVoters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ConsensusBased extends AbstractAccessDecisionManager {

private boolean allowIfEqualGrantedDeniedDecisions = true;

public ConsensusBased(List<AccessDecisionVoter<? extends Object>> decisionVoters) {
public ConsensusBased(List<AccessDecisionVoter<?>> decisionVoters) {
super(decisionVoters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public class UnanimousBased extends AbstractAccessDecisionManager {

public UnanimousBased(List<AccessDecisionVoter<? extends Object>> decisionVoters) {
public UnanimousBased(List<AccessDecisionVoter<?>> decisionVoters) {
super(decisionVoters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ class ComparableVersion implements Comparable<ComparableVersion> {
private ListItem items;

private interface Item {
final int INTEGER_ITEM = 0;
final int STRING_ITEM = 1;
final int LIST_ITEM = 2;
int INTEGER_ITEM = 0;
int STRING_ITEM = 1;
int LIST_ITEM = 2;

int compareTo(Item item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public interface Attributes2GrantedAuthoritiesMapper {
* @param attributes the attributes to be mapped
* @return the collection of authorities created from the attributes
*/
public Collection<? extends GrantedAuthority> getGrantedAuthorities(
Collection<? extends GrantedAuthority> getGrantedAuthorities(
Collection<String> attributes);
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Token allocateToken(String extendedInformation) {
long creationTime = new Date().getTime();
String serverSecret = computeServerSecretApplicableAt(creationTime);
String pseudoRandomNumber = generatePseudoRandomNumber();
String content = Long.toString(creationTime) + ":" + pseudoRandomNumber + ":"
String content = creationTime + ":" + pseudoRandomNumber + ":"
+ extendedInformation;

// Compute key
Expand Down Expand Up @@ -126,7 +126,7 @@ public Token verifyToken(String key) {
String sha1Hex = tokens[tokens.length - 1];

// Verification
String content = Long.toString(creationTime) + ":" + pseudoRandomNumber + ":"
String content = creationTime + ":" + pseudoRandomNumber + ":"
+ extendedInfo.toString();
String expectedSha512Hex = Sha512DigestUtils.shaHex(content + ":" + serverSecret);
Assert.isTrue(expectedSha512Hex.equals(sha1Hex), "Key verification failure");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package org.springframework.security.crypto.bcrypt;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Arrays;
Expand Down Expand Up @@ -733,11 +732,7 @@ private byte[] crypt_raw(byte password[], byte salt[], int log_rounds,
public static String hashpw(String password, String salt) {
byte passwordb[];

try {
passwordb = password.getBytes("UTF-8");
} catch (UnsupportedEncodingException uee) {
throw new AssertionError("UTF-8 is not supported");
}
passwordb = password.getBytes(StandardCharsets.UTF_8);

return hashpw(passwordb, salt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
* UTF-8 Charset encoder/decoder.
Expand All @@ -28,7 +29,7 @@
* @author Luke Taylor
*/
public final class Utf8 {
private static final Charset CHARSET = Charset.forName("UTF-8");
private static final Charset CHARSET = StandardCharsets.UTF_8;

/**
* Get the bytes of the String in UTF-8 encoded form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum CipherAlgorithm {
private BytesKeyGenerator ivGenerator;
private String name;

private CipherAlgorithm(String name, BytesKeyGenerator ivGenerator) {
CipherAlgorithm(String name, BytesKeyGenerator ivGenerator) {
this.name = name;
this.ivGenerator = ivGenerator;
}
Expand Down
1 change: 1 addition & 0 deletions etc/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<!-- Coding -->
<module name="EmptyStatementCheck" />
<module name="RedundantModifier" />

<!-- Imports -->
<module name="UnusedImportsCheck">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void provideDataOnScalingWithNumberOfAuthoritiesUserHas() throws Exceptio
HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
SecurityContextHolder.getContext());
SecurityContextHolder.clearContext();
sw.start(Integer.toString(nAuthorities) + " authorities");
sw.start(nAuthorities + " authorities");
runWithStack(minimalStack);
System.out.println(sw.shortSummary());
sw.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

public interface UserRepository {

public void doSomething();
void doSomething();

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
public interface TestService {

@PreAuthorize("someMethod.py")
public void someMethod();
void someMethod();

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public enum PasswordPolicyErrorStatus {
private final String errorCode;
private final String defaultMessage;

private PasswordPolicyErrorStatus(String errorCode, String defaultMessage) {
PasswordPolicyErrorStatus(String errorCode, String defaultMessage) {
this.errorCode = errorCode;
this.defaultMessage = defaultMessage;
}
Expand Down
Loading