extends SecurityManager : SecurityManager « Security « Java






extends SecurityManager

    

import java.io.IOException;

public class MainClass {
  public static void main(String args[]) throws IOException {
    System.setSecurityManager(new MySecurityManager());
  }
}

class MySecurityManager extends SecurityManager {
  public void checkRead(String file) {
    if (!(file.endsWith(".txt")) && !(file.endsWith(".java")) && !(file.endsWith(".class"))
        && !(file.startsWith("C:\\"))) {
      throw new SecurityException("No Read Permission for : " + file);
    }
  }
}

   
    
    
  








Related examples in the same category

1.Use SecurityManager to check AWT permission and file permission
2.Listing All Permissions Granted to Classes Loaded from a URL or Directory
3.Security Manager TestSecurity Manager Test
4.Enabling the Security Manager
5.The security manager can be installed from the command line:
6.Security Support