package com.inspur.customer.client.keycloak; import com.alibaba.cola.dto.PageResponse; import com.alibaba.cola.dto.Response; import com.alibaba.cola.dto.SingleResponse; import com.inspur.customer.object.keycloak.KeycloakUserCO; import com.inspur.customer.object.keycloak.UsersRoleMappingDTO; import com.inspur.customer.object.org.SmsbDepartmentCmd; import com.inspur.customer.object.org.SmsbUserAdd; import com.inspur.customer.object.wechat.Pair; import org.keycloak.representations.idm.CredentialRepresentation; import org.keycloak.representations.idm.GroupRepresentation; import org.keycloak.representations.idm.RoleRepresentation; import org.keycloak.representations.idm.UserRepresentation; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.Map; /** * keycloak接口能力适配 * @author wangbo13 */ public interface KeycloakService { /** * 获取当前releam下用户Map * * @return */ Map getUserMap(); List getUsersInRole(String role); List getUsersByIds(List userIds); /** * 检查用户是否具备某角色权限 * * @param userId * @param role * @return */ Boolean checkUserRole(String userId,String role); /** * 更新用户attribute * * @param userId * @param property * @param value */ void updateAttribute(String userId ,String property , String value); /** * 获取attributes * * @param groupPath * @param key * @return */ List getAttrByGroupPath(String groupPath, String key); List getGroupSupervisor(String group); List getSuperAdmin(); List getGroupAdmin(String group); String getSingleAttrByGroupPath(String group, String key); /** * 根据属性键值对查找用户 * * @param entries 属性键值对 * @return 找到的用户 */ List searchUserByAttrEntry(List entries); List getUserGroupPathList(String userId); List getUserRealmRoles(String userId); Map> getUserClientRoles(String userId); void changePassword(String userId, String newPassword); /** * 获取当前releam下用户Map * * @return */ Map getUsersMap(); /** * 该租户下添加部门 * * @param id * @param groupRepresentation * @return */ Response addKeycloakGroup(String id , GroupRepresentation groupRepresentation); /** * 该租户下修改部门 * * @param id * @param groupRepresentation * @return */ Response updateKeycloakGroup(String id , GroupRepresentation groupRepresentation); /** * 该租户下删除部门 * * @param id * @return */ Response removeGroup(String id); /** * 添加用户 * * @param smsbUserAdd * @return */ SingleResponse addKeyClaokUser(SmsbUserAdd smsbUserAdd); /** * 更新用户信息 * * @param userId * @param representation * @param oprateType 1:账号启用/禁用 2:重置密码 * @return */ Response updateUser(String userId , Object representation ,Integer oprateType); /** * 注销用户 * * @param userId * @return */ Response removeUser(String userId); /** * 用户重分组 * * @param userId * @param groupId * @return */ Response regrouping(String userId , String groupId); /** * 用户角色分配 * * @param ssersRoleMappingDTO * @return */ Response roleMapping(UsersRoleMappingDTO ssersRoleMappingDTO); /** * 获取用户凭证 * * @param userId * @return */ Response queryUserCredentials(String userId); /** * 删除用户凭证 * * @param userId * @param credentialId * @return */ Response removeUserCredentials(String userId ,String credentialId); /** * 新增租户 * * @param groupRepresentation * @return */ Response addKeyclaokTenant(GroupRepresentation groupRepresentation); /** * 判断用户是否具有某角色 * * @param userId * @param role * @return */ Boolean isExitTargetRole(String userId ,String role); /** * 获取用户所属租户 * * @param userId * @return 租户 */ String queryUserTenant(String userId); /** * 新增或修改用户attributes * * @param userId * @param key key * @param values values * @return if success */ Boolean addAttributesByUserId(String userId , String key , List values); /** * 获取用户列表 * * @param departmentCmd * @param userId * @return */ PageResponse getUserListByIds(SmsbDepartmentCmd departmentCmd , List userId); }