Source Code Cross Referenced for AllPermission.java in  » 6.0-JDK-Modules » j2me » java » security » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » java.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)AllPermission.java	1.21 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.  
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER  
006:         *   
007:         * This program is free software; you can redistribute it and/or  
008:         * modify it under the terms of the GNU General Public License version  
009:         * 2 only, as published by the Free Software Foundation.   
010:         *   
011:         * This program is distributed in the hope that it will be useful, but  
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of  
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  
014:         * General Public License version 2 for more details (a copy is  
015:         * included at /legal/license.txt).   
016:         *   
017:         * You should have received a copy of the GNU General Public License  
018:         * version 2 along with this work; if not, write to the Free Software  
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
020:         * 02110-1301 USA   
021:         *   
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa  
023:         * Clara, CA 95054 or visit www.sun.com if you need additional  
024:         * information or have any questions. 
025:         *
026:         */
027:
028:        package java.security;
029:
030:        import java.security.*;
031:        import java.util.Enumeration;
032:        import java.util.Hashtable;
033:        import java.util.StringTokenizer;
034:        import sun.security.util.SecurityConstants;
035:
036:        /**
037:         * The AllPermission is a permission that implies all other permissions.
038:         * <p>
039:         * <b>Note:</b> Granting AllPermission should be done with extreme care,
040:         * as it implies all other permissions. Thus, it grants code the ability 
041:         * to run with security
042:         * disabled.  Extreme caution should be taken before granting such
043:         * a permission to code.  This permission should be used only during testing,
044:         * or in extremely rare cases where an application or applet is
045:         * completely trusted and adding the necessary permissions to the policy 
046:         * is prohibitively cumbersome.
047:         * 
048:         * @see java.security.Permission
049:         * @see java.security.AccessController
050:         * @see java.security.Permissions
051:         * @see java.security.PermissionCollection
052:         * @see java.lang.SecurityManager
053:         *
054:         * @version 1.14 00/02/17
055:         *
056:         * @author Roland Schemers
057:         *
058:         * @serial exclude
059:         */
060:
061:        public final class AllPermission extends Permission {
062:
063:            /**
064:             * Creates a new AllPermission object.
065:             */
066:
067:            public AllPermission() {
068:                super ("<all permissions>");
069:            }
070:
071:            /**
072:             * Creates a new AllPermission object. This
073:             * constructor exists for use by the <code>Policy</code> object
074:             * to instantiate new Permission objects.
075:             *
076:             * @param name ignored
077:             * @param actions ignored.
078:             */
079:            public AllPermission(String name, String actions) {
080:                this ();
081:            }
082:
083:            /**
084:             * Checks if the specified permission is "implied" by 
085:             * this object. This method always returns true.
086:             *
087:             * @param p the permission to check against.
088:             *
089:             * @return return
090:             */
091:            public boolean implies(Permission p) {
092:                return true;
093:            }
094:
095:            /**
096:             * Checks two AllPermission objects for equality. Two AllPermission
097:             * objects are always equal.
098:             *
099:             * @param obj the object we are testing for equality with this object.
100:             * @return true if <i>obj</i> is an AllPermission, false otherwise.
101:             */
102:            public boolean equals(Object obj) {
103:                return (obj instanceof  AllPermission);
104:            }
105:
106:            /**
107:             * Returns the hash code value for this object.
108:             * 
109:             * @return a hash code value for this object.
110:             */
111:
112:            public int hashCode() {
113:                return 1;
114:            }
115:
116:            /**
117:             * Returns the canonical string representation of the actions.
118:             *
119:             * @return the actions.
120:             */
121:            public String getActions() {
122:                return "<all actions>";
123:            }
124:
125:            /**
126:             * Returns a new PermissionCollection object for storing AllPermission 
127:             * objects.
128:             * <p>
129:             * 
130:             * @return a new PermissionCollection object suitable for 
131:             * storing AllPermissions.
132:             */
133:
134:            public PermissionCollection newPermissionCollection() {
135:                return new AllPermissionCollection();
136:            }
137:
138:        }
139:
140:        /**
141:         * A AllPermissionCollection stores a collection
142:         * of AllPermission permissions. AllPermission objects
143:         * must be stored in a manner that allows them to be inserted in any
144:         * order, but enable the implies function to evaluate the implies
145:         * method in an efficient (and consistent) manner. 
146:         *
147:         * @see java.security.Permission
148:         * @see java.security.Permissions
149:         *
150:         * @version 1.14 02/17/00
151:         *
152:         * @author Roland Schemers
153:         *
154:         * @serial include
155:         */
156:
157:        final class AllPermissionCollection extends PermissionCollection
158:                implements  java.io.Serializable {
159:
160:            // use serialVersionUID from JDK 1.2.2 for interoperability
161:            private static final long serialVersionUID = -4023755556366636806L;
162:
163:            private boolean all_allowed; // true if any all permissions have been added
164:
165:            /**
166:             * Create an empty AllPermissions object.
167:             *
168:             */
169:
170:            public AllPermissionCollection() {
171:                all_allowed = false;
172:            }
173:
174:            /**
175:             * Adds a permission to the AllPermissions. The key for the hash is
176:             * permission.path.
177:             *
178:             * @param permission the Permission object to add.
179:             *
180:             * @exception IllegalArgumentException - if the permission is not a
181:             *                                       AllPermission
182:             *
183:             * @exception SecurityException - if this AllPermissionCollection object
184:             *                                has been marked readonly
185:             */
186:
187:            public void add(Permission permission) {
188:                if (!(permission instanceof  AllPermission))
189:                    throw new IllegalArgumentException("invalid permission: "
190:                            + permission);
191:                if (isReadOnly())
192:                    throw new SecurityException(
193:                            "attempt to add a Permission to a readonly PermissionCollection");
194:
195:                all_allowed = true;
196:            }
197:
198:            /**
199:             * Check and see if this set of permissions implies the permissions 
200:             * expressed in "permission".
201:             *
202:             * @param p the Permission object to compare
203:             *
204:             * @return always returns true.
205:             */
206:
207:            public boolean implies(Permission permission) {
208:                return all_allowed;
209:            }
210:
211:            /**
212:             * Returns an enumeration of all the AllPermission objects in the 
213:             * container.
214:             *
215:             * @return an enumeration of all the AllPermission objects.
216:             */
217:            public Enumeration elements() {
218:                return new Enumeration() {
219:                    private boolean hasMore = all_allowed;
220:
221:                    public boolean hasMoreElements() {
222:                        return hasMore;
223:                    }
224:
225:                    public Object nextElement() {
226:                        hasMore = false;
227:                        return SecurityConstants.ALL_PERMISSION;
228:                    }
229:                };
230:            }
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.