Archived
0

don't save login in field

This commit is contained in:
Mo
2015-07-19 12:47:33 +03:00
committed by iMoHax
parent 37e147055f
commit 0ab1490d1c
2 changed files with 7 additions and 9 deletions

View File

@@ -32,15 +32,11 @@ public class EDSession {
private final static String USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257"; private final static String USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257";
private final static String COOKIE_FILE = "edce.tmp"; private final static String COOKIE_FILE = "edce.tmp";
private final String login;
private final String password;
private CookieStore cookieStore; private CookieStore cookieStore;
private CloseableHttpClient httpClient; private CloseableHttpClient httpClient;
private ED_SESSION_STATUS lastStatus; private ED_SESSION_STATUS lastStatus;
public EDSession(String login, String password) throws IOException, ClassNotFoundException { public EDSession() throws IOException, ClassNotFoundException {
this.login = login;
this.password = password;
this.lastStatus = ED_SESSION_STATUS.LOGIN_REQUIRED; this.lastStatus = ED_SESSION_STATUS.LOGIN_REQUIRED;
initClient(); initClient();
} }
@@ -55,7 +51,7 @@ public class EDSession {
.build(); .build();
} }
public void login(){ public void login(String login, String password){
LOG.info("Login to {}, email {}", COMPANION_DOMAIN, login); LOG.info("Login to {}, email {}", COMPANION_DOMAIN, login);
HttpUriRequest loginRequest = RequestBuilder.post(LOGIN_URL) HttpUriRequest loginRequest = RequestBuilder.post(LOGIN_URL)
.addParameter("email", login) .addParameter("email", login)

View File

@@ -22,18 +22,20 @@ public class EDSessionDemo {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
LOG.info("Test ED Companion connect"); LOG.info("Test ED Companion connect");
EDSession edSession = new EDSession("frontier@mail.ru","elite"); EDSession edSession = new EDSession();
if (edSession.getLastStatus() == ED_SESSION_STATUS.OK){ if (edSession.getLastStatus() == ED_SESSION_STATUS.OK){
LOG.info("Check get profile"); LOG.info("Check get profile");
edSession.readProfile(s ->{}); edSession.readProfile(s ->{});
} }
if (edSession.getLastStatus() == ED_SESSION_STATUS.LOGIN_REQUIRED) { if (edSession.getLastStatus() == ED_SESSION_STATUS.LOGIN_REQUIRED) {
edSession.login(); String login = readLine("Login:");
String pass = readLine("Password:");
edSession.login(login, pass);
if (edSession.getLastStatus() == ED_SESSION_STATUS.VERIFICATION_REQUIRED) { if (edSession.getLastStatus() == ED_SESSION_STATUS.VERIFICATION_REQUIRED) {
LOG.info("Check verification"); LOG.info("Check verification");
String code = readLine("Verify code:"); String code = readLine("Verify code:");
edSession.submitVerifyCode(code); edSession.submitVerifyCode(code);
edSession.login(); edSession.login(login, pass);
} }
if (edSession.getLastStatus() == ED_SESSION_STATUS.OK) { if (edSession.getLastStatus() == ED_SESSION_STATUS.OK) {
LOG.info("Check get profile"); LOG.info("Check get profile");