jdk/src/share/classes/java/sql/SQLPermission.java
author lancea
Thu, 27 Jun 2013 15:07:56 -0400
changeset 18564 f9db68ff2cbb
parent 17199 28853592ce2b
child 20880 1b610151b316
permissions -rw-r--r--
8017471: Fix JDBC -Xdoclint public errors Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
17199
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
     2
 * Copyright (c) 1999, 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.sql;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * The permission for which the <code>SecurityManager</code> will check
17199
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
    33
 * when code that is running an application with a
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    34
 * <code>SecurityManager</code> enabled, calls the
17199
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
    35
 * {@code DriverManager.deregisterDriver} method,
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    36
 * <code>DriverManager.setLogWriter</code> method,
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    37
 * <code>DriverManager.setLogStream</code> (deprecated) method,
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    38
 * {@code SyncFactory.setJNDIContext} method,
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    39
 * {@code SyncFactory.setLogger} method,
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    40
 * {@code Connection.setNetworktimeout} method,
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    41
 * or the <code>Connection.abort</code> method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * If there is no <code>SQLPermission</code> object, these methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * throw a <code>java.lang.SecurityException</code> as a runtime exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * A <code>SQLPermission</code> object contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * a name (also referred to as a "target name") but no actions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * list; there is either a named permission or there is not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * The target name is the name of the permission (see below). The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * naming convention follows the  hierarchical property naming convention.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * In addition, an asterisk
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * may appear at the end of the name, following a ".", or by itself, to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * signify a wildcard match. For example: <code>loadLibrary.*</code>
14667
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents: 9262
diff changeset
    53
 * and <code>*</code> signify a wildcard match,
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents: 9262
diff changeset
    54
 * while <code>*loadLibrary</code> and <code>a*b</code> do not.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * The following table lists all the possible <code>SQLPermission</code> target names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * The table gives a description of what the permission allows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * and a discussion of the risks of granting code the permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <table border=1 cellpadding=5 summary="permission target name, what the permission allows, and associated risks">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <th>Permission Target Name</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <th>What the Permission Allows</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <th>Risks of Allowing this Permission</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *   <td>setLog</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *   <td>Setting of the logging stream</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *   <td>This is a dangerous permission to grant.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * The contents of the log may contain usernames and passwords,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * SQL statements, and SQL data.</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * </tr>
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    75
 * <tr>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    76
 * <td>callAbort</td>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    77
 *   <td>Allows the invocation of the {@code Connection} method
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    78
 *   {@code abort}</td>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    79
 *   <td>Permits an application to terminate a physical connection to a
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    80
 *  database.</td>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    81
 * </tr>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    82
 * <tr>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    83
 * <td>setSyncFactory</td>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    84
 *   <td>Allows the invocation of the {@code SyncFactory} methods
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    85
 *   {@code setJNDIContext} and {@code setLogger}</td>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    86
 *   <td>Permits an application to specify the JNDI context from which the
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    87
 *   {@code SyncProvider} implementations can be retrieved from and the logging
7284
0e3ea546be45 7001669: Typo in javadocs for SQLPermission
lancea
parents: 6540
diff changeset
    88
 *   object to be used by the {@code SyncProvider} implementation.</td>
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    89
 * </tr>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    91
 * <tr>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    92
 * <td>setNetworkTimeout</td>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    93
 *   <td>Allows the invocation of the {@code Connection} method
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    94
 *   {@code setNetworkTimeout}</td>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    95
 *   <td>Permits an application to specify the maximum period a
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    96
 * <code>Connection</code> or
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    97
 * objects created from the <code>Connection</code>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    98
 * will wait for the database to reply to any one request.</td>
17199
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
    99
 * <tr>
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
   100
 * <td>deregisterDriver</td>
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
   101
 *   <td>Allows the invocation of the {@code DriverManager}
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
   102
 * method {@code deregisterDriver}</td>
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
   103
 *   <td>Permits an application to remove a JDBC driver from the list of
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
   104
 * registered Drivers and release its resources.</td>
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 14668
diff changeset
   105
 * </tr>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * </table>
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   107
 *<p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * @see java.security.BasicPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * @see java.security.Permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * @see java.security.Permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * @see java.security.PermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * @see java.lang.SecurityManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
public final class SQLPermission extends BasicPermission {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * Creates a new <code>SQLPermission</code> object with the specified name.
9262
8d4c68eccc47 7036251: Correct SQLPermission constructor javadocs for permission target names
lancea
parents: 7284
diff changeset
   121
     * The name is the symbolic name of the <code>SQLPermission</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param name the name of this <code>SQLPermission</code> object, which must
9262
8d4c68eccc47 7036251: Correct SQLPermission constructor javadocs for permission target names
lancea
parents: 7284
diff changeset
   124
     * be either {@code  setLog}, {@code callAbort}, {@code setSyncFactory},
8d4c68eccc47 7036251: Correct SQLPermission constructor javadocs for permission target names
lancea
parents: 7284
diff changeset
   125
     *  or {@code setNetworkTimeout}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @throws NullPointerException if <code>name</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @throws IllegalArgumentException if <code>name</code> is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public SQLPermission(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Creates a new <code>SQLPermission</code> object with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * The name is the symbolic name of the <code>SQLPermission</code>; the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * actions <code>String</code> is currently unused and should be
9262
8d4c68eccc47 7036251: Correct SQLPermission constructor javadocs for permission target names
lancea
parents: 7284
diff changeset
   139
     * <code>null</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @param name the name of this <code>SQLPermission</code> object, which must
9262
8d4c68eccc47 7036251: Correct SQLPermission constructor javadocs for permission target names
lancea
parents: 7284
diff changeset
   142
     * be either {@code  setLog}, {@code callAbort}, {@code setSyncFactory},
8d4c68eccc47 7036251: Correct SQLPermission constructor javadocs for permission target names
lancea
parents: 7284
diff changeset
   143
     *  or {@code setNetworkTimeout}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param actions should be <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @throws NullPointerException if <code>name</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @throws IllegalArgumentException if <code>name</code> is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public SQLPermission(String name, String actions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        super(name, actions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * Private serial version unique ID to ensure serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    static final long serialVersionUID = -1439323187199563495L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
}