@Test public void testConfirmLogin() throws LoginFailedException, IOException, MediaWikiApiErrorException { String token = connection.getOrFetchToken("login"); connection.confirmLogin(token, "username", "password"); }
protected void confirmLogin(String token, String username, String password) throws IOException, LoginFailedException, MediaWikiApiErrorException { Map<String, String> params = new HashMap<>(); params.put(PARAM_ACTION, "login"); params.put(PARAM_LOGIN_USERNAME, username); params.put(PARAM_LOGIN_PASSWORD, password); params.put(PARAM_LOGIN_TOKEN, token); JsonNode root = sendJsonRequest("POST", params); String result = root.path("login").path("result").textValue(); if (LOGIN_RESULT_SUCCESS.equals(result)) { this.loggedIn = true; this.username = username; this.password = password; } else { String message = getLoginErrorMessage(result); logger.warn(message); if (LOGIN_WRONG_TOKEN.equals(result)) { throw new NeedLoginTokenException(message); } else { throw new LoginFailedException(message); } } }
BasicApiConnection extends ApiConnection { protected void confirmLogin(String token, String username, String password) throws IOException, LoginFailedException, MediaWikiApiErrorException { Map<String, String> params = new HashMap<>(); params.put(PARAM_ACTION, "login"); params.put(PARAM_LOGIN_USERNAME, username); params.put(PARAM_LOGIN_PASSWORD, password); params.put(PARAM_LOGIN_TOKEN, token); JsonNode root = sendJsonRequest("POST", params); String result = root.path("login").path("result").textValue(); if (LOGIN_RESULT_SUCCESS.equals(result)) { this.loggedIn = true; this.username = username; this.password = password; } else { String message = getLoginErrorMessage(result); logger.warn(message); if (LOGIN_WRONG_TOKEN.equals(result)) { throw new NeedLoginTokenException(message); } else { throw new LoginFailedException(message); } } } }
BasicApiConnection extends ApiConnection { protected void confirmLogin(String token, String username, String password) throws IOException, LoginFailedException, MediaWikiApiErrorException { Map<String, String> params = new HashMap<>(); params.put(PARAM_ACTION, "login"); params.put(PARAM_LOGIN_USERNAME, username); params.put(PARAM_LOGIN_PASSWORD, password); params.put(PARAM_LOGIN_TOKEN, token); JsonNode root = sendJsonRequest("POST", params); String result = root.path("login").path("result").textValue(); if (LOGIN_RESULT_SUCCESS.equals(result)) { this.loggedIn = true; this.username = username; this.password = password; } else { String message = getLoginErrorMessage(result); logger.warn(message); if (LOGIN_WRONG_TOKEN.equals(result)) { throw new NeedLoginTokenException(message); } else { throw new LoginFailedException(message); } } } BasicApiConnection(String apiBaseUrl); @JsonCreator protected  BasicApiConnection(
			@JsonProperty("baseUrl") String apiBaseUrl,
			@JsonProperty("cookies") List<HttpCookieWrapper> cookies,
			@JsonProperty("username") String username,
			@JsonProperty("loggedIn") boolean loggedIn,
			@JsonProperty("tokens") Map<String, String> tokens,
			@JsonProperty("connectTimeout") int connectTimeout,
			@JsonProperty("readTimeout") int readTimeout); }
BasicApiConnection extends ApiConnection { protected void confirmLogin(String token, String username, String password) throws IOException, LoginFailedException, MediaWikiApiErrorException { Map<String, String> params = new HashMap<>(); params.put(PARAM_ACTION, "login"); params.put(PARAM_LOGIN_USERNAME, username); params.put(PARAM_LOGIN_PASSWORD, password); params.put(PARAM_LOGIN_TOKEN, token); JsonNode root = sendJsonRequest("POST", params); String result = root.path("login").path("result").textValue(); if (LOGIN_RESULT_SUCCESS.equals(result)) { this.loggedIn = true; this.username = username; this.password = password; } else { String message = getLoginErrorMessage(result); logger.warn(message); if (LOGIN_WRONG_TOKEN.equals(result)) { throw new NeedLoginTokenException(message); } else { throw new LoginFailedException(message); } } } BasicApiConnection(String apiBaseUrl); @JsonCreator protected  BasicApiConnection(
			@JsonProperty("baseUrl") String apiBaseUrl,
			@JsonProperty("cookies") List<HttpCookieWrapper> cookies,
			@JsonProperty("username") String username,
			@JsonProperty("loggedIn") boolean loggedIn,
			@JsonProperty("tokens") Map<String, String> tokens,
			@JsonProperty("connectTimeout") int connectTimeout,
			@JsonProperty("readTimeout") int readTimeout); static BasicApiConnection getTestWikidataApiConnection(); static BasicApiConnection getWikidataApiConnection(); static BasicApiConnection getWikimediaCommonsApiConnection(); void login(String username, String password); @JsonProperty("cookies") List<HttpCookie> getCookies(); void clearCookies(); void logout(); }
BasicApiConnection extends ApiConnection { protected void confirmLogin(String token, String username, String password) throws IOException, LoginFailedException, MediaWikiApiErrorException { Map<String, String> params = new HashMap<>(); params.put(PARAM_ACTION, "login"); params.put(PARAM_LOGIN_USERNAME, username); params.put(PARAM_LOGIN_PASSWORD, password); params.put(PARAM_LOGIN_TOKEN, token); JsonNode root = sendJsonRequest("POST", params); String result = root.path("login").path("result").textValue(); if (LOGIN_RESULT_SUCCESS.equals(result)) { this.loggedIn = true; this.username = username; this.password = password; } else { String message = getLoginErrorMessage(result); logger.warn(message); if (LOGIN_WRONG_TOKEN.equals(result)) { throw new NeedLoginTokenException(message); } else { throw new LoginFailedException(message); } } } BasicApiConnection(String apiBaseUrl); @JsonCreator protected  BasicApiConnection(
			@JsonProperty("baseUrl") String apiBaseUrl,
			@JsonProperty("cookies") List<HttpCookieWrapper> cookies,
			@JsonProperty("username") String username,
			@JsonProperty("loggedIn") boolean loggedIn,
			@JsonProperty("tokens") Map<String, String> tokens,
			@JsonProperty("connectTimeout") int connectTimeout,
			@JsonProperty("readTimeout") int readTimeout); static BasicApiConnection getTestWikidataApiConnection(); static BasicApiConnection getWikidataApiConnection(); static BasicApiConnection getWikimediaCommonsApiConnection(); void login(String username, String password); @JsonProperty("cookies") List<HttpCookie> getCookies(); void clearCookies(); void logout();  }