@Override public UserPrincipal lookupUser(String s) { if ("admin".equals(s)) { return new UserPrincipal("admin"); } else { return null; } }
public static String retrieveUser(Subject subject) { if (subject != null && subject.getPrivateCredentials(String.class) != null && !subject.getPrivateCredentials(String.class).isEmpty() && subject.getPrincipals(UserPrincipal.class) != null && !subject.getPrincipals(UserPrincipal.class).isEmpty()) { Set<UserPrincipal> userPrincipals = subject.getPrincipals(UserPrincipal.class); UserPrincipal userPrincipal = userPrincipals.iterator().next(); return userPrincipal.getName(); } return null; }
@Override public List<UserPrincipal> listUsers() { return Collections.singletonList(new UserPrincipal("admin")); }
@Override public UserPrincipal lookupUser(String username) { for (UserPrincipal userPrincipal : listUsers()) { if (userPrincipal.getName().equals(username)) { return userPrincipal; } } 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; }
@Override public List<GroupPrincipal> listGroups(UserPrincipal user) { String userName = user.getName(); return listGroups(userName); }
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; }
public static String retrieveUser(Subject subject) { if (subject != null && subject.getPrivateCredentials(String.class) != null && !subject.getPrivateCredentials(String.class).isEmpty() && subject.getPrincipals(UserPrincipal.class) != null && !subject.getPrincipals(UserPrincipal.class).isEmpty()) { Set<UserPrincipal> userPrincipals = subject.getPrincipals(UserPrincipal.class); UserPrincipal userPrincipal = userPrincipals.iterator().next(); return userPrincipal.getName(); } 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; }
private String getCurrentUserName() { AccessControlContext acc = AccessController.getContext(); final Subject subject = Subject.getSubject(acc); if (subject != null && subject.getPrincipals().iterator().hasNext()) { return subject.getPrincipals(UserPrincipal.class).iterator().next().getName(); } else { 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<GroupPrincipal> listGroups(UserPrincipal user) { String userName = user.getName(); return listGroups(userName); }
@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) { for (UserPrincipal userPrincipal : listUsers()) { if (userPrincipal.getName().equals(username)) { return userPrincipal; } } 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; }
public static String getCurrentUserName() { AccessControlContext acc = AccessController.getContext(); final Subject subject = Subject.getSubject(acc); if (subject != null && subject.getPrincipals(UserPrincipal.class).iterator().hasNext()) { return subject.getPrincipals(UserPrincipal.class).iterator().next().getName(); } else { 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; }
@Override public UserPrincipal lookupUser(String username) { for (UserPrincipal userPrincipal : listUsers()) { if (userPrincipal.getName().equals(username)) { return userPrincipal; } } 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 List<GroupPrincipal> listGroups(UserPrincipal user) { String userName = user.getName(); return listGroups(userName); }