Developing a resource manager
A resource manager is a Java application that uses the JAAS and the ISAM authorization API Java classes to make access control decisions.
// Identify the configuration status and callback routine lc = new LoginContext("pd-debug", np); // Drive the login() and commit() methods of the LoginModule class lc.login(); whoami = lc.getSubject(); System.out.println(whoami); // Become that user Subject.doAsPrivileged(whoami, new java.security.PrivilegedAction() { public java.lang.Object run() { boolean worked; java.security.Permission perm = new PDPermission(“/test/private”, “a”); try { // sm is a reference to a SecurityManager sm.checkPermission(perm); worked = true; } catch (AccessControlException e) { if (VERBOSE) e.printStackTrace(); worked = false; } if (worked) { System.out.println(“user “ + user + “ has \”\””+perm.getActions()+”\” permission(s) to target “+perm.getName()); } else { System.out.println(“user “ + user + “ DOES NOT HAVE \”\””+perm.getActions()+”\” permission(s) to target “+perm.getName()); } } }, (java.security.AccessControlContext)null ) ;Parent topic: Java application development