public UserInfo getUserInfo(String username, String appId, String repoCode) { Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("username", username); parameterMap.put("appId", appId); parameterMap.put("repoCode", repoCode); try { String content = httpHandler.readText(url, parameterMap); logger.info(content); JsonMapper jsonMapper = new JsonMapper(); Map map = jsonMapper.fromJson(content, Map.class); logger.debug("{}", map); long userId = ((Number) map.get("userId")).longValue(); List<String> authorities = (List<String>) map.get("authorities"); List<String> attributes = (List<String>) map.get("attributes"); UserInfoImpl userInfo = new UserInfoImpl(); userInfo.setUsername(username); userInfo.setPassword((String) map.get("password")); userInfo.setAuthorities(authorities); userInfo.setAttributes(attributes); userInfo.getExtra().put("userId", userId); userInfo.getExtra().put("appId", appId); return userInfo; } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new UsernameNotFoundException(username, ex); } }
public Map<String, String> getSource(String type) { Map<String, Object> parameterMap = new HashMap<String, Object>(); if (appId != null) { parameterMap.put("appId", appId); } try { String content = httpHandler.readText(url, parameterMap); logger.info(content); JsonMapper jsonMapper = new JsonMapper(); List<Map> list = jsonMapper.fromJson(content, List.class); Map<String, String> resourceMap = new LinkedHashMap<String, String>(); for (Map map : list) { String access = (String) map.get("access"); String permission = (String) map.get("permission"); if (resourceMap.containsKey(access)) { String value = resourceMap.get(access); resourceMap.put(access, value + "," + permission); } else { resourceMap.put(access, permission); } } return resourceMap; } catch (Exception ex) { logger.error("", ex); throw new RuntimeException(ex); } }