Element deniedElem = new Element("denied");
permissionListSerializer.write(entry.getDeniedPermissions(), deniedElem);
elem.addContent(deniedElem);
}
public JaasAclEntry readAclEntry(Element elem) throws IOException {
JaasAclEntry entry = new JaasAclEntry(null);
List children = elem.getChildren();
Element child;
for (int i=0; i<children.size(); i++) {
child = (Element)children.get(i);
String name = child.getName().toLowerCase();
if (name.equals("principal")) {
Principal p = (Principal)principalSerializer.read(child);
entry.setPrincipal(p);
}
else if (name.equals("allowed")) {
List allowed = (List)permissionListSerializer.read(child);
for (int j=0; j<allowed.size(); j++)
entry.addAllowedPermission((Permission)allowed.get(j));
}
else if (name.equals("denied")) {
List denied = (List)permissionListSerializer.read(child);
for (int j=0; j<denied.size(); j++)
entry.addDeniedPermission((Permission)denied.get(j));
}
}
//validate:
if (entry.getPrincipal() == null)
throw new IOException("Invalid AclEntry: Missing principal");
return entry;
}