mercredi 5 août 2015

Understanding Java code and make it jQuery. (loginpage)


I'm trying to understand a login-procedure to a balance-only login page at a bank. There is already a project that has the procedure in Java, but i'm not too familiar with it so I cant fully understand it. (http://ift.tt/1IkcNmO)

I would like to make it in jQuery.

My attempt is:

<html>
<head>
<script src="http://ift.tt/1HheyD3"></script>
</head>
<script>
var user_id="8311117173";
var password="secret";
var pemUrl="http://ift.tt/1IkcNmQ";
var loginUrl="http://ift.tt/1IkcPuY";
var epochTime=Date.now();
$.ajax({
    async: false,
    cache: false,
    type: 'post',
    data: ({
        'p_tranid':epochTime,
        'p_errorScreen':'LOGON_REPOST_ERROR',
        'n_bank':'',
        'empty_pwd':'',
        'username': user_id,
        'password': password
    }),
    url: loginUrl,
    success: function (response) {
        console.log(response);
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        console.log(XMLHttpRequest.responseText);
        console.log(XMLHttpRequest);
        console.log(textStatus);
        console.log(errorThrown);
    }
});
</script>
</html>

The response should include "LOGON_OK", but it does not.

I've seen that in the Java-code, there is something about a certificate-file (http://ift.tt/1KQ3lv4) The code that I'm talking about is below. What is the procedure that I'm missing?

protected LoginPackage preLogin() throws BankException, IOException {
    urlopen = new Urllib(context, CertificateReader.getCertificates(context, R.raw.cert_okq8));
    Date d = new Date();
    List<NameValuePair> postData = new ArrayList<NameValuePair>();
    response = urlopen
            .open("http://ift.tt/1IkcNmQ");
    //p_tranid is the epoch time in milliseconds
    postData.add(new BasicNameValuePair("p_tranid", Long.toString(d.getTime())));
    postData.add(new BasicNameValuePair("p_errorScreen", "LOGON_REPOST_ERROR"));
    postData.add(new BasicNameValuePair("n_bank", ""));
    postData.add(new BasicNameValuePair("empty_pwd", ""));
    postData.add(new BasicNameValuePair("user_id", getUsername().toUpperCase()));
    postData.add(new BasicNameValuePair("password", getPassword()));
    return new LoginPackage(urlopen, postData, response,
            "http://ift.tt/1IkcPuY");
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire