Source Code Cross Referenced for ProsePermission.java in  » Byte-Code » PROSE » ch » ethz » prose » 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 » Byte Code » PROSE » ch.ethz.prose 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // 
002:        //  This file is part of the prose package.
003:        // 
004:        //  The contents of this file are subject to the Mozilla Public License
005:        //  Version 1.1 (the "License"); you may not use this file except in
006:        //  compliance with the License. You may obtain a copy of the License at
007:        //  http://www.mozilla.org/MPL/
008:        // 
009:        //  Software distributed under the License is distributed on an "AS IS" basis,
010:        //  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011:        //  for the specific language governing rights and limitations under the
012:        //  License.
013:        // 
014:        //  The Original Code is prose.
015:        // 
016:        //  The Initial Developer of the Original Code is Andrei Popovici. Portions
017:        //  created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
018:        //  All Rights Reserved.
019:        // 
020:        //  Contributor(s):
021:        // $Id: ProsePermission.java,v 1.1.1.1 2003/07/02 15:30:50 apopovic Exp $
022:        // =====================================================================
023:        //
024:        // (history at end)
025:        //
026:
027:        package ch.ethz.prose;
028:
029:        // used packages
030:        import java.io.Serializable;
031:        import java.security.Permission;
032:
033:        /**
034:         * The class ProsePermission is used for access control of critical parts
035:         * in the RUNES system. The names recognized and their semantics can be
036:         * seen in the following list, to specify all names, one can use the wildcard "*".<p>
037:         *
038:         * <ul>
039:         * <li> registerListener: guards the creation of breakpoints
040:         * <li> startupExtensionSystem: if granted, <code>ProseSystem.startup</code>
041:         *      will be performed privileged under the the restrictions of <code>ProseSystem</code>
042:         *      only. This permission should simplify the Java security policy definition, as
043:         *      only <code>ProseSystem</code> needs several fine grained permissions, and all
044:         *      classes that need to start runes can do with the ProsePermission "startupExtensionSystem"
045:         * </ul>
046:         * <p>
047:         * So an entry in the standard policy file allowing all classes to install
048:         * extensions would look like:<p><pre>
049:         * grant {
050:         *   ch.ethz.prose.ProsePermission "registerListener";
051:         * }
052:         * </pre>
053:         *
054:         * @version	$Revision: 1.1.1.1 $
055:         * @author	Marcel Muller
056:         */
057:        public final class ProsePermission extends Permission implements 
058:                Serializable {
059:
060:            private static final long serialVersionUID = 3258134652291133489L;
061:            private final static String[] NAMES = { "registerListener",
062:                    "startupExtensionSystem" };
063:            private final static String WILDCARD = "*";
064:
065:            private int nameIndex = -1;
066:
067:            /**
068:             * Constructs a runes permission with the specified name.
069:             *
070:             * @param name the name of the permission or <code>*</code> for all names.
071:             */
072:            public ProsePermission(String name) {
073:                super (name);
074:
075:                if (name == null) {
076:                    throw new NullPointerException("name can't be null");
077:                }
078:
079:                for (int i = 0; i < NAMES.length; i++) {
080:                    if (name.equals(NAMES[i])) {
081:                        nameIndex = i;
082:                        break;
083:                    }
084:                }
085:
086:                if (nameIndex == -1) {
087:                    String names = NAMES[0];
088:                    for (int i = 1; i < NAMES.length; i++) {
089:                        names += ", " + NAMES[i];
090:                    }
091:
092:                    throw new IllegalArgumentException("Invalid name \"" + name
093:                            + "\". Valid choices are: " + names);
094:                }
095:            }
096:
097:            /**
098:             * Constructs a runes permission with the specified name and action. This constructor
099:             * seems to be necessary to the standard policy file implementation though this
100:             * class completely ignores the action parameter.
101:             *
102:             * @param name the name of the permission or <code>*</code> for all names.
103:             * @param actions ignored!!!
104:             */
105:            public ProsePermission(String name, String actions) {
106:                this (name);
107:            }
108:
109:            /**
110:             * Checks whether this permission implies permission <code>p</code> (if names are
111:             * equal or at least this permission was created with the wildcard as parameter) or not.
112:             *
113:             * @param p the permission to be compared to
114:             */
115:            public boolean implies(Permission p) {
116:                if (p instanceof  ProsePermission) {
117:                    if (getName().equals(WILDCARD)) {
118:                        return true;
119:                    }
120:
121:                    return nameIndex == ((ProsePermission) p).nameIndex;
122:                }
123:
124:                return false;
125:            }
126:
127:            /**
128:             * Returns an empty string as this class does not use actions.
129:             */
130:            public String getActions() {
131:                return "";
132:            }
133:
134:            public boolean equals(Object obj) {
135:                if (obj instanceof  ProsePermission) {
136:                    return nameIndex == ((ProsePermission) obj).nameIndex;
137:                } else {
138:                    return false;
139:                }
140:            }
141:
142:            public int hashCode() {
143:                return getName().hashCode();
144:            }
145:        }
146:
147:        //======================================================================
148:        //
149:        // $Log: ProsePermission.java,v $
150:        // Revision 1.1.1.1  2003/07/02 15:30:50  apopovic
151:        // Imported from ETH Zurich
152:        //
153:        // Revision 1.1  2003/05/05 13:58:29  popovici
154:        // renaming from runes to prose
155:        //
156:        // Revision 1.4  2003/03/04 18:36:37  popovici
157:        // Organization of imprts
158:        //
159:        // Revision 1.3  2003/03/04 11:27:16  popovici
160:        // Important refactorization step (march):
161:        // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
162:        // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
163:        //   structures
164:        //
165:        // Revision 1.2  2002/03/28 13:48:37  popovici
166:        // Mozilla-ified
167:        //
168:        // Revision 1.1.1.1  2001/11/29 18:13:16  popovici
169:        // Sources from runes
170:        //
171:        // Revision 1.1.2.3  2001/04/04 13:08:52  mrmuller
172:        // JavaDoc improved
173:        //
174:        // Revision 1.1.2.2  2001/03/16 17:29:15  mrmuller
175:        // cosmetics, javadoc and exception handling changes
176:        //
177:        // Revision 1.1.2.1  2001/03/16 13:12:29  mrmuller
178:        // initial release of new (really) secure extension insertion mechanism
179:        //
180:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.