Skip to content

Commit d1bfb46

Browse files
committed
Address checkstyle warnings
1 parent c1fc9ae commit d1bfb46

File tree

5 files changed

+116
-68
lines changed

5 files changed

+116
-68
lines changed

config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/mfa/MultiFactorAuthenticationProviderConfigurer.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,35 @@
2626
* @param <B> the type of the {@link SecurityBuilder}
2727
*/
2828
public class MultiFactorAuthenticationProviderConfigurer<B extends ProviderManagerBuilder<B>>
29-
extends SecurityConfigurerAdapter<AuthenticationManager, B> {
30-
31-
//~ Instance fields
32-
// ================================================================================================
33-
private AuthenticationProvider authenticationProvider;
34-
private MFATokenEvaluator mfaTokenEvaluator = new MFATokenEvaluatorImpl();
35-
36-
/**
37-
* Constructor
38-
* @param authenticationProvider {@link AuthenticationProvider} to be delegated
39-
*/
40-
public MultiFactorAuthenticationProviderConfigurer(AuthenticationProvider authenticationProvider) {
41-
this.authenticationProvider = authenticationProvider;
42-
}
29+
extends SecurityConfigurerAdapter<AuthenticationManager, B> {
30+
31+
//~ Instance fields
32+
// ================================================================================================
33+
private AuthenticationProvider authenticationProvider;
34+
private MFATokenEvaluator mfaTokenEvaluator = new MFATokenEvaluatorImpl();
35+
36+
/**
37+
* Constructor
38+
* @param authenticationProvider {@link AuthenticationProvider} to be delegated
39+
*/
40+
public MultiFactorAuthenticationProviderConfigurer(AuthenticationProvider authenticationProvider) {
41+
this.authenticationProvider = authenticationProvider;
42+
}
4343

4444

4545
public static MultiFactorAuthenticationProviderConfigurer multiFactorAuthenticationProvider(AuthenticationProvider authenticationProvider){
4646
return new MultiFactorAuthenticationProviderConfigurer(authenticationProvider);
4747
}
4848

49-
@Override
50-
public void configure(B builder) {
51-
MultiFactorAuthenticationProvider multiFactorAuthenticationProvider = new MultiFactorAuthenticationProvider(authenticationProvider, mfaTokenEvaluator);
52-
multiFactorAuthenticationProvider = postProcess(multiFactorAuthenticationProvider);
53-
builder.authenticationProvider(multiFactorAuthenticationProvider);
54-
}
55-
56-
public MultiFactorAuthenticationProviderConfigurer<B> mfaTokenEvaluator(MFATokenEvaluator mfaTokenEvaluator) {
57-
this.mfaTokenEvaluator = mfaTokenEvaluator;
58-
return this;
59-
}
49+
@Override
50+
public void configure(B builder) {
51+
MultiFactorAuthenticationProvider multiFactorAuthenticationProvider = new MultiFactorAuthenticationProvider(authenticationProvider, mfaTokenEvaluator);
52+
multiFactorAuthenticationProvider = postProcess(multiFactorAuthenticationProvider);
53+
builder.authenticationProvider(multiFactorAuthenticationProvider);
54+
}
55+
56+
public MultiFactorAuthenticationProviderConfigurer<B> mfaTokenEvaluator(MFATokenEvaluator mfaTokenEvaluator) {
57+
this.mfaTokenEvaluator = mfaTokenEvaluator;
58+
return this;
59+
}
6060
}

config/src/test/java/org/springframework/security/config/annotation/authentication/configurers/mfa/MultiFactorAuthenticationProviderConfigurerTests.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.security.config.annotation.authentication.configurers.mfa;
218

319
import org.junit.Test;
@@ -25,7 +41,7 @@ public void test(){
2541
configurer.configure(providerManagerBuilder);
2642
ArgumentCaptor<AuthenticationProvider> argumentCaptor = ArgumentCaptor.forClass(AuthenticationProvider.class);
2743
verify(providerManagerBuilder).authenticationProvider(argumentCaptor.capture());
28-
MultiFactorAuthenticationProvider authenticationProvider = (MultiFactorAuthenticationProvider)argumentCaptor.getValue();
44+
MultiFactorAuthenticationProvider authenticationProvider = (MultiFactorAuthenticationProvider) argumentCaptor.getValue();
2945

3046
assertThat(authenticationProvider.getAuthenticationProvider()).isEqualTo(delegatedAuthenticationProvider);
3147
assertThat(authenticationProvider.getMFATokenEvaluator()).isEqualTo(mfaTokenEvaluator);

core/src/main/java/org/springframework/security/authentication/MultiFactorAuthenticationProvider.java

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,56 +30,56 @@
3030
public class MultiFactorAuthenticationProvider implements AuthenticationProvider {
3131

3232

33-
// ~ Instance fields
34-
// ================================================================================================
35-
protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
33+
// ~ Instance fields
34+
// ================================================================================================
35+
protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
3636

37-
/**
38-
* {@link AuthenticationProvider} to be delegated
39-
*/
40-
private AuthenticationProvider authenticationProvider;
41-
private MFATokenEvaluator mfaTokenEvaluator;
37+
/**
38+
* {@link AuthenticationProvider} to be delegated
39+
*/
40+
private AuthenticationProvider authenticationProvider;
41+
private MFATokenEvaluator mfaTokenEvaluator;
4242

43-
/**
44-
* Constructor
45-
* @param authenticationProvider {@link AuthenticationProvider} to be delegated
46-
*/
47-
public MultiFactorAuthenticationProvider(AuthenticationProvider authenticationProvider, MFATokenEvaluator mfaTokenEvaluator) {
48-
Assert.notNull(authenticationProvider, "authenticationProvider must be set");
43+
/**
44+
* Constructor
45+
* @param authenticationProvider {@link AuthenticationProvider} to be delegated
46+
*/
47+
public MultiFactorAuthenticationProvider(AuthenticationProvider authenticationProvider, MFATokenEvaluator mfaTokenEvaluator) {
48+
Assert.notNull(authenticationProvider, "authenticationProvider must be set");
4949
Assert.notNull(mfaTokenEvaluator, "mfaTokenEvaluator must be set");
50-
this.authenticationProvider = authenticationProvider;
51-
this.mfaTokenEvaluator = mfaTokenEvaluator;
52-
}
50+
this.authenticationProvider = authenticationProvider;
51+
this.mfaTokenEvaluator = mfaTokenEvaluator;
52+
}
5353

54-
/**
55-
* {@inheritDoc}
56-
*/
57-
@Override
58-
public Authentication authenticate(Authentication authentication) {
59-
if (!supports(authentication.getClass())) {
60-
throw new IllegalArgumentException("Not supported AuthenticationToken " + authentication.getClass() + " was attempted");
61-
}
54+
/**
55+
* {@inheritDoc}
56+
*/
57+
@Override
58+
public Authentication authenticate(Authentication authentication) {
59+
if (!supports(authentication.getClass())) {
60+
throw new IllegalArgumentException("Not supported AuthenticationToken " + authentication.getClass() + " was attempted");
61+
}
6262

63-
Authentication result = authenticationProvider.authenticate(authentication);
63+
Authentication result = authenticationProvider.authenticate(authentication);
6464

65-
if(mfaTokenEvaluator.isSingleFactorAuthenticationAllowed(result)){
66-
return result;
67-
}
65+
if(mfaTokenEvaluator.isSingleFactorAuthenticationAllowed(result)){
66+
return result;
67+
}
6868

69-
return new MultiFactorAuthenticationToken(
70-
result.getPrincipal(),
71-
result.getCredentials(),
72-
Collections.emptyList() // result.getAuthorities() is not used as not to inherit authorities from result
73-
);
74-
}
69+
return new MultiFactorAuthenticationToken(
70+
result.getPrincipal(),
71+
result.getCredentials(),
72+
Collections.emptyList() // result.getAuthorities() is not used as not to inherit authorities from result
73+
);
74+
}
7575

76-
/**
77-
* {@inheritDoc}
78-
*/
79-
@Override
80-
public boolean supports(Class<?> authentication) {
81-
return authenticationProvider.supports(authentication);
82-
}
76+
/**
77+
* {@inheritDoc}
78+
*/
79+
@Override
80+
public boolean supports(Class<?> authentication) {
81+
return authenticationProvider.supports(authentication);
82+
}
8383

8484
/**
8585
* {@link AuthenticationProvider} to be delegated

core/src/main/java/org/springframework/security/core/userdetails/MFAUserDetails.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.security.core.userdetails;
218

319
public interface MFAUserDetails extends UserDetails {

core/src/test/java/org/springframework/security/authentication/MultiFactorAuthenticationProviderTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.security.authentication;
218

319

0 commit comments

Comments
 (0)