How to authenticate a Flex/Flash application consuming Domino web services...
The Flex 3 WebService class methods setCredentials() and setRemoteCredentials() do not work when accessing Domino web services. The following describes a workaround solution...
Domino provides a very simple way of authentication via a parameterized URL request. The syntax is looking like this:
RootURL + "/names.nsf?login&username=<username>&password=<password>
RootURL is the website domain address e.g. http://www.flexdomino.net
<username> is the name of the registered Domino user as listed in names.nsf (public address book)
<password> is the user's internet password, NOT the Notes Client (user.id) password.
I used names.nsf in this example as this database definitely exists. However, one can authenticate using the same syntax against any existing Notes database.
Instead of HTTP one can use (temporarily) HTTPS to avoid passing the credentials in clear text. After authentication, the web service can be accessed via HTTP.
The trick on the Flex side is to wrap the Flex Web Service class into a custom class that contains at least the following properties:
- webservice:WebService
- urlrequest:URLRequest
- urlloader:URLLoader
The URLRequest and URLLoader classes are used to authenticate, the WebService class for calling the web services. As all classes are wrapped in one custom class, the entire custom class object is authenticated through the session ID returned by the URL request call.
The following is a code snip set (not working code) that shows how this wrapper class could look like:
public class myDominoWebService
{
private var wsrv:WebService;
private var wsrvOpDBCOLUMN:AbstractOperation;
private var wsrvOpDBLOOKUP:AbstractOperation;
public var loginURLRequester:URLRequest;
public var loginURLLoader:URLLoader;
private var rootURL:String;
private var applURL:String;
private var credentials:String;
public function myDominoWebService(
rURL:String, // root URL
aURL:String, // application URL for redirect
username:String,
password:String
):void {
this.loginURLRequester = new URLRequest(rURL + "/names.nsf?login&username=" +
username + "&password=" + password + "&redirectto=" + aURL);
this.loginURLLoader = new URLLoader();
// you require listeners here to be able to react on success and failure of the next operation
this.loginURLLoader.load(this.loginURLRequester);
}
//... write here the (wrapping) methods for the web service operations
}
The authentication takes place at the time the wrapper class object is intantiated. Once authenticated it is possible to call the web service operations, which idealy are also wrapped in the same custom wrapper class.
As soon as I have some time I will post a working sample.