Cross-Platform C++

ot::net
class Authenticator  (abstract)

#include "ot/net/Authenticator.h"

ot::ManagedObject ot::auxil::NetAccessHelper An abstract base class that defines a call-back mechanism invoked when a network protocol requires authentication. One example of when an Authenticator is required is when an application attempts to connect to a HTTP resource. If the HTTP server requires client connections to authenticate themselves, the HttpURLStreamHandler obtains the necessary credentials from the default (global) Authenticator.

OpenTop does not create a default Authenticator, so the default action is for access requests for authenticated services to be denied. However, an example implementation of the Authenticator interface is provided by the NetAccessHelper class.

Applications use Authenticator by creating a derived class, and registering an instance of that class using the SetDefault() method. When authentication is required, the network component calls RequestPasswordAuthentication() which delegates the request to the registered Authenticator.




Method Summary
protected  virtual bool getPasswordAuthentication(InetAddress* pAddr, int port, const String& protocol, const String& prompt, const String& scheme, bool bProxy, String& userRet, String& passwordRet)=0
         Called when password authorization is needed.
static bool RequestPasswordAuthentication(InetAddress* pAddr, int port, const String& protocol, const String& prompt, const String& scheme, bool bProxy, String& userRet, String& passwordRet)
         Static method that simply passes the request to the registered global Authenticator (if any).
static void SetDefault(Authenticator* pAuthenticator)
         Sets the default (and global) Authenticator for the application.

Methods inherited from class ot::ManagedObject
addRef, getRefCount, onFinalRelease, operator=, release

Method Detail

getPasswordAuthentication

protected virtual bool getPasswordAuthentication(InetAddress* pAddr,
                                                 int port,
                                                 const String& protocol,
                                                 const String& prompt,
                                                 const String& scheme,
                                                 bool bProxy,
                                                 String& userRet,
                                                 String& passwordRet)=0
Called when password authorization is needed. Derived classes must provide an implementation of this pure virtual function.

Parameters:
pAddr - the IP address of the server requesting authentication
port - the port number of the remote server
protocol - the name of the protocol being used, e.g. 'HTTP'
prompt - a string from the server indicating why a password is required
scheme - the authentication scheme being used
bProxy - indicates if the authentication request is coming from the local proxy server
userRet - a return parameter for the required user name
passwordRet - a return parameter for the required password
Returns:
true if userRet and passwordRet have been set; false otherwise

RequestPasswordAuthentication

static bool RequestPasswordAuthentication(InetAddress* pAddr,
                                          int port,
                                          const String& protocol,
                                          const String& prompt,
                                          const String& scheme,
                                          bool bProxy,
                                          String& userRet,
                                          String& passwordRet)
Static method that simply passes the request to the registered global Authenticator (if any).

Parameters:
pAddr - the IP address of the server requesting authentication
port - the port number of the remote server
protocol - the name of the protocol being used, e.g. 'HTTP'
prompt - a string from the server indicating why a password is required
scheme - the authentication scheme being used
bProxy - indicates if the authentication request is coming from the local proxy server
userRet - a return parameter for the required user name
passwordRet - a return parameter for the required password
Returns:
the return value from the global Authenticator's method or false if no global Authenticator has been registered.

SetDefault

static void SetDefault(Authenticator* pAuthenticator)
Sets the default (and global) Authenticator for the application. In common with all OpenTop global objects, the system ensures the passed object will exist for the lifetime of the application by registering it with the ObjectManager. Therefore, the application does not need to concern itself with managing the lifetime of the object.

For example, the following is perfectly valid and does not present a resource leak:

   Authenticator::SetDefault(new MyCustomAuthenticator);



Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements