joel24 Posted September 19, 2011 Share Posted September 19, 2011 I'm currently writing a Java applet to access and scan wifi networks and I need to execute the netsh with the parameters "wlan show networks mode=bssid". The script is being run from a HTML page and so the Applet is limited to the sandbox environment. What would be the best way to grant permissions to execute said command? At the moment I'm getting warnings when compiling the class, sorry this is my first Java applet - feel free to point me toward any relevant tutorials? warning: [unchecked] unchecked con version AccessController.doPrivileged(new PrivilegedAction() { ^ required: PrivilegedAction<T> found: <anonymous PrivilegedAction> where T is a type-variable: T extends Object declared in method <T>doPrivileged(PrivilegedAction<T>) c:\users\joel\desktop\javaTest\wifox.java:28: warning: [unchecked] unchecked met hod invocation: method doPrivileged in class AccessController is applied to give n types AccessController.doPrivileged(new PrivilegedAction() { ^ required: PrivilegedAction<T> found: <anonymous PrivilegedAction> where T is a type-variable: T extends Object declared in method <T>doPrivileged(PrivilegedAction<T>) 2 warnings and the current code public static void testing() { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { // Run "netsh" Windows command Process process = Runtime.getRuntime().exec("netsh.exe wlan show networks mode=bssid"); // Get input streams BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream())); // Read command standard output String s; System.out.println("Networks Found: "); while ((s = stdInput.readLine()) != null) { System.out.println(s); } // Read command errors System.out.println("Errors: "); while ((s = stdError.readLine()) != null) { System.out.println(s); } } catch (Exception e) { e.printStackTrace(System.err); } } }); } Quote Link to comment https://forums.phpfreaks.com/topic/247417-java-help-with-doprivilege-access-controller-and-security/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.