Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/nio/file/LinkPermission.java
38918 views
/*1* Copyright (c) 2007, 2011, 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*/2425package java.nio.file;2627import java.security.BasicPermission;2829/**30* The {@code Permission} class for link creation operations.31*32* <p> The following table provides a summary description of what the permission33* allows, and discusses the risks of granting code the permission.34*35* <table border=1 cellpadding=536* summary="Table shows permission target name, what the permission allows, and associated risks">37* <tr>38* <th>Permission Target Name</th>39* <th>What the Permission Allows</th>40* <th>Risks of Allowing this Permission</th>41* </tr>42* <tr>43* <td>hard</td>44* <td> Ability to add an existing file to a directory. This is sometimes45* known as creating a link, or hard link. </td>46* <td> Extreme care should be taken when granting this permission. It allows47* linking to any file or directory in the file system thus allowing the48* attacker access to all files. </td>49* </tr>50* <tr>51* <td>symbolic</td>52* <td> Ability to create symbolic links. </td>53* <td> Extreme care should be taken when granting this permission. It allows54* linking to any file or directory in the file system thus allowing the55* attacker to access to all files. </td>56* </tr>57* </table>58*59* @since 1.760*61* @see Files#createLink62* @see Files#createSymbolicLink63*/64public final class LinkPermission extends BasicPermission {65static final long serialVersionUID = -1441492453772213220L;6667private void checkName(String name) {68if (!name.equals("hard") && !name.equals("symbolic")) {69throw new IllegalArgumentException("name: " + name);70}71}7273/**74* Constructs a {@code LinkPermission} with the specified name.75*76* @param name77* the name of the permission. It must be "hard" or "symbolic".78*79* @throws IllegalArgumentException80* if name is empty or invalid81*/82public LinkPermission(String name) {83super(name);84checkName(name);85}8687/**88* Constructs a {@code LinkPermission} with the specified name.89*90* @param name91* the name of the permission; must be "hard" or "symbolic".92* @param actions93* the actions for the permission; must be the empty string or94* {@code null}95*96* @throws IllegalArgumentException97* if name is empty or invalid, or actions is a non-empty string98*/99public LinkPermission(String name, String actions) {100super(name);101checkName(name);102if (actions != null && actions.length() > 0) {103throw new IllegalArgumentException("actions: " + actions);104}105}106}107108109