ソースを参照

Merge branch 'cancel/keycloak' into 'develop'

Cancel/keycloak



See merge request !2

wangbo 3 年 前
コミット
4af94629db

+ 11 - 0
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/keycloak/KeycloakServiceImpl.java

@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.keycloak.admin.client.Keycloak;
 import org.keycloak.admin.client.resource.UserResource;
+import org.keycloak.representations.idm.GroupRepresentation;
 import org.keycloak.representations.idm.RoleRepresentation;
 import org.keycloak.representations.idm.UserRepresentation;
 import org.springframework.beans.factory.annotation.Value;
@@ -115,4 +116,14 @@ public class KeycloakServiceImpl implements KeycloakService {
         user.update(userRepresentation);
     }
 
+    @Override
+    public List<String> getAttrByGroupPath(String groupPath, String key) {
+        GroupRepresentation groupRepresentation = keycloak.realm(realm).getGroupByPath(groupPath);
+        if (groupRepresentation != null) {
+            Map<String, List<String>> attributes = groupRepresentation.getAttributes();
+            return attributes != null ? attributes.get(key) : Collections.emptyList();
+        }
+        return Collections.emptyList();
+    }
+
 }

+ 9 - 1
smsb-customer-manager-client/src/main/java/com/inspur/customer/service/client/keycloak/KeycloakService.java

@@ -1,6 +1,5 @@
 package com.inspur.customer.service.client.keycloak;
 import com.inspur.customer.service.dto.KeycloakUserCO;
-
 import java.util.List;
 import java.util.Map;
 
@@ -38,4 +37,13 @@ public interface KeycloakService {
      * @param value
      */
     void updateAttribute(String userId ,String property , String value);
+
+    /**
+     * 获取attributes
+     *
+     * @param groupPath
+     * @param key
+     * @return
+     */
+    List<String> getAttrByGroupPath(String groupPath, String key);
 }