PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PSecureHTTPServiceProcess Class Reference

#include <shttpsvc.h>

Inheritance diagram for PSecureHTTPServiceProcess:
Collaboration diagram for PSecureHTTPServiceProcess:

Classes

struct  Params
 

Public Member Functions

 PSecureHTTPServiceProcess (const Info &inf)
 
 ~PSecureHTTPServiceProcess ()
 
virtual bool InitialiseBase (PHTTPServiceProcess::Params &params)
 
virtual PChannelCreateChannelForHTTP (PChannel *channel)
 Call back to create transport socket, or TLS, channel. More...
 
virtual void OnHTTPStarted (PHTTPServer &server)
 Callback when a new HTTP connection has begun. More...
 
bool SetServerCertificate (const PFilePath &certFile, bool create=false, const char *dn=NULL)
 Set/Create the server certificate to use. More...
 
bool SetServerCredentials (const PString &cert, const PString &key, const PString &ca)
 Set the server credentials, certificates etc, to use. More...
 
virtual PBoolean OnDetectedNonSSLConnection (PChannel *chan, const PString &line)
 
virtual PString CreateNonSSLMessage (const PString &url)
 
virtual PString CreateRedirectMessage (const PString &url)
 
void DisableSSL ()
 
- Public Member Functions inherited from PHTTPServiceProcess
 PHTTPServiceProcess (const Info &inf)
 
 ~PHTTPServiceProcess ()
 
PBoolean OnStart ()
 Called when the service is started. More...
 
void OnStop ()
 Called by the system when the service is stopped. More...
 
PBoolean OnPause ()
 Called by the system when the service is to be paused. More...
 
void OnContinue ()
 Resume after the service was paused. More...
 
const char * GetServiceDependencies () const
 
virtual void OnConfigChanged ()=0
 
virtual PBoolean Initialise (const char *initMsg)=0
 
virtual PString GetPageGraphic ()
 
void GetPageHeader (PHTML &)
 
void GetPageHeader (PHTML &, const PString &title)
 
virtual PString GetCopyrightText ()
 
const PStringGetMacroKeyword () const
 
const PTimeGetCompilationDate () const
 
const PStringGetHomePage () const
 
const PStringGetEMailAddress () const
 
const PStringGetProductName () const
 
const PStringGetGifHTML () const
 
const PStringGetCopyrightHolder () const
 
const PStringGetCopyrightHomePage () const
 
const PStringGetCopyrightEmail () const
 
const PTEACypher::Key & GetProductKey () const
 
const PStringArrayGetSecuredKeys () const
 
const PTEACypher::Key & GetSignatureKey () const
 
bool ShouldIgnoreSignatures () const
 
void SetIgnoreSignatures (bool ig)
 
virtual void AddRegisteredText (PHTML &html)
 
virtual void AddUnregisteredText (PHTML &html)
 
virtual PBoolean SubstituteEquivalSequence (PHTTPRequest &request, const PString &, PString &)
 
- Public Member Functions inherited from PServiceProcess
virtual void Main ()
 User override function for the main execution routine of the thread. More...
 
virtual int InternalMain (void *arg=NULL)
 Main function for process, called from real main after initialisation. More...
 
virtual bool IsServiceProcess () const
 
 ~PServiceProcess ()
 
virtual void AddRunTimeSignalHandlers (const int *signals=NULL)
 Add all the C run-time signal handlers. More...
 
virtual void AsynchronousRunTimeSignal (int signal, PProcessIdentifier source)
 Asynchronous C run-time signal handler, direct callback from OS. More...
 
virtual void HandleRunTimeSignal (int signal)
 
 PServiceProcess (const char *manuf, const char *name, unsigned majorVersion, unsigned minorVersion, CodeStatus status, unsigned patchVersion, unsigned oemVersion=0)
 Create a new service process. More...
 
virtual void OnControl ()
 The Control menu option was used in the SysTray menu. More...
 
- Public Member Functions inherited from PProcess
void PreInitialise (int argc, char **argv)
 Internal initialisation function called directly from InternalMain(). More...
 
bool SignalTimerChange ()
 
 ~PProcess ()
 
Comparison Compare (const PObject &obj) const
 Compare two process instances. More...
 
virtual void PrintOn (ostream &strm) const
 This will print out performance indicators for the process. More...
 
virtual void Terminate ()
 Terminate the process. More...
 
 PProcess (const char *manuf="", const char *name="", unsigned majorVersion=1, unsigned minorVersion=0, CodeStatus status=ReleaseCode, unsigned patchVersion=1, bool library=false, bool suppressStartup=false, unsigned oemVersion=0)
 Create a new process instance. More...
 
void Startup ()
 Start up all items registered with PProcessStartupFactory. More...
 
bool GetAllThreadIdentifiers (std::vector< PThreadIdentifier > &identifiers)
 Return the operating system thread identifiers of all threads. More...
 
PThreadGetThread (PThreadIdentifier threadId) const
 Return the thread for the operating system thread identifier. More...
 
virtual void OnThreadStart (PThread &thread)
 Callback for when a thread is started by the PTLib system. More...
 
virtual void OnThreadEnded (PThread &thread)
 Callback for when a thread is ended if wqas started in the PTLib system. More...
 
virtual bool OnInterrupt (bool terminating)
 Callback for when a ^C (SIGINT), hangup (SIGHUP) or termination request (SIGTERM) is received by process. More...
 
void SetTerminationValue (int value)
 Set the termination value for the process. More...
 
int GetTerminationValue () const
 Get the termination value for the process. More...
 
PArgListGetArguments ()
 Get the programme arguments. More...
 
virtual const PStringGetManufacturer () const
 Get the name of the manufacturer of the software. More...
 
virtual const PStringGetName () const
 Get the name of the process. More...
 
virtual PString GetVersion (PBoolean full=true) const
 Get the version of the software. More...
 
const PFilePathGetFile () const
 Get the processes executable image file path. More...
 
PProcessIdentifier GetProcessID () const
 Get the platform dependent process identifier for the process. More...
 
bool IsMultipleInstance () const
 Indicate if this is the second, or more, instance of this executable. More...
 
PTime GetStartTime () const
 Return the time at which the program was started. More...
 
void GetMemoryUsage (MemoryUsage &usage) const
 Get process memory suage. More...
 
 PPROFILE_EXCLUDE (bool GetProcessTimes(Times &times) const )
 
 PPROFILE_EXCLUDE (static bool GetSystemTimes(Times &times))
 
PString GetUserName () const
 Get the effective user name of the owner of the process, eg "root" etc. More...
 
PBoolean SetUserName (const PString &username, PBoolean permanent=false)
 Set the effective owner of the process. More...
 
PDirectory GetHomeDirectory () const
 Get the "home" directory for the logged in user. More...
 
PString GetGroupName () const
 Get the effective group name of the owner of the process, eg "root" etc. More...
 
PBoolean SetGroupName (const PString &groupname, PBoolean permanent=false)
 Set the effective group of the process. More...
 
int GetMaxHandles () const
 Get the maximum file handle value for the process. More...
 
PBoolean SetMaxHandles (int newLimit)
 Set the maximum number of file handles for the process. More...
 
virtual PString GetConfigurationFile ()
 Get the default file to use in PConfig instances. More...
 
void SetConfigurationPath (const PString &path)
 Set the default file or set of directories to search for use in PConfig. More...
 
virtual void RemoveRunTimeSignalHandlers ()
 Remove all the C run-time signal handlers. More...
 
virtual void HandleRunTimeSignal (const RunTimeSignalInfo &signalInfo)
 Synchronous C run-time signal handler, this is executed in the housekeeper thread. More...
 
- Public Member Functions inherited from PThread
bool IsAutoDelete () const
 
int PXBlockOnChildTerminate (int pid, const PTimeInterval &timeout)
 
int PXBlockOnIO (int handle, int type, const PTimeInterval &timeout)
 
void PXAbortBlock () const
 
void PrintOn (ostream &strm) const
 Standard stream print function. More...
 
 P_DECLARE_TRACED_ENUM (Priority, LowestPriority, LowPriority, NormalPriority, HighPriority, HighestPriority)
 Codes for thread priorities. More...
 
 PThread (PINDEX stack, AutoDeleteFlag deletion=AutoDeleteThread, Priority priorityLevel=NormalPriority, const PString &threadName=PString::Empty())
 Create a new thread instance. More...
 
 ~PThread ()
 Destroy the thread, this simply calls the Terminate() function with all its restrictions and penalties. More...
 
virtual void Restart ()
 Restart a terminated thread using the same stack priority etc that was current when the thread terminated. More...
 
virtual PBoolean IsTerminated () const
 Determine if the thread has been terminated or ran to completion. More...
 
void WaitForTermination () const
 Block and wait for the thread to terminate. More...
 
PBoolean WaitForTermination (const PTimeInterval &maxWait) const
 Block and wait for the thread to terminate. More...
 
virtual void Suspend (PBoolean susp=true)
 Suspend or resume the thread. More...
 
virtual void Resume ()
 Resume thread execution, this is identical to Suspend(false). More...
 
virtual PBoolean IsSuspended () const
 Determine if the thread is currently suspended. More...
 
virtual void SetPriority (Priority priorityLevel)
 Set the priority of the thread relative to other threads in the current process. More...
 
virtual Priority GetPriority () const
 Get the current priority of the thread in the current process. More...
 
virtual void SetAutoDelete (AutoDeleteFlag deletion=AutoDeleteThread)
 Set the flag indicating thread object is to be automatically deleted when the thread ends. More...
 
void SetNoAutoDelete ()
 Reet the flag indicating thread object is to be automatically deleted when the thread ends. More...
 
virtual PString GetThreadName () const
 Get the name of the thread. More...
 
virtual void SetThreadName (const PString &name)
 Change the name of the thread. More...
 
 PPROFILE_EXCLUDE (PThreadIdentifier GetThreadId() const )
 
 PPROFILE_EXCLUDE (static PThreadIdentifier GetCurrentThreadId())
 
 PPROFILE_EXCLUDE (PUniqueThreadIdentifier GetUniqueIdentifier() const )
 
 PPROFILE_EXCLUDE (static PUniqueThreadIdentifier GetCurrentUniqueIdentifier())
 
 PPROFILE_EXCLUDE (static PINDEX GetTotalCount())
 
 PPROFILE_EXCLUDE (bool GetTimes(Times &times))
 
 PPROFILE_EXCLUDE (static bool GetTimes(PThreadIdentifier id, Times &times))
 
 PPROFILE_EXCLUDE (static void GetTimes(std::vector< Times > &times))
 
- Public Member Functions inherited from PObject
__inline unsigned GetTraceContextIdentifier () const
 Get PTRACE context identifier. More...
 
__inline void SetTraceContextIdentifier (unsigned id)
 
__inline void SetTraceContextIdentifier (const PObject &obj)
 
__inline void SetTraceContextIdentifier (const PObject *obj)
 
__inline void CopyTraceContextIdentifier (PObject &obj) const
 
__inline void CopyTraceContextIdentifier (PObject *obj) const
 
virtual ~PObject ()
 
__inline const char * GetClass () const
 
__inline bool IsClass (const char *name) const
 
__inline const PObjectPTraceObjectInstance () const
 
virtual PObjectClone () const
 Create a copy of the class on the heap. More...
 
template<class CLS >
CLS * CloneAs () const
 As for Clone() but converts to specified type. More...
 
virtual PINDEX HashFunction () const
 This function yields a hash value required by the PDictionary class. More...
 
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
 Determine the byte wise comparison of two objects. More...
 
bool operator== (const PObject &obj) const
 Compare the two objects. More...
 
bool operator!= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator< (const PObject &obj) const
 Compare the two objects. More...
 
bool operator> (const PObject &obj) const
 Compare the two objects. More...
 
bool operator<= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator>= (const PObject &obj) const
 Compare the two objects. More...
 
virtual void ReadFrom (istream &strm)
 Input the contents of the object from the stream. More...
 
- Public Member Functions inherited from PHTTPListener
 PHTTPListener (unsigned maxWorkers=10)
 Construct new HTTP listsner with specified maximum number of threads in pool. More...
 
 ~PHTTPListener ()
 Shut down all listeners on destruction. More...
 
bool ListenForHTTP (WORD port, PSocket::Reusability reuse=PSocket::CanReuseAddress, unsigned queueSize=10)
 Start listening for HTTP connections. More...
 
bool ListenForHTTP (const PString &interfaces, WORD port, PSocket::Reusability reuse=PSocket::CanReuseAddress, unsigned queueSize=10)
 
void ShutdownListeners ()
 Shut down the listener socket, it's thread, and all threads in the pool. More...
 
bool IsListening () const
 Indicate is currently listening and processing requests. More...
 
WORD GetPort () const
 Get the port we are lkstening on. More...
 
virtual PHTTPServerCreateServerForHTTP ()
 
const ThreadPoolGetThreadPool () const
 Get the thread pool in use for this HTTP listener. More...
 
ThreadPoolGetThreadPool ()
 
const PHTTPSpaceGetSpace () const
 Get the resource space for HTTP listener. More...
 
PHTTPSpaceGetSpace ()
 

Protected Attributes

PSSLContextm_sslContext
 
- Protected Attributes inherited from PHTTPServiceProcess
PString m_macroKeyword
 
PTEACypher::Key m_productKey
 
PStringArray m_securedKeys
 
PTEACypher::Key m_signatureKey
 
bool m_ignoreSignatures
 
PTime m_compilationDate
 
PString m_manufacturersHomePage
 
PString m_manufacturersEmail
 
PString m_productNameHTML
 
PString m_gifFilename
 
unsigned m_gifWidth
 
unsigned m_gifHeight
 
PString m_gifHTML
 
PString m_copyrightHolder
 
PString m_copyrightHomePage
 
PString m_copyrightEmail
 
atomic< PThread * > m_restartThread
 
- Protected Attributes inherited from PServiceProcess
PSyncPoint m_exitMain
 
bool m_debugMode
 Flag to indicate service is run in simulation mode. More...
 
PString pidFileToRemove
 
PBoolean isTerminating
 
- Protected Attributes inherited from PProcess
bool m_library
 
int m_terminationValue
 
PString m_manufacturer
 
PString m_productName
 
VersionInfo m_version
 
PFilePath m_executableFile
 
PStringArray m_configurationPaths
 
PArgList m_arguments
 
int m_maxHandles
 
PTime m_programStartTime
 
atomic< bool > m_shuttingDown
 
PCriticalSection m_threadMutex
 
ThreadMap m_activeThreads
 
ThreadList m_externalThreads
 
PSyncQueue< PThread * > m_autoDeleteThreads
 
atomic< bool > m_keepingHouse
 
PThreadm_houseKeeper
 
PSyncPoint m_signalHouseKeeper
 
PProcessIdentifier m_processID
 
std::vector
< PRunTimeSignalHandler > 
m_previousRunTimeSignalHandlers
 
std::vector< RunTimeSignalInfom_RunTimeSignalsQueueBuffer
 
size_t m_RunTimeSignalsQueueIn
 
size_t m_RunTimeSignalsQueueOut
 
PCriticalSection m_RunTimeSignalsQueueMutex
 
- Protected Attributes inherited from PThread
enum PThread::Type m_type
 
PINDEX m_originalStackSize
 
PString m_threadName
 
PCriticalSection m_threadNameMutex
 
PThreadIdentifier m_threadId
 
PUniqueThreadIdentifier m_uniqueId
 
- Protected Attributes inherited from PObject
unsigned m_traceContextIdentifier
 
- Protected Attributes inherited from PHTTPListener
PHTTPSpace m_httpNameSpace
 
PString m_listenerInterfaces
 
WORD m_listenerPort
 
PThreadm_listenerThread
 
PSocketList m_httpListeningSockets
 
PList< PHTTPServerm_httpServers
 
ThreadPool m_threadPool
 

Additional Inherited Members

- Public Types inherited from PHTTPServiceProcess
enum  { MaxSecuredKeys = 10 }
 
- Public Types inherited from PProcess
enum  CodeStatus { AlphaCode, BetaCode, ReleaseCode, HotfixCode }
 Release status for the program. More...
 
- Public Types inherited from PThread
enum  AutoDeleteFlag { AutoDeleteThread, NoAutoDeleteThread }
 Codes for thread autodelete flag. More...
 
- Public Types inherited from PObject
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
 Result of the comparison operation performed by the Compare() function. More...
 
- Public Types inherited from PHTTPListener
typedef PQueuedThreadPool< WorkerThreadPool
 
- Static Public Member Functions inherited from PHTTPServiceProcess
static const PStringGetDefaultSection ()
 
static PHTTPServiceProcessCurrent ()
 
- Static Public Member Functions inherited from PServiceProcess
static PServiceProcessCurrent ()
 Get the current service process object. More...
 
- Static Public Member Functions inherited from PProcess
static PString GetOSClass ()
 Get the class of the operating system the process is running on, eg "unix". More...
 
static PString GetOSName ()
 Get the name of the operating system the process is running on, eg "Linux". More...
 
static PString GetOSHardware ()
 Get the hardware the process is running on, eg "sparc". More...
 
static PString GetOSVersion ()
 Get the version of the operating system the process is running on, eg "2.0.33". More...
 
static bool IsOSVersion (unsigned major, unsigned minor=0, unsigned build=0)
 See if operating system is later than the version specified. More...
 
static PDirectory GetOSConfigDir ()
 Get the configuration directory of the operating system the process is running on, eg "/etc" for Unix, "c:\windows" for Win95 or "c:\winnt\system32\drivers\etc" for NT. More...
 
static PString GetLibVersion ()
 Get the version of the PTLib library the process is running on, eg "2.5beta3". More...
 
static PProcessCurrent ()
 Get the current processes object instance. More...
 
static PBoolean IsInitialised ()
 Determine if the current processes object instance has been initialised. More...
 
static PProcessIdentifier GetCurrentProcessID ()
 Get the platform dependent process identifier for the currentprocess. More...
 
static const char * GetRunTimeSignalName (int signal)
 Get the name of the signal. More...
 
- Static Public Member Functions inherited from PThread
static bool WaitAndDelete (PThread *&thread, const PTimeInterval &maxWait=10000, PMutex *mutex=NULL, bool lock=true)
 Wait for thread termination and delete object. More...
 
static void Sleep (const PTimeInterval &delay)
 Suspend the current thread for the specified amount of time. More...
 
static PString GetThreadName (PThreadIdentifier id)
 Get the name of the thread. More...
 
static PString GetCurrentThreadName ()
 Get the current threads name. More...
 
static PString GetIdentifiersAsString (PThreadIdentifier tid, PUniqueThreadIdentifier uid)
 Convert to thread identifers as a string. More...
 
static void GetTimes (std::list< Times > &times)
 
static void GetTimes (std::set< Times > &times)
 
static int GetPercentageCPU (Times &previousTimes, const PTimeInterval &period=PTimeInterval(0, 1), PThreadIdentifier id=PNullThreadIdentifier)
 Calculate the percentage CPU used over a period of time. More...
 
static unsigned GetNumProcessors ()
 Get number of processors, or processor cores, this machine has available. More...
 
static PThreadCurrent ()
 Get the currently running thread object instance. More...
 
static void Yield ()
 Yield to another thread without blocking. More...
 
static PThreadCreate (const PNotifier &notifier, INT parameter=0, AutoDeleteFlag deletion=AutoDeleteThread, Priority priorityLevel=NormalPriority, const PString &threadName=PString::Empty(), PINDEX stackSize=0)
 Create a simple thread executing the specified notifier. More...
 
static PThreadCreate (const PNotifier &notifier, const PString &threadName)
 
- Static Public Member Functions inherited from PObject
static __inline void CopyTraceContextIdentifier (PObject &to, const PObject &from)
 
static __inline void CopyTraceContextIdentifier (PObject &to, const PObject *from)
 
static __inline void CopyTraceContextIdentifier (PObject *to, const PObject &from)
 
static __inline void CopyTraceContextIdentifier (PObject *to, const PObject *from)
 
static __inline const char * Class ()
 
static __inline const PObjectPTraceObjectInstance (const char *)
 
static __inline const PObjectPTraceObjectInstance (const PObject *obj)
 
template<typename T >
static Comparison Compare2 (T v1, T v2)
 Compare two types, returning Comparison type. More...
 
static Comparison InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
 Internal function caled from CompareObjectMemoryDirect() More...
 
- Protected Types inherited from PProcess
typedef std::map
< PThreadIdentifier, PThread * > 
ThreadMap
 
typedef std::list< PSharedPtr
< PExternalThread > > 
ThreadList
 
- Protected Types inherited from PThread
enum  Type { e_IsAutoDelete, e_IsManualDelete, e_IsProcess, e_IsExternal }
 
- Protected Member Functions inherited from PHTTPServiceProcess
void BeginRestartSystem ()
 
void EndRestartSystem ()
 
virtual void OnHTTPEnded (PHTTPServer &server)
 Callback when an existing HTTP connection has ended. More...
 
 P_REMOVE_VIRTUAL (PHTTPServer *, CreateHTTPServer(PChannel &), 0)
 
 P_REMOVE_VIRTUAL (PHTTPServer *, OnCreateHTTPServer(const PHTTPSpace &), 0)
 
- Protected Member Functions inherited from PServiceProcess
int InitialiseService ()
 
- Protected Member Functions inherited from PProcess
void PlatformConstruct ()
 
void PlatformDestruct ()
 
void InternalThreadStarted (PThread *thread)
 
void InternalThreadEnded (PThread *thread)
 
void HouseKeeping ()
 
void InternalPostRunTimeSignal (int signal, PProcessIdentifier source)
 
void InternalHandleRunTimeSignal (const RunTimeSignalInfo &signalInfo)
 
 PDICTIONARY (PXFdDict, POrdinalKey, PThread)
 
- Protected Member Functions inherited from PObject
 PObject ()
 Constructor for PObject, made protected so cannot ever create one on its own. More...
 
- Protected Member Functions inherited from PHTTPListener
void ListenMain ()
 
 PDECLARE_MUTEX (m_httpServersMutex)
 
- Static Protected Member Functions inherited from PProcess
static PRunTimeSignalHandler PlatformSetRunTimeSignalHandler (int signal)
 
static void PlatformResetRunTimeSignalHandler (int signal, PRunTimeSignalHandler previous)
 
- Static Protected Attributes inherited from PProcess
static
POrdinalToString::Initialiser
const 
InternalSigNames []
 

Constructor & Destructor Documentation

PSecureHTTPServiceProcess::PSecureHTTPServiceProcess ( const Info inf)
PSecureHTTPServiceProcess::~PSecureHTTPServiceProcess ( )

Member Function Documentation

virtual PChannel* PSecureHTTPServiceProcess::CreateChannelForHTTP ( PChannel channel)
virtual

Call back to create transport socket, or TLS, channel.

Reimplemented from PHTTPListener.

virtual PString PSecureHTTPServiceProcess::CreateNonSSLMessage ( const PString url)
virtual
virtual PString PSecureHTTPServiceProcess::CreateRedirectMessage ( const PString url)
virtual
void PSecureHTTPServiceProcess::DisableSSL ( )
virtual bool PSecureHTTPServiceProcess::InitialiseBase ( PHTTPServiceProcess::Params params)
virtual

Reimplemented from PHTTPServiceProcess.

virtual PBoolean PSecureHTTPServiceProcess::OnDetectedNonSSLConnection ( PChannel chan,
const PString line 
)
virtual
virtual void PSecureHTTPServiceProcess::OnHTTPStarted ( PHTTPServer server)
virtual

Callback when a new HTTP connection has begun.

Reimplemented from PHTTPListener.

bool PSecureHTTPServiceProcess::SetServerCertificate ( const PFilePath certFile,
bool  create = false,
const char *  dn = NULL 
)

Set/Create the server certificate to use.

Must be called before ListenForHTTP() or https will not be supported.

Parameters
certFileCombined certificate/private key file
createFlag indicating a self signed certificate should be generated if it does not exist.
dnDistinguished Name to use if creating new self signed certificate.
bool PSecureHTTPServiceProcess::SetServerCredentials ( const PString cert,
const PString key,
const PString ca 
)

Set the server credentials, certificates etc, to use.

Must be called before ListenForHTTP() or https will not be supported.

Parameters
certCertificate file or text string
keyPrivate key file or text string
caCertificate authority file, directory or text string

Member Data Documentation

PSSLContext* PSecureHTTPServiceProcess::m_sslContext
protected

The documentation for this class was generated from the following file: