From 066cdb7decd4163d28cdd9b549374a435fc47b40 Mon Sep 17 00:00:00 2001 From: Andrei Arlou Date: Sun, 10 Nov 2019 12:16:28 +0300 Subject: [PATCH] KEYCLOAK-11993 Remove unused import and use diamond operator for collection in module adapters/oidc/adapter-core --- .../src/main/java/org/keycloak/adapters/AdapterUtils.java | 2 +- .../main/java/org/keycloak/adapters/CookieTokenStore.java | 2 +- .../main/java/org/keycloak/adapters/HttpAdapterUtils.java | 1 - .../org/keycloak/adapters/NodesRegistrationManagement.java | 3 --- .../java/org/keycloak/adapters/PreAuthActionsHandler.java | 1 - .../java/org/keycloak/adapters/RequestAuthenticator.java | 5 ++--- .../src/main/java/org/keycloak/adapters/ServerRequest.java | 2 +- .../authentication/JWTClientCredentialsProvider.java | 5 ----- .../authentication/JWTClientSecretCredentialsProvider.java | 1 - .../keycloak/adapters/jaas/AbstractKeycloakLoginModule.java | 2 +- .../adapters/jaas/DirectAccessGrantsLoginModule.java | 2 +- .../adapters/rotation/HardcodedPublicKeyLocator.java | 1 - .../org/keycloak/adapters/rotation/PublicKeyLocator.java | 1 - 13 files changed, 7 insertions(+), 21 deletions(-) diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/AdapterUtils.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/AdapterUtils.java index a6dfa0637e..8779eea363 100755 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/AdapterUtils.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/AdapterUtils.java @@ -87,6 +87,6 @@ public class AdapterUtils { } public static KeycloakPrincipal createPrincipal(KeycloakDeployment deployment, RefreshableKeycloakSecurityContext securityContext) { - return new KeycloakPrincipal(getPrincipalName(deployment, securityContext.getToken()), securityContext); + return new KeycloakPrincipal<>(getPrincipalName(deployment, securityContext.getToken()), securityContext); } } diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/CookieTokenStore.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/CookieTokenStore.java index a3a44571f5..de837c4a8a 100755 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/CookieTokenStore.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/CookieTokenStore.java @@ -91,7 +91,7 @@ public class CookieTokenStore { log.debug("Token Verification succeeded!"); RefreshableKeycloakSecurityContext secContext = new RefreshableKeycloakSecurityContext(deployment, tokenStore, accessTokenString, accessToken, idTokenString, idToken, refreshTokenString); - return new KeycloakPrincipal(AdapterUtils.getPrincipalName(deployment, accessToken), secContext); + return new KeycloakPrincipal<>(AdapterUtils.getPrincipalName(deployment, accessToken), secContext); } catch (VerificationException ve) { log.warn("Failed verify token", ve); return null; diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/HttpAdapterUtils.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/HttpAdapterUtils.java index b7877964a0..6a3176a3b9 100644 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/HttpAdapterUtils.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/HttpAdapterUtils.java @@ -22,7 +22,6 @@ import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpRequestBase; import org.keycloak.util.JsonSerialization; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/NodesRegistrationManagement.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/NodesRegistrationManagement.java index ef5cfb8db0..f32fa0dce1 100755 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/NodesRegistrationManagement.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/NodesRegistrationManagement.java @@ -23,13 +23,10 @@ import org.keycloak.common.util.Time; import java.io.IOException; import java.util.Collection; -import java.util.LinkedList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; /** * @author Marek Posolda diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/PreAuthActionsHandler.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/PreAuthActionsHandler.java index 5e1be4cd1d..f3c3c6abec 100755 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/PreAuthActionsHandler.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/PreAuthActionsHandler.java @@ -32,7 +32,6 @@ import org.keycloak.jose.jwk.JSONWebKeySet; import org.keycloak.jose.jwk.JWK; import org.keycloak.jose.jwk.JWKBuilder; import org.keycloak.representations.JsonWebToken; -import org.keycloak.representations.VersionRepresentation; import org.keycloak.constants.AdapterConstants; import org.keycloak.jose.jws.JWSInput; import org.keycloak.representations.adapters.action.AdminAction; diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/RequestAuthenticator.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/RequestAuthenticator.java index 4f3029015b..23938a5d97 100755 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/RequestAuthenticator.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/RequestAuthenticator.java @@ -24,7 +24,6 @@ import org.keycloak.KeycloakPrincipal; import org.keycloak.adapters.spi.AuthChallenge; import org.keycloak.adapters.spi.AuthOutcome; import org.keycloak.adapters.spi.HttpFacade; -import org.keycloak.common.enums.SslRequired; /** * @author Bill Burke @@ -214,7 +213,7 @@ public abstract class RequestAuthenticator { protected void completeAuthentication(OAuthRequestAuthenticator oauth) { RefreshableKeycloakSecurityContext session = new RefreshableKeycloakSecurityContext(deployment, tokenStore, oauth.getTokenString(), oauth.getToken(), oauth.getIdTokenString(), oauth.getIdToken(), oauth.getRefreshToken()); - final KeycloakPrincipal principal = new KeycloakPrincipal(AdapterUtils.getPrincipalName(deployment, oauth.getToken()), session); + final KeycloakPrincipal principal = new KeycloakPrincipal<>(AdapterUtils.getPrincipalName(deployment, oauth.getToken()), session); completeOAuthAuthentication(principal); log.debugv("User ''{0}'' invoking ''{1}'' on client ''{2}''", principal.getName(), facade.getRequest().getURI(), deployment.getResourceName()); } @@ -233,7 +232,7 @@ public abstract class RequestAuthenticator { protected void completeAuthentication(BearerTokenRequestAuthenticator bearer, String method) { RefreshableKeycloakSecurityContext session = new RefreshableKeycloakSecurityContext(deployment, null, bearer.getTokenString(), bearer.getToken(), null, null, null); - final KeycloakPrincipal principal = new KeycloakPrincipal(AdapterUtils.getPrincipalName(deployment, bearer.getToken()), session); + final KeycloakPrincipal principal = new KeycloakPrincipal<>(AdapterUtils.getPrincipalName(deployment, bearer.getToken()), session); completeBearerAuthentication(principal, method); log.debugv("User ''{0}'' invoking ''{1}'' on client ''{2}''", principal.getName(), facade.getRequest().getURI(), deployment.getResourceName()); } diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/ServerRequest.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/ServerRequest.java index f5bfad0db2..12c2462694 100755 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/ServerRequest.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/ServerRequest.java @@ -253,7 +253,7 @@ public class ServerRequest { throw new IOException("You need to configure URI for register/unregister node for application " + deployment.getResourceName()); } - List formparams = new ArrayList(); + List formparams = new ArrayList<>(); formparams.add(new BasicNameValuePair(AdapterConstants.CLIENT_CLUSTER_HOST, host)); HttpPost post = new HttpPost(endpointUrl); diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authentication/JWTClientCredentialsProvider.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authentication/JWTClientCredentialsProvider.java index 8d07c007c2..4e109ce285 100644 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authentication/JWTClientCredentialsProvider.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authentication/JWTClientCredentialsProvider.java @@ -30,11 +30,6 @@ import org.keycloak.jose.jws.JWSBuilder; import org.keycloak.representations.JsonWebToken; import org.keycloak.common.util.KeystoreUtil; import org.keycloak.common.util.Time; -import org.keycloak.jose.jws.JWSBuilder; -import org.keycloak.representations.JsonWebToken; - -import java.security.PrivateKey; -import java.util.Map; /** * Client authentication based on JWT signed by client private key . diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authentication/JWTClientSecretCredentialsProvider.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authentication/JWTClientSecretCredentialsProvider.java index 24ef3a9d17..5a89234a21 100644 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authentication/JWTClientSecretCredentialsProvider.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authentication/JWTClientSecretCredentialsProvider.java @@ -12,7 +12,6 @@ import org.keycloak.adapters.AdapterUtils; import org.keycloak.adapters.KeycloakDeployment; import org.keycloak.common.util.Time; import org.keycloak.jose.jws.JWSBuilder; -import org.keycloak.jose.jws.JWSInput; import org.keycloak.representations.JsonWebToken; /** diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/jaas/AbstractKeycloakLoginModule.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/jaas/AbstractKeycloakLoginModule.java index 1c27d6e61c..2a8dc15163 100755 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/jaas/AbstractKeycloakLoginModule.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/jaas/AbstractKeycloakLoginModule.java @@ -65,7 +65,7 @@ public abstract class AbstractKeycloakLoginModule implements LoginModule { protected String rolePrincipalClass; // This is to avoid parsing keycloak.json file in each request. Key is file location, Value is parsed keycloak deployment - private static ConcurrentMap deployments = new ConcurrentHashMap(); + private static ConcurrentMap deployments = new ConcurrentHashMap<>(); @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/jaas/DirectAccessGrantsLoginModule.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/jaas/DirectAccessGrantsLoginModule.java index b39ff85920..9e88855755 100755 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/jaas/DirectAccessGrantsLoginModule.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/jaas/DirectAccessGrantsLoginModule.java @@ -155,7 +155,7 @@ public class DirectAccessGrantsLoginModule extends AbstractKeycloakLoginModule { URI logoutUri = deployment.getLogoutUrl().clone().build(); HttpPost post = new HttpPost(logoutUri); - List formparams = new ArrayList(); + List formparams = new ArrayList<>(); ClientCredentialsProviderUtils.setClientCredentials(deployment, post, formparams); formparams.add(new BasicNameValuePair(OAuth2Constants.REFRESH_TOKEN, refreshToken)); diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/rotation/HardcodedPublicKeyLocator.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/rotation/HardcodedPublicKeyLocator.java index 9e285a2c8c..feb6e48449 100644 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/rotation/HardcodedPublicKeyLocator.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/rotation/HardcodedPublicKeyLocator.java @@ -18,7 +18,6 @@ package org.keycloak.adapters.rotation; import org.keycloak.adapters.KeycloakDeployment; -import org.keycloak.jose.jws.JWSInput; import java.security.PublicKey; diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/rotation/PublicKeyLocator.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/rotation/PublicKeyLocator.java index 096f75f042..ca0e7c6a85 100644 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/rotation/PublicKeyLocator.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/rotation/PublicKeyLocator.java @@ -18,7 +18,6 @@ package org.keycloak.adapters.rotation; import org.keycloak.adapters.KeycloakDeployment; -import org.keycloak.jose.jws.JWSInput; import java.security.PublicKey;