From 2785cab59661f97fa4eb293fe4b5661edbc69654 Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Mon, 6 Dec 2021 15:56:39 +0100 Subject: [PATCH] Simplify component model overrides Fixes #9021 --- .../keycloak/component/ComponentModelScope.java | 4 ++++ .../org/keycloak/component/ComponentModel.java | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/server-spi-private/src/main/java/org/keycloak/component/ComponentModelScope.java b/server-spi-private/src/main/java/org/keycloak/component/ComponentModelScope.java index 6b4fbadb89..4d225a86bc 100644 --- a/server-spi-private/src/main/java/org/keycloak/component/ComponentModelScope.java +++ b/server-spi-private/src/main/java/org/keycloak/component/ComponentModelScope.java @@ -119,4 +119,8 @@ public class ComponentModelScope implements Scope { throw new UnsupportedOperationException("Not implemented"); } + public ComponentModel getComponentModel() { + return componentConfig; + } + } diff --git a/server-spi/src/main/java/org/keycloak/component/ComponentModel.java b/server-spi/src/main/java/org/keycloak/component/ComponentModel.java index 7a1a2cc565..abdb481ec8 100755 --- a/server-spi/src/main/java/org/keycloak/component/ComponentModel.java +++ b/server-spi/src/main/java/org/keycloak/component/ComponentModel.java @@ -85,22 +85,22 @@ public class ComponentModel implements Serializable { } public String get(String key, String defaultValue) { - String s = config.getFirst(key); + String s = get(key); return s != null ? s : defaultValue; } public int get(String key, int defaultValue) { - String s = config.getFirst(key); + String s = get(key); return s != null ? Integer.parseInt(s) : defaultValue; } public long get(String key, long defaultValue) { - String s = config.getFirst(key); + String s = get(key); return s != null ? Long.parseLong(s) : defaultValue; } public boolean get(String key, boolean defaultValue) { - String s = config.getFirst(key); + String s = get(key); return s != null ? Boolean.parseBoolean(s) : defaultValue; } @@ -109,15 +109,15 @@ public class ComponentModel implements Serializable { } public void put(String key, int value) { - config.putSingle(key, Integer.toString(value)); + put(key, Integer.toString(value)); } public void put(String key, long value) { - config.putSingle(key, Long.toString(value)); + put(key, Long.toString(value)); } public void put(String key, boolean value) { - config.putSingle(key, Boolean.toString(value)); + put(key, Boolean.toString(value)); } public boolean hasNote(String key) {