Search in sources :

Example 1 with AuthForm

use of forpdateam.ru.forpda.api.auth.models.AuthForm in project ForPDA by RadiationX.

the class Auth method getForm.

public AuthForm getForm() throws Exception {
    NetworkResponse response = Api.getWebClient().get(AUTH_BASE_URL);
    if (response.getBody() == null || response.getBody().isEmpty())
        throw new Exception("Page empty!");
    if (checkLogin(response.getBody()))
        throw new Exception("You already logged");
    AuthForm form = new AuthForm();
    Matcher matcher = captchaPattern.matcher(response.getBody());
    if (matcher.find()) {
        form.setCaptchaTime(matcher.group(1));
        form.setCaptchaSig(matcher.group(2));
        form.setCaptchaImageUrl(matcher.group(3));
    } else {
        throw new Exception("Form Not Found");
    }
    form.setBody(response.getBody());
    return form;
}
Also used : Matcher(java.util.regex.Matcher) NetworkResponse(forpdateam.ru.forpda.api.NetworkResponse) AuthForm(forpdateam.ru.forpda.api.auth.models.AuthForm)

Aggregations

NetworkResponse (forpdateam.ru.forpda.api.NetworkResponse)1 AuthForm (forpdateam.ru.forpda.api.auth.models.AuthForm)1 Matcher (java.util.regex.Matcher)1