FileDocCategorySizeDatePackage
JDK12Security.javaAPI DocJMF 2.1.1e4641Mon May 12 12:20:50 BST 2003com.sun.media

JDK12Security

public class JDK12Security extends Object implements JMFSecurity

Fields Summary
public static final JMFSecurity
security
private static Class
cls
private static Method
dummyMethodRef
private static Permission
threadPermission
private static Permission
threadGroupPermission
private static Permission
connectPermission
private static Permission
multicastPermission
private static Permission
readAllFilesPermission
private static Constructor
filepermcons
Constructors Summary
private JDK12Security()


    
Methods Summary
public static voiddummyMethod()


    
public static java.security.PermissiongetConnectPermission()

	return connectPermission;
    
public static java.security.PermissiongetMulticastPermission()

	return multicastPermission;
    
public java.lang.StringgetName()

	return "jdk12";
    
public static java.security.PermissiongetReadAllFilesPermission()

	return readAllFilesPermission;
    
public static java.security.PermissiongetReadFilePermission(java.lang.String name)


     

    	security = new JDK12Security();
        try {
	    cls = security.getClass();
	    dummyMethodRef = cls.getMethod("dummyMethod",new Class[0]);


	    Class rtperm = Class.forName("java.lang.RuntimePermission");
	    Class socketperm = Class.forName("java.net.SocketPermission");
	    Class fileperm = Class.forName("java.io.FilePermission");
	    filepermcons = fileperm.getConstructor(new Class[] {String.class, String.class});


	    Constructor cons = rtperm.getConstructor(new Class[] {String.class});
	    threadPermission = (Permission) cons.newInstance(new Object[] {"modifyThread"});
	    // System.out.println("threadPermission is " + threadPermission);

	    threadGroupPermission = (Permission) cons.newInstance(new Object[] {"modifyThreadGroup"});
	    // System.out.println("threadGroupPermission is " + threadGroupPermission);


	    cons = socketperm.getConstructor(new
	     Class[] {
		String.class, String.class
		     });
	    connectPermission = (Permission) cons.newInstance(
                     new Object[] {"*", "connect"});
	    // System.out.println("connectPermission is " + connectPermission);

	    multicastPermission = (Permission) cons.newInstance(
                     new Object[] {"*", "accept,connect"});
	    // System.out.println("multicastPermission is " + multicastPermission);

	    // I don't think there is a way of saying
	    // give permission to read a file called jmf.properties
	    // no matter what the path. Check

// 	    readAllFilesPermission = (Permission) cons.newInstance(
// 		   new Object[] {"ALL FILES", "read"});
// 	    System.out.println("readAllFilesPermission is " + readAllFilesPermission);


        } catch (Exception e) {
	}

    
	try {
 	    return  (Permission) filepermcons.newInstance(
				     new Object[] {name, "read"});
	} catch (Exception e) {
	    return null;
	}
    
public static java.security.PermissiongetThreadGroupPermission()

	return threadGroupPermission;
    
public static java.security.PermissiongetThreadPermission()

	return threadPermission;
    
public static java.security.PermissiongetWriteFilePermission(java.lang.String name)

	try {
 	    return  (Permission) filepermcons.newInstance(
				     new Object[] {name, "read, write"});
	} catch (Exception e) {
	    return null;
	}
    
public booleanisLinkPermissionEnabled()

       return true;
    
public voidloadLibrary(java.lang.String name)


	AccessController.doPrivileged(
	    new java.security.PrivilegedAction() {
	      public Object run()  {
		  System.loadLibrary(name);
		  return null;
	      }
	}
      );
   
public voidpermissionFailureNotification(int permission)

    
public voidrequestPermission(java.lang.reflect.Method[] m, java.lang.Class[] c, java.lang.Object[][] args, int request)



	m[0] = dummyMethodRef;
	c[0] = cls;
	args[0] = null;

	//throw new SecurityException("DefulatSecurity : Cannot request permission");
    
public voidrequestPermission(java.lang.reflect.Method[] m, java.lang.Class[] c, java.lang.Object[][] args, int request, java.lang.String parameter)

	requestPermission(m, c, args, request);