FileDocCategorySizeDatePackage
PasswordAliasConfigMBean.javaAPI DocGlassfish v2 API7085Fri May 04 22:24:10 BST 2007com.sun.enterprise.admin.mbeans

PasswordAliasConfigMBean

public class PasswordAliasConfigMBean extends com.sun.enterprise.admin.config.BaseConfigMBean

Fields Summary
private static final com.sun.enterprise.util.i18n.StringManager
_strMgr
private static Logger
_logger
private static ExceptionHandler
_handler
Constructors Summary
public PasswordAliasConfigMBean()

        super();        
    
Methods Summary
public voidaddPasswordAlias(java.lang.String aliasName, java.lang.String password)
Add a non-existing password alias

param
aliasName the name of the alias
param
password the password of the alias
throws
ConfigException

        try {            
            PasswordAdapter p = getPasswordAdapter();
            if (p.aliasExists(aliasName)) {
                throw new ConfigException(_strMgr.getString("passwordAliasExists", aliasName));
            } 
            p.setPasswordForAlias(aliasName, password.getBytes());           
        } catch (Exception ex) {
            throw getExceptionHandler().handleConfigException(
                ex, "addPasswordAliasException", aliasName);
        }
    
protected static ExceptionHandlergetExceptionHandler()

    
    //The exception handler is used to parse and log exceptions
        
    
        if (_handler == null) {
            _handler = new ExceptionHandler(getLogger());
        }
        return _handler;
    
private static java.util.logging.LoggergetLogger()

   
        
        
    
        if (_logger == null) {
            _logger = Logger.getLogger(AdminConstants.kLoggerName);
        }
        return _logger;
    
private com.sun.enterprise.security.store.PasswordAdaptergetPasswordAdapter()

        //The masterPassword in the IdentityManager is available only through
        //a running DAS, server instance, or node agent.
        String masterPassword = IdentityManager.getMasterPassword();
        return new PasswordAdapter(masterPassword.toCharArray());
    
public java.lang.String[]getPasswordAliases()
Get all the password aliases

throws
ConfigException
return
The list of password aliases

        try {   
            ArrayList result = new ArrayList();
            Enumeration en = getPasswordAdapter().getAliases();
            while (en.hasMoreElements()) {                            
                result.add((String)en.nextElement());                               
            }            
            return (String[])result.toArray(new String[result.size()]);
        } catch (Exception ex) {
            throw getExceptionHandler().handleConfigException(
                ex, "listPasswordAliasException", "");
        }
    
public voidremovePasswordAlias(java.lang.String aliasName)
Remove an existing password alias

param
aliasName the name of the password alias to remove
throws
ConfigException

        try {            
            PasswordAdapter p = getPasswordAdapter();
            if (!p.aliasExists(aliasName)) {
                throw new ConfigException(_strMgr.getString("passwordAliasDoesNotExist", aliasName));
            }
            p.removeAlias(aliasName);
        } catch (Exception ex) {
            throw getExceptionHandler().handleConfigException(
                ex, "removePasswordAliasException", aliasName);
        }
    
public voidupdatePasswordAlias(java.lang.String aliasName, java.lang.String password)
Update the password for an existing alias

param
aliasName the name of the alias whose password is to be updated
param
password the new password
throws
ConfigException

        try {
            PasswordAdapter p = getPasswordAdapter();
            if (!p.aliasExists(aliasName)) {
                throw new ConfigException(_strMgr.getString("passwordAliasDoesNotExist", aliasName));
            }
            p.setPasswordForAlias(aliasName, password.getBytes());
        } catch (Exception ex) {
            throw getExceptionHandler().handleConfigException(
                ex, "updatePasswordAliasException", aliasName);
        }