@Test(expected = IllegalArgumentException.class) public void testSerializePrivilegesByRoleWithNull() throws Exception { AccessInformationUtil.serializePrivilegesByRole(null); }
public static JSONObject serializePrivilegesByRole(AccessControlList acl) { if (acl == null) throw new IllegalArgumentException("The parameter trans must not be null"); Map<String, JSONObject> privilegesByRole = new HashMap<String, JSONObject>(); for (AccessControlEntry entry : acl.getEntries()) { JSONObject rolePrivileges; if (privilegesByRole.containsKey(entry.getRole())) { rolePrivileges = privilegesByRole.get(entry.getRole()); } else { rolePrivileges = new JSONObject(); privilegesByRole.put(entry.getRole(), rolePrivileges); } try { rolePrivileges.put(entry.getAction(), entry.isAllow()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } JSONObject privilegesJson = new JSONObject(); for (Entry<String, JSONObject> privilege : privilegesByRole.entrySet()) { try { privilegesJson.put(privilege.getKey(), privilege.getValue()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } return privilegesJson; }
AccessInformationUtil { public static JSONObject serializePrivilegesByRole(AccessControlList acl) { if (acl == null) throw new IllegalArgumentException("The parameter trans must not be null"); Map<String, JSONObject> privilegesByRole = new HashMap<String, JSONObject>(); for (AccessControlEntry entry : acl.getEntries()) { JSONObject rolePrivileges; if (privilegesByRole.containsKey(entry.getRole())) { rolePrivileges = privilegesByRole.get(entry.getRole()); } else { rolePrivileges = new JSONObject(); privilegesByRole.put(entry.getRole(), rolePrivileges); } try { rolePrivileges.put(entry.getAction(), entry.isAllow()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } JSONObject privilegesJson = new JSONObject(); for (Entry<String, JSONObject> privilege : privilegesByRole.entrySet()) { try { privilegesJson.put(privilege.getKey(), privilege.getValue()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } return privilegesJson; } }
AccessInformationUtil { public static JSONObject serializePrivilegesByRole(AccessControlList acl) { if (acl == null) throw new IllegalArgumentException("The parameter trans must not be null"); Map<String, JSONObject> privilegesByRole = new HashMap<String, JSONObject>(); for (AccessControlEntry entry : acl.getEntries()) { JSONObject rolePrivileges; if (privilegesByRole.containsKey(entry.getRole())) { rolePrivileges = privilegesByRole.get(entry.getRole()); } else { rolePrivileges = new JSONObject(); privilegesByRole.put(entry.getRole(), rolePrivileges); } try { rolePrivileges.put(entry.getAction(), entry.isAllow()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } JSONObject privilegesJson = new JSONObject(); for (Entry<String, JSONObject> privilege : privilegesByRole.entrySet()) { try { privilegesJson.put(privilege.getKey(), privilege.getValue()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } return privilegesJson; } private  AccessInformationUtil(); }
AccessInformationUtil { public static JSONObject serializePrivilegesByRole(AccessControlList acl) { if (acl == null) throw new IllegalArgumentException("The parameter trans must not be null"); Map<String, JSONObject> privilegesByRole = new HashMap<String, JSONObject>(); for (AccessControlEntry entry : acl.getEntries()) { JSONObject rolePrivileges; if (privilegesByRole.containsKey(entry.getRole())) { rolePrivileges = privilegesByRole.get(entry.getRole()); } else { rolePrivileges = new JSONObject(); privilegesByRole.put(entry.getRole(), rolePrivileges); } try { rolePrivileges.put(entry.getAction(), entry.isAllow()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } JSONObject privilegesJson = new JSONObject(); for (Entry<String, JSONObject> privilege : privilegesByRole.entrySet()) { try { privilegesJson.put(privilege.getKey(), privilege.getValue()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } return privilegesJson; } private  AccessInformationUtil(); static JSONObject serializeManagedAcl(ManagedAcl managedAcl); static JSONObject serializePrivilegesByRole(AccessControlList acl); static Option<ManagedAcl> matchAcls(List<ManagedAcl> acls, final AccessControlList acl); }
AccessInformationUtil { public static JSONObject serializePrivilegesByRole(AccessControlList acl) { if (acl == null) throw new IllegalArgumentException("The parameter trans must not be null"); Map<String, JSONObject> privilegesByRole = new HashMap<String, JSONObject>(); for (AccessControlEntry entry : acl.getEntries()) { JSONObject rolePrivileges; if (privilegesByRole.containsKey(entry.getRole())) { rolePrivileges = privilegesByRole.get(entry.getRole()); } else { rolePrivileges = new JSONObject(); privilegesByRole.put(entry.getRole(), rolePrivileges); } try { rolePrivileges.put(entry.getAction(), entry.isAllow()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } JSONObject privilegesJson = new JSONObject(); for (Entry<String, JSONObject> privilege : privilegesByRole.entrySet()) { try { privilegesJson.put(privilege.getKey(), privilege.getValue()); } catch (JSONException e) { logger.error("An unexpected error occured:", e); } } return privilegesJson; } private  AccessInformationUtil(); static JSONObject serializeManagedAcl(ManagedAcl managedAcl); static JSONObject serializePrivilegesByRole(AccessControlList acl); static Option<ManagedAcl> matchAcls(List<ManagedAcl> acls, final AccessControlList acl);  }