diff --git a/commons-auth-adapter/src/main/java/io/rocketbase/commons/security/CommonsPrincipal.java b/commons-auth-adapter/src/main/java/io/rocketbase/commons/security/CommonsPrincipal.java index ea4e9c9b..580ef4d7 100644 --- a/commons-auth-adapter/src/main/java/io/rocketbase/commons/security/CommonsPrincipal.java +++ b/commons-auth-adapter/src/main/java/io/rocketbase/commons/security/CommonsPrincipal.java @@ -31,7 +31,7 @@ public static CommonsPrincipal getCurrent() { * @return the value of the given key when user is logged in and key exists
* key is stored internally in lowercase so that this function also lowers the given key... */ - public String getCurrentKeyValue(String key) { + public static String getCurrentKeyValue(String key) { CommonsPrincipal current = getCurrent(); if (current != null) { return current.getKeyValues() != null ? current.getKeyValues().getOrDefault(key.toLowerCase(), null) : null; diff --git a/commons-auth-api/src/main/java/io/rocketbase/commons/dto/appuser/AppUserRead.java b/commons-auth-api/src/main/java/io/rocketbase/commons/dto/appuser/AppUserRead.java index ea783842..bf0856a5 100644 --- a/commons-auth-api/src/main/java/io/rocketbase/commons/dto/appuser/AppUserRead.java +++ b/commons-auth-api/src/main/java/io/rocketbase/commons/dto/appuser/AppUserRead.java @@ -49,4 +49,11 @@ public AppUserReference toReference() { .build(); } + public boolean hasKeyValue(String key) { + return keyValues != null && key != null && keyValues.containsKey(key.toLowerCase()); + } + + public String getKeyValue(String key) { + return keyValues != null && key != null ? keyValues.getOrDefault(key.toLowerCase() , null) : null; + } }