#1 2016-05-21 05:55:22

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

How to mORMot authenication from android

How to mORMot authenication from android  please sample to me

i found this
http://synopse.info/forum/viewtopic.php … 515#p12515

but i am not javascript expert , i can not convert to java


thank you.


Jongruk Aripoo

Offline

#2 2016-05-21 06:57:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: How to mORMot authenication from android

Do you need a Java or JavaScript client?

Offline

#3 2016-05-21 12:09:22

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

Re: How to mORMot authenication from android

java for android studio


Jongruk Aripoo

Offline

#4 2016-05-21 13:04:53

warleyalex
Member
From: Sete Lagoas-MG, Brasil
Registered: 2013-01-20
Posts: 250

Re: How to mORMot authenication from android

Unfortunatly, I couldn't find my native Android/mORMot project, I think my sneak nephew delete this project, I'll try to recover that project and post the full source, anyway, take a look at this source:
https://raw.githubusercontent.com/synop … tcode.java

Offline

#5 2016-05-21 13:58:33

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

Re: How to mORMot authenication from android

thank you warleyalex


Jongruk Aripoo

Offline

#6 2016-05-22 11:17:08

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

Re: How to mORMot authenication from android

i modify some code all work fine until this method

       public String sessionSign(String url) {
        long Tix;
        Date  d = new Date();
        Tix = d.getTime();
        if(lastSessionTickCount == Tix)
            Tix += 1;

        lastSessionTickCount = Tix;

        String aNonce = Long.toHexString(Tix);

        while(aNonce.length() < 8)
            aNonce = '0' +aNonce;
        if (aNonce.length() > 8)
            aNonce = aNonce.substring(aNonce.length() - 8, aNonce.length());

        String ss = Long.toHexString(getCRC32(url,
                getCRC32(aNonce, sessionPrivateKey)));

        while(ss.length() < 8) { ss = '0'+ss; }

        String s = url.indexOf("?") == -1 ? url+ "?session_signature=" : url+ "&session_signature=";
        System.out.println("## sessionIDHexa8="+sessionIDHexa8+" ,aNonce="+aNonce+" ,ss="+ss+" ,s="+s);
        return s + sessionIDHexa8 + aNonce + ss;
    }

i am not understand 2 variable (aNonce,ss)   , the value of aNonce,ss not same javascript at below  , sessionIDHexa8  is same as javascripts

        Client.prototype.signUrl = function (url) {
            if (Client._instance.loggedIn === true) {
              
                var Tix, Nonce, s, ss, d = new Date();
                Tix = d.getTime() - Client._instance.SessionTickCountOffset;
                Nonce = Tix.toString(16);
                
                while (Nonce.length < 8) {
                    Nonce = '0' + Nonce;
                }
                if (Nonce.length > 8) {
                    Nonce = Nonce.slice(Nonce.length - 8);
                }
                ss = Client._instance.crc32(url, Client._instance.crc32(Nonce, Client._instance.SessionPrivateKey)).toString(16);
                while (ss.length < 8) {
                    ss = '0' + ss;
                }
                s = url.indexOf("?") === -1 ? url + '?session_signature=' : url + '&session_signature=';

                console.log("SessionIDHexa8="+Client._instance.SessionIDHexa8+" , Nonce="+Nonce+" ,ss= "+ss+" ,s="+s);

                return s + Client._instance.SessionIDHexa8 + Nonce + ss;
            } else {
                return url;
            }
        };

Jongruk Aripoo

Offline

#7 2016-05-22 11:39:51

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

Re: How to mORMot authenication from android

i think everythink is right. but atfer get with this signutl  server rerturn :

{
"errorCode":403,
"errorText":"Forbidden"
}


Jongruk Aripoo

Offline

#8 2016-05-22 12:36:32

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: How to mORMot authenication from android

You should use the Delphi debugger and check on the server side what is not as expected.

Offline

Board footer

Powered by FluxBB