Example 6-11: Granting Java2 Security privileges using dbms_java package

BEGIN
    -- Grant Permission to read a file in the C:\xmlfiles directory
    dbms_java.grant_permission(
             grantee => 'XMLBOOK',
     permission_type => 'SYS:java.io.FilePermission',
     permission_name => 'C:\xmlfiles\*',
   permission_action => 'read');

    -- Grant Permission to set the URLStreamHandlerFactory
    dbms_java.grant_permission(
             grantee => 'XMLBOOK',
     permission_type => 'SYS:java.lang.RuntimePermission',
     permission_name => 'setFactory',
   permission_action => '');

    -- Grant Permission to resolve and connect to URL at xml.us.oracle.com
    dbms_java.grant_permission(
             grantee => 'XMLBOOK',
     permission_type => 'SYS:java.net.SocketPermission',
     permission_name => 'xml.us.oracle.com',
   permission_action => 'connect,resolve');

    -- Grant Permission to debug JServer java code
    dbms_java.grant_permission(
             grantee => 'XMLBOOK',
     permission_type => 'SYS:oracle.aurora.security.JServerPermission',
     permission_name => 'Debug',
   permission_action => '');
  COMMIT;
END;