jdk/src/java.base/share/classes/java/security/PolicySpi.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 18579 jdk/src/share/classes/java/security/PolicySpi.java@b678846778ad
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
     2
 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package java.security;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    31
 * for the {@code Policy} class.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * All the abstract methods in this class must be implemented by each
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * service provider who wishes to supply a Policy implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <p> Subclass implementations of this abstract class must provide
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    36
 * a public constructor that takes a {@code Policy.Parameters}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * object as an input parameter.  This constructor also must throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * an IllegalArgumentException if it does not understand the
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    39
 * {@code Policy.Parameters} input.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public abstract class PolicySpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * Check whether the policy has granted a Permission to a ProtectionDomain.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * @param domain the ProtectionDomain to check.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * @param permission check whether this permission is granted to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     *          specified domain.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @return boolean true if the permission is granted to the domain.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected abstract boolean engineImplies
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        (ProtectionDomain domain, Permission permission);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * Refreshes/reloads the policy configuration. The behavior of this method
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    62
     * depends on the implementation. For example, calling {@code refresh}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * on a file-based policy will cause the file to be re-read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * <p> The default implementation of this method does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * This method should be overridden if a refresh operation is supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * by the policy implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    protected void engineRefresh() { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Return a PermissionCollection object containing the set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * permissions granted to the specified CodeSource.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * <p> The default implementation of this method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Policy.UNSUPPORTED_EMPTY_COLLECTION object.  This method can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * overridden if the policy implementation can return a set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * permissions granted to a CodeSource.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @param codesource the CodeSource to which the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *          PermissionCollection has been granted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @return a set of permissions granted to the specified CodeSource.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *          If this operation is supported, the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *          set of permissions must be a new mutable instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *          and it must support heterogeneous Permission types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *          If this operation is not supported,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *          Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    protected PermissionCollection engineGetPermissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                                        (CodeSource codesource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        return Policy.UNSUPPORTED_EMPTY_COLLECTION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * Return a PermissionCollection object containing the set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * permissions granted to the specified ProtectionDomain.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * <p> The default implementation of this method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Policy.UNSUPPORTED_EMPTY_COLLECTION object.  This method can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * overridden if the policy implementation can return a set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * permissions granted to a ProtectionDomain.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @param domain the ProtectionDomain to which the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *          PermissionCollection has been granted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @return a set of permissions granted to the specified ProtectionDomain.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *          If this operation is supported, the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *          set of permissions must be a new mutable instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *          and it must support heterogeneous Permission types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *          If this operation is not supported,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *          Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    protected PermissionCollection engineGetPermissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                                        (ProtectionDomain domain) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        return Policy.UNSUPPORTED_EMPTY_COLLECTION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
}