FileDocCategorySizeDatePackage
FileUserCommand.javaAPI DocGlassfish v2 API6273Fri May 04 22:25:10 BST 2007com.sun.enterprise.cli.commands

FileUserCommand

public class FileUserCommand extends S1ASCommand
This class gets called when create-file-user command is invoked. This class will overwrite validOptions in GenericCommand to validate the userpassword option. If the userpassword and passwordfile options are not entered in the command line and interactive is true, then CLI will prompt the user for the password.

Fields Summary
private static final String
USER_PASSWORD
private static final String
FILE_USER_NAME
Constructors Summary
Methods Summary
protected booleanconfirmPassword()

        return true;
    
protected java.lang.StringgetPasswordConfirmationPrompt()

        return "FileUserPasswordConfirmationPrompt";
    
protected java.lang.StringgetPasswordOption()
this methods returns the user/alias password.

return
user/alias password
throws
CommandValidationException if could not get userpassword or aliaspassword option

        //getPassword(optionName, allowedOnCommandLine, readPrefsFile, readPasswordOptionFromPrefs, readMasterPasswordFile, mgr, config,
        //promptUser, confirm, validate)
        return getPassword(getPasswordOptionName(), getPasswordPrompt(), 
                            getPasswordConfirmationPrompt(),
                            true, false, false, false, null, null,
                            true, confirmPassword(), false, true);
    
protected java.lang.StringgetPasswordOptionName()

    
       
        return USER_PASSWORD;
    
protected java.lang.StringgetPasswordPrompt()

        return "FileUserPasswordPrompt";
    
private java.lang.StringgetUserName()

        String userName;
        if ((getOperands() != null) && (getOperands().size() != 0))
            userName = (String) getOperands().get(0);
        else //prompt for fileuser
        {
            try {
                InputsAndOutputs.getInstance().getUserOutput().print(
                                    getLocalizedString(this.getUserPrompt()));
                userName = InputsAndOutputs.getInstance().getUserInput().getLine();
            }
            catch (IOException ioe)
            {
                throw new CommandValidationException(
                            getLocalizedString("CannotReadOption", 
                                        new Object[]{getUserOptionName()}));
            }
        }   
        
        return userName;
    
protected java.lang.StringgetUserOptionName()

        return FILE_USER_NAME;
    
protected java.lang.StringgetUserPrompt()

        return "FileUserPrompt";
    
public voidrunCommand()

        validateOptions();
        //use http connector
        MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 
                                                              getUser(), getPassword());
        final String objectName = getObjectName();
        final Object[] params = getParamsInfo();
        final String operationName = getOperationName();
        final String[] types = getTypesInfo();

        //get fileuser and set it in the params
        params[0] = getUserName();
        //get fileuser password and set it in the params
        params[1] = getPasswordOption();
        try
        { 
	    //if (System.getProperty("Debug") != null) printDebug(mbsc, objectName);
            Object returnValue = mbsc.invoke(new ObjectName(objectName), 
					     operationName, params, types);
            handleReturnValue(returnValue);
	    CLILogger.getInstance().printDetailMessage(getLocalizedString(
						       "CommandSuccessful",
						       new Object[] {name}));
        }
        catch(Exception e)
        {
            displayExceptionMessage(e);
        }        
    
public booleanvalidateOptions()
Validate the userpassword option.

    	return super.validateOptions();