source: trunk/src/gcc/libjava/java/security/Permission.java@ 1124

Last change on this file since 1124 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.7 KB
Line 
1/* Permission.java -- The superclass for all permission objects
2 Copyright (C) 1998, 2001 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38package java.security;
39
40import java.io.Serializable;
41
42/**
43 * This class is the abstract superclass of all classes that implement
44 * the concept of a permission. A permission consists of a permission name
45 * and optionally a list of actions that relate to the permission. The
46 * actual meaning of the name of the permission is defined only in the
47 * context of a subclass. It may name a resource to which access permissions
48 * are granted (for example, the name of a file) or it might represent
49 * something else entirely. Similarly, the action list only has meaning
50 * within the context of a subclass. Some permission names may have no
51 * actions associated with them. That is, you either have the permission
52 * or you don't.
53 *
54 * The most important method in this class is <code>implies</code>. This
55 * checks whether if one has this permission, then the specified
56 * permission is also implied. As a conceptual example, consider the
57 * permissions "Read All Files" and "Read File foo". The permission
58 * "Read All Files" implies that the caller has permission to read the
59 * file foo.
60 *
61 * <code>Permission</code>'s are not dynamic objects. Once created, a
62 * <code>Permission</code>'s name and action list cannot be changed.
63 *
64 * @version 0.0
65 *
66 * @author Aaron M. Renn ([email protected])
67 */
68public abstract class Permission implements Guard, Serializable
69{
70 /**
71 * This is the name assigned to this permission object.
72 */
73 private String name; // Taken from the serializable form information
74
75 /**
76 * This method initializes a new instance of <code>Permission</code> to
77 * have the specified name.
78 */
79 public Permission(String name)
80 {
81 this.name = name;
82 }
83
84 /**
85 * This method returns the name of this <code>Permission</code>
86 *
87 * @return The name of this <code>Permission</code>
88 */
89 public final String getName()
90 {
91 return (name);
92 }
93
94 /**
95 * This method returns the list of actions for this <code>Permission</code>
96 * as a <code>String</code>.
97 *
98 * @return The action list for this <code>Permission</code>.
99 */
100 public abstract String getActions();
101
102 /**
103 * This method implements the <code>Guard</code> interface for this class.
104 * It calls the <code>checkPermission</code> method in
105 * <code>SecurityManager</code> with this <code>Permission</code> as its
106 * argument. This method returns silently if the security check succeeds
107 * or throws an exception if it fails.
108 *