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

ASLoginDriverImpl

public class ASLoginDriverImpl extends Object implements LoginDriver

Fields Summary
private static final String
ASADMIN_GROUP
private static Logger
_logger
private static com.sun.enterprise.util.i18n.StringManager
_strings
Constructors Summary
public ASLoginDriverImpl()


      
    
Methods Summary
private voidauthorize(java.lang.String user, java.lang.String password, java.lang.String realmName)

        boolean isAuthorized = false;
        try {
            boolean isValid = Realm.isValidRealm(realmName);
            if (!isValid) {
                realmName = Realm.getDefaultRealm();
            }
            Realm realm = Realm.getInstance(realmName);
            Enumeration groups = realm.getGroupNames(user);
            while (groups != null && groups.hasMoreElements()) {
                String groupName = (String)groups.nextElement();
                if (ASADMIN_GROUP.equals(groupName)) {
                    isAuthorized = true;
                    break;
                }
            }
        } catch (Exception ee) {
            _logger.log(Level.WARNING, "core.auth_failed", realmName);
            _logger.log(Level.INFO, "core.auth_fail_exception", ee);
            SecurityException se = new SecurityException(
                    _strings.getString("admin.auth.failed"));
            se.initCause(ee);
            throw se;
        }
        if (!isAuthorized) {
            throw new SecurityException(
                    _strings.getString("admin.auth.failed.nogroup"));
        }
        return;
    
public javax.security.auth.Subjectlogin(java.lang.String user, java.lang.String password, java.lang.String realm)

        LoginContextDriver.login(user, password, realm);
        // Login succeeded, try authorization
        authorize(user, password, realm);
        /* **
        ** TODO: The subject needs to be initialized properly 
        JMXPrincipal principal = new JMXPrincipal(user);
        HashSet principalSet = new HashSet();
        principalSet.add(principal);
        Subject subj = new Subject(true, principalSet, new HashSet(),
                new HashSet());
        return subj;
        ** */
        return null;