@Test public void testRolesExtractionSyncope1() throws Exception { String syncopeResponse = read("syncope1Response.xml"); SyncopeLoginModule syncopeLoginModule = new SyncopeLoginModule(); List<String> roles = syncopeLoginModule.extractingRolesSyncope1(syncopeResponse); assertThat(roles, contains("admin", "another")); }
protected List<String> extractingRolesSyncope1(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { int index = response.indexOf("<memberships>"); if (index != -1) { response = response.substring(index + "<memberships>".length()); index = response.indexOf("</memberships>"); response = response.substring(0, index); index = response.indexOf("<roleName>"); while (index != -1) { response = response.substring(index + "<roleName>".length()); int end = response.indexOf("</roleName>"); if (end == -1) { index = -1; } String role = response.substring(0, end); roles.add(role); response = response.substring(end + "</roleName>".length()); index = response.indexOf("<roleName>"); } } } return roles; }
SyncopeLoginModule extends AbstractKarafLoginModule { protected List<String> extractingRolesSyncope1(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { int index = response.indexOf("<memberships>"); if (index != -1) { response = response.substring(index + "<memberships>".length()); index = response.indexOf("</memberships>"); response = response.substring(0, index); index = response.indexOf("<roleName>"); while (index != -1) { response = response.substring(index + "<roleName>".length()); int end = response.indexOf("</roleName>"); if (end == -1) { index = -1; } String role = response.substring(0, end); roles.add(role); response = response.substring(end + "</roleName>".length()); index = response.indexOf("<roleName>"); } } } return roles; } }
SyncopeLoginModule extends AbstractKarafLoginModule { protected List<String> extractingRolesSyncope1(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { int index = response.indexOf("<memberships>"); if (index != -1) { response = response.substring(index + "<memberships>".length()); index = response.indexOf("</memberships>"); response = response.substring(0, index); index = response.indexOf("<roleName>"); while (index != -1) { response = response.substring(index + "<roleName>".length()); int end = response.indexOf("</roleName>"); if (end == -1) { index = -1; } String role = response.substring(0, end); roles.add(role); response = response.substring(end + "</roleName>".length()); index = response.indexOf("<roleName>"); } } } return roles; }  }
SyncopeLoginModule extends AbstractKarafLoginModule { protected List<String> extractingRolesSyncope1(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { int index = response.indexOf("<memberships>"); if (index != -1) { response = response.substring(index + "<memberships>".length()); index = response.indexOf("</memberships>"); response = response.substring(0, index); index = response.indexOf("<roleName>"); while (index != -1) { response = response.substring(index + "<roleName>".length()); int end = response.indexOf("</roleName>"); if (end == -1) { index = -1; } String role = response.substring(0, end); roles.add(role); response = response.substring(end + "</roleName>".length()); index = response.indexOf("<roleName>"); } } } return roles; }  void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options); boolean login(); }
SyncopeLoginModule extends AbstractKarafLoginModule { protected List<String> extractingRolesSyncope1(String response) throws Exception { List<String> roles = new ArrayList<>(); if (response != null && !response.isEmpty()) { int index = response.indexOf("<memberships>"); if (index != -1) { response = response.substring(index + "<memberships>".length()); index = response.indexOf("</memberships>"); response = response.substring(0, index); index = response.indexOf("<roleName>"); while (index != -1) { response = response.substring(index + "<roleName>".length()); int end = response.indexOf("</roleName>"); if (end == -1) { index = -1; } String role = response.substring(0, end); roles.add(role); response = response.substring(end + "</roleName>".length()); index = response.indexOf("<roleName>"); } } } 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; }