Path: blob/master/src/java.sql/share/classes/java/sql/SQLPermission.java
41153 views
/*1* Copyright (c) 1999, 2020, 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} will check32* when code that is running an application with a33* {@code SecurityManager} enabled, calls the34* {@code DriverManager.deregisterDriver} method,35* {@code DriverManager.setLogWriter} method,36* {@code DriverManager.setLogStream} (deprecated) method,37* {@code SyncFactory.setJNDIContext} method,38* {@code SyncFactory.setLogger} method,39* {@code Connection.setNetworkTimeout} method,40* or the {@code Connection.abort} method.41* If there is no {@code SQLPermission} object, these methods42* throw a {@code java.lang.SecurityException} as a runtime exception.43* <P>44* A {@code SQLPermission} 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.*}52* and {@code *} signify a wildcard match,53* while {@code *loadLibrary} and {@code a*b} do not.54* <P>55* The following table lists all the possible {@code SQLPermission} 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 class="striped">61* <caption style="display:none">permission target name, what the permission allows, and associated risks</caption>62* <thead>63* <tr>64* <th scope="col">Permission Target Name</th>65* <th scope="col">What the Permission Allows</th>66* <th scope="col">Risks of Allowing this Permission</th>67* </tr>68* </thead>69*70* <tbody>71* <tr>72* <th scope="row">setLog</th>73* <td>Setting of the logging stream</td>74* <td>This is a dangerous permission to grant.75* The contents of the log may contain usernames and passwords,76* SQL statements, and SQL data.</td>77* </tr>78* <tr>79* <th scope="row">callAbort</th>80* <td>Allows the invocation of the {@code Connection} method81* {@code abort}</td>82* <td>Permits an application to terminate a physical connection to a83* database.</td>84* </tr>85* <tr>86* <th scope="row">setSyncFactory</th>87* <td>Allows the invocation of the {@code SyncFactory} methods88* {@code setJNDIContext} and {@code setLogger}</td>89* <td>Permits an application to specify the JNDI context from which the90* {@code SyncProvider} implementations can be retrieved from and the logging91* object to be used by the {@code SyncProvider} implementation.</td>92* </tr>93*94* <tr>95* <th scope="row">setNetworkTimeout</th>96* <td>Allows the invocation of the {@code Connection} method97* {@code setNetworkTimeout}</td>98* <td>Permits an application to specify the maximum period a99* {@code Connection} or100* objects created from the {@code Connection}101* will wait for the database to reply to any one request.</td>102* <tr>103* <th scope="row">deregisterDriver</th>104* <td>Allows the invocation of the {@code DriverManager}105* method {@code deregisterDriver}</td>106* <td>Permits an application to remove a JDBC driver from the list of107* registered Drivers and release its resources.</td>108* </tr>109* </tbody>110* </table>111*112* @since 1.3113* @see java.security.BasicPermission114* @see java.security.Permission115* @see java.security.Permissions116* @see java.security.PermissionCollection117* @see java.lang.SecurityManager118*119*/120121public final class SQLPermission extends BasicPermission {122123/**124* Creates a new {@code SQLPermission} object with the specified name.125* The name is the symbolic name of the {@code SQLPermission}.126*127* @param name the name of this {@code SQLPermission} object, which must128* be either {@code setLog}, {@code callAbort}, {@code setSyncFactory},129* {@code deregisterDriver}, or {@code setNetworkTimeout}130* @throws NullPointerException if {@code name} is {@code null}.131* @throws IllegalArgumentException if {@code name} is empty.132133*/134135public SQLPermission(String name) {136super(name);137}138139/**140* Creates a new {@code SQLPermission} object with the specified name.141* The name is the symbolic name of the {@code SQLPermission}; the142* actions {@code String} is currently unused and should be143* {@code null}.144*145* @param name the name of this {@code SQLPermission} object, which must146* be either {@code setLog}, {@code callAbort}, {@code setSyncFactory},147* {@code deregisterDriver}, or {@code setNetworkTimeout}148* @param actions should be {@code null}149* @throws NullPointerException if {@code name} is {@code null}.150* @throws IllegalArgumentException if {@code name} is empty.151152*/153154public SQLPermission(String name, String actions) {155super(name, actions);156}157158/**159* Private serial version unique ID to ensure serialization160* compatibility.161*/162static final long serialVersionUID = -1439323187199563495L;163164}165166167