@Override public UserPrincipal lookupUser(String s) { if ("admin".equals(s)) { return new UserPrincipal("admin"); } else { return null; } }
@Override public List<UserPrincipal> listUsers() { return Collections.singletonList(new UserPrincipal("admin")); }
private UserPrincipal lookupUserSyncope1(String username) { HttpGet request = new HttpGet(address + "/users?username=" + username); request.setHeader("Content-Type", "application/xml"); try { HttpResponse response = client.execute(request); String responseTO = EntityUtils.toString(response.getEntity()); if (responseTO != null && !responseTO.isEmpty()) { return new UserPrincipal(username); } } catch (Exception e) { throw new RuntimeException("Error getting user", e); } return null; }
private UserPrincipal lookupUserSyncope1(String username) { HttpGet request = new HttpGet(address + "/users?username=" + username); request.setHeader("Content-Type", "application/xml"); try { HttpResponse response = client.execute(request); String responseTO = EntityUtils.toString(response.getEntity()); if (responseTO != null && !responseTO.isEmpty()) { return new UserPrincipal(username); } } catch (Exception e) { throw new RuntimeException("Error getting user", e); } return null; }
private UserPrincipal lookupUserSyncope2(String username) { HttpGet request = new HttpGet(address + "/users/" + username); request.setHeader("Content-Type", "application/json"); try { HttpResponse httpResponse = client.execute(request); String response = EntityUtils.toString(httpResponse.getEntity()); if (response != null && !response.isEmpty()) { return new UserPrincipal(username); } } catch (Exception e) { throw new RuntimeException("Error getting user", e); } return null; }
/** * List Users */ public List<UserPrincipal> listUsers() { List<UserPrincipal> result = new ArrayList<UserPrincipal>(); for (String userName : users.keySet()) { if (userName.startsWith(GROUP_PREFIX)) { continue; } UserPrincipal userPrincipal = new UserPrincipal(userName); result.add(userPrincipal); } return result; }
@Override public List<UserPrincipal> listUsers() { List<UserPrincipal> result = new ArrayList<>(); for (Object user : users.keySet()) { String userName = (String) user; if (userName.startsWith(GROUP_PREFIX)) continue; UserPrincipal userPrincipal = new UserPrincipal(userName); result.add(userPrincipal); } return result; }
@Override public List<UserPrincipal> listUsers() { List<UserPrincipal> result = new ArrayList<>(); for (Object user : users.keySet()) { String userName = (String) user; if (userName.startsWith(GROUP_PREFIX)) continue; UserPrincipal userPrincipal = new UserPrincipal(userName); result.add(userPrincipal); } return result; }
@Override public List<UserPrincipal> listUsers() { List<UserPrincipal> result = new ArrayList<>(); for (Object user : users.keySet()) { String userName = (String) user; if (userName.startsWith(GROUP_PREFIX)) continue; UserPrincipal userPrincipal = new UserPrincipal(userName); result.add(userPrincipal); } return result; }
private UserPrincipal lookupUserSyncope2(String username) { HttpGet request = new HttpGet(address + "/users/" + username); request.setHeader("Content-Type", "application/json"); try { HttpResponse httpResponse = client.execute(request); String response = EntityUtils.toString(httpResponse.getEntity()); if (response != null && !response.isEmpty()) { return new UserPrincipal(username); } } catch (Exception e) { throw new RuntimeException("Error getting user", e); } return null; }
@Override public List<UserPrincipal> listUsers() { List<UserPrincipal> result = new ArrayList<>(); for (Object user : users.keySet()) { String userName = (String) user; if (userName.startsWith(GROUP_PREFIX)) continue; UserPrincipal userPrincipal = new UserPrincipal(userName); result.add(userPrincipal); } return result; }
@Override public UserPrincipal lookupUser(String username) { try { try (Connection connection = dataSource.getConnection()) { List<String> names = rawSelect(connection, selectUserQuery, username); if (names.size() == 0) { return null; } return new UserPrincipal(username); } } catch (SQLException e) { throw new RuntimeException("Error getting user", e); } }
/** * List Users * * @return */ public List<UserPrincipal> listUsers() { List<UserPrincipal> result = new ArrayList<UserPrincipal>(); for (String userNames : (Set<String>) users.keySet()) { UserPrincipal userPrincipal = new UserPrincipal(userNames); result.add(userPrincipal); } return result; }
@Override public UserPrincipal lookupUser(String username) { try { try (Connection connection = dataSource.getConnection()) { List<String> names = rawSelect(connection, selectUserQuery, username); if (names.size() == 0) { return null; } return new UserPrincipal(username); } } catch (SQLException e) { throw new RuntimeException("Error getting user", e); } }
/** * List all users. * * @return the list of {@link UserPrincipal}. */ public List<UserPrincipal> listUsers() { try { try (Connection connection = dataSource.getConnection()) { List<UserPrincipal> users = new ArrayList<>(); for (String name : rawSelect(connection, selectUsersQuery)) { if (!name.startsWith(GROUP_PREFIX)) { users.add(new UserPrincipal(name)); } } return users; } } catch (SQLException e) { throw new RuntimeException("Error listing users", e); } }
private Subject createLocalKarafSubject() { String userName = System.getProperty(KARAF_LOCAL_USER); if (userName == null) { userName = "karaf"; } final Subject subject = new Subject(); subject.getPrincipals().add(new UserPrincipal(userName)); subject.getPrincipals().add(new ClientPrincipal("local", "localhost")); String roles = System.getProperty(KARAF_LOCAL_ROLES, KARAF_LOCAL_ROLES_DEFAULT); if (roles != null) { for (String role : roles.split("[,]")) { subject.getPrincipals().add(new RolePrincipal(role.trim())); } } return subject; }
private List<UserPrincipal> listUsersSyncope2() { List<UserPrincipal> users = new ArrayList<>(); HttpGet request = new HttpGet(address + "/users"); request.setHeader("Content-Type", "application/json"); try { HttpResponse httpResponse = client.execute(request); String response = EntityUtils.toString(httpResponse.getEntity()); JSONParser parser = new JSONParser(response); List<Map<String, Object>> results = (List<Map<String, Object>>) parser.getParsed().get("result"); for (Map<String, Object> result : results) { users.add(new UserPrincipal((String) result.get("username"))); } } catch (Exception e) { throw new RuntimeException("Error listing users", e); } return users; }
private Subject createLocalKarafSubject() { String userName = System.getProperty(KARAF_LOCAL_USER); if (userName == null) { userName = "karaf"; } final Subject subject = new Subject(); subject.getPrincipals().add(new UserPrincipal(userName)); subject.getPrincipals().add(new ClientPrincipal("local", "localhost")); String roles = System.getProperty(KARAF_LOCAL_ROLES, KARAF_LOCAL_ROLES_DEFAULT); if (roles != null) { for (String role : roles.split("[,]")) { subject.getPrincipals().add(new RolePrincipal(role.trim())); } } return subject; }
private List<UserPrincipal> listUsersSyncope2() { List<UserPrincipal> users = new ArrayList<>(); HttpGet request = new HttpGet(address + "/users"); request.setHeader("Content-Type", "application/json"); try { HttpResponse httpResponse = client.execute(request); String response = EntityUtils.toString(httpResponse.getEntity()); JSONParser parser = new JSONParser(response); List<Map<String, Object>> results = (List<Map<String, Object>>) parser.getParsed().get("result"); for (Map<String, Object> result : results) { users.add(new UserPrincipal((String) result.get("username"))); } } catch (Exception e) { throw new RuntimeException("Error listing users", e); } return users; }
Set<Principal> principals = subject.getPrincipals(); Group roleGroup = new JAASGroup("Roles"); for (String role : userRoles) roleGroup.addMember(new RolePrincipal(role)); // group principal principals.add(roleGroup); // username principal principals.add(new UserPrincipal("user"));