FileDocCategorySizeDatePackage
PropertyPermissionCollection.javaAPI DocAndroid 1.5 API3795Wed May 06 22:41:04 BST 2009java.util

PropertyPermissionCollection

public class PropertyPermissionCollection extends PermissionCollection
A {@code PermissionCollection} for holding {@code PropertyPermission}s.
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
Hashtable
permissions
private static final ObjectStreamField[]
serialPersistentFields
Constructors Summary
Methods Summary
public voidadd(java.security.Permission perm)


    
        
        if (!isReadOnly()) {
            Permission prev = permissions.put(perm.getName(), perm);
            /*
             * If the permission already existed but with only "read" or "write"
             * set, then replace with both set.
             */
            if (prev != null && !prev.getActions().equals(perm.getActions())) {
                Permission np = new PropertyPermission(perm.getName(),
                        "read,write"); //$NON-NLS-1$
                permissions.put(perm.getName(), np);
            }
        } else {
            throw new IllegalStateException();
        }
    
public java.util.Enumerationelements()

        return permissions.elements();
    
public booleanimplies(java.security.Permission perm)

        Enumeration<Permission> elemEnum = elements();
        while (elemEnum.hasMoreElements()) {
            if ((elemEnum.nextElement()).implies(perm)) {
                return true;
            }
        }
        /*
         * At this point, the only way it can succeed is if both read and write
         * are set, and these are separately granted by two different
         * permissions with one representing a parent directory.
         */
        return perm.getActions().equals("read,write") //$NON-NLS-1$
                && implies(new PropertyPermission(perm.getName(), "read")) //$NON-NLS-1$
                && implies(new PropertyPermission(perm.getName(), "write")); //$NON-NLS-1$
    
private voidreadObject(java.io.ObjectInputStream stream)

        ObjectInputStream.GetField fields = stream.readFields();
        permissions = (Hashtable<String, Permission>) fields.get(
                "permissions", null); //$NON-NLS-1$
    
private voidwriteObject(java.io.ObjectOutputStream stream)

 //$NON-NLS-1$

          
        ObjectOutputStream.PutField fields = stream.putFields();
        fields.put("permissions", permissions); //$NON-NLS-1$
        fields.put("all_allowed", false); //$NON-NLS-1$
        stream.writeFields();