Fix code smells.
Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
package org.eclipse.hawkbit.security;
|
package org.eclipse.hawkbit.security;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class PreAuthTokenSourceTrustAuthenticationProvider implements Authentica
|
|||||||
throw new BadCredentialsException("The provided principal and credentials are not match");
|
throw new BadCredentialsException("The provided principal and credentials are not match");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* The credentials may either be of type HeaderAuthentication or of type
|
* The credentials may either be of type HeaderAuthentication or of type
|
||||||
* Collection<HeaderAuthentication> depending on the authentication mode in
|
* Collection<HeaderAuthentication> depending on the authentication mode in
|
||||||
@@ -129,7 +129,7 @@ public class PreAuthTokenSourceTrustAuthenticationProvider implements Authentica
|
|||||||
* <code>false</code>
|
* <code>false</code>
|
||||||
*/
|
*/
|
||||||
private boolean calculateAuthenticationSuccess(Object principal, Object credentials, Object tokenDetails) {
|
private boolean calculateAuthenticationSuccess(Object principal, Object credentials, Object tokenDetails) {
|
||||||
boolean successAuthentication = false;
|
boolean successAuthentication = false;
|
||||||
if (Collection.class.isAssignableFrom(credentials.getClass())) {
|
if (Collection.class.isAssignableFrom(credentials.getClass())) {
|
||||||
final Collection<?> multiValueCredentials = (Collection<?>) credentials;
|
final Collection<?> multiValueCredentials = (Collection<?>) credentials;
|
||||||
if (multiValueCredentials.contains(principal)) {
|
if (multiValueCredentials.contains(principal)) {
|
||||||
@@ -139,7 +139,7 @@ public class PreAuthTokenSourceTrustAuthenticationProvider implements Authentica
|
|||||||
successAuthentication = checkSourceIPAddressIfNeccessary(tokenDetails);
|
successAuthentication = checkSourceIPAddressIfNeccessary(tokenDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
return successAuthentication;
|
return successAuthentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkSourceIPAddressIfNeccessary(final Object tokenDetails) {
|
private boolean checkSourceIPAddressIfNeccessary(final Object tokenDetails) {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest {
|
|||||||
assertThat(credentials.contains(expected)).isTrue();
|
assertThat(credentials.contains(expected)).isTrue();
|
||||||
|
|
||||||
Object principal = underTest.getPreAuthenticatedPrincipal(securityToken);
|
Object principal = underTest.getPreAuthenticatedPrincipal(securityToken);
|
||||||
assertEquals(expected, principal);
|
assertEquals("hash1 expected in principal!", expected, principal);
|
||||||
|
|
||||||
securityToken = prepareSecurityToken();
|
securityToken = prepareSecurityToken();
|
||||||
securityToken.getHeaders().put(X_SSL_ISSUER_HASH_1, "hash2");
|
securityToken.getHeaders().put(X_SSL_ISSUER_HASH_1, "hash2");
|
||||||
@@ -135,7 +135,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest {
|
|||||||
assertThat(credentials.contains(expected)).isTrue();
|
assertThat(credentials.contains(expected)).isTrue();
|
||||||
|
|
||||||
principal = underTest.getPreAuthenticatedPrincipal(securityToken);
|
principal = underTest.getPreAuthenticatedPrincipal(securityToken);
|
||||||
assertEquals(expected, principal);
|
assertEquals("hash2 expected in principal!", expected, principal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user