final String name = ep.getName(); synchronized (this) { final int newMask = ep.action_mask; if (oldMask != newMask) { pc.put(name, new EndpointPermission(name, oldMask | newMask));
super(createName(endpoint)); setTransients(null, parseActions(actions)); Map<String, Object> props; if ((localFrameworkUUID != null) && localFrameworkUUID.equals(endpoint.getFrameworkUUID())) {
/** * Returns the hash code value for this object. * * @return Hash code value for this object. */ public int hashCode() { int h = 31 * 17 + getName().hashCode(); h = 31 * h + getActions().hashCode(); if (endpoint != null) { h = 31 * h + endpoint.hashCode(); } return h; }
/** * Package private constructor used by EndpointPermissionCollection. * * @param name class name * @param mask action mask */ EndpointPermission(String name, int mask) { super(name); setTransients(parseFilter(name), mask); this.endpoint = null; this.properties = 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)); }
/** * Determines if a {@code EndpointPermission} 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. */ public boolean implies(Permission p) { if (!(p instanceof EndpointPermission)) { return false; } EndpointPermission requested = (EndpointPermission) p; if (endpoint != 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 (endpoint != 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(); }
/** * Create a new EndpointPermission with the specified filter. * * <p> * The filter will be evaluated against the endpoint properties of a * requested EndpointPermission. * * <p> * There are three possible actions: {@code read}, {@code import} and * {@code export}. The {@code read} action allows the owner of this * permission to see the presence of distributed services. The * {@code import} action allows the owner of this permission to import an * endpoint. The {@code export} action allows the owner of this permission * to export a service. * * @param filterString The filter string or "*" to match all * endpoints. * @param actions The actions {@code read}, {@code import}, or * {@code export}. * @throws IllegalArgumentException If the filter has an invalid syntax or * the actions are not valid. */ public EndpointPermission(String filterString, String actions) { this(filterString, parseActions(actions)); }
/** * Internal implies method. Used by the implies and the permission * collection implies methods. * * @param requested The requested EndpointPermission which has already be * validated as a proper argument. The requested EndpointPermission * must not have a filter expression. * @param effective The effective actions with which to start. * @return {@code true} if the specified permission is implied by this * object; {@code false} otherwise. */ boolean implies0(EndpointPermission requested, int effective) { /* check actions first - much faster */ effective |= action_mask; final int desired = requested.action_mask; if ((effective & desired) != desired) { return false; } /* if we have no filter */ Filter f = filter; if (f == null) { // it's "*" return true; } return f.matchCase(requested.getProperties()); }
void addExportedEndpoints(Collection<ExportReference> collection) { SecurityManager securityManager = System.getSecurityManager(); String frameworkUUID = getFrameworkUUID(getBundleContext()); synchronized (m_exportedEndpoints) { for (Entry<EndpointDescription, Set<ExportedEndpointImpl>> entry : m_exportedEndpoints.entrySet()) { try { if (securityManager != null) { securityManager.checkPermission(new EndpointPermission(entry.getKey(), frameworkUUID, READ)); } collection.addAll(entry.getValue()); } catch (SecurityException e) {} } } }
/** * Determines the equality of two EndpointPermission objects. * * Checks that specified object has the same name, actions and endpoint as * this {@code EndpointPermission}. * * @param obj The object to test for equality. * @return true If obj is a {@code EndpointPermission}, and has the same * name, actions and endpoint as this {@code EndpointPermission} * object; {@code false} otherwise. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof EndpointPermission)) { return false; } EndpointPermission ep = (EndpointPermission) obj; return (action_mask == ep.action_mask) && getName().equals(ep.getName()) && ((endpoint == ep.endpoint) || ((endpoint != null) && (ep.endpoint != null) && endpoint.equals(ep.endpoint))); }
/** * 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)); }
/** * Package private constructor used by EndpointPermissionCollection. * * @param name class name * @param mask action mask */ EndpointPermission(String name, int mask) { super(name); setTransients(parseFilter(name), mask); this.endpoint = null; this.properties = null; }
if (iter.next().implies0(requested, effective)) { return true;
/** * 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 (endpoint != 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(); }
/** * Create a new EndpointPermission with the specified filter. * * <p> * The filter will be evaluated against the endpoint properties of a * requested EndpointPermission. * * <p> * There are three possible actions: {@code read}, {@code import} and * {@code export}. The {@code read} action allows the owner of this * permission to see the presence of distributed services. The * {@code import} action allows the owner of this permission to import an * endpoint. The {@code export} action allows the owner of this permission * to export a service. * * @param filterString The filter string or "*" to match all * endpoints. * @param actions The actions {@code read}, {@code import}, or * {@code export}. * @throws IllegalArgumentException If the filter has an invalid syntax or * the actions are not valid. */ public EndpointPermission(String filterString, String actions) { this(filterString, parseActions(actions)); }
/** * Internal implies method. Used by the implies and the permission * collection implies methods. * * @param requested The requested EndpointPermission which has already be * validated as a proper argument. The requested EndpointPermission * must not have a filter expression. * @param effective The effective actions with which to start. * @return {@code true} if the specified permission is implied by this * object; {@code false} otherwise. */ boolean implies0(EndpointPermission requested, int effective) { /* check actions first - much faster */ effective |= action_mask; final int desired = requested.action_mask; if ((effective & desired) != desired) { return false; } /* if we have no filter */ Filter f = filter; if (f == null) { // it's "*" return true; } return f.matchCase(requested.getProperties()); }
void addImportedEndpoints(Collection<ImportReference> collection) { SecurityManager securityManager = System.getSecurityManager(); String frameworkUUID = getFrameworkUUID(getBundleContext()); synchronized (m_importedEndpoints) { for (Entry<EndpointDescription, Set<ImportedEndpointImpl>> entry : m_importedEndpoints.entrySet()) { try { if (securityManager != null) { securityManager.checkPermission(new EndpointPermission(entry.getKey(), frameworkUUID, READ)); } collection.addAll(entry.getValue()); } catch (SecurityException e) {} } } }
/** * Determines the equality of two EndpointPermission objects. * * Checks that specified object has the same name, actions and endpoint as * this {@code EndpointPermission}. * * @param obj The object to test for equality. * @return true If obj is a {@code EndpointPermission}, and has the same * name, actions and endpoint as this {@code EndpointPermission} * object; {@code false} otherwise. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof EndpointPermission)) { return false; } EndpointPermission ep = (EndpointPermission) obj; return (action_mask == ep.action_mask) && getName().equals(ep.getName()) && ((endpoint == ep.endpoint) || ((endpoint != null) && (ep.endpoint != null) && endpoint.equals(ep.endpoint))); }
/** * 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)); }