/** * Returns a new {@code PermissionCollection} object for storing * {@code UserAdminPermission} objects. * * @return a new {@code PermissionCollection} object suitable for storing * {@code UserAdminPermission} objects. */ public PermissionCollection newPermissionCollection() { return new UserAdminPermissionCollection(); }
/** * Package private constructor used by {@code UserAdminPermissionCollection} * . * * @param name class name * @param mask action mask */ UserAdminPermission(String name, int mask) { super(name); setTransients(mask); }
/** * Creates a new {@code UserAdminPermission} with the specified name and * actions. {@code name} is either the reserved string "admin" or * the name of a credential or property, and {@code actions} contains a * comma-separated list of the actions granted on the specified name. Valid * actions are {@code changeProperty},{@code changeCredential}, and * getCredential. * * @param name the name of this {@code UserAdminPermission} * @param actions the action string. * * @throws IllegalArgumentException If {@code name} equals "admin" * and {@code actions} are specified. */ public UserAdminPermission(String name, String actions) { this(name, parseActions(actions)); }
if (!(permission instanceof UserAdminPermission)) throw new IllegalArgumentException("Invalid permission: " + permission); if (isReadOnly()) { throw new SecurityException("Attempt to add a Permission to a " + "readonly PermissionCollection"); final String name = uap.getName(); synchronized (this) { final UserAdminPermission existing = (UserAdminPermission) permissions.get(name); if (existing != null) { int oldMask = existing.getActionsMask(); int newMask = uap.getActionsMask(); if (oldMask != newMask) { permissions.put(name, new UserAdminPermission(name, oldMask | newMask));
if (i >= 12 && match_get(a, i - 10) && match_credential(a, i)) { matchlen = 13; mask |= ACTION_GET_CREDENTIAL; } else if (i >= 13 && match_change(a, i - 8) && match_property(a, i)) { matchlen = 14; mask |= ACTION_CHANGE_PROPERTY; } else if (i >= 15 && match_change(a, i - 10) && match_credential(a, i)) { matchlen = 16; mask |= ACTION_CHANGE_CREDENTIAL;
/** * Returns the hash code value for this object. * * @return A hash code value for this object. */ public int hashCode() { int h = 31 * 17 + getName().hashCode(); h = 31 * h + getActions().hashCode(); return h; }
private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the action, then initialize the rest s.defaultReadObject(); setTransients(parseActions(actions)); }
/** * Checks two {@code UserAdminPermission} objects for equality. Checks that * {@code obj} is a {@code UserAdminPermission}, and has the same name and * actions as this object. * * @param obj the object to be compared for equality with this object. * * @return {@code true} if {@code obj} is a {@code UserAdminPermission} * object, and has the same name and actions as this * {@code UserAdminPermission} object. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof UserAdminPermission)) { return false; } UserAdminPermission uap = (UserAdminPermission) obj; return (getActionsMask() == uap.getActionsMask()) && getName().equals(uap.getName()); }
/** * writeObject is called to save the state of this object to a stream. The * actions are serialized, and the superclass takes care of the name. */ private synchronized void writeObject(java.io.ObjectOutputStream s) throws IOException { // Write out the actions. The superclass takes care of the name // call getActions to make sure actions field is initialized if (actions == null) getActions(); s.defaultWriteObject(); }
if (p instanceof UserAdminPermission) { UserAdminPermission requested = (UserAdminPermission) p; int mask = getActionsMask(); int targetMask = requested.getActionsMask(); return // Check that the we have the requested action ((targetMask & mask) == targetMask) &&
/** * Called by constructors and when deserialized. * * @param mask action mask */ private synchronized void setTransients(int mask) { if (getName().equals(ADMIN)) { if (mask != ACTION_NONE) { throw new IllegalArgumentException("Actions specified for " + "no-action " + "UserAdminPermission"); } } else { if ((mask == ACTION_NONE) || ((mask & ACTION_ALL) != mask)) { throw new IllegalArgumentException("Invalid action string"); } } action_mask = mask; }
/** * Returns a string describing this {@code UserAdminPermission} object. This * string must be in {@code PermissionInfo} encoded format. * * @return The {@code PermissionInfo} encoded string for this * {@code UserAdminPermission} object. * @see "org.osgi.service.permissionadmin.PermissionInfo.getEncoded()" */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append('('); sb.append(getClass().getName()); sb.append(" \""); sb.append(getName()); String a = getActions(); if (a.length() > 0) { sb.append("\" \""); sb.append(a); } sb.append("\")"); return sb.toString(); } }
private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the action, then initialize the rest s.defaultReadObject(); setTransients(parseActions(actions)); }
String name = requested.getName(); final int desired = requested.getActionsMask(); UserAdminPermission x; int effective = 0; x = (UserAdminPermission) permissions.get("*"); if (x != null) { effective |= x.getActionsMask(); if ((effective & desired) == desired) { return true; effective |= x.getActionsMask(); if ((effective & desired) == desired) { return true; effective |= x.getActionsMask(); if ((effective & desired) == desired) { return true;
/** * Returns a new <code>PermissionCollection</code> object for storing * <code>UserAdminPermission</code> objects. * * @return a new <code>PermissionCollection</code> object suitable for * storing <code>UserAdminPermission</code> objects. */ public PermissionCollection newPermissionCollection() { return new UserAdminPermissionCollection(); }
/** * Package private constructor used by * <code>UserAdminPermissionCollection</code>. * * @param name class name * @param mask action mask */ UserAdminPermission(String name, int mask) { super(name); setTransients(mask); }
/** * writeObject is called to save the state of this object to a stream. The * actions are serialized, and the superclass takes care of the name. */ private synchronized void writeObject(java.io.ObjectOutputStream s) throws IOException { // Write out the actions. The superclass takes care of the name // call getActions to make sure actions field is initialized if (actions == null) getActions(); s.defaultWriteObject(); }
/** * Creates a new <code>UserAdminPermission</code> with the specified name * and actions. <code>name</code> is either the reserved string * "admin" or the name of a credential or property, and * <code>actions</code> contains a comma-separated list of the actions * granted on the specified name. Valid actions are * <code>changeProperty</code>,<code>changeCredential</code>, and * getCredential. * * @param name the name of this <code>UserAdminPermission</code> * @param actions the action string. * * @throws IllegalArgumentException If <code>name</code> equals * "admin" and <code>actions</code> are specified. */ public UserAdminPermission(String name, String actions) { this(name, parseActions(actions)); }
StringBuffer sb = new StringBuffer(); boolean comma = false; int mask = getActionsMask(); if ((mask & ACTION_CHANGE_CREDENTIAL) == ACTION_CHANGE_CREDENTIAL) { sb.append(CHANGE_CREDENTIAL);
/** * Returns the hash code value for this object. * * @return A hash code value for this object. */ public int hashCode() { int h = 31 * 17 + getName().hashCode(); h = 31 * h + getActions().hashCode(); return h; }