HTTPS Properties The HTTPS Protocol Handler

public void logout Log the current user out. This invalidates the subject object. This method throws a LoginException if the logout operation fails. public Subject getSubject Return the subject object that represents the authenticated user.

15.2.1.2 The Subject class

The Subject class javax.security.auth.Subject is used to represent an authenticated user. In essence, each user is represented as an array of Principal objects stored by this class. There is an array of objects because each user is likely to have several identifying characteristics. For example, on my Sun system I have a principal that represents me by username sdo, one that represents me by user ID 6058, and many that represent me by the groups to which I belong group 20, group 45. In addition, I may have other identities such as a database login with a name of scott. Since a principal contains only a single name, my identity is modeled as a set of these principals. For the most part, subjects are opaque objects. You can retrieve the entire set of principals from the subject object as well as private and public credentials i.e., keys and certificates if they are set by the login system. Unless youre implementing your own authentication system, you really use the subject object only as an argument to one of the following static methods of the Subject class: public static Object doAsSubject s, PrivilegedAction pa public static Object doAsSubject s, PrivilegedExceptionAction pea public static Object doAsPrivilegedSubject s, PrivilegedAction pa, AccessControlContext acc public static Object doAsPrivilegedSubject s, PrivilegedExceptionAction pa, AccessControlContext acc Execute the run method of the given object on behalf of the given subject possibly with the given access control context. If the run method can throw an exception, you must use a method that requires a PrivilegedExceptionAction parameter; the exception will be wrapped into a PrivilegedExecption . The doAs method looks remarkably similar to the doPrivileged method of the access controller. This is not an accident: the doAs method sets up special checking that the access controller uses to perform permission checking. The details of how that works are coming up next.

15.2.2 The JAAS User−Specific Code

The code that well execute in our simple example looks like this: package javasec.samples.ch15; import java.io.; import java.security.; class CountFilesAction implements PrivilegedAction { public Object run { File f = new FileFile.separatorChar + files; File fArray[] = f.listFiles ; return new IntegerfArray.length; } }