diff --git a/server-spi/src/main/java/org/keycloak/component/ComponentFactory.java b/server-spi/src/main/java/org/keycloak/component/ComponentFactory.java index b4c6f44610..32f70a87b4 100644 --- a/server-spi/src/main/java/org/keycloak/component/ComponentFactory.java +++ b/server-spi/src/main/java/org/keycloak/component/ComponentFactory.java @@ -98,7 +98,7 @@ public interface ComponentFactory ex */ default List getCommonProviderConfigProperties() { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } /** @@ -109,7 +109,7 @@ public interface ComponentFactory ex */ default Map getTypeMetadata() { - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } diff --git a/server-spi/src/main/java/org/keycloak/models/AuthenticatorConfigModel.java b/server-spi/src/main/java/org/keycloak/models/AuthenticatorConfigModel.java index 8bcae9f65a..308613d990 100755 --- a/server-spi/src/main/java/org/keycloak/models/AuthenticatorConfigModel.java +++ b/server-spi/src/main/java/org/keycloak/models/AuthenticatorConfigModel.java @@ -29,7 +29,7 @@ public class AuthenticatorConfigModel implements Serializable { private String id; private String alias; - private Map config = new HashMap(); + private Map config = new HashMap<>(); public String getId() { diff --git a/server-spi/src/main/java/org/keycloak/models/IdentityProviderModel.java b/server-spi/src/main/java/org/keycloak/models/IdentityProviderModel.java index 9aec8ffe5e..63b8a475ba 100755 --- a/server-spi/src/main/java/org/keycloak/models/IdentityProviderModel.java +++ b/server-spi/src/main/java/org/keycloak/models/IdentityProviderModel.java @@ -66,7 +66,7 @@ public class IdentityProviderModel implements Serializable { *

A map containing the configuration and properties for a specific identity provider instance and implementation. The items * in the map are understood by the identity provider implementation.

*/ - private Map config = new HashMap(); + private Map config = new HashMap<>(); public IdentityProviderModel() { } @@ -77,7 +77,7 @@ public class IdentityProviderModel implements Serializable { this.providerId = model.getProviderId(); this.alias = model.getAlias(); this.displayName = model.getDisplayName(); - this.config = new HashMap(model.getConfig()); + this.config = new HashMap<>(model.getConfig()); this.enabled = model.isEnabled(); this.trustEmail = model.isTrustEmail(); this.storeToken = model.isStoreToken(); diff --git a/server-spi/src/main/java/org/keycloak/models/RequiredCredentialModel.java b/server-spi/src/main/java/org/keycloak/models/RequiredCredentialModel.java index d942412a92..85ad4552fb 100755 --- a/server-spi/src/main/java/org/keycloak/models/RequiredCredentialModel.java +++ b/server-spi/src/main/java/org/keycloak/models/RequiredCredentialModel.java @@ -79,7 +79,7 @@ public class RequiredCredentialModel implements Serializable { public static final RequiredCredentialModel KERBEROS; static { - Map map = new HashMap(); + Map map = new HashMap<>(); PASSWORD = new RequiredCredentialModel(); PASSWORD.setType(PasswordCredentialModel.TYPE); PASSWORD.setInput(true); diff --git a/server-spi/src/main/java/org/keycloak/models/utils/HmacOTP.java b/server-spi/src/main/java/org/keycloak/models/utils/HmacOTP.java index e3a1bd2347..f8489d4cee 100755 --- a/server-spi/src/main/java/org/keycloak/models/utils/HmacOTP.java +++ b/server-spi/src/main/java/org/keycloak/models/utils/HmacOTP.java @@ -174,8 +174,7 @@ public class HmacOTP { // Copy all the REAL bytes, not the "first" byte[] ret = new byte[bArray.length - 1]; - for (int i = 0; i < ret.length; i++) - ret[i] = bArray[i + 1]; + System.arraycopy(bArray, 1, ret, 0, ret.length); return ret; } } diff --git a/server-spi/src/main/java/org/keycloak/storage/UserStorageProviderFactory.java b/server-spi/src/main/java/org/keycloak/storage/UserStorageProviderFactory.java index 4d31aeebac..1815c5a4dc 100755 --- a/server-spi/src/main/java/org/keycloak/storage/UserStorageProviderFactory.java +++ b/server-spi/src/main/java/org/keycloak/storage/UserStorageProviderFactory.java @@ -78,7 +78,7 @@ public interface UserStorageProviderFactory exten @Override default List getConfigProperties() { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } @Override diff --git a/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapter.java b/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapter.java index b0d7ca3772..ae8eabe680 100644 --- a/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapter.java +++ b/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapter.java @@ -62,7 +62,7 @@ public abstract class AbstractUserAdapter implements UserModel { @Override public Set getRequiredActions() { - return Collections.EMPTY_SET; + return Collections.emptySet(); } @Override @@ -94,7 +94,7 @@ public abstract class AbstractUserAdapter implements UserModel { * @return */ protected Set getGroupsInternal() { - return Collections.EMPTY_SET; + return Collections.emptySet(); } /** @@ -138,7 +138,7 @@ public abstract class AbstractUserAdapter implements UserModel { public Set getRealmRoleMappings() { Set roleMappings = getRoleMappings(); - Set realmRoles = new HashSet(); + Set realmRoles = new HashSet<>(); for (RoleModel role : roleMappings) { RoleContainerModel container = role.getContainer(); if (container instanceof RealmModel) { @@ -152,7 +152,7 @@ public abstract class AbstractUserAdapter implements UserModel { public Set getClientRoleMappings(ClientModel app) { Set roleMappings = getRoleMappings(); - Set roles = new HashSet(); + Set roles = new HashSet<>(); for (RoleModel role : roleMappings) { RoleContainerModel container = role.getContainer(); if (container instanceof ClientModel) { @@ -190,7 +190,7 @@ public abstract class AbstractUserAdapter implements UserModel { } protected Set getRoleMappingsInternal() { - return Collections.EMPTY_SET; + return Collections.emptySet(); } @Override diff --git a/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapterFederatedStorage.java b/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapterFederatedStorage.java index fe9a41ed1b..c14f981fc9 100644 --- a/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapterFederatedStorage.java +++ b/server-spi/src/main/java/org/keycloak/storage/adapter/AbstractUserAdapterFederatedStorage.java @@ -102,7 +102,7 @@ public abstract class AbstractUserAdapterFederatedStorage implements UserModel { * @return */ protected Set getGroupsInternal() { - return Collections.EMPTY_SET; + return Collections.emptySet(); } /** @@ -126,8 +126,7 @@ public abstract class AbstractUserAdapterFederatedStorage implements UserModel { */ @Override public Set getGroups() { - Set set = new HashSet<>(); - set.addAll(getFederatedStorage().getGroups(realm, this.getId())); + Set set = new HashSet<>(getFederatedStorage().getGroups(realm, this.getId())); if (appendDefaultGroups()) set.addAll(realm.getDefaultGroups()); set.addAll(getGroupsInternal()); return set; @@ -163,7 +162,7 @@ public abstract class AbstractUserAdapterFederatedStorage implements UserModel { public Set getRealmRoleMappings() { Set roleMappings = getRoleMappings(); - Set realmRoles = new HashSet(); + Set realmRoles = new HashSet<>(); for (RoleModel role : roleMappings) { RoleContainerModel container = role.getContainer(); if (container instanceof RealmModel) { @@ -185,7 +184,7 @@ public abstract class AbstractUserAdapterFederatedStorage implements UserModel { public Set getClientRoleMappings(ClientModel app) { Set roleMappings = getRoleMappings(); - Set roles = new HashSet(); + Set roles = new HashSet<>(); for (RoleModel role : roleMappings) { RoleContainerModel container = role.getContainer(); if (container instanceof ClientModel) { @@ -223,7 +222,7 @@ public abstract class AbstractUserAdapterFederatedStorage implements UserModel { } protected Set getRoleMappingsInternal() { - return Collections.EMPTY_SET; + return Collections.emptySet(); } /** @@ -235,8 +234,7 @@ public abstract class AbstractUserAdapterFederatedStorage implements UserModel { */ @Override public Set getRoleMappings() { - Set set = new HashSet<>(); - set.addAll(getFederatedRoleMappings()); + Set set = new HashSet<>(getFederatedRoleMappings()); if (appendDefaultRolesToRoleMappings()) set.addAll(DefaultRoles.getDefaultRoles(realm)); set.addAll(getRoleMappingsInternal()); return set;