Source Code Cross Referenced for PermissionAccessor.java in  » 6.0-JDK-Modules » j2me » com » sun » mmedia » 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 » com.sun.mmedia 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
004:         * 
005:         * This program is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU General Public License version
007:         * 2 only, as published by the Free Software Foundation.
008:         * 
009:         * This program is distributed in the hope that it will be useful, but
010:         * WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012:         * General Public License version 2 for more details (a copy is
013:         * included at /legal/license.txt).
014:         * 
015:         * You should have received a copy of the GNU General Public License
016:         * version 2 along with this work; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
018:         * 02110-1301 USA
019:         * 
020:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
021:         * Clara, CA 95054 or visit www.sun.com if you need additional
022:         * information or have any questions.
023:         */
024:        package com.sun.mmedia;
025:
026:        import com.sun.midp.security.Permissions;
027:        import com.sun.midp.midlet.Scheduler;
028:        import com.sun.midp.midlet.MIDletSuite;
029:
030:        /**
031:         * A Wrapper class for platform/product specific permission management.
032:         * This file contains CLDC/MIDP speecific version of the class.
033:         */
034:        public final class PermissionAccessor {
035:
036:            public static final int PERMISSION_SYSTEM = 0;
037:
038:            public static final int PERMISSION_HTTP_READ = 1;
039:            public static final int PERMISSION_HTTP_WRITE = 2;
040:            public static final int PERMISSION_FILE_READ = 3;
041:            public static final int PERMISSION_FILE_WRITE = 4;
042:            public static final int PERMISSION_SOCKET_READ = 5;
043:            public static final int PERMISSION_SOCKET_WRITE = 6;
044:
045:            public static final int PERMISSION_IMAGE_CAPTURE = 7;
046:            public static final int PERMISSION_VIDEO_CAPTURE = 8;
047:            public static final int PERMISSION_AUDIO_CAPTURE = 9;
048:
049:            public static final int PERMISSION_VIDEO_RECORDING = 10;
050:            public static final int PERMISSION_AUDIO_RECORDING = 11;
051:
052:            public static final int PERMISSION_VIDEO_SNAPSHOT = 12;
053:
054:            public static final int PERMISSION_VIDEO_CAMERA_SHUTTER_FEEDBACK = 13;
055:            public static final int PERMISSION_RADIO_TUNER_SET_PRESET = 14;
056:
057:            private static final int mapPermissions[] = {
058:                    /* PERMISSION_SYSTEM                        */Permissions.MIDP,
059:
060:                    /* PERMISSION_HTTP_READ                     */Permissions.HTTP,
061:                    /* PERMISSION_HTTP_WRITE                    */Permissions.HTTP,
062:                    /* PERMISSION_FILE_READ                     */Permissions.FILE_CONNECTION_READ,
063:                    /* PERMISSION_FILE_WRITE                    */Permissions.FILE_CONNECTION_WRITE,
064:                    /* PERMISSION_SOCKET_READ                   */Permissions.TCP,
065:                    /* PERMISSION_SOCKET_WRITE                  */Permissions.TCP,
066:
067:                    /* PERMISSION_IMAGE_CAPTURE                 */Permissions.MM_IMAGE_CAPTURING,
068:                    /* PERMISSION_VIDEO_CAPTURE                 */Permissions.MM_RECORD,
069:                    /* PERMISSION_AUDIO_CAPTURE                 */Permissions.MM_RECORD,
070:
071:                    /* PERMISSION_VIDEO_RECORDING               */Permissions.MM_RECORD,
072:                    /* PERMISSION_AUDIO_RECORDING               */Permissions.MM_RECORD,
073:
074:                    /* PERMISSION_VIDEO_SNAPSHOT                */Permissions.MM_IMAGE_CAPTURING,
075:
076:            //ATTENTION: THE FOLLOWING AMMS PERMISSIONS ARE NOT DEFINED YET
077:            /* PERMISSION_VIDEO_CAMERA_SHUTTER_FEEDBACK *///Permissions.AMMS_CAMERA_SHUTTERFEEDBACK,
078:            /* PERMISSION_RADIO_TUNER_SET_PRESET        *///Permissions.AMMS_TUNER_SETPRESET
079:            };
080:
081:            /**
082:             * Method indended to be called by Players & Controls to check
083:             * if user application has enough permissions to perform
084:             * a secured operation ...
085:             *
086:             * @param thePermission - one of PERMISSION_* constants that 
087:             *        define permissions in an product-independent form.
088:             */
089:            public static void checkPermissions(int thePermission)
090:                    throws SecurityException {
091:                try {
092:                    /* 
093:                     * Map between PermissionAccessor.* permission constants
094:                     * and Permissions.* ...
095:                     * Any incorrect permission constant will result in 
096:                     * ArrayIndexOutOfBoundsException -> 
097:                     * a SecurityException will be thrown !
098:                     */
099:                    int permission = mapPermissions[thePermission];
100:
101:                    MIDletSuite midletSuite = Scheduler.getScheduler()
102:                            .getMIDletSuite();
103:                    midletSuite.checkIfPermissionAllowed(permission);
104:                } catch (SecurityException se) {
105:                    ///*DEBUG:*/ se.printStackTrace();
106:                    throw se;
107:                } catch (Exception e) {
108:                    ///*DEBUG:*/ e.printStackTrace();
109:                    throw new SecurityException(
110:                            "Failed to check user permission");
111:                }
112:            }
113:
114:            private static final String locatorTypes[] = { "capture://audio",
115:                    "capture://video", "capture://radio", "capture://",
116:                    "device://", "file://", "http://" };
117:
118:            // inidicates that corresponding locator type needs no special permissions.
119:            private static final int NEED_NO_PERMISSIONS = 0;
120:            private static final int FAILED_PERMISSIONS = -1;
121:
122:            private static final int mapLocatorPermissions[] = {
123:            /* "capture://audio" */NEED_NO_PERMISSIONS,
124:            /* "capture://video" */NEED_NO_PERMISSIONS,
125:            /* "capture://radio" */NEED_NO_PERMISSIONS,
126:            /* "capture://"      */NEED_NO_PERMISSIONS,
127:            /* "device://"       */NEED_NO_PERMISSIONS,
128:            /* "file://"         */Permissions.FILE_CONNECTION_READ,
129:            /* "http://"         */Permissions.HTTP };
130:
131:            /**
132:             * Method indended to be called by Manager.createDataSource(locator)
133:             * and checks if user application has enough permissions to use given type
134:             * of locators to play media contents.
135:             *
136:             * @param locator - the URL to be used as media source for player
137:             */
138:            public static void checkLocatorPermissions(String locator)
139:                    throws SecurityException {
140:                int permission = FAILED_PERMISSIONS;
141:                try {
142:                    /* 
143:                     * Find Locator type, and map this type to permission.
144:                     * Any incorrect locator will result in 
145:                     * ArrayIndexOutOfBoundsException or NullPointerException -> 
146:                     * a SecurityException will be thrown !
147:                     */
148:                    String locStr = locator.toLowerCase();
149:                    for (int i = 0; i < locatorTypes.length; ++i) {
150:                        if (locStr.startsWith(locatorTypes[i])) {
151:                            permission = mapLocatorPermissions[i];
152:                            if (permission == NEED_NO_PERMISSIONS)
153:                                return;
154:                            break;
155:                        }
156:                    }
157:
158:                    MIDletSuite midletSuite = Scheduler.getScheduler()
159:                            .getMIDletSuite();
160:                    midletSuite.checkIfPermissionAllowed(permission);
161:                } catch (SecurityException se) {
162:                    ///*DEBUG:*/ se.printStackTrace();
163:                    throw se;
164:                } catch (Exception e) {
165:                    ///*DEBUG:*/ e.printStackTrace();
166:                    throw new SecurityException(
167:                            "Failed to check locator permission");
168:                }
169:            }
170:
171:            /**
172:             * Method indended to be called by Manager.createPlayer(DataSource)
173:             * and checks if user application has enough permissions to playback 
174:             * media of a given content-type using given type
175:             * of locators.
176:             *
177:             * @param locator - the URL to be used as media source for player, 
178:             *        can be null if DataSOurce has been created not from locator
179:             * @param contentType - content-type boolean of the media
180:             */
181:            public static void checkContentTypePermissions(String locator,
182:                    String contentType) throws SecurityException {
183:                /*
184:                 * THIS IS A STUB
185:                 */
186:            }
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.