Source Code Cross Referenced for UnresolvedPermissionCollection.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:         * @(#)UnresolvedPermissionCollection.java	1.17 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.util.*;
031:        import java.io.ObjectStreamField;
032:        import java.io.ObjectOutputStream;
033:        import java.io.ObjectInputStream;
034:        import java.io.IOException;
035:
036:        /**
037:         * A UnresolvedPermissionCollection stores a collection
038:         * of UnresolvedPermission permissions.
039:         *
040:         * @see java.security.Permission
041:         * @see java.security.Permissions
042:         * @see java.security.UnresolvedPermission
043:         *
044:         * @version 1.9 00/02/02
045:         *
046:         * @author Roland Schemers
047:         *
048:         * @serial include
049:         */
050:
051:        final class UnresolvedPermissionCollection extends PermissionCollection
052:                implements  java.io.Serializable {
053:            /**
054:             * Key is permission type, value is a list of the UnresolvedPermissions
055:             * of the same type.
056:             * Not serialized; see serialization section at end of class.
057:             */
058:            private transient Map perms;
059:
060:            /**
061:             * Create an empty UnresolvedPermissionCollection object.
062:             *
063:             */
064:            public UnresolvedPermissionCollection() {
065:                perms = new HashMap(11);
066:            }
067:
068:            /**
069:             * Adds a permission to this UnresolvedPermissionCollection. 
070:             * The key for the hash is the unresolved permission's type (class) name.
071:             *
072:             * @param permission the Permission object to add.
073:             */
074:
075:            public void add(Permission permission) {
076:                if (!(permission instanceof  UnresolvedPermission))
077:                    throw new IllegalArgumentException("invalid permission: "
078:                            + permission);
079:                UnresolvedPermission up = (UnresolvedPermission) permission;
080:
081:                // No need to synchronize because all adds are done sequentially
082:                // (by policy provider) before any getUnresolvedPermissions() calls.
083:                // If policy provider is multithreaded, it should lock the
084:                // collection to allow concurrent adds
085:
086:                List v = (List) perms.get(up.getName());
087:                if (v == null) {
088:                    v = new ArrayList();
089:                    perms.put(up.getName(), v);
090:                }
091:                v.add(up);
092:            }
093:
094:            /**
095:             * get any unresolved permissions of the same type as p,
096:             * and return the List containing them.
097:             */
098:            // No need to synchronize; list is only gotten for reading
099:            List getUnresolvedPermissions(Permission p) {
100:                return (List) perms.get(p.getClass().getName());
101:            }
102:
103:            /**
104:             * always returns false for unresolved permissions
105:             *
106:             */
107:            public boolean implies(Permission permission) {
108:                return false;
109:            }
110:
111:            /**
112:             * Returns an enumeration of all the UnresolvedPermission lists in the
113:             * container.
114:             *
115:             * @return an enumeration of all the UnresolvedPermission objects.
116:             */
117:
118:            // No need to synchronize; lists won't change after initial adds
119:            // A performance improvement might be to construct the global 
120:            // list lazily as enumeration proceeds.
121:            public Enumeration elements() {
122:                List results = new ArrayList(); // where results are stored
123:
124:                // Get iterator of Map values (which are lists of permissions)
125:                for (Iterator iter = perms.values().iterator(); iter.hasNext();) {
126:                    results.addAll((List) iter.next());
127:                }
128:
129:                return Collections.enumeration(results);
130:            }
131:
132:            private static final long serialVersionUID = -7176153071733132400L;
133:
134:            // Need to maintain serialization interoperability with earlier releases,
135:            // which had the serializable field:
136:            // private Hashtable permissions; // keyed on type
137:
138:            /**
139:             * @serialField permissions java.util.Hashtable
140:             *     A table of the UnresolvedPermissions keyed on type, value is Vector
141:             *     of permissions
142:             */
143:            private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
144:                    "permissions", Hashtable.class), };
145:
146:            /**
147:             * @serialData Default field.
148:             */
149:            /*
150:             * Writes the contents of the perms field out as a Hashtable 
151:             * in which the values are Vectors for
152:             * serialization compatibility with earlier releases.
153:             */
154:            private void writeObject(ObjectOutputStream out) throws IOException {
155:                // Don't call out.defaultWriteObject()
156:
157:                // Copy perms into a Hashtable
158:                Hashtable permissions = new Hashtable(perms.size() * 2);
159:
160:                // Convert each entry (List) into a Vector
161:                Set set = perms.entrySet();
162:                for (Iterator iter = set.iterator(); iter.hasNext();) {
163:                    Map.Entry e = (Map.Entry) iter.next();
164:
165:                    // Convert list into Vector
166:                    List list = (List) e.getValue();
167:                    Vector vec = new Vector(list.size());
168:                    vec.addAll(list);
169:
170:                    // Add to Hashtable being serialized
171:                    permissions.put(e.getKey(), vec);
172:                }
173:
174:                // Write out serializable fields
175:                ObjectOutputStream.PutField pfields = out.putFields();
176:                pfields.put("permissions", permissions);
177:                out.writeFields();
178:            }
179:
180:            /*
181:             * Reads in a Hashtable in which the values are Vectors of
182:             * UnresolvedPermissions and saves them in the perms field. 
183:             */
184:            private void readObject(ObjectInputStream in) throws IOException,
185:                    ClassNotFoundException {
186:                // Don't call defaultReadObject()
187:
188:                // Read in serialized fields
189:                ObjectInputStream.GetField gfields = in.readFields();
190:
191:                // Get permissions
192:                Hashtable permissions = (Hashtable) gfields.get("permissions",
193:                        null);
194:                perms = new HashMap(permissions.size() * 2);
195:
196:                // Convert each entry (Vector) into a List
197:                Set set = permissions.entrySet();
198:                for (Iterator iter = set.iterator(); iter.hasNext();) {
199:                    Map.Entry e = (Map.Entry) iter.next();
200:
201:                    // Convert Vector into ArrayList
202:                    Vector vec = (Vector) e.getValue();
203:                    List list = new ArrayList(vec.size());
204:                    list.addAll(vec);
205:
206:                    // Add to Hashtable being serialized
207:                    perms.put(e.getKey(), list);
208:                }
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.