src/share/classes/javax/crypto/CryptoAllPermission.java

Print this page




 119     private static final long serialVersionUID = 7450076868380144072L;
 120 
 121     // true if a CryptoAllPermission has been added
 122     private boolean all_allowed;
 123 
 124     /**
 125      * Create an empty CryptoAllPermissions object.
 126      */
 127     CryptoAllPermissionCollection() {
 128         all_allowed = false;
 129     }
 130 
 131     /**
 132      * Adds a permission to the CryptoAllPermissions.
 133      *
 134      * @param permission the Permission object to add.
 135      *
 136      * @exception SecurityException - if this CryptoAllPermissionCollection
 137      * object has been marked readonly
 138      */
 139     public void add(Permission permission)
 140     {
 141         if (isReadOnly())
 142             throw new SecurityException("attempt to add a Permission to " +
 143                                         "a readonly PermissionCollection");
 144 
 145         if (permission != CryptoAllPermission.INSTANCE)
 146             return;
 147 
 148         all_allowed = true;
 149     }
 150 
 151     /**
 152      * Check and see if this set of permissions implies the permissions
 153      * expressed in "permission".
 154      *
 155      * @param p the Permission object to compare
 156      *
 157      * @return true if the given permission is implied by this
 158      * CryptoAllPermissionCollection.
 159      */
 160     public boolean implies(Permission permission)
 161     {
 162         if (!(permission instanceof CryptoPermission)) {
 163             return false;
 164         }
 165         return all_allowed;
 166     }
 167 
 168     /**
 169      * Returns an enumeration of all the CryptoAllPermission
 170      * objects in the  container.
 171      *
 172      * @return an enumeration of all the CryptoAllPermission objects.
 173      */
 174     public Enumeration<Permission> elements() {
 175         Vector<Permission> v = new Vector<>(1);
 176         if (all_allowed) v.add(CryptoAllPermission.INSTANCE);
 177         return v.elements();
 178     }
 179 }


 119     private static final long serialVersionUID = 7450076868380144072L;
 120 
 121     // true if a CryptoAllPermission has been added
 122     private boolean all_allowed;
 123 
 124     /**
 125      * Create an empty CryptoAllPermissions object.
 126      */
 127     CryptoAllPermissionCollection() {
 128         all_allowed = false;
 129     }
 130 
 131     /**
 132      * Adds a permission to the CryptoAllPermissions.
 133      *
 134      * @param permission the Permission object to add.
 135      *
 136      * @exception SecurityException - if this CryptoAllPermissionCollection
 137      * object has been marked readonly
 138      */
 139     public void add(Permission permission) {

 140         if (isReadOnly())
 141             throw new SecurityException("attempt to add a Permission to " +
 142                                         "a readonly PermissionCollection");
 143 
 144         if (permission != CryptoAllPermission.INSTANCE)
 145             return;
 146 
 147         all_allowed = true;
 148     }
 149 
 150     /**
 151      * Check and see if this set of permissions implies the permissions
 152      * expressed in "permission".
 153      *
 154      * @param permission the Permission object to compare
 155      *
 156      * @return true if the given permission is implied by this
 157      * CryptoAllPermissionCollection.
 158      */
 159     public boolean implies(Permission permission) {

 160         if (!(permission instanceof CryptoPermission)) {
 161             return false;
 162         }
 163         return all_allowed;
 164     }
 165 
 166     /**
 167      * Returns an enumeration of all the CryptoAllPermission
 168      * objects in the  container.
 169      *
 170      * @return an enumeration of all the CryptoAllPermission objects.
 171      */
 172     public Enumeration<Permission> elements() {
 173         Vector<Permission> v = new Vector<>(1);
 174         if (all_allowed) v.add(CryptoAllPermission.INSTANCE);
 175         return v.elements();
 176     }
 177 }