Skip to content
Snippets Groups Projects
Commit 60624fb9 authored by Felix Reichenbach's avatar Felix Reichenbach
Browse files

OZG-6733 refactor buildUsersHref

parent 9a75b545
No related branches found
No related tags found
1 merge request!2Ozg 6733 provide keycloak api link
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
*/ */
package de.ozgcloud.admin.keycloak; package de.ozgcloud.admin.keycloak;
import java.util.Map;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
...@@ -41,6 +43,10 @@ import lombok.RequiredArgsConstructor; ...@@ -41,6 +43,10 @@ import lombok.RequiredArgsConstructor;
@ConditionalOnProperty(prefix = FeatureToggleProperties.FEATURE_TOGGLE_PREFIX, name = "benutzer-rollen", havingValue = "true") @ConditionalOnProperty(prefix = FeatureToggleProperties.FEATURE_TOGGLE_PREFIX, name = "benutzer-rollen", havingValue = "true")
class KeyCloakRootProcessor implements RepresentationModelProcessor<EntityModel<Root>> { class KeyCloakRootProcessor implements RepresentationModelProcessor<EntityModel<Root>> {
private static final String REALM_KEY = "realm";
private static final String BASE_URL_KEY = "baseUrl";
private static final String KEYCLOAK_API_TEMPLATE = "{baseUrl}/admin/realms/{realm}/users";
public static final String REL_USERS = "users"; public static final String REL_USERS = "users";
private final KeycloakApiProperties keycloakApiProperties; private final KeycloakApiProperties keycloakApiProperties;
...@@ -52,8 +58,8 @@ class KeyCloakRootProcessor implements RepresentationModelProcessor<EntityModel< ...@@ -52,8 +58,8 @@ class KeyCloakRootProcessor implements RepresentationModelProcessor<EntityModel<
} }
String buildUsersHref() { String buildUsersHref() {
return UriComponentsBuilder.fromUriString(keycloakApiProperties.getUrl()) Map<String, Object> pathVariableMap = Map.of(BASE_URL_KEY, keycloakApiProperties.getUrl(), REALM_KEY, keycloakApiProperties.getRealm());
.pathSegment("admin", "realms", keycloakApiProperties.getRealm(), "users") // NOSONAR return UriComponentsBuilder.fromUriString(KEYCLOAK_API_TEMPLATE).uriVariables(pathVariableMap)
.build().toUriString(); .build().toUriString();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment