@Test public void testGroupsExtractionSyncope2() throws Exception { String syncopeResponse = read("syncope2Response.json"); SyncopeLoginModule syncopeLoginModule = new SyncopeLoginModule(); List<String> roles = syncopeLoginModule.extractingRolesSyncope2(syncopeResponse); assertThat(roles, contains("manager")); }
@SuppressWarnings("unchecked") protected List<String> extractingRolesSyncope2(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { JSONParser parser = new JSONParser(response); if (useRolesForSyncope2) { return (List<String>) parser.getParsed().get("roles"); } else { List<Map<String, String>> memberships = (List<Map<String, String>>) parser.getParsed().get("memberships"); if (memberships != null) { for (Map<String, String> membership : memberships) { if (membership.containsKey("groupName")) { roles.add(membership.get("groupName")); } } } } } return roles; }
SyncopeLoginModule extends AbstractKarafLoginModule { @SuppressWarnings("unchecked") protected List<String> extractingRolesSyncope2(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { JSONParser parser = new JSONParser(response); if (useRolesForSyncope2) { return (List<String>) parser.getParsed().get("roles"); } else { List<Map<String, String>> memberships = (List<Map<String, String>>) parser.getParsed().get("memberships"); if (memberships != null) { for (Map<String, String> membership : memberships) { if (membership.containsKey("groupName")) { roles.add(membership.get("groupName")); } } } } } return roles; } }
SyncopeLoginModule extends AbstractKarafLoginModule { @SuppressWarnings("unchecked") protected List<String> extractingRolesSyncope2(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { JSONParser parser = new JSONParser(response); if (useRolesForSyncope2) { return (List<String>) parser.getParsed().get("roles"); } else { List<Map<String, String>> memberships = (List<Map<String, String>>) parser.getParsed().get("memberships"); if (memberships != null) { for (Map<String, String> membership : memberships) { if (membership.containsKey("groupName")) { roles.add(membership.get("groupName")); } } } } } return roles; }  }
SyncopeLoginModule extends AbstractKarafLoginModule { @SuppressWarnings("unchecked") protected List<String> extractingRolesSyncope2(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { JSONParser parser = new JSONParser(response); if (useRolesForSyncope2) { return (List<String>) parser.getParsed().get("roles"); } else { List<Map<String, String>> memberships = (List<Map<String, String>>) parser.getParsed().get("memberships"); if (memberships != null) { for (Map<String, String> membership : memberships) { if (membership.containsKey("groupName")) { roles.add(membership.get("groupName")); } } } } } return roles; }  void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options); boolean login(); }
SyncopeLoginModule extends AbstractKarafLoginModule { @SuppressWarnings("unchecked") protected List<String> extractingRolesSyncope2(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { JSONParser parser = new JSONParser(response); if (useRolesForSyncope2) { return (List<String>) parser.getParsed().get("roles"); } else { List<Map<String, String>> memberships = (List<Map<String, String>>) parser.getParsed().get("memberships"); if (memberships != null) { for (Map<String, String> membership : memberships) { if (membership.containsKey("groupName")) { roles.add(membership.get("groupName")); } } } } } return roles; }  void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options); boolean login(); final static String ADDRESS; final static String VERSION; final static String USE_ROLES_FOR_SYNCOPE2; final static String ADMIN_USER; final static String ADMIN_PASSWORD; }