/** * Creates a new standard authentication system with the given options. * * @param configLocation The location of the Spring configuration file (Spring context). * @param propertiesFilesBean The name of the properties file bean (Spring context). * @param userPropertyName The property name for the username (Spring context). * @param passwordPropertyName The property name for the password (Spring context). * @param userShort The short form of the command-line option for the username (command-line * context). * @param userLong The long form of the command-line option for the username (command-line * context). * @param passwordShort The short form of the command-line option for the password (command-line * context). * @param passwordLong The long form of the command-line option for the password (command-line * context). * @param cliArgs The command-line arguments (command-line context). */ public StandardAuthentication( String configLocation, String propertiesFilesBean, String userPropertyName, String passwordPropertyName, String userShort, String userLong, String passwordShort, String passwordLong, String[] cliArgs) { mSystem = new AuthenticationSystem(); mUserHolder = new Holder<String>(Messages.NO_USER); mPasswordHolder = new HolderCharArray(Messages.NO_PASSWORD); SpringContext springContext = new SpringContext(true, configLocation, propertiesFilesBean); springContext.add( new SpringSetterString( mUserHolder, new I18NBoundMessage1P(Messages.USER_SPRING_USAGE, userPropertyName), userPropertyName)); springContext.add( new SpringSetterCharArray( mPasswordHolder, new I18NBoundMessage1P(Messages.PASSWORD_SPRING_USAGE, passwordPropertyName), passwordPropertyName)); mSystem.add(springContext); mCliContext = new CliContext(true, cliArgs); mCliContext.add( new CliSetterString( mUserHolder, new I18NBoundMessage2P(Messages.USER_CLI_USAGE, userShort, userLong), userShort, userLong, Messages.USER_DESCRIPTION)); mCliContext.add( new CliSetterCharArray( mPasswordHolder, new I18NBoundMessage2P(Messages.PASSWORD_CLI_USAGE, passwordShort, passwordLong), passwordShort, passwordLong, Messages.PASSWORD_DESCRIPTION)); mSystem.add(mCliContext); ConsoleContext consoleContext = new ConsoleContext(false); consoleContext.add( new ConsoleSetterString(mUserHolder, Messages.USER_CONSOLE_USAGE, Messages.USER_PROMPT)); consoleContext.add( new ConsoleSetterCharArray( mPasswordHolder, Messages.PASSWORD_CONSOLE_USAGE, Messages.PASSWORD_PROMPT)); mSystem.add(consoleContext); }
/** * Returns the command-line arguments which the receiver was unable to parse. * * @return The arguments. */ public String[] getOtherArgs() { return mCliContext.getCommandLine().getArgs(); }