pion::net::HTTPBasicAuth Class Reference

#include <HTTPBasicAuth.hpp>

Inherits pion::net::HTTPAuth.

List of all members.


Detailed Description

HTTPBasicAuth: a base class for handling HTTP Authentication and session management in accordance with RFC 2617 http://tools.ietf.org/html/rfc2617

Definition at line 27 of file HTTPBasicAuth.hpp.

Public Member Functions

 HTTPBasicAuth (PionUserManagerPtr userManager, const std::string &realm="PION:NET")
 default constructor
virtual ~HTTPBasicAuth ()
 virtual destructor
virtual bool handleRequest (HTTPRequestPtr &request, TCPConnectionPtr &tcp_conn)
virtual void setOption (const std::string &name, const std::string &value)

Protected Member Functions

void handleUnauthorized (HTTPRequestPtr &http_request, TCPConnectionPtr &tcp_conn)

Static Protected Member Functions

static bool parseAuthorization (std::string const &authorization, std::string &credentials)
static bool parseCredentials (std::string const &credentials, std::string &username, std::string &password)


Member Function Documentation

bool pion::net::HTTPBasicAuth::handleRequest ( HTTPRequestPtr request,
TCPConnectionPtr tcp_conn 
) [virtual]

attempts to validate authentication of a new HTTP request. If request valid, pointer to user identity object (if any) will be preserved in the request and return "true". If request not authenticated, appropriate response is sent over tcp_conn and return "false";

Parameters:
request the new HTTP request to handle
tcp_conn the TCP connection that has the new request
Returns:
true if request valid and user identity inserted into request

Implements pion::net::HTTPAuth.

Definition at line 34 of file HTTPBasicAuth.cpp.

References handleUnauthorized(), pion::net::HTTPTypes::HEADER_AUTHORIZATION, pion::net::HTTPAuth::m_user_manager, pion::net::HTTPAuth::needAuthentication(), parseAuthorization(), and parseCredentials().

void pion::net::HTTPBasicAuth::handleUnauthorized ( HTTPRequestPtr http_request,
TCPConnectionPtr tcp_conn 
) [protected]

used to send responses when access to resource is not authorized

Parameters:
http_request the new HTTP request to handle
tcp_conn the TCP connection that has the new request

Definition at line 132 of file HTTPBasicAuth.cpp.

References pion::net::HTTPResponseWriter::create(), pion::net::TCPConnection::finish(), pion::net::HTTPTypes::RESPONSE_CODE_UNAUTHORIZED, and pion::net::HTTPTypes::RESPONSE_MESSAGE_UNAUTHORIZED.

Referenced by handleRequest().

bool pion::net::HTTPBasicAuth::parseAuthorization ( std::string const &  authorization,
std::string &  credentials 
) [static, protected]

extracts base64 user credentials from authorization string

Parameters:
authorization value of the HEADER_AUTHORIZATION

Definition at line 103 of file HTTPBasicAuth.cpp.

Referenced by handleRequest().

bool pion::net::HTTPBasicAuth::parseCredentials ( std::string const &  credentials,
std::string &  username,
std::string &  password 
) [static, protected]

parse base64 credentials and extract username/password

Definition at line 113 of file HTTPBasicAuth.cpp.

References pion::net::HTTPTypes::base64_decode().

Referenced by handleRequest().

void pion::net::HTTPBasicAuth::setOption ( const std::string &  name,
const std::string &  value 
) [virtual]

sets a configuration option Valid options:

Parameters:
name the name of the option to change
value the value of the option

Reimplemented from pion::net::HTTPAuth.

Definition at line 95 of file HTTPBasicAuth.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 14:48:54 2010 for pion-net by  doxygen 1.4.7