Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/sql/SQLPermission.java
38829 views
/*1* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/242526package java.sql;2728import java.security.*;2930/**31* The permission for which the <code>SecurityManager</code> will check32* when code that is running an application with a33* <code>SecurityManager</code> enabled, calls the34* {@code DriverManager.deregisterDriver} method,35* <code>DriverManager.setLogWriter</code> method,36* <code>DriverManager.setLogStream</code> (deprecated) method,37* {@code SyncFactory.setJNDIContext} method,38* {@code SyncFactory.setLogger} method,39* {@code Connection.setNetworktimeout} method,40* or the <code>Connection.abort</code> method.41* If there is no <code>SQLPermission</code> object, these methods42* throw a <code>java.lang.SecurityException</code> as a runtime exception.43* <P>44* A <code>SQLPermission</code> object contains45* a name (also referred to as a "target name") but no actions46* list; there is either a named permission or there is not.47* The target name is the name of the permission (see below). The48* naming convention follows the hierarchical property naming convention.49* In addition, an asterisk50* may appear at the end of the name, following a ".", or by itself, to51* signify a wildcard match. For example: <code>loadLibrary.*</code>52* and <code>*</code> signify a wildcard match,53* while <code>*loadLibrary</code> and <code>a*b</code> do not.54* <P>55* The following table lists all the possible <code>SQLPermission</code> target names.56* The table gives a description of what the permission allows57* and a discussion of the risks of granting code the permission.58*59*60* <table border=1 cellpadding=5 summary="permission target name, what the permission allows, and associated risks">61* <tr>62* <th>Permission Target Name</th>63* <th>What the Permission Allows</th>64* <th>Risks of Allowing this Permission</th>65* </tr>66*67* <tr>68* <td>setLog</td>69* <td>Setting of the logging stream</td>70* <td>This is a dangerous permission to grant.71* The contents of the log may contain usernames and passwords,72* SQL statements, and SQL data.</td>73* </tr>74* <tr>75* <td>callAbort</td>76* <td>Allows the invocation of the {@code Connection} method77* {@code abort}</td>78* <td>Permits an application to terminate a physical connection to a79* database.</td>80* </tr>81* <tr>82* <td>setSyncFactory</td>83* <td>Allows the invocation of the {@code SyncFactory} methods84* {@code setJNDIContext} and {@code setLogger}</td>85* <td>Permits an application to specify the JNDI context from which the86* {@code SyncProvider} implementations can be retrieved from and the logging87* object to be used by the {@code SyncProvider} implementation.</td>88* </tr>89*90* <tr>91* <td>setNetworkTimeout</td>92* <td>Allows the invocation of the {@code Connection} method93* {@code setNetworkTimeout}</td>94* <td>Permits an application to specify the maximum period a95* <code>Connection</code> or96* objects created from the <code>Connection</code>97* will wait for the database to reply to any one request.</td>98* <tr>99* <td>deregisterDriver</td>100* <td>Allows the invocation of the {@code DriverManager}101* method {@code deregisterDriver}</td>102* <td>Permits an application to remove a JDBC driver from the list of103* registered Drivers and release its resources.</td>104* </tr>105* </table>106*<p>107* @since 1.3108* @see java.security.BasicPermission109* @see java.security.Permission110* @see java.security.Permissions111* @see java.security.PermissionCollection112* @see java.lang.SecurityManager113*114*/115116public final class SQLPermission extends BasicPermission {117118/**119* Creates a new <code>SQLPermission</code> object with the specified name.120* The name is the symbolic name of the <code>SQLPermission</code>.121*122* @param name the name of this <code>SQLPermission</code> object, which must123* be either {@code setLog}, {@code callAbort}, {@code setSyncFactory},124* {@code deregisterDriver}, or {@code setNetworkTimeout}125* @throws NullPointerException if <code>name</code> is <code>null</code>.126* @throws IllegalArgumentException if <code>name</code> is empty.127128*/129130public SQLPermission(String name) {131super(name);132}133134/**135* Creates a new <code>SQLPermission</code> object with the specified name.136* The name is the symbolic name of the <code>SQLPermission</code>; the137* actions <code>String</code> is currently unused and should be138* <code>null</code>.139*140* @param name the name of this <code>SQLPermission</code> object, which must141* be either {@code setLog}, {@code callAbort}, {@code setSyncFactory},142* {@code deregisterDriver}, or {@code setNetworkTimeout}143* @param actions should be <code>null</code>144* @throws NullPointerException if <code>name</code> is <code>null</code>.145* @throws IllegalArgumentException if <code>name</code> is empty.146147*/148149public SQLPermission(String name, String actions) {150super(name, actions);151}152153/**154* Private serial version unique ID to ensure serialization155* compatibility.156*/157static final long serialVersionUID = -1439323187199563495L;158159}160161162