Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) OSGi Alliance (2005, 2012). All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.osgi.service.deploymentadmin.spi;
 
The DeploymentCustomizerPermission permission gives the right to Resource Processors to access a bundle's (residing in a Deployment Package) private area. The bundle and the Resource Processor (customizer) have to be in the same Deployment Package.

The Resource Processor that has this permission is allowed to access the bundle's private area by calling the DeploymentSession.getDataFile(org.osgi.framework.Bundle) method during the session (see DeploymentSession). After the session ends the FilePermissions are withdrawn. The Resource Processor will have FilePermission with "read", "write" and "delete" actions for the returned java.io.File that represents the the base directory of the persistent storage area and for its subdirectories.

The actions string is converted to lowercase before processing.

 
 public class DeploymentCustomizerPermission extends Permission {

 
 	private static final long			serialVersionUID	= 1L;

Constant String to the "privatearea" action.
 
 	public static final String			PRIVATEAREA"privatearea";
 
 	private static final String			delegateProperty"org.osgi.vendor.deploymentadmin";
 	private static final Constructor	constructor;
 	private final Permission			delegate;
 	static {
 		 = (Constructor) AccessController.doPrivileged(new PrivilegedAction() {
 			public Object run() {
 				String pckg = System.getProperty();
 				if (null == pckg)
 					throw new RuntimeException("Property '" +  + "' is not set");
 				try {
 					Class c = Class.forName(pckg + ".DeploymentCustomizerPermission");
 					return c.getConstructor(new Class[] {String.classString.class});
 				} catch (Exception e) {
 					throw new RuntimeException(e);
 				}
 			}
 		});
 	}

Creates a new DeploymentCustomizerPermission object for the given name and action.

The name parameter is a filter string. This filter has the same syntax as an OSGi filter but only the "name" attribute is allowed. The value of the attribute is a Bundle Symbolic Name that represents a bundle. The only allowed action is the "privatearea" action. E.g.

 Permission perm = new DeploymentCustomizerPermission(
     "(name=com.acme.bundle)", "privatearea");
 
The Resource Processor that has this permission is allowed to access the bundle's private area by calling the DeploymentSession.getDataFile(org.osgi.framework.Bundle) method. The Resource Processor will have FilePermission with "read", "write" and "delete" actions for the returned java.io.File and its subdirectories during the deployment session.

Parameters:
name Bundle Symbolic Name of the target bundle, must not be null.
actions action string (only the "privatearea" or "*" action is valid; "*" means all the possible actions), must not be null.
Throws:
java.lang.IllegalArgumentException if the filter is invalid, the list of actions contains unknown operations or one of the parameters is null
	public DeploymentCustomizerPermission(String nameString actions) {
		super(name);
		try {
			try {
				 = (Permission.newInstance(new Object[] {nameactions});
catch (InvocationTargetException e) {
			}
catch (Error e) {
			throw e;
catch (RuntimeException e) {
			throw e;
catch (Throwable e) {
			throw new RuntimeException(e);
		}
	}

Checks two DeploymentCustomizerPermission objects for equality. Two permission objects are equal if:

  • their target filters are equal (semantically and not character by character) and
  • their actions are the same

Parameters:
obj the reference object with which to compare.
Returns:
true if the two objects are equal.
See also:
java.lang.Object.equals(java.lang.Object)
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof DeploymentCustomizerPermission))
			return false;
		return .equals(dcp.delegate);
	}

Returns hash code for this permission object.

Returns:
Hash code for this permission object.
See also:
java.lang.Object.hashCode()
	public int hashCode() {
		return .hashCode();
	}

Returns the String representation of the action list.

Returns:
Action list of this permission instance. It is always "privatearea".
See also:
java.security.Permission.getActions()
	public String getActions() {
	}

Checks if this DeploymentCustomizerPermission would imply the parameter permission. This permission implies another DeploymentCustomizerPermission permission if: The value of the name attribute means Bundle Symbolic Name and not Deployment Package Symbolic Name here!

Parameters:
permission Permission to check.
Returns:
true if this DeploymentCustomizerPermission object implies the specified permission.
See also:
java.security.Permission.implies(java.security.Permission)
	public boolean implies(Permission permission) {
		if (!(permission instanceof DeploymentCustomizerPermission))
			return false;
		return .implies(dcp.delegate);
	}

Returns a new PermissionCollection object for storing DeploymentCustomizerPermission objects.

Returns:
The new PermissionCollection.
See also:
java.security.Permission.newPermissionCollection()
	}
New to GrepCode? Check out our FAQ X