diff --git a/src/main/java/de/sventorben/keycloak/authorization/client/RestrictClientAuthAuthenticatorFactory.java b/src/main/java/de/sventorben/keycloak/authorization/client/RestrictClientAuthAuthenticatorFactory.java index 062ad59..711746b 100755 --- a/src/main/java/de/sventorben/keycloak/authorization/client/RestrictClientAuthAuthenticatorFactory.java +++ b/src/main/java/de/sventorben/keycloak/authorization/client/RestrictClientAuthAuthenticatorFactory.java @@ -1,6 +1,7 @@ package de.sventorben.keycloak.authorization.client; import de.sventorben.keycloak.authorization.client.access.AccessProvider; +import de.sventorben.keycloak.authorization.client.common.OperationalInfo; import org.jboss.logging.Logger; import org.keycloak.Config; import org.keycloak.authentication.Authenticator; @@ -93,10 +94,6 @@ public String getId() { @Override public Map getOperationalInfo() { - String version = getClass().getPackage().getImplementationVersion(); - if (version == null) { - version = "unknown"; - } - return Map.of("Version", version); + return OperationalInfo.get(); } } diff --git a/src/main/java/de/sventorben/keycloak/authorization/client/access/policy/PolicyBasedAccessProviderFactory.java b/src/main/java/de/sventorben/keycloak/authorization/client/access/policy/PolicyBasedAccessProviderFactory.java index 3378e25..5385a36 100755 --- a/src/main/java/de/sventorben/keycloak/authorization/client/access/policy/PolicyBasedAccessProviderFactory.java +++ b/src/main/java/de/sventorben/keycloak/authorization/client/access/policy/PolicyBasedAccessProviderFactory.java @@ -2,6 +2,7 @@ import de.sventorben.keycloak.authorization.client.access.AccessProvider; import de.sventorben.keycloak.authorization.client.access.AccessProviderFactory; +import de.sventorben.keycloak.authorization.client.common.OperationalInfo; import org.keycloak.Config; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; @@ -41,11 +42,7 @@ public String getId() { @Override public Map getOperationalInfo() { - String version = getClass().getPackage().getImplementationVersion(); - if (version == null) { - version = "unknown"; - } - return Map.of("Version", version); + return OperationalInfo.get(); } } diff --git a/src/main/java/de/sventorben/keycloak/authorization/client/access/role/ClientRoleBasedAccessProviderFactory.java b/src/main/java/de/sventorben/keycloak/authorization/client/access/role/ClientRoleBasedAccessProviderFactory.java index e421237..84abf0a 100755 --- a/src/main/java/de/sventorben/keycloak/authorization/client/access/role/ClientRoleBasedAccessProviderFactory.java +++ b/src/main/java/de/sventorben/keycloak/authorization/client/access/role/ClientRoleBasedAccessProviderFactory.java @@ -2,6 +2,7 @@ import de.sventorben.keycloak.authorization.client.access.AccessProvider; import de.sventorben.keycloak.authorization.client.access.AccessProviderFactory; +import de.sventorben.keycloak.authorization.client.common.OperationalInfo; import org.keycloak.Config; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; @@ -9,6 +10,7 @@ import org.keycloak.provider.ProviderConfigurationBuilder; import org.keycloak.provider.ServerInfoAwareProviderFactory; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -50,11 +52,9 @@ public String getId() { @Override public Map getOperationalInfo() { - String version = getClass().getPackage().getImplementationVersion(); - if (version == null) { - version = "unknown"; - } - return Map.of("Version", version, CLIENT_ROLE_NAME, getClientRoleName()); + Map operationalInfo = new HashMap<>(OperationalInfo.get()); + operationalInfo.put(CLIENT_ROLE_NAME, getClientRoleName()); + return operationalInfo; } @Override diff --git a/src/main/java/de/sventorben/keycloak/authorization/client/clientpolicy/condition/RestrictedClientAuthEnabledPolicyConditionProviderFactory.java b/src/main/java/de/sventorben/keycloak/authorization/client/clientpolicy/condition/RestrictedClientAuthEnabledPolicyConditionProviderFactory.java index ce45972..7d43264 100755 --- a/src/main/java/de/sventorben/keycloak/authorization/client/clientpolicy/condition/RestrictedClientAuthEnabledPolicyConditionProviderFactory.java +++ b/src/main/java/de/sventorben/keycloak/authorization/client/clientpolicy/condition/RestrictedClientAuthEnabledPolicyConditionProviderFactory.java @@ -1,5 +1,6 @@ package de.sventorben.keycloak.authorization.client.clientpolicy.condition; +import de.sventorben.keycloak.authorization.client.common.OperationalInfo; import org.keycloak.models.KeycloakSession; import org.keycloak.provider.ProviderConfigProperty; import org.keycloak.provider.ServerInfoAwareProviderFactory; @@ -39,10 +40,6 @@ public String getId() { @Override public Map getOperationalInfo() { - String version = getClass().getPackage().getImplementationVersion(); - if (version == null) { - version = "unknown"; - } - return Map.of("Version", version); + return OperationalInfo.get(); } } diff --git a/src/main/java/de/sventorben/keycloak/authorization/client/clientpolicy/executor/AutoConfigClientPolicyExecutorFactory.java b/src/main/java/de/sventorben/keycloak/authorization/client/clientpolicy/executor/AutoConfigClientPolicyExecutorFactory.java index 5f8627d..30b5cf6 100755 --- a/src/main/java/de/sventorben/keycloak/authorization/client/clientpolicy/executor/AutoConfigClientPolicyExecutorFactory.java +++ b/src/main/java/de/sventorben/keycloak/authorization/client/clientpolicy/executor/AutoConfigClientPolicyExecutorFactory.java @@ -2,21 +2,24 @@ import de.sventorben.keycloak.authorization.client.RestrictClientAuthConfigProperties; import de.sventorben.keycloak.authorization.client.access.AccessProvider; +import de.sventorben.keycloak.authorization.client.common.OperationalInfo; import org.keycloak.Config; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.provider.ProviderConfigProperty; import org.keycloak.provider.ProviderConfigurationBuilder; import org.keycloak.provider.ProviderFactory; +import org.keycloak.provider.ServerInfoAwareProviderFactory; import org.keycloak.services.clientpolicy.executor.ClientPolicyExecutorProvider; import org.keycloak.services.clientpolicy.executor.ClientPolicyExecutorProviderFactory; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import static de.sventorben.keycloak.authorization.client.RestrictClientAuthConfigProperties.ACCESS_PROVIDER_ID_PROPERTY; -public class AutoConfigClientPolicyExecutorFactory implements ClientPolicyExecutorProviderFactory { +public class AutoConfigClientPolicyExecutorFactory implements ClientPolicyExecutorProviderFactory, ServerInfoAwareProviderFactory { private static final List CONFIG_PROPERTIES = ProviderConfigurationBuilder.create() .property(ACCESS_PROVIDER_ID_PROPERTY) @@ -59,4 +62,9 @@ public void close() { public String getId() { return AutoConfigClientPolicyExecutor.PROVIDER_ID; } + + @Override + public Map getOperationalInfo() { + return OperationalInfo.get(); + } } diff --git a/src/main/java/de/sventorben/keycloak/authorization/client/common/OperationalInfo.java b/src/main/java/de/sventorben/keycloak/authorization/client/common/OperationalInfo.java new file mode 100644 index 0000000..3b9f047 --- /dev/null +++ b/src/main/java/de/sventorben/keycloak/authorization/client/common/OperationalInfo.java @@ -0,0 +1,14 @@ +package de.sventorben.keycloak.authorization.client.common; + +import java.util.Map; + +public class OperationalInfo { + + public static Map get() { + String version = OperationalInfo.class.getPackage().getImplementationVersion(); + if (version == null) { + version = "unknown"; + } + return Map.of("Version", version); + } +}