< prev index next >

## src/java.base/share/classes/java/security/Policy.java

Print this page

     66  * The policy data may be stored, for example, in a flat ASCII file,
     67  * in a serialized binary file of the Policy class, or in a database.
     68  *
     69  * <p> The {@code refresh} method causes the policy object to
     70  * refresh/reload its data.  This operation is implementation-dependent.
     71  * For example, if the policy object stores its data in configuration files,
     72  * calling {@code refresh} will cause it to re-read the configuration
     73  * policy files.  If a refresh operation is not supported, this method does
     74  * nothing.  Note that refreshed policy may not have an effect on classes
     75  * in a particular ProtectionDomain. This is dependent on the Policy
     76  * provider's implementation of the {@code implies}
     77  * method and its PermissionCollection caching strategy.
     78  *
     79  * @author Roland Schemers
     80  * @author Gary Ellison
     81  * @since 1.2
     82  * @see java.security.Provider
     83  * @see java.security.ProtectionDomain
     84  * @see java.security.Permission
     85  * @see java.security.Security security properties

     86  */
     87

     88 public abstract class Policy {
     89
     90     /**
     91      * Constructor for subclasses to call.
     92      */
     93     public Policy() {}
     94
     95     /**
     96      * A read-only empty PermissionCollection instance.
     97      * @since 1.6
     98      */
     99     public static final PermissionCollection UNSUPPORTED_EMPTY_COLLECTION =
    100                         new UnsupportedEmptyCollection();
    101
    102     // Information about the system-wide policy.
    103     private static class PolicyInfo {
    104         // the system-wide policy
    105         final Policy policy;
    106         // a flag indicating if the system-wide policy has been initialized
    107         final boolean initialized;
    793             return spi.engineGetPermissions(codesource);
    794         }
    795         @Override
    796         public PermissionCollection getPermissions(ProtectionDomain domain) {
    797             return spi.engineGetPermissions(domain);
    798         }
    799         @Override
    800         public boolean implies(ProtectionDomain domain, Permission perm) {
    801             return spi.engineImplies(domain, perm);
    802         }
    803         @Override
    804         public void refresh() {
    805             spi.engineRefresh();
    806         }
    807     }
    808
    809     /**
    810      * This represents a marker interface for Policy parameters.
    811      *
    812      * @since 1.6

    813      */

    814     public static interface Parameters { }
    815
    816     /**
    817      * This class represents a read-only empty PermissionCollection object that
    818      * is returned from the {@code getPermissions(CodeSource)} and
    819      * {@code getPermissions(ProtectionDomain)}
    820      * methods in the Policy class when those operations are not
    821      * supported by the Policy implementation.
    822      */
    823     private static class UnsupportedEmptyCollection
    824         extends PermissionCollection {
    825
    826         @java.io.Serial
    827         private static final long serialVersionUID = -8492269157353014774L;
    828
    829         private Permissions perms;
    830
    831         /**
    832          * Create a read-only empty PermissionCollection object.
    833          */
     66  * The policy data may be stored, for example, in a flat ASCII file,
     67  * in a serialized binary file of the Policy class, or in a database.
     68  *
     69  * <p> The {@code refresh} method causes the policy object to
     70  * refresh/reload its data.  This operation is implementation-dependent.
     71  * For example, if the policy object stores its data in configuration files,
     72  * calling {@code refresh} will cause it to re-read the configuration
     73  * policy files.  If a refresh operation is not supported, this method does
     74  * nothing.  Note that refreshed policy may not have an effect on classes
     75  * in a particular ProtectionDomain. This is dependent on the Policy
     76  * provider's implementation of the {@code implies}
     77  * method and its PermissionCollection caching strategy.
     78  *
     79  * @author Roland Schemers
     80  * @author Gary Ellison
     81  * @since 1.2
     82  * @see java.security.Provider
     83  * @see java.security.ProtectionDomain
     84  * @see java.security.Permission
     85  * @see java.security.Security security properties
     86  * @deprecated This class is only useful in conjunction with
     87  *       {@linkplain SecurityManager the Security Manager}, which is deprecated
     88  *       and subject to removal in a future release. Consequently, this class
     89  *       is also deprecated and subject to removal. There is no replacement for
     90  *       the Security Manager or this class.
     91  */
     92
     93 @Deprecated(since="17", forRemoval=true)
     94 public abstract class Policy {
     95
     96     /**
     97      * Constructor for subclasses to call.
     98      */
     99     public Policy() {}
    100
    101     /**
    102      * A read-only empty PermissionCollection instance.
    103      * @since 1.6
    104      */
    105     public static final PermissionCollection UNSUPPORTED_EMPTY_COLLECTION =
    106                         new UnsupportedEmptyCollection();
    107
    108     // Information about the system-wide policy.
    109     private static class PolicyInfo {
    110         // the system-wide policy
    111         final Policy policy;
    112         // a flag indicating if the system-wide policy has been initialized
    113         final boolean initialized;
    799             return spi.engineGetPermissions(codesource);
    800         }
    801         @Override
    802         public PermissionCollection getPermissions(ProtectionDomain domain) {
    803             return spi.engineGetPermissions(domain);
    804         }
    805         @Override
    806         public boolean implies(ProtectionDomain domain, Permission perm) {
    807             return spi.engineImplies(domain, perm);
    808         }
    809         @Override
    810         public void refresh() {
    811             spi.engineRefresh();
    812         }
    813     }
    814
    815     /**
    816      * This represents a marker interface for Policy parameters.
    817      *
    818      * @since 1.6
    819      * @deprecated This class is only useful in conjunction with
    820      *       {@linkplain SecurityManager the Security Manager}, which is
    821      *       deprecated and subject to removal in a future release.
    822      *       Consequently, this class is also deprecated and subject to removal.
    823      *       There is no replacement for the Security Manager or this class.
    824      */
    825     @Deprecated(since="17", forRemoval=true)
    826     public static interface Parameters { }
    827
    828     /**
    829      * This class represents a read-only empty PermissionCollection object that
    830      * is returned from the {@code getPermissions(CodeSource)} and
    831      * {@code getPermissions(ProtectionDomain)}
    832      * methods in the Policy class when those operations are not
    833      * supported by the Policy implementation.
    834      */
    835     private static class UnsupportedEmptyCollection
    836         extends PermissionCollection {
    837
    838         @java.io.Serial
    839         private static final long serialVersionUID = -8492269157353014774L;
    840
    841         private Permissions perms;
    842
    843         /**
    844          * Create a read-only empty PermissionCollection object.
    845          */

< prev index next >