Methods Summary |
---|
public boolean | equals(java.lang.Object o)
if (!(o instanceof XYZPayrollPermission))
return false;
XYZPayrollPermission p = (XYZPayrollPermission) o;
return ((p.getName().equals(getName())) && (p.mask == mask));
|
public java.lang.String | getActions()
if (mask == 0)
return "";
else if (mask == VIEW)
return "view";
else if (mask == UPDATE)
return "update";
else if (mask == (VIEW | UPDATE))
return "view, update";
else throw new IllegalArgumentException("Unknown mask");
|
public int | hashCode()
return getName().hashCode() ^ mask;
|
public boolean | implies(java.security.Permission permission)
if (!(permission instanceof XYZPayrollPermission))
return false;
XYZPayrollPermission p = (XYZPayrollPermission) permission;
String name = getName();
if (!name.equals("*") && !name.equals(p.getName()))
return false;
if ((mask & p.mask) != p.mask)
return false;
return true;
|
public static void | main(java.lang.String[] args)
XYZPayrollPermission sdo = new XYZPayrollPermission("sdo", "view");
XYZPayrollPermission sdoAll = new XYZPayrollPermission("sdo", "view, update");
XYZPayrollPermission su = new XYZPayrollPermission("*", "view, update");
System.out.println("sdo -> sdoAll " + sdo.implies(sdoAll));
System.out.println("sdoAll -> sdo " + sdoAll.implies(sdo));
System.out.println("sdoAll -> su " + sdoAll.implies(su));
System.out.println("su -> sdo " + su.implies(sdo));
|
public java.security.PermissionCollection | newPermissionsCollection()
return new XYZPayrollPermissionCollection();
|
private void | parse(java.lang.String action)
StringTokenizer st = new StringTokenizer(action, ",\t ");
mask = 0;
while (st.hasMoreTokens()) {
String tok = st.nextToken();
if (tok.equals("view"))
mask |= VIEW;
else if (tok.equals("update"))
mask |= UPDATE;
else throw new IllegalArgumentException("Unknown action " + tok);
}
|