< prev index next >

src/java.base/share/classes/java/nio/file/LinkPermission.java

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.nio.file;
  27 
  28 import java.security.BasicPermission;
  29 
  30 /**
  31  * The {@code Permission} class for link creation operations.
  32  *
  33  * <p> The following table provides a summary description of what the permission
  34  * allows, and discusses the risks of granting code the permission.
  35  *
  36  * <table border=1 cellpadding=5
  37  *        summary="Table shows permission target name, what the permission allows, and associated risks">

  38  * <tr>
  39  * <th>Permission Target Name</th>
  40  * <th>What the Permission Allows</th>
  41  * <th>Risks of Allowing this Permission</th>
  42  * </tr>


  43  * <tr>
  44  *   <td>hard</td>
  45  *   <td> Ability to add an existing file to a directory. This is sometimes
  46  *   known as creating a link, or hard link. </td>
  47  *   <td> Extreme care should be taken when granting this permission. It allows
  48  *   linking to any file or directory in the file system thus allowing the
  49  *   attacker access to all files. </td>
  50  * </tr>
  51  * <tr>
  52  *   <td>symbolic</td>
  53  *   <td> Ability to create symbolic links. </td>
  54  *   <td> Extreme care should be taken when granting this permission. It allows
  55  *   linking to any file or directory in the file system thus allowing the
  56  *   attacker to access to all files. </td>
  57  * </tr>

  58  * </table>
  59  *
  60  * @since 1.7
  61  *
  62  * @see Files#createLink
  63  * @see Files#createSymbolicLink
  64  */
  65 public final class LinkPermission extends BasicPermission {
  66     static final long serialVersionUID = -1441492453772213220L;
  67 
  68     private void checkName(String name) {
  69         if (!name.equals("hard") && !name.equals("symbolic")) {
  70             throw new IllegalArgumentException("name: " + name);
  71         }
  72     }
  73 
  74     /**
  75      * Constructs a {@code LinkPermission} with the specified name.
  76      *
  77      * @param   name




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.nio.file;
  27 
  28 import java.security.BasicPermission;
  29 
  30 /**
  31  * The {@code Permission} class for link creation operations.
  32  *
  33  * <p> The following table provides a summary description of what the permission
  34  * allows, and discusses the risks of granting code the permission.
  35  *
  36  * <table class="striped">
  37  * <caption style="display:none">Table shows permission target name, what the permission allows, and associated risks</caption>
  38  * <thead>
  39  * <tr>
  40  * <th>Permission Target Name</th>
  41  * <th>What the Permission Allows</th>
  42  * <th>Risks of Allowing this Permission</th>
  43  * </tr>
  44  * </thead>
  45  * <tbody>
  46  * <tr>
  47  *   <td>hard</td>
  48  *   <td> Ability to add an existing file to a directory. This is sometimes
  49  *   known as creating a link, or hard link. </td>
  50  *   <td> Extreme care should be taken when granting this permission. It allows
  51  *   linking to any file or directory in the file system thus allowing the
  52  *   attacker access to all files. </td>
  53  * </tr>
  54  * <tr>
  55  *   <td>symbolic</td>
  56  *   <td> Ability to create symbolic links. </td>
  57  *   <td> Extreme care should be taken when granting this permission. It allows
  58  *   linking to any file or directory in the file system thus allowing the
  59  *   attacker to access to all files. </td>
  60  * </tr>
  61  * </tbody>
  62  * </table>
  63  *
  64  * @since 1.7
  65  *
  66  * @see Files#createLink
  67  * @see Files#createSymbolicLink
  68  */
  69 public final class LinkPermission extends BasicPermission {
  70     static final long serialVersionUID = -1441492453772213220L;
  71 
  72     private void checkName(String name) {
  73         if (!name.equals("hard") && !name.equals("symbolic")) {
  74             throw new IllegalArgumentException("name: " + name);
  75         }
  76     }
  77 
  78     /**
  79      * Constructs a {@code LinkPermission} with the specified name.
  80      *
  81      * @param   name


< prev index next >