FileDocCategorySizeDatePackage
SimpleLoginModule.javaAPI DocExample3633Mon Jan 15 13:05:10 GMT 2001javasec.samples.ch15

SimpleLoginModule.java

package javasec.samples.ch15;

import java.util.*;
import java.io.IOException;
import javax.security.auth.*;
import javax.security.auth.callback.*;
import javax.security.auth.login.*;
import javax.security.auth.spi.*;

public class SimpleLoginModule implements LoginModule {

    private Subject subject;
    private CallbackHandler callbackHandler;
    private SimplePrincipal principal;
    private boolean debug;

    // State information for the currently-authenticated user
    private String userName = null;
    private boolean succeeded = false;
    private boolean commitSucceeded = false;

    public void initialize(Subject s, CallbackHandler cb,
                           Map sharedMap, Map options) {
 
        subject = s;
        callbackHandler = cb;

        // initialize any configured options
        debug = "true".equalsIgnoreCase((String)options.get("debug"));

        // We don