FileDocCategorySizeDatePackage
Permission.javaAPI DocAndroid 1.5 API6285Wed May 06 22:41:06 BST 2009java.security

Permission

public abstract class Permission extends Object implements Serializable, Guard
{@code Permission} is the common base class of all permissions that participate in the access control security framework around {@link AccessController} and {@link AccessControlContext}. A permission constitutes of a name and associated actions.
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
private final String
name
Constructors Summary
public Permission(String name)
Constructs a new instance of {@code Permission} with its name.

param
name the name of the permission.
since
Android 1.0


                                                                                                            
        

                                                          
       

                                                                                                      
       

                                                                                    
        

                                         
       
        this.name = name;
    
Methods Summary
public voidcheckGuard(java.lang.Object obj)
Invokes {@link SecurityManager#checkPermission(Permission)} with this permission as its argument. This method implements the {@link Guard} interface.

param
obj as specified in {@link Guard#checkGuard(Object)} but ignored in this implementation.
throws
SecurityException if this permission is not granted.
see
Guard
see
SecurityManager#checkPermission(Permission)
since
Android 1.0

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(this);
        }
    
public abstract booleanequals(java.lang.Object obj)
Compares the specified object with this {@code Permission} for equality and returns {@code true} if the specified object is equal, {@code false} otherwise.

The {@link #implies(Permission)} method should be used for making access control checks.

param
obj object to be compared for equality with this {@code Permission}.
return
{@code true} if the specified object is equal to this {@code Permission}, otherwise {@code false}.
since
Android 1.0

public abstract java.lang.StringgetActions()
Returns a comma separated string identifying the actions associated with this permission. The returned actions are in canonical form. For example:
sp0 = new SocketPermission("www.google.com", "connect,resolve")
sp1 = new SocketPermission("www.google.com", "resolve,connect")
sp0.getActions().equals(sp1.getActions()) //yields true
Both permissions return "connect,resolve" (in that order) if {@code #getActions()} is invoked. Returns an empty String, if no actions are associated with this permission.

return
the actions associated with this permission or an empty string if no actions are associated with this permission.
since
Android 1.0

public final java.lang.StringgetName()
Returns the name of this permission.

return
the name of this permission.
since
Android 1.0

        return name;
    
public abstract inthashCode()
Returns the hash code value for this {@code Permission}. Returns the same hash code for {@code Permission}s that are equal to each other as required by the general contract of {@link Object#hashCode}.

return
the hash code value for this {@code Permission}.
see
Object#equals(Object)
see
Permission#equals(Object)
since
Android 1.0

public abstract booleanimplies(java.security.Permission permission)
Indicates whether the specified permission is implied by this permission. The {@link AccessController} uses this method to check whether permission protected access is allowed with the present policy.

param
permission the permission to check against this permission.
return
{@code true} if the specified permission is implied by this permission, {@code false} otherwise.
since
Android 1.0

public java.security.PermissionCollectionnewPermissionCollection()
Returns a specific {@link PermissionCollection} container for permissions of this type. Returns {@code null} if any permission collection can be used.

Subclasses may override this method to return an appropriate collection for the specific permissions they implement.

return
an empty {@link PermissionCollection} or {@code null} if any permission collection can be used.
since
Android 1.0

        return null;
    
public java.lang.StringtoString()
Returns a string containing a concise, human-readable description of the this {@code Permission} including its name and its actions.

return
a printable representation for this {@code Permission}.
since
Android 1.0

        String actions = getActions();
        actions = (actions == null || actions.length() == 0) ? "" : " " //$NON-NLS-1$ //$NON-NLS-2$
                + getActions();
        return "(" + getClass().getName() + " " + getName() + actions + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$