/** * Returns a new {@code PermissionCollection} object suitable for storing * {@code ConfigurationPermission}s. * * @return A new {@code PermissionCollection} object. */ public PermissionCollection newPermissionCollection() { return new ConfigurationPermissionCollection(); }
/** * Package private constructor used by ConfigurationPermissionCollection. * * @param name location string * @param mask action mask */ ConfigurationPermission(String name, int mask) { super(name); setTransients(mask); }
/** * Create a new ConfigurationPermission. * * @param name Name of the permission. Wildcards ({@code '*'}) are allowed * in the name. During {@link #implies(Permission)}, the name is * matched to the requested permission using the substring matching * rules used by {@link Filter}s. * @param actions Comma separated list of {@link #CONFIGURE}, * {@link #TARGET} (case insensitive). */ public ConfigurationPermission(String name, String actions) { this(name, parseActions(actions)); }
private String getConfigurationFromConfigAdmin(ConfigKey pkey) { ConfigurationAdmin configAdmin = (ConfigurationAdmin) configAdminTracker.getService(); if (configAdmin == null) { return null; } try { Configuration config = configAdmin.getConfiguration(CONFIG_ADMIN_PID); if (config == null) { return null; } Dictionary<?, ?> props = config.getProperties(); if (props == null) { return null; } return (String) props.get(CONFIG_PREFIX + "." + pkey.getKeyValue()); } catch (IOException e) { return null; } }
@Override public void configAdminUpdate(String pid, Map<String, String> data) { ServiceReference sref = bundleContext.getServiceReference(ConfigurationAdmin.class.getName()); if (sref == null) { throw new IllegalStateException("The configuration admin service cannot be found."); } try { ConfigurationAdmin ca = (ConfigurationAdmin) bundleContext.getService(sref); if (ca == null) { throw new IllegalStateException("The configuration admin service cannot be found."); } Configuration config = ca.getConfiguration(pid, null); config.update(new Hashtable<String, String>(data)); } catch (IOException ioe) { throw new RuntimeException(ioe); } finally { bundleContext.ungetService(sref); } } }
Configuration[] configurations = configAdmin.listConfigurations("(service.pid=jmx.acl*)"); if (configurations == null) { return;
if (isReadOnly()) throw new SecurityException("attempt to add a Permission to a " + "readonly PermissionCollection"); final String name = cp.getName(); synchronized (this) { Map<String, ConfigurationPermission> pc = permissions; final int newMask = cp.action_mask; if (oldMask != newMask) { pc.put(name, new ConfigurationPermission(name, oldMask | newMask));
/** * 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(); return h; }
/** * Called by constructors and when deserialized. * * @param mask action mask */ private void setTransients(int mask) { if ((mask == ACTION_NONE) || ((mask & ACTION_ALL) != mask)) { throw new IllegalArgumentException("invalid action string"); } action_mask = mask; substrings = parseSubstring(getName()); }
/** * 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 data, then initialize the transients s.defaultReadObject(); setTransients(parseActions(actions)); } }
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField gfields = in.readFields(); boolean hasElement = gfields.get("hasElement", false); if (hasElement) { // old format permissions = new HashMap<String, ConfigurationPermission>(); permissions.put("*", new ConfigurationPermission("*", ConfigurationPermission.CONFIGURE)); all_allowed = true; } else { permissions = (HashMap<String, ConfigurationPermission>) gfields.get("permissions", new HashMap<String, ConfigurationPermission>()); all_allowed = gfields.get("all_allowed", false); } } }
/** * Determines the equality of two {@code ConfigurationPermission} objects. * <p> * Two {@code ConfigurationPermission} objects are equal. * * @param obj The object being compared for equality with this object. * @return {@code true} if {@code obj} is equivalent to this * {@code ConfigurationPermission}; {@code false} otherwise. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ConfigurationPermission)) { return false; } ConfigurationPermission cp = (ConfigurationPermission) obj; return (action_mask == cp.action_mask) && getName().equals(cp.getName()); }
/** * WriteObject is called to save the state of this permission 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(); }
/** * Determines if a {@code ConfigurationPermission} 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 ConfigurationPermission)) { return false; } ConfigurationPermission requested = (ConfigurationPermission) p; return implies0(requested, ACTION_NONE); }
protected void activate(final ComponentContext cContext) throws Exception { context = cContext.getBundleContext(); repositories = new ArrayList<Repository>(); installedSubsystems = new ArrayList<Subsystem>(); config = getConfigurationAdmin().getConfiguration("installedRepositories"); installedRepos = config.getProperties(); if (installedRepos == null) { installedRepos = new Hashtable(); } populateRepositories(); }
/** * 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(); return h; }
public Object nextElement() { if (more) { more = false; return new ConfigurationPermission("*", ConfigurationPermission.CONFIGURE); } else { throw new NoSuchElementException(); } } };
/** * Returns a new <code>PermissionCollection</code> object suitable for * storing <code>ConfigurationPermission</code>s. * * @return A new <code>PermissionCollection</code> object. */ public PermissionCollection newPermissionCollection() { return new ConfigurationPermissionCollection(); } }
if (perm.implies0(requested, effective)) { return true;