Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 4 made on Thursday February 12, 2009 at 00:17
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
Password Authorization:

I just added the code to SlimPronto to submit userid and password on http requets. It was actually quite trivial after some pointers from Lyndel and some web searching. In my case I submit on every request as I close the socket down on each request . I do not believe the server cares if it comes in on each transaction.

Basically I add the Authorization sequence in the portion of the message after the http/1.0. How to do it and what it looks like is well documented on the web. Search for http and Authorization. You will find various modes. I am using basic authorization and I just plug it in after the http/1.0\r\n so it looks like
"http: GET . . . / http/1.0\r\n"+"Authorization: Basic "+base64(LOGIN.Userid +":"+ LOGIN.Password)+"\r\n\r\n"

Login.userid is the userid string and login.password is the password string. I made sure my userid and password did not need to be URI encoded, but in the general case it should be URI encoded prior to applying the base64 function. You will also need the function to convert to base 64 which is also well documented on the web but looks like: (written to be understood, not to be efficient)


function base64(inp) { // this program converts the string to base 64 notation.
var password=""; var a=inp.length; var b=Math.floor(a/3); var c=a%3;
var d=0; var e=0; var f=0; var g=0; var trailer=""; var result=""; var i=0;
var LUT="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
for(i=0; i < a-c; i=i+3)
{
d=(inp[i].charCodeAt(0) & 0x00FC)/4;
e=(inp[i].charCodeAt(0) & 0x0003)*16 + (inp[i+1].charCodeAt(0) & 0X00F0)/16;
f=(inp[i+1].charCodeAt(0) & 0X000F)*4+(inp[i+2].charCodeAt(0) & 0X00C0)/64;
g=(inp[i+2].charCodeAt(0) & 0X003F);
result=LUT.charAt(d)+LUT.charAt(e)+LUT.charAt(f)+LUT.charAt(g)
password=password+result
}
switch(c)
{
case 0: break;
case 1: d=(inp[i].charCodeAt(0) & 0X00FC)/4;
e=(inp[i].charCodeAt(0) & 0x0003)*16 +0;
trailer=LUT.charAt(d)+LUT.charAt(e)+"=="; break;
case 2: d=(inp[i].charCodeAt(0) & 0x00FC)/4;
e=(inp[i].charCodeAt(0) & 0x0003)*16 + (inp[i+1].charCodeAt(0) & 0X00F0)/16;
f=(inp[i+1].charCodeAt(0) & 0X000F)*4+0;
trailer=LUT.charAt(d)+LUT.charAt(e)+LUT.charAt(f)+"="; break
}
return password+trailer
}

Last edited by Barry Gordon on February 12, 2009 00:27.


Hosting Services by ipHouse