jdk/src/share/classes/java/sql/SQLPermission.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 6540 a4ae668f6125
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2005, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * when code that is running in an applet calls the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <code>DriverManager.setLogWriter</code> method or the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <code>DriverManager.setLogStream</code> (deprecated) method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * If there is no <code>SQLPermission</code> object, these methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * throw a <code>java.lang.SecurityException</code> as a runtime exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * A <code>SQLPermission</code> object contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * a name (also referred to as a "target name") but no actions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * list; there is either a named permission or there is not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * The target name is the name of the permission (see below). The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * naming convention follows the  hierarchical property naming convention.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * In addition, an asterisk
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * may appear at the end of the name, following a ".", or by itself, to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * signify a wildcard match. For example: <code>loadLibrary.*</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * or <code>*</code> is valid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * but <code>*loadLibrary</code> or <code>a*b</code> is not valid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * The following table lists all the possible <code>SQLPermission</code> target names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Currently, the only name allowed is <code>setLog</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * The table gives a description of what the permission allows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * and a discussion of the risks of granting code the permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <table border=1 cellpadding=5 summary="permission target name, what the permission allows, and associated risks">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <th>Permission Target Name</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <th>What the Permission Allows</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <th>Risks of Allowing this Permission</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *   <td>setLog</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *   <td>Setting of the logging stream</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *   <td>This is a dangerous permission to grant.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * The contents of the log may contain usernames and passwords,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * SQL statements, and SQL data.</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * The person running an applet decides what permissions to allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * and will run the <code>Policy Tool</code> to create an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <code>SQLPermission</code> in a policy file.  A programmer does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * not use a constructor directly to create an instance of <code>SQLPermission</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * but rather uses a tool.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * @see java.security.BasicPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * @see java.security.Permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * @see java.security.Permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * @see java.security.PermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * @see java.lang.SecurityManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
public final class SQLPermission extends BasicPermission {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Creates a new <code>SQLPermission</code> object with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * The name is the symbolic name of the <code>SQLPermission</code>; currently,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * the only name allowed is "setLog".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @param name the name of this <code>SQLPermission</code> object, which must
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
         *             be <code>setLog</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @throws NullPointerException if <code>name</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @throws IllegalArgumentException if <code>name</code> is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public SQLPermission(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Creates a new <code>SQLPermission</code> object with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * The name is the symbolic name of the <code>SQLPermission</code>; the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * actions <code>String</code> is currently unused and should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
         * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param name the name of this <code>SQLPermission</code> object, which must
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *             be <code>setLog</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param actions should be <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @throws NullPointerException if <code>name</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @throws IllegalArgumentException if <code>name</code> is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public SQLPermission(String name, String actions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        super(name, actions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Private serial version unique ID to ensure serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    static final long serialVersionUID = -1439323187199563495L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
}