FileDocCategorySizeDatePackage
PermissionAccessor.javaAPI DocphoneME MR2 API (J2ME)8026Wed May 02 16:47:10 BST 2007com.sun.mmedia

PermissionAccessor

public final class PermissionAccessor extends Object
A Wrapper class for platform/product specific permission management. This file contains CLDC/MIDP speecific version of the class.

Fields Summary
public static final int
PERMISSION_SYSTEM
public static final int
PERMISSION_HTTP_READ
public static final int
PERMISSION_HTTP_WRITE
public static final int
PERMISSION_FILE_READ
public static final int
PERMISSION_FILE_WRITE
public static final int
PERMISSION_SOCKET_READ
public static final int
PERMISSION_SOCKET_WRITE
public static final int
PERMISSION_IMAGE_CAPTURE
public static final int
PERMISSION_VIDEO_CAPTURE
public static final int
PERMISSION_AUDIO_CAPTURE
public static final int
PERMISSION_VIDEO_RECORDING
public static final int
PERMISSION_AUDIO_RECORDING
public static final int
PERMISSION_VIDEO_SNAPSHOT
public static final int
PERMISSION_VIDEO_CAMERA_SHUTTER_FEEDBACK
public static final int
PERMISSION_RADIO_TUNER_SET_PRESET
private static final int[]
mapPermissions
private static final String[]
locatorTypes
private static final int
NEED_NO_PERMISSIONS
private static final int
FAILED_PERMISSIONS
private static final int[]
mapLocatorPermissions
Constructors Summary
Methods Summary
public static voidcheckContentTypePermissions(java.lang.String locator, java.lang.String contentType)
Method indended to be called by Manager.createPlayer(DataSource) and checks if user application has enough permissions to playback media of a given content-type using given type of locators.

param
locator - the URL to be used as media source for player, can be null if DataSOurce has been created not from locator
param
contentType - content-type boolean of the media

        /*
         * THIS IS A STUB
         */
    
public static voidcheckLocatorPermissions(java.lang.String locator)
Method indended to be called by Manager.createDataSource(locator) and checks if user application has enough permissions to use given type of locators to play media contents.

param
locator - the URL to be used as media source for player

    
                                               
           
        int permission = FAILED_PERMISSIONS;
        try {
            /* 
             * Find Locator type, and map this type to permission.
             * Any incorrect locator will result in 
             * ArrayIndexOutOfBoundsException or NullPointerException -> 
             * a SecurityException will be thrown !
             */
            String locStr = locator.toLowerCase();
            for (int i = 0; i < locatorTypes.length; ++i) {
                if (locStr.startsWith(locatorTypes[i])) {
                    permission = mapLocatorPermissions[i];
                    if (permission == NEED_NO_PERMISSIONS)
                        return; 
                    break;
                }
            }
            
            MIDletSuite midletSuite = Scheduler.getScheduler().getMIDletSuite();
            midletSuite.checkIfPermissionAllowed( permission );
        } catch (SecurityException se) {
            ///*DEBUG:*/ se.printStackTrace();
            throw se;
        } catch (Exception e) {
            ///*DEBUG:*/ e.printStackTrace();
            throw new SecurityException(
                "Failed to check locator permission");
        }
    
public static voidcheckPermissions(int thePermission)
Method indended to be called by Players & Controls to check if user application has enough permissions to perform a secured operation ...

param
thePermission - one of PERMISSION_* constants that define permissions in an product-independent form.

    
                                                      
           
        try {
            /* 
             * Map between PermissionAccessor.* permission constants
             * and Permissions.* ...
             * Any incorrect permission constant will result in 
             * ArrayIndexOutOfBoundsException -> 
             * a SecurityException will be thrown !
             */
            int permission = mapPermissions[thePermission];
        
            MIDletSuite midletSuite = Scheduler.getScheduler().getMIDletSuite();
            midletSuite.checkIfPermissionAllowed( permission );
        } catch (SecurityException se) {
            ///*DEBUG:*/ se.printStackTrace();
            throw se;
        } catch (Exception e) {
            ///*DEBUG:*/ e.printStackTrace();
            throw new SecurityException(
                "Failed to check user permission");
        }