A LoginContext is little more than a factory to create a {@link Subject} and can be discardedafterwards. Usually it contains some credentials such as username and password. Note that generally it is no a good idea to store those type of credentials in the session, so if you plan on keeping this context in the session be sure to clear them before you return a Subject in {@link #login()}. Some applications will require you to login with two or more different LoginContexts before a user is fully authenticated. For that purpose a sortOrder is available in the context. which is used in descending order to pass authentication requests to the subjects until one of them authenticates. Sort orders are >=0 and are not required to have an interval of 1. For example 0, 5,6 are all perfectly legal sort orders for one user. Duplicates are also allowed, in that case they are queried in reverse order of login. The context also contains a flag to indicate if an additional login is allowed. Note that both the sort order and the additional login flag must be constant. Also note that all LoginContexts of the same class and with the same sort order are equal, thus for logoff you do not need to keep a reference to the context but can simply use a new instance.
@author marrink
@see #preventsAdditionalLogins()
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.