00001 #ifndef DVTICKET_CGI_H 00002 #define DVTICKET_CGI_H 00003 // $Id: cgi.h,v 1.7 2003/08/16 10:10:23 dvermeir Exp $ 00004 00005 #include <stdexcept> 00006 #include <dvcgi/cgi.h> 00007 #include <dvticket/ticket.h> 00008 00009 namespace Dv { 00010 namespace Ticket { 00011 00012 /** A specialization of Dv::Cgi::Cgi, which transparently verifies 00013 * the user identity, using a login.cgi server. One of the 00014 * advantages of this class is that the cgi program never needs 00015 * to handle or know passwords. 00016 */ 00017 class Cgi: public Dv::Cgi::Cgi { 00018 public: 00019 /** Constructor. Upon success, the identity of the use is known. 00020 * @param name of application. 00021 * @param login_url (suffix) where login server runs. Should be such 00022 * that https://login_url is a well-formed (and valid!) url. 00023 * @param default_language 2-letter ISO code of default language to 00024 * be used (may be switched by user when logging in via login.cgi) 00025 * @param ssl_only if true, non-SSL connections will be redirected 00026 * to the https-version of the same url. 00027 * @param type mime type to be returned by this cgi program. 00028 * @param debug if true, header() will have debug flag set. 00029 */ 00030 Cgi(const std::string& name, const std::string& login_url, 00031 const std::string& default_language, bool ssl_only=false, 00032 const std::string& type="text/html", bool debug=false) throw (); 00033 /** Destructor. */ 00034 ~Cgi(); 00035 00036 /** @return Ticket or 0 if none. */ 00037 Dv::Ticket::Ticket::Ref ticket() const { return ticket_; } 00038 /** @return user owning ticket corresponding to cookie. */ 00039 const Dv::Ticket::User& user() const { return ticket_->user(); } 00040 /** @return true iff we were called using https. */ 00041 bool is_ssl() const { return is_ssl_; } 00042 /** @return value of language cookie, default is "nl". */ 00043 const std::string& language() const { return language_; } 00044 00045 00046 private: 00047 /** the ticket, identifying an authenticated user (or, possibly, 00048 * an anonymous user), associated with this CGI object */ 00049 Dv::Ticket::Ticket::Ref ticket_; 00050 /** true iff this cgi program must be accessed only using SSL connections */ 00051 bool is_ssl_; 00052 /** language to communicate with the user */ 00053 std::string language_; 00054 }; 00055 00056 }} 00057 #endif
dvticket-0.7.1 | [24 October, 2003] |