OSDN Git Service

31140c089ef8431b6c523b927b169ac949e7b5ce
[pf3gnuchains/gcc-fork.git] / libjava / java / security / AllPermission.java
1 /* AllPermission.java -- Permission to do anything
2    Copyright (C) 1998, 2001 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
20
21 As a special exception, if you link this library with other files to
22 produce an executable, this library does not by itself cause the
23 resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License. */
26
27 package java.security;
28
29 /**
30  * This class is a permission that implies all other permissions.  Granting
31  * this permission effectively grants all others.  Extreme caution should
32  * be exercised in granting this permission.
33  *
34  * @version 0.0
35  *
36  * @author Aaron M. Renn (arenn@urbanophile.com)
37  */
38 public final class AllPermission extends Permission
39 {
40   /**
41    * This method initializes a new instance of <code>AllPermission</code>.  It
42    * performs no actions.
43    */
44   public AllPermission()
45   {
46     super("all");
47   }
48
49   /**
50    * This method initializes a new instance of <code>AllPermission</code>.  The
51    * arguments passed to this method are used to set internal field for the
52    * permission name.  However, these are not used in 
53    * determining the actual permissions granted.  This class always will
54    * return <code>true</code> in its implies method.
55    *
56    * @param name The name of this permission.
57    * @param actions The action list for this permission - ignored in this class.
58    */
59   public AllPermission(String name, String actions)
60   {
61     super(name);
62   }
63
64   /**
65    * This method always returns <code>true</code> to indicate that this
66    * permission always implies that any other permission is also granted.
67    *
68    * @param perm The <code>Permission</code> to test against - ignored in this class.
69    *
70    * @return Always returns <code>true</code>
71    */
72   public boolean implies(Permission perm)
73   {
74     return (true);
75   }
76
77   /**
78    * This method tests this class for equality against another <code>Object</code>.
79    * This will return <code>true</code> if and only if the specified 
80    * <code>Object</code> is an instance of <code>AllPermission</code>.
81    *
82    * @param obj The <code>Object</code> to test for equality to this object
83    */
84   public boolean equals(Object obj)
85   {
86     if (obj instanceof AllPermission)
87       return (true);
88
89     return (false);
90   }
91
92   /**
93    * This method returns a hash code for this object.
94    *
95    * @return A hash value for this object.
96    */
97   public int hashCode()
98   {
99     return (System.identityHashCode(this));
100   }
101
102   /**
103    * This method returns the list of actions associated with this object.
104    * This will always be the empty string ("") for this class.
105    *
106    * @return The action list.
107    */
108   public String getActions()
109   {
110     return ("");
111   }
112
113   /**
114    * This method returns a new instance of <code>PermissionCollection</code>
115    * suitable for holding instance of <code>AllPermission</code>.
116    *
117    * @return A new <code>PermissionCollection</code>.
118    */
119   public PermissionCollection newPermissionCollection()
120   {
121     return (null);
122   }
123 }