/** * Tries to authorize current connection and throws AuthenticationErrorException if not * successful. * * <p>Retrieved token is stored for later use with all commands that need authentication. */ public void login(@NotNull String userName, @NotNull String password) throws AuthenticationErrorException, CommandExecutionException, IOException { final Login login = new Login(this); login.setParameter("login", userName); login.setParameter("password", password); final CommandResult<String> result = execute(login); if (result.success()) { authorization = result.getResult(); this.userName = userName; this.password = password; timeout = Calendar.getInstance().getTimeInMillis(); } else throw new AuthenticationErrorException(this, userName, password.replaceAll(".", "*")); }