FileDocCategorySizeDatePackage
ASJMXAuthenticator.javaAPI DocGlassfish v2 API4748Fri May 04 22:33:54 BST 2007com.sun.enterprise.admin.server.core.jmx.auth

ASJMXAuthenticator

public class ASJMXAuthenticator extends Object implements JMXAuthenticator

Fields Summary
private static final boolean
_debug
private static Logger
_logger
private static com.sun.enterprise.util.i18n.StringManager
_strings
private String
realmName
private LoginDriver
loginDriver
Constructors Summary
public ASJMXAuthenticator()


      
    
public ASJMXAuthenticator(String realmName)

        setRealmName(realmName);
    
Methods Summary
public javax.security.auth.Subjectauthenticate(java.lang.Object credentials)

        
        if (credentials == null) {
            if (_debug) {
                System.out.println("JMXAuthenticator: Null credentials sent from the client");
            }
            throwInvalidCredentialsException();
        }
        if (!(credentials instanceof String[])) {
            if (_debug) {
                System.out.println("JMXAuthenticator: Invalid credentials sent from the client " + credentials.getClass().getName());
            }
            throwInvalidCredentialsException();
        }
        String[] userpass = (String[])credentials;
        if (userpass.length != 2) {
            if (_debug) {
                System.out.println("JMXAuthenticator: Invalid credentials sent from client, string array of length " + userpass.length);
            }
            throwInvalidCredentialsException();
        }
        if (_debug) {
            System.out.println("JMX authentication request for user "
                + userpass[0] + " and password " + userpass[1]);
            System.out.println("Authentication realm is " + realmName);
        }

        Subject subject = null;
        if (loginDriver != null) {
            subject = loginDriver.login(userpass[0], userpass[1], realmName);
        } else {
            // TODO: WARNING message, JMX connector not protected
        }
        return subject;
    
public LoginDrivergetLoginDriver()

        return loginDriver;
    
public java.lang.StringgetRealmName()

        return realmName;
    
public voidsetLoginDriver(LoginDriver driver)

        // TODO: Add permission check.
        loginDriver = driver;
    
public voidsetRealmName(java.lang.String realm)

        // TODO: Add permission check.
        realmName = realm;
    
private voidthrowInvalidCredentialsException()

        throw new SecurityException(
                _strings.getString("admin.auth.invalid.credentials"));