Refine search
final String name = sp.getName(); final Filter f = sp.filter; synchronized (this) { final int newMask = sp.action_mask; if (oldMask != newMask) { pc.put(name, new ServicePermission(name, oldMask | newMask));
/** * Returns the hash code value for this object. * * @return Hash code value for this object. */ @Override public int hashCode() { int h = 31 * 17 + getName().hashCode(); h = 31 * h + getActions().hashCode(); if (service != null) { h = 31 * h + service.hashCode(); } return h; }
/** * Creates a new requested {@code ServicePermission} object to be used by * code that must perform {@code checkPermission} for the {@code get} * action. {@code ServicePermission} objects created with this constructor * cannot be added to a {@code ServicePermission} permission collection. * * @param reference The requested service. * @param actions The action {@code get}. * @throws IllegalArgumentException If the specified action is not * {@code get} or reference is {@code null}. * @since 1.5 */ public ServicePermission(ServiceReference<?> reference, String actions) { super(createName(reference)); setTransients(null, parseActions(actions)); this.service = reference; this.objectClass = (String[]) reference.getProperty(Constants.OBJECTCLASS); if ((action_mask & ACTION_ALL) != ACTION_GET) { throw new IllegalArgumentException("invalid action string"); } }
/** * Package private constructor used by ServicePermissionCollection. * * @param name class name * @param mask action mask */ ServicePermission(String name, int mask) { super(name); setTransients(parseFilter(name), mask); this.service = null; this.objectClass = null; }
/** * readObject is called to restore the state of this permission from a * stream. */ private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the action, then initialize the rest s.defaultReadObject(); setTransients(parseFilter(getName()), parseActions(actions)); }
return f.matches(requested.getProperties()); String name = getName(); for (int i = 0, l = requestedNames.length; i < l; i++) { if (requestedNames[i].equals(name)) {
/** * Check for permission to get a service. */ private static void checkGetServicePermission(ServiceReference<?> reference) { SecurityManager sm = System.getSecurityManager(); if (sm == null) { return; } sm.checkPermission(new ServicePermission(reference, ServicePermission.GET)); }
/** * Determines the equality of two ServicePermission objects. * * Checks that specified object has the same class name and action as this * {@code ServicePermission}. * * @param obj The object to test for equality. * @return true if obj is a {@code ServicePermission}, and has the same * class name and actions as this {@code ServicePermission} object; * {@code false} otherwise. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ServicePermission)) { return false; } ServicePermission sp = (ServicePermission) obj; return (action_mask == sp.action_mask) && getName().equals(sp.getName()) && ((service == sp.service) || ((service != null) && (service.compareTo(sp.service) == 0))); }
/** * Determines if a {@code ServicePermission} object "implies" the specified * permission. * * @param p The target permission to check. * @return {@code true} if the specified permission is implied by this * object; {@code false} otherwise. */ @Override public boolean implies(Permission p) { if (!(p instanceof ServicePermission)) { return false; } ServicePermission requested = (ServicePermission) p; if (service != null) { return false; } // if requested permission has a filter, then it is an invalid argument if (requested.filter != null) { return false; } return implies0(requested, ACTION_NONE); }
/** * WriteObject is called to save the state of this permission 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 { if (service != null) { throw new NotSerializableException("cannot serialize"); } // 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(); }
/** * Called by constructors and when deserialized. * * @param mask action mask */ private void setTransients(Filter f, int mask) { if ((mask == ACTION_NONE) || ((mask & ACTION_ALL) != mask)) { throw new IllegalArgumentException("invalid action string"); } action_mask = mask; filter = f; if (f == null) { String name = getName(); int l = name.length(); /* if "*" or endsWith ".*" */ wildcard = ((name.charAt(l - 1) == '*') && ((l == 1) || (name.charAt(l - 2) == '.'))); if (wildcard && (l > 1)) { prefix = name.substring(0, l - 1); } } }
this(name, parseActions(actions)); if ((filter != null) && ((action_mask & ACTION_ALL) != ACTION_GET)) { throw new IllegalArgumentException("invalid action string for filter expression");
/** * readObject is called to restore the state of this permission from a * stream. */ private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the action, then initialize the rest s.defaultReadObject(); setTransients(parseFilter(getName()), parseActions(actions)); }
return f.matches(requested.getProperties()); String name = getName(); for (int i = 0, l = requestedNames.length; i < l; i++) { if (requestedNames[i].equals(name)) {
/** * Check for permission to get a service. */ private static void checkGetServicePermission(ServiceReference<?> reference) { SecurityManager sm = System.getSecurityManager(); if (sm == null) { return; } sm.checkPermission(new ServicePermission(reference, ServicePermission.GET)); }
/** * Determines the equality of two ServicePermission objects. * * Checks that specified object has the same class name and action as this * {@code ServicePermission}. * * @param obj The object to test for equality. * @return true if obj is a {@code ServicePermission}, and has the same * class name and actions as this {@code ServicePermission} object; * {@code false} otherwise. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ServicePermission)) { return false; } ServicePermission sp = (ServicePermission) obj; return (action_mask == sp.action_mask) && getName().equals(sp.getName()) && ((service == sp.service) || ((service != null) && (service.compareTo(sp.service) == 0))); }
/** * Determines if a {@code ServicePermission} object "implies" the specified * permission. * * @param p The target permission to check. * @return {@code true} if the specified permission is implied by this * object; {@code false} otherwise. */ @Override public boolean implies(Permission p) { if (!(p instanceof ServicePermission)) { return false; } ServicePermission requested = (ServicePermission) p; if (service != null) { return false; } // if requested permission has a filter, then it is an invalid argument if (requested.filter != null) { return false; } return implies0(requested, ACTION_NONE); }
/** * Package private constructor used by ServicePermissionCollection. * * @param name class name * @param mask action mask */ ServicePermission(String name, int mask) { super(name); setTransients(parseFilter(name), mask); this.service = null; this.objectClass = null; }