Real Estate Forums

Coding HTML, ASP, PHP, JAVA MYSQL and more. All coding questions should be asked here.

Reply
 
Thread Tools Display Modes
Old 05-31-2007, 11:21 AM
Rottmanj Rottmanj is offline
New real estate webmaster
 
Join Date: May 2007
Posts: 3
Rottmanj is on a distinguished road
Default Working RETS Auth Script

Well since this project got canned due to server errors with my local IDX provider I really don't have time to write up a formal tutorial on how I did this. But I am going to post my code (pretty easy to understand).


<cfhttp url="http://myrets.server.com/LOGIN_URI" method="get" />

<h3>Initial Server Response</h3>
<cfdump var="#cfhttp#" />

<cfscript>
/* These three vars should be provided to you by your IDX provided.
In the case you are not given the login url, use everything after the port number or tld (.com)
Do not use the page name in your login uri (login.aspx) It should look something like this /rets/login
*/
username = "USERNAME";
password = "PASSWORD";
login_uri = "LOGINURI";
// create an array without the auth type. So you are left only with the auth parameters.
tempList = Replace(cfhttp.responseHeader["WWW-Authenticate"],"Digest ",'','All');
headerArr = ListToArray(Trim(tempList));
/* create an array holding the auth type. This can be used to extend
this script to allow fo both basic and digest auth
*/
auth_Temp = ListToArray(Trim(cfhttp.responseHeader["WWW-Authenticate"]),' ');
/* Set a variable to the auth type */
auth_Type = auth_Temp[1];

/* Create a structure that will hold the auth parameter objects.
We set the struct key to the value of the auth paramter.
*/
authStc = structNew();
for(i=1;i lte ArrayLen(headerArr);i=i+1){
key = Replace(Left(headerArr,Find('=',headerArr)),'=','' ,'ALL');
value = Replace(RemoveChars(headerArr,1,Find('=',headerArr ,"1")),'"','','ALL');
authStc[key] = value;
}
// Define the authentication realm.
auth_Realm = authStc['realm'];

A1 = username & ':' & auth_Realm & ':' & password;
A2 = 'GET:' & login_uri;

auth_Nonce = authStc['nonce'];
auth_Opaque = authStc['opaque'];
// create the raw_digest
raw_Digest = Lcase(Hash(A1,"MD5")) & ':' & auth_Nonce & ':' & Lcase(Hash(A2,"MD5"));
// create the final response
response = Lcase(Hash(raw_digest,"MD5"));
// create the final digest auth string
encodedAuth = 'Digest username=' & chr(34) & username & chr(34) & ',' &
'realm=' & chr(34) & auth_Realm & chr(34) & ',' &
'nonce=' & chr(34) & auth_Nonce & chr(34) & ',' &
'uri=' & chr(34) & login_uri & chr(34) & ',' &
'response=' & chr(34) & response & chr(34) & ',' &
'opaque=' & chr(34) & auth_Opaque & chr(34);
</cfscript>

<cfoutput>#encodedAuth#</cfoutput><br />
<br />



<cfhttp url="http://myrets.server.com/LOGIN_URI" method="get" >
<cfhttpparam name="Authorization:" type="header" value="#encodedAuth#" />
</cfhttp>

<cfoutput>#cfhttp.StatusCode#</cfoutput>

Last edited by Rottmanj; 06-02-2007 at 06:24 PM.
Reply With Quote
Old 07-10-2007, 10:46 PM
CodeGuy CodeGuy is offline
New real estate webmaster
 
Join Date: Jul 2007
Posts: 25
CodeGuy is on a distinguished road
Default Re: Working RETS Auth Script

I've got some working vb.net examples that I've implemented with our marketlinx RETS service.
If anyone is interested?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



For our members

Main Sections

IDX Coverage Areas

Spiders Welcome

All times are GMT -7. The time now is 04:55 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.