Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

authenticator.h

Go to the documentation of this file.
00001 #ifndef DV_TICKET_AUTHENTICATOR
00002 #define DV_TICKET_AUTHENTICATOR
00003 // $Id: authenticator.h,v 1.9 2003/07/23 17:58:38 dvermeir Exp $
00004 #include <stdexcept>
00005 #include <dvticket/user.h>
00006 
00007 namespace Dv {
00008 namespace Ticket {
00009 /**
00010  * A class that can check a user's identity,
00011  * based on a login name and password.
00012  * This is an abstract class. An application should implement
00013  * a derived class. The default implementation always succeeds.
00014  *
00015  * @see Dv::Ticket::Request
00016  */
00017 class Authenticator {
00018 public:
00019   /** Destructor. */
00020   virtual ~Authenticator() {}
00021  
00022   /** @return name of this Authenticator.
00023    * Derived classes should have different names, which will
00024    * show up in the server logs.
00025    * @sa Dv::Ticket::Server
00026    */
00027   virtual std::string const name() { return "DefaultAuthenticator"; }
00028 
00029   /** Actual authentication of a user.
00030    * @param host from which user requests authentication
00031    * @param name login name of the user.
00032    * @param passwd password of the user.
00033    * @param info extra info on user.
00034    * @exception runtime_error if there is no user
00035    *   corresponding to the @a name and @a passwd.
00036    */
00037   virtual Dv::Ticket::User validate(const std::string& host, const std::string& name,
00038     const std::string& passwd, const std::string& info="") 
00039       throw (std::runtime_error) { return Dv::Ticket::User("student", 10, name, info); }
00040 
00041   /** Return an anonymous user. Derived classes may decide, based on
00042    * the various parameters whether they will allow an anonymous
00043    * ticket to be issued.
00044    * @param host from which user requests authentication (dot address)
00045    * @param name login name of the user.
00046    * @param info extra info on user.
00047    * @exception runtime_error if the operation failed.
00048    */
00049   virtual Dv::Ticket::User anon_validate(const std::string& host, const std::string& name,
00050     const std::string& info="") throw (std::runtime_error) {
00051       return Dv::Ticket::User("anonymous", 0, name, info); }
00052 };
00053 
00054 }}
00055 #endif
00056 

dvticket-0.7.1 [24 October, 2003]