Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: addressed my bullet points

...

Code Block
bgColor#FFcccc
class LoadLibrary {
  private void loadLibrary() {
    AccessController.doPrivileged(new PrivilegedAction() {
      public Object run() {
        // privileged code
        System.loadLibrary("awtmyLib.so");
        // perform some sensitive operation like setting the default exception handler
        MyExceptionReporter.setExceptionReporter(reporter); 
        return null; 
      }
    });		  
  }
}

...

Code Block
bgColor#ccccff
class LoadLibrary {
  private void loadLibrary() {
    AccessController.doPrivileged(new PrivilegedAction() {
      public Object run() {
        // privileged code
        System.loadLibrary("awtmyLib.so");

       
      // perform some sensitive operation like setting the default exception handler
   SecurityManager   sm = SystemMyExceptionReporter.getSecurityManagersetExceptionReporter(reporter); 
        if(sm !=return null); {
      }
    sm.checkPermission(new ExceptionReporterPermission("exc.reporter"));
        }

        // perform some sensitive operation like setting the default exception handler
  });		  
  }
}

 
final class MyExceptionReporter extends ExceptionReporter {
  public void setExceptionReporter(ExceptionReporter reporter) {
    SecurityManager sm = System.getSecurityManager();
    if(sm != null) {
      MyExceptionReporter.setExceptionReporter(reporter); sm.checkPermission(new ExceptionReporterPermission("exc.reporter"));
    }

    return// null;Proceed 
to set the exception reporter
  }
 
  //  });		  
  }... other methods of MyExceptionReporter
}
 
final class ExceptionReporterPermission extends BasicPermission {
  public ExceptionReporterPermission(String permName) {
    super(permName);
  }

  // Even though the actions parameter is ignored, this constructor has to be defined
  public ExceptionReporterPermission(String permName, String actions) {
    super(permName, actions);
  }
}

...