diff options
Diffstat (limited to 'base/tps/src/include/httpClient')
68 files changed, 8412 insertions, 0 deletions
diff --git a/base/tps/src/include/httpClient/httpc/AccessLogger.h b/base/tps/src/include/httpClient/httpc/AccessLogger.h new file mode 100644 index 000000000..2b600d7e6 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/AccessLogger.h @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __ACCESS_LOGGER_H__ +#define __ACCESS_LOGGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/Logger.h" + +/** + * A singleton class for writing to an access log + */ +class EXPORT_DECL AccessLogger : public Logger { +private: + AccessLogger(); + virtual ~AccessLogger(); + +public: +/** + * Gets a logger object with parameters obtained from the configuration manager + */ +static AccessLogger *GetAccessLogger(); + +/** + * Writes an access log entry + * + * @param hostName The IP address or host name of the requestor + * @param userName The authenticated user name; NULL or "" if not authenticated + * @param requestName The name of the requested function + * @param status The status returned to the client + * @param responseLength The number of bytes returned to the client + * @return 0 on success + */ +int Log( const char *hostName, + const char *userName, + const char *requestName, + int status, + int responseLength ); + +/** + * Initializes the object with parameters from the Config Manager + * + * @param configName The name of the configuration entry to use + * @return 0 on success + */ + int Initialize( const char *configName ); + +/** + * Flush any unwritten buffers + */ +void Flush(); + +protected: +/** + * Gets a formatted timestamp + * + * @param now The current time + * @param buffer Buffer to put time in + * @return A formatted timestamp + */ +char *GetTimeStamp( struct tm *now, char *buffer ); + +private: + char *m_buffer; + int m_bufferIndex; + int m_bufferTime; + int m_bufferSize; + time_t m_lastWrite; + char m_gmtOffset[16]; +}; + +#endif // __ACCESS_LOGGER_H__ diff --git a/base/tps/src/include/httpClient/httpc/Auth.h b/base/tps/src/include/httpClient/httpc/Auth.h new file mode 100644 index 000000000..72a5f77ee --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/Auth.h @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_AUTH_H__ +#define __PS_AUTH_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "ldap.h" + +class PSConfig; +class Pool; +class PoolNode; + +/** + * Utility classes for authentication and authorization + * + * @author rweltman@netscape.com + * @version 1.0 + */ + +/** + * Maintains a pool of LDAP connections; not yet implemented as a pool + */ +class LDAPConnectionPool { +public: + LDAPConnectionPool( const char *host, int port, int poolSize ); + virtual ~LDAPConnectionPool() {} + int Initialize(); + PoolNode *GetConnection(); + PoolNode *GetAuthenticatedConnection( const char *binddn, + const char *bindpwd ); + void ReleaseConnection( PoolNode *node ); +protected: +private: + const char* m_host; + int m_port; + int m_size; + Pool *m_pool; + bool m_initialized; +}; + +/** + * Produces an authenticator for an auth domain and authenticates + */ +class EXPORT_DECL Authenticator { +public: + virtual int Authenticate( const char *username, + const char *password, + char *&actualID ) = 0; + static Authenticator *GetAuthenticator( const char *domain ); +}; + +class EXPORT_DECL LDAPAuthenticator:public Authenticator { +public: + LDAPAuthenticator(); + virtual ~LDAPAuthenticator(); + virtual int Authenticate( const char *username, + const char *password, + char *&dn ); + +protected: + static int GetHashSize(); + char *CheckCache( const char *username, + const char *password ); + void UpdateCache( const char *username, + const char *dn, + const char *password ); + char *CreateHash( const char *password, + char *hash, + int maxChars ); + /** + * Returns the DN corresponding to a username, if any + * + * @param username The user name to look up + * @param status The status of an LDAP search, if any + * @return The corresponding DN, or NULL if no DN found + */ + char *GetUserDN( const char *username, int& status ); + +private: + LDAPConnectionPool *m_pool; + const char* m_host; + int m_port; + const char* m_binddn; + const char* m_bindpassword; + const char* m_basedn; + const char* m_searchfilter; + const char* m_searchscope; + int m_nsearchscope; + char* m_attrs[2]; + StringKeyCache *m_cache; +}; + +class EXPORT_DECL LDAPAuthorizer { +public: + LDAPAuthorizer(); + virtual ~LDAPAuthorizer(); + static LDAPAuthorizer *GetAuthorizer(); + virtual int Authorize( const char *dn, + const char *pwd, + const char *methodName ); + +protected: + int GetLdapConnection( LDAP** ld ); + int CheckCache( const char *username, + const char *methodName ); + void UpdateCache( const char *username, + const char *methodName ); + +private: + LDAPConnectionPool *m_pool; + const char* m_binddn; + const char* m_bindpassword; + const char* m_basedn; + const char* m_searchfilter; + const char* m_searchscope; + int m_nsearchscope; + char* m_attrs[2]; + StringKeyCache *m_cache; +}; + +#endif // __PS_HELPER_H__ diff --git a/base/tps/src/include/httpClient/httpc/ByteBuffer.h b/base/tps/src/include/httpClient/httpc/ByteBuffer.h new file mode 100644 index 000000000..cd5568c35 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/ByteBuffer.h @@ -0,0 +1,194 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __BYTE_BUFFER_H +#define __BYTE_BUFFER_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ByteBuffer.h 1.000 06/12/2002 + * + * A byte buffer class + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) + +typedef unsigned char Byte; + +class EXPORT_DECL ByteBuffer { +public: + /** + * Constructor + */ + ByteBuffer(); + + /** + * Destructor + */ + virtual ~ByteBuffer(); + +public: + /** + * Reads a single byte from the buffer + * + * @param b byte returned + * @return 0 on success + */ + int GetByte(Byte* b); + + /** + * Reads a number of bytes as specified by size from the buffer + * + * @param size bytes to read + * @param buf bytes read + * @return 0 on success + */ + int GetBytes(int size, Byte* buf); + + /** + * Reads a short value from the buffer + * + * @param s a short value + * @return 0 on success + */ + int GetShort(unsigned short* s); + + /** + * Reads a integer value from the buffer + * + * @param i a integer value + * @return 0 on success + */ + int GetInt(unsigned int* i); + + /** + * Reads a string of given length from the buffer + * + * @param len length of the string + * @param str string value + * @return 0 on success + */ + int GetString(int len, char* str); + + /** + * Writes a single byte to the buffer + * + * @param b byte to set + * @return 0 on success + */ + int SetByte(Byte b); + + /** + * Writes a number of bytes as specified by size to the buffer + * + * @param size number of bytes + * @param buf bytes to write + * @return 0 on success + */ + int SetBytes(int size, Byte* buf); + + /** + * Writes a short value to the buffer + * + * @param s a short value + * @return 0 on success + */ + int SetShort(unsigned short s); + + /** + * Writes an integer value to the buffer + * + * @param i an integer value + * @return 0 on success + */ + int SetInt(unsigned int i); + + /** + * Writes a string to the buffer + * + * @param str a string to write + * @return 0 on success + */ + int SetString(char* str); + + /** + * Gets the current position in the buffer + * + * @param pos position in the buffer + * @return 0 on success + */ + int GetPosition(unsigned long* pos); + + /** + * Sets the pointer to the position specified by pos in the buffer + * + * @param pos position to be set in the buffer + * @return 0 on success + */ + int SetPosition(unsigned long pos); + + /** + * Gets total number of bytes in the buffer + * + * @param total total number of bytes + * @return 0 on success + */ + int GetTotalBytes(unsigned long* total); + + /** + * Dumps the buffer to the debug log + * + * @param logLevel Lowest debug level for which the log should be dumped + */ + void Dump(int logLevel); + +private: + int SetTotalBytes(unsigned long size, unsigned long allocUnit); + int ValidateBuffer(unsigned long increment); + +private: + Byte* m_buffer; + Byte* m_bufferEnd; + Byte* m_bufPtr; + Byte* m_maxPtr; +}; + +#endif // __BYTE_BUFFER_H + diff --git a/base/tps/src/include/httpClient/httpc/CERTUtil.h b/base/tps/src/include/httpClient/httpc/CERTUtil.h new file mode 100644 index 000000000..1f26efbb8 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/CERTUtil.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _CERT_UTIL_H +#define _CERT_UTIL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * NSS CERT utility functions + */ +class EXPORT_DECL CERTUtil { +private: + /** + * Constructor - can't be instantiated + */ + CERTUtil() {} + + /** + * Destructor + */ + ~CERTUtil() {} + +public: + static CERTCertificate* FindCertificate(const char* nickname); + static SECItem* FindExtension(CERTCertificate* cert, const SECItem* oid); + static int GetAsInteger(SECItem* item); + static char* GetAsString(SECItem* item); + static bool IsCertExpired(CERTCertificate* cert); +}; + +#endif // _CERT_UTIL_H + diff --git a/base/tps/src/include/httpClient/httpc/Cache.h b/base/tps/src/include/httpClient/httpc/Cache.h new file mode 100644 index 000000000..bc68f04df --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/Cache.h @@ -0,0 +1,226 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _CACHE_H_ +#define _CACHE_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/Iterator.h" + +/** + * Simple cache implementation + */ + +/** + * Contains a cache entry and housekeeping info + */ +class CacheEntry { +public: + /** + * Constructor + * + * @param key Pointer to the key being cached + * @param data Pointer to the data being cached + */ + CacheEntry( const char *key, void *data ); + /** + * Destructor + */ + virtual ~CacheEntry(); + + /** + * Returns a pointer to the cached key + * + * @return A pointer to the cached key + */ + const char *GetKey(); + + /** + * Returns a pointer to the cached data + * + * @return A pointer to the cached data + */ + void *GetData(); + /** + * Returns the time when the entry was created + * + * @return The time when the entry was created + */ + long GetStartTime(); + +private: + char *m_key; + void *m_data; + time_t m_startTime; +}; + +/** + * Contains a generic cache; this is currently an abstract base class + */ +class Cache { +protected: + /** + * Default constructor + */ + Cache(); + +public: + /** + * Constructor + * + * @param name of the cache + * @param ttl Time to live of each cache entry + * @param implicitLock true if the Cached is to do locking internally + * when required; false if the caller will take responsibility + */ + Cache( const char *name, int ttl, bool implictLock = false ); + + /** + * Destructor + */ + virtual ~Cache(); + + /** + * Returns the number of entries in the cache + * + * @return The number of entries in the cache + */ + virtual int GetCount(); + + /** + * Acquires a read lock on the cache. Multiple threads may simultaneously + * have a read lock, but attempts to acquire a read lock will block + * if another thread already has a write lock. It is illegal to request + * a read lock if the thread already has one. + */ + void ReadLock(); + + /** + * Acquires a write lock on the cache. Only one thread may have a write + * lock at any given time; attempts to acquire a write lock will block + * if another thread already has one. It is illegal to request + * a write lock if the thread already has one. + */ + void WriteLock(); + + /** + * Releases a read or write lock that the thread has on the cache + */ + void Unlock(); + +protected: + /** + * Initializes the object - to be called from the constructor + * + * @param name of the cache + * @param ttl Time to live of each cache entry + * @param implicitLock true if the Cached is to do locking internally + * when required; false if the caller will take responsibility + */ + void Initialize( const char *name, int ttl, bool implictLock ); + +protected: + const char *m_name; + int m_ttl; + PLHashTable* m_cache; + PRRWLock* m_cacheLock; + bool m_implicitLock; +}; + +/** + * Contains a cache where the keys are strings + */ +class StringKeyCache : public Cache { +public: + /** + * Constructor + * + * @param name of the cache + * @param ttl Time to live of each cache entry + * @param implicitLock true if the Cached is to do locking internally + * when required; false if the caller will take responsibility + */ + StringKeyCache( const char *name, int ttl, bool implictLock = false ); + + /** + * Destructor + */ + virtual ~StringKeyCache(); + + /** + * Returns a cache entry + * + * @param key The name of the cache entry + * @return The corresponding cache entry, or NULL if not found + */ + CacheEntry *Get( const char *key ); + + /** + * Adds a cache entry + * + * @param key The name of the cache entry; an internal copy is made + * @param value The value of the cache entry + * @return The corresponding cache entry, or NULL if it couldn't be added + */ + CacheEntry *Put( const char *key, void *value ); + + /** + * Removes a cache entry; does not free the entry object + * + * @param key The name of the cache entry + * @return The corresponding cache entry, or NULL if not found + */ + CacheEntry *Remove( const char *key ); + + /** + * Allocates and returns a list of keys in the cache + * + * @param keys Returns an array of names; each name and also the + * array itself are to be freed by the caller with delete + * @return The number of keys found + */ + int GetKeys( char ***keys ); + + /** + * Returns an iterator over keys in the cache + * + * @return An iterator over keys in the cache + */ + Iterator *GetKeyIterator(); + +}; + +#endif // _CACHE_H_ diff --git a/base/tps/src/include/httpClient/httpc/Connection.h b/base/tps/src/include/httpClient/httpc/Connection.h new file mode 100644 index 000000000..5619d0dff --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/Connection.h @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __CONNECTION_H +#define __CONNECTION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Connection.h 1.000 06/12/2002 + * + * Base class for all connection types. A user should extend this class + * and provide its protocol specific implementation + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL Connection { + friend class ServerConnection; +public: + /** + * Constructor + */ + Connection(); + + /** + * Destructor + */ + virtual ~Connection(); + +public: + /** + * Initiates a connection to a specified host. + * + * @param host server host name + * @param port server port + * @return 0 on success, negative error code otherwise + */ + int Connect(const char* host, int port); + + /** + * Reads specified number of bytes from the connection. The connection + * is locked for the period it is being read. + * + * @param buf buffer to read into + * @param size number of bytes to read + * @param timeout timeout before the read terminates + * @return number of bytes actually read + */ + int Read(void* buf, int size, long timeout); + + /** + * Writes specified number of bytes to the connection. The connection + * is locked for the period it is being written. + * + * @param buf buffer to write from + * @param size number of bytes to write + * @param timeout timeout before the write terminates + * @return number of bytes actually written + */ + int Write(void* buf, int size, long timeout); + + /** + * Gets the status of the connection + * + * @return true if closed, false otherwise + */ + bool IsClosed(); + + /** + * Closes the connection + */ + void Close(); + +protected: + Socket* m_socket; + +private: + PRLock* m_lock; + bool m_closed; +}; + +#endif // __CONNECTION_H + diff --git a/base/tps/src/include/httpClient/httpc/ConnectionListener.h b/base/tps/src/include/httpClient/httpc/ConnectionListener.h new file mode 100644 index 000000000..0b55900b3 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/ConnectionListener.h @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __CONNECTION_LISTENER_H +#define __CONNECTION_LISTENER_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ConnectionListener.h 1.000 06/12/2002 + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL ConnectionListener { +public: + virtual int OnConnectionReceived(Connection*) = 0; + virtual int OnDataAvailable(Connection*) = 0; + virtual int OnConnectionClosed(Connection*) = 0; + virtual int OnConnectionError(Connection*, int, const char*) = 0; +}; + +#endif // __CONNECTION_LISTENER_H + + diff --git a/base/tps/src/include/httpClient/httpc/DebugLogger.h b/base/tps/src/include/httpClient/httpc/DebugLogger.h new file mode 100644 index 000000000..37c7971c0 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/DebugLogger.h @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __DEBUG_LOGGER_H__ +#define __DEBUG_LOGGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +struct PLHashTable; + +/** + * The DebugLogger class writes debug log entries conditionally. A single + * instance can be shared among modules or different modules can have + * their own instances. In either case, the log level can be changed + * globally across all instances with a single function call. All instances + * write through a singleton to ensure coordination in writing to a single + * file. + */ +class EXPORT_DECL DebugLogger { +public: +private: + DebugLogger( const char *moduleName ); + virtual ~DebugLogger(); + +public: +/** + * Gets a logger object for a particular module. Provide a module name + * if there will be more than one logger object in use, with each module + * having its own instance. Pass NULL if a single logger object will be + * shared throughout the application. + * + * @param moduleName Name of a module + * @return A logger instance + */ +static DebugLogger *GetDebugLogger( const char *moduleName = NULL ); + +/** + * Sets global default values for loggers; the values are assigned to + * DebugLogger objects created after this call returns + * + * @param configParams A table of key-value pairs to assign configuration + * parameters + */ +static void SetDefaults( PLHashTable *configParams ); + +/** + * Sets the log level for this object + * + * @param logLevel Log level setting for the module + */ +void SetLogLevel( int logLevel ); + +/** + * Gets the log level for this object + * + * @return logLevel Log level setting for the object + */ +int GetLogLevel(); + +/** + * Sets the log level for a particular module or all modules + * in all debug logger objects + * + * @param logLevel Log level setting for the module + * @param moduleName Name of the module (does not need to be known before + * this call); if NULL, the level is applied to all modules + */ +static void SetGlobalLogLevel( int logLevel, + const char *moduleName = NULL ); + +/** + * Gets the log level for a particular module + * + * @param moduleName Name of the module + * @return logLevel Log level setting for the module + */ +static int GetLogLevel( const char *moduleName ); + +/** + * Writes a debug log entry if logLevel is equal to or higher than the + * logLevel setting of the object + * + * @param logLevel One of the log levels defined above + * @param className The name of the class recording the log entry + * @param methodName The name of the method that is calling this log method + * @param fmt A sprintf format string for the remaining arguments + * @param ... A varargs list of things to log + * @return 0 on success + */ +int Log( int logLevel, + const char *className, + const char *methodName, + const char *fmt, ... ); + +/** + * Writes a trace entry if the logLevel setting of the object is FINER or FINEST + * + * @param className The name of the class recording the log entry + * @param methodName The name of the method that is calling this log method + * @param args An optional descriptive string + * @return 0 on success + */ +int Entering( const char *className, + const char *methodName, + const char *args = NULL ); + +/** + * Writes a trace entry if the logLevel setting of the object is FINER or FINEST + * + * @param className The name of the class recording the log entry + * @param methodName The name of the method that is calling this log method + * @param args An optional descriptive string + * @return 0 on success + */ +int Exiting( const char *className, + const char *methodName, + const char *args = NULL ); +/** + * Shut down, flushing any buffers and releasing resources + */ +void Close(); + +/** + * Shut down, flushing any buffers and releasing resources + */ +static void CloseAll(); + +protected: +/** + * Sets the log level for a particular module + * + * @param logLevel Log level setting for the module + * @param moduleName Name of the module (does not need to be known before + * this call) + */ +static void SetOneLogLevel( int logLevel, + const char *moduleName ); + +private: +/** + * Initializes the object with parameters from the Config Manager + * + * @param configName The name of the configuration entry to use + * @return 0 on success + */ +static int Initialize( const char *configName ); + +private: + int m_level; + char *m_module; +}; + +#endif // __DEBUG_LOGGER_H__ diff --git a/base/tps/src/include/httpClient/httpc/Defines.h b/base/tps/src/include/httpClient/httpc/Defines.h new file mode 100644 index 000000000..90af8e3d0 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/Defines.h @@ -0,0 +1,219 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __DEFINES_H__ +#define __DEFINES_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Defines.h 1.000 04/30/2002 + * + * This file contains global constants for the Presence Server + * + * @author Rob Weltman + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ + +// ??? SSR till we have server logging functionality +#ifdef _DEBUG +#define PS_LOG_LEVEL PS_LOG_LEVEL_DEBUG +#else +#define PS_LOG_LEVEL PS_LOG_LEVEL_WARN +#endif + +#define PS_SERVER_CONFIG_FILE "psserver.conf" + +// Configuration file for WASP SOAP server +#define SOAP_CONFIG_FILE "config.xml" + +#define CLIENT_DESCRIPTION "Netscape Presence Server" +#define SERVER_VERSION "1.0" + +// Key to SoapAction field in WASP call context +#define HEADER_FIELD_SOAPACTION "SOAP_ACTION" +// Key to status field in WASP call context +#define HEADER_STATUS "HEADER_STATUS" + +// Keys to client parameters passed through the call context + +#define SERVER_URL "SERVER_URL" +#define CERTIFICATE_DIRECTORY "CERTIFICATE_DIRECTORY" +#define CERTIFICATE_NICKNAME "CERTIFICATE_NICKNAME" +#define DO_SERVER_CERT_VALIDATION "DO_SERVER_CERT_VALIDATION" +#define CERTIFICATE_PASSWORD "CERTIFICATE_PASSWORD" + +#define STRING_ON_LINE "ONLINE" +#define STRING_OFF_LINE "OFFLINE" + +#define BATCH_RESULT_SIZE 1000 +#define MAX_ATTR_SIZE 5 + +#define NAME_BUFFER_LENGTH 256 +#define ATTR_BUFFER_LENGTH 256 + +// Static strings for the attributes we support +#define BUDDY_ATTRIBUTE_ON_LINE_STATUS "onlinestatus" +#define BUDDY_ATTRIBUTE_IDLE_TIME "idletime" +#define BUDDY_ATTRIBUTE_ON_LINE_SINCE "onlinesince" +#define BUDDY_ATTRIBUTE_AWAY_MESSAGE "awaymessage" +#define BUDDY_ATTRIBUTE_PROFILE "profile" +#define BUDDY_ATTRIBUTE_CONNECTION_TYPE "connectiontype" +#define BUDDY_ATTRIBUTE_CAPABILITIES "capabilities" + +#define PS_LOG_LEVEL_DEBUG 0 +#define PS_LOG_LEVEL_WARN 1 +#define PS_LOG_LEVEL_ERROR 2 + + +// Presence Server config parameters in the bootstrap configuration file +// psserver.conf +#define INSTANCE_ID "instanceid" +#define HOST_ID "hostid" +#define DOMAIN_NAME "domainname" +#define SERVER_HOST "serverhost" +#define SERVER_PORT "serverport" +#define BINDDN "binddn" +#define BINDPASSWORD "bindpassword" + +// dn, cn constants +#define PS_ATTRIBUTE_DN "dn" +#define PS_ATTRIBUTE_CN "cn" + +// nsPlugin class required attributes +#define PLUGIN_DN "dn" +#define PLUGIN_CN "cn" +#define PLUGIN_ID "nspluginid" +#define PLUGIN_PATH "nspluginpath" +#define PLUGIN_INIT_FUNC "nsplugininitfunc" +#define PLUGIN_ENABLED "nspluginenabled" +#define PLUGIN_VERSION "nspluginversion" +#define PLUGIN_DESC "nsplugindescription" + +// Operations when updating server +#define PS_OPERATION_ADD 1 +#define PS_OPERATION_DELETE 2 +#define PS_OPERATION_REPLACE 4 + +// Names of LDAP attributes for the LDAP data source +#define LDAP_SOURCE_DN "dn" +#define LDAP_SOURCE_CN "cn" +#define LDAP_SOURCE_GROUP_NAME "nspsgroupname" +#define LDAP_SOURCE_SERVER_ADDRESS "nsserveraddress" +#define LDAP_SOURCE_SERVER_PORT "nsserverport" +#define LDAP_SOURCE_BIND_DN "nsbinddn" +#define LDAP_SOURCE_BIND_PASSWORD "nsbindpassword" +#define LDAP_SOURCE_BASE_DN "nsbasedn" +#define LDAP_SOURCE_SEARCH_FILTER "nssearchfilter" +#define LDAP_SOURCE_SEARCH_SCOPE "nssearchscope" +#define LDAP_SOURCE_IM_ID "nsimattributetype" +#define LDAP_SOURCE_SEARCHABLE_ATTRIBUTES "nssearchableattributes" +#define LDAP_SOURCE_ENABLE_SSL "nsenablessl" + + +// Configuration attribute name for max results to return +#define SEARCH_MAX_RESULTS "nsmaxresults" + +// Max results to return if SEARCH_MAX_RESULTS is not defined +#define DEFAULT_MAX_RESULTS 1000 + +// Names of configuration clusters +#define CONFIG_BASE "ConfigBase" +#define CONFIG_AUTHORIZE "ConfigAuthorize" +#define CONFIG_ACCESS_LOG "ConfigAccessLog" +#define CONFIG_ERROR_LOG "ConfigErrorLog" +#define CONFIG_DEBUG_LOG "ConfigDebugLog" +#define CONFIG_SERVER_LOCAL "ConfigServerLocal" + +// Configuration attributes for loggers +#define LOG_ACCESS_DIR "nslogdir" +#define LOG_ERROR_DIR "nslogdir" +#define LOG_DEBUG_DIR "nslogdir" +#define LOG_ACCESS_BUFFER_SIZE "nslogbuffersize" +#define LOG_ACCESS_BUFFER_TIME "nslogbuffertime" +#define LOG_ACCESS_ROTATION_TIME "nslogrotationtime" +#define LOG_ACCESS_ROTATION_SIZE "nslogrotationsize" +#define LOG_ACCESS_MAX_LOGS "nslogmaxlogs" +#define LOG_ERROR_ROTATION_TIME "nslogrotationtime" +#define LOG_ERROR_ROTATION_SIZE "nslogrotationsize" +#define LOG_ERROR_MAX_LOGS "nslogmaxlogs" +#define LOG_DEBUG_LEVEL "nsloglevel" +#define LOG_DEBUG_FORMAT "nslogformat" + +// Static constants for logging +#define LOG_ACCESS_FILENAME "access" +#define LOG_ERROR_FILENAME "error" +#define LOG_DEBUG_FILENAME "debug" + +// Log level definitions + +typedef enum { + LOGLEVEL_OFF = 0, + LOGLEVEL_SEVERE = 1, + LOGLEVEL_WARNING = 2, + LOGLEVEL_INFO = 3, + LOGLEVEL_CONFIG = 4, + LOGLEVEL_FINE = 5, + LOGLEVEL_FINER = 6, + LOGLEVEL_FINEST = 7, + LOGLEVEL_ALL = 100 +} LogLevel; + +// Config params +#define CONFIG_DEFAULT_BUFFER_LEN 2048 +#define BASE_CONFIG_DN "cn=Netscape Presence Server,cn=Server Group,cn=%s,ou=%s,o=NetscapeRoot" + +// COOL Service params +#define COOL_SERVICE_SERVER_HOST "CoolServerHost" +#define COOL_SERVICE_SERVER_PORT "CoolServerPort" +#define COOL_SERVICE_LOGIN_NAME "CoolLoginName" +#define COOL_SERVICE_LOGIN_PSWD "CoolLoginPswd" + +#define COOL_DEFAULT_SERVER_HOST "coolkey.fedora.redhat.com" +#define COOL_DEFAULT_SERVER_PORT "5190" + +// Key to service ID in global config +#define SERVICE_TYPE "service_type" + +#define MODULE_IM_SERVICE "ModuleIMService" +#define MODULE_DATA_SOURCE "ModuleDataSource" + +#define PROVIDER_BATCH_SIZE_ATTR "nsbatchsize" +#define PROVIDER_UPDATE_INTERVAL_ATTR "nsupdateinterval" + +#define THREAD_POOL_TASK_NAME "ThreadPoolTask" + +#endif // __DEFINES_H__ diff --git a/base/tps/src/include/httpClient/httpc/ErrorLogger.h b/base/tps/src/include/httpClient/httpc/ErrorLogger.h new file mode 100644 index 000000000..df2617b06 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/ErrorLogger.h @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __ERROR_LOGGER_H__ +#define __ERROR_LOGGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/Logger.h" + +/** + * A singleton class for writing to an error log + */ +class EXPORT_DECL ErrorLogger : public Logger { +private: + ErrorLogger(); + virtual ~ErrorLogger(); + +public: + /** + * Gets a logger object with parameters obtained from the + * configuration manager + */ + static ErrorLogger *GetErrorLogger(); + + /** + * Writes an error log entry + * + * @param level SEVERE, WARNING, or INFO + * @param errorCode An error code + * @param fmt A message to be written to the log + * @return 0 on success + */ + int Log( int level, + int errorCode, + const char *fmt, + ... ); + + /** + * Initializes the object with parameters from the Config Manager + * + * @param configName The name of the configuration entry to use + * @return 0 on success + */ + int Initialize( const char *configName ); + +protected: + /** + * Writes the fixed argument part of an error log entry + * + * @param fp File pointer to write to + * @param level SEVERE, WARNING, or INFO + * @param errorCode An error code + * @return 0 on success + */ + int LogProlog( FILE *fp, + int level, + int errorCode ); +}; + +#endif // __ERROR_LOGGER_H__ diff --git a/base/tps/src/include/httpClient/httpc/Iterator.h b/base/tps/src/include/httpClient/httpc/Iterator.h new file mode 100644 index 000000000..9b15a93e2 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/Iterator.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _ITERATOR_H_ +#define _ITERATOR_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Base class for iterators + */ + +class EXPORT_DECL Iterator { +public: + /** + * Returns true if there is at least one more element + * + * @return true if there is at least one more element + */ + virtual bool HasMore() = 0; + + /** + * Returns the next element, if any + * + * @return The next element, if any, or NULL + */ + virtual void *Next() = 0; +}; + +#endif // _ITERATOR_H_ diff --git a/base/tps/src/include/httpClient/httpc/LogRotationTask.h b/base/tps/src/include/httpClient/httpc/LogRotationTask.h new file mode 100644 index 000000000..eed098b6b --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/LogRotationTask.h @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __LOG_ROTATION_TASK_H__ +#define __LOG_ROTATION_TASK_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/ScheduledTask.h" + +/** + * Log rotation task in Presence Server + */ + +class EXPORT_DECL LogRotationTask: public ScheduledTask { +public: + /** + * Constructor - creates an initialized task for log rotation + * + * @param name Name of task + * @param fileName Name of file to rotate + * @param startTime Time when the file is to be rotated + * @param maxLogs Max logs to keep + * @param interval Time between rotations + * @param fp File pointer for log file + * @param lock Lock for writing to log file + */ + LogRotationTask( const char *name, + const char *fileName, + time_t startTime, + int maxLogs, + int interval, + FILE **fp, + PRLock *lock ); + /** + * Destructor + */ + virtual ~LogRotationTask(); + /** + * Returns a copy of the task + * + * @return A copy of the task + */ + virtual ScheduledTask *Clone(); + /** + * Executes the task + * + * @return 0 on successfully starting the task + */ + virtual int Start(); + +protected: + /** + * Composes a file name from a base name and a time value + * + * @param filename The base file name (may be a path) + * @param ltime The time value + * @param outbuf Returns the composed file name + * @return 0 on success + */ + int CreateFilename( const char *filename, + time_t ltime, + char *outbuf ); + /** + * Extracts the folder and base name components of a file path + * + * @param fileName The full file path to examine + * @param dirName A buffer in which to place the folder found + * @param baseName A buffer in which to place the base name found + */ + static void GetPathComponents( const char *fileName, + char *dirName, + char *baseName ); + + /** + * Counts the number of files with the same initial path as fileName + * (the same folder and the same base pattern) + * + * @param fileName The file name to compare (including a folder) + * @return The number of matching files + */ + static int CountFiles( const char *fileName ); + + /** + * Purges (deletes) files with the same initial path as fileName + * (the same folder and the same base pattern) + * + * @param fileName The file name to compare (including a folder) + * @param maxLogs The number of files to purge to + * @return The number of files purged + */ + static int PurgeLogs( const char *fileName, int maxLogs ); + + char *m_fileName; + int m_maxLogs; + FILE **m_fp; + PRLock *m_lock; +}; + +#endif // __LOG_ROTATION_TASK_H__ diff --git a/base/tps/src/include/httpClient/httpc/Logger.h b/base/tps/src/include/httpClient/httpc/Logger.h new file mode 100644 index 000000000..b41d5dfbf --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/Logger.h @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __LOGGER_H__ +#define __LOGGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <time.h> + +struct PRLock; +class LogRotationTask; + +/** + * A base class for writing to a log + */ +class EXPORT_DECL Logger { + +protected: + /** + * Constructor + */ + Logger(); + + /** + * Destructor + */ + virtual ~Logger(); + + /** + * Parses a time string in HH:MM format into a time_t for the next + * occurrence of the time + * + * @param timeString A time string in HH:MM format + * @return A time_t for the next occurrence of the time, or -1 if the + * string is not in a valid format + */ + time_t ParseTime( const char *timeString ); + + /** + * Creates a time-of-day rotation task + * + * @param taskName Name of task + * @param filename Name of log file + * @param rotationTime Time of day to rotate at + * @return Rotation task on success + */ + LogRotationTask *CreateRotationTask( const char *taskName, + const char *filename, + const char *rotationTime ); + +public: + + /** + * Shut down, flushing any buffers and releasing resources + */ + void Close(); + /** + * Gets the local time of day + * + * @param now The current local time of day + */ + static void GetLocalTime( struct tm *now ); + +protected: + int m_rotationSize; + time_t m_rotationTime; + int m_maxLogs; + char *m_dir; + FILE *m_fp; + /** + * Lock for writing to the file + */ + PRLock *m_fileLock; + /** + * Task that rotates a log file + */ + LogRotationTask *m_rotator; + /** + * True if object has been successfully initialized + */ + bool m_initialized; +}; + +#endif // __LOGGER_H__ diff --git a/base/tps/src/include/httpClient/httpc/NSPRerrs.h b/base/tps/src/include/httpClient/httpc/NSPRerrs.h new file mode 100644 index 000000000..2e131fd7a --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/NSPRerrs.h @@ -0,0 +1,160 @@ +/** BEGIN COPYRIGHT BLOCK + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1994-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * END COPYRIGHT BLOCK **/ + +/* Originally obtained from: + * + * CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot + * cvs export -r NSS_3_11_3_RTM -N mozilla/security/nss/cmd/lib/NSPRerrs.h + */ + +/* General NSPR 2.0 errors */ +/* Caller must #include "prerror.h" */ + +ER2( PR_OUT_OF_MEMORY_ERROR, "Memory allocation attempt failed." ) +ER2( PR_BAD_DESCRIPTOR_ERROR, "Invalid file descriptor." ) +ER2( PR_WOULD_BLOCK_ERROR, "The operation would have blocked." ) +ER2( PR_ACCESS_FAULT_ERROR, "Invalid memory address argument." ) +ER2( PR_INVALID_METHOD_ERROR, "Invalid function for file type." ) +ER2( PR_ILLEGAL_ACCESS_ERROR, "Invalid memory address argument." ) +ER2( PR_UNKNOWN_ERROR, "Some unknown error has occurred." ) +ER2( PR_PENDING_INTERRUPT_ERROR,"Operation interrupted by another thread." ) +ER2( PR_NOT_IMPLEMENTED_ERROR, "function not implemented." ) +ER2( PR_IO_ERROR, "I/O function error." ) +ER2( PR_IO_TIMEOUT_ERROR, "I/O operation timed out." ) +ER2( PR_IO_PENDING_ERROR, "I/O operation on busy file descriptor." ) +ER2( PR_DIRECTORY_OPEN_ERROR, "The directory could not be opened." ) +ER2( PR_INVALID_ARGUMENT_ERROR, "Invalid function argument." ) +ER2( PR_ADDRESS_NOT_AVAILABLE_ERROR, "Network address not available (in use?)." ) +ER2( PR_ADDRESS_NOT_SUPPORTED_ERROR, "Network address type not supported." ) +ER2( PR_IS_CONNECTED_ERROR, "Already connected." ) +ER2( PR_BAD_ADDRESS_ERROR, "Network address is invalid." ) +ER2( PR_ADDRESS_IN_USE_ERROR, "Local Network address is in use." ) +ER2( PR_CONNECT_REFUSED_ERROR, "Connection refused by peer." ) +ER2( PR_NETWORK_UNREACHABLE_ERROR, "Network address is presently unreachable." ) +ER2( PR_CONNECT_TIMEOUT_ERROR, "Connection attempt timed out." ) +ER2( PR_NOT_CONNECTED_ERROR, "Network file descriptor is not connected." ) +ER2( PR_LOAD_LIBRARY_ERROR, "Failure to load dynamic library." ) +ER2( PR_UNLOAD_LIBRARY_ERROR, "Failure to unload dynamic library." ) +ER2( PR_FIND_SYMBOL_ERROR, +"Symbol not found in any of the loaded dynamic libraries." ) +ER2( PR_INSUFFICIENT_RESOURCES_ERROR, "Insufficient system resources." ) +ER2( PR_DIRECTORY_LOOKUP_ERROR, +"A directory lookup on a network address has failed." ) +ER2( PR_TPD_RANGE_ERROR, +"Attempt to access a TPD key that is out of range." ) +ER2( PR_PROC_DESC_TABLE_FULL_ERROR, "Process open FD table is full." ) +ER2( PR_SYS_DESC_TABLE_FULL_ERROR, "System open FD table is full." ) +ER2( PR_NOT_SOCKET_ERROR, +"Network operation attempted on non-network file descriptor." ) +ER2( PR_NOT_TCP_SOCKET_ERROR, +"TCP-specific function attempted on a non-TCP file descriptor." ) +ER2( PR_SOCKET_ADDRESS_IS_BOUND_ERROR, "TCP file descriptor is already bound." ) +ER2( PR_NO_ACCESS_RIGHTS_ERROR, "Access Denied." ) +ER2( PR_OPERATION_NOT_SUPPORTED_ERROR, +"The requested operation is not supported by the platform." ) +ER2( PR_PROTOCOL_NOT_SUPPORTED_ERROR, +"The host operating system does not support the protocol requested." ) +ER2( PR_REMOTE_FILE_ERROR, "Access to the remote file has been severed." ) +ER2( PR_BUFFER_OVERFLOW_ERROR, +"The value requested is too large to be stored in the data buffer provided." ) +ER2( PR_CONNECT_RESET_ERROR, "TCP connection reset by peer." ) +ER2( PR_RANGE_ERROR, "Unused." ) +ER2( PR_DEADLOCK_ERROR, "The operation would have deadlocked." ) +ER2( PR_FILE_IS_LOCKED_ERROR, "The file is already locked." ) +ER2( PR_FILE_TOO_BIG_ERROR, +"Write would result in file larger than the system allows." ) +ER2( PR_NO_DEVICE_SPACE_ERROR, "The device for storing the file is full." ) +ER2( PR_PIPE_ERROR, "Unused." ) +ER2( PR_NO_SEEK_DEVICE_ERROR, "Unused." ) +ER2( PR_IS_DIRECTORY_ERROR, +"Cannot perform a normal file operation on a directory." ) +ER2( PR_LOOP_ERROR, "Symbolic link loop." ) +ER2( PR_NAME_TOO_LONG_ERROR, "File name is too long." ) +ER2( PR_FILE_NOT_FOUND_ERROR, "File not found." ) +ER2( PR_NOT_DIRECTORY_ERROR, +"Cannot perform directory operation on a normal file." ) +ER2( PR_READ_ONLY_FILESYSTEM_ERROR, +"Cannot write to a read-only file system." ) +ER2( PR_DIRECTORY_NOT_EMPTY_ERROR, +"Cannot delete a directory that is not empty." ) +ER2( PR_FILESYSTEM_MOUNTED_ERROR, +"Cannot delete or rename a file object while the file system is busy." ) +ER2( PR_NOT_SAME_DEVICE_ERROR, +"Cannot rename a file to a file system on another device." ) +ER2( PR_DIRECTORY_CORRUPTED_ERROR, +"The directory object in the file system is corrupted." ) +ER2( PR_FILE_EXISTS_ERROR, +"Cannot create or rename a filename that already exists." ) +ER2( PR_MAX_DIRECTORY_ENTRIES_ERROR, +"Directory is full. No additional filenames may be added." ) +ER2( PR_INVALID_DEVICE_STATE_ERROR, +"The required device was in an invalid state." ) +ER2( PR_DEVICE_IS_LOCKED_ERROR, "The device is locked." ) +ER2( PR_NO_MORE_FILES_ERROR, "No more entries in the directory." ) +ER2( PR_END_OF_FILE_ERROR, "Encountered end of file." ) +ER2( PR_FILE_SEEK_ERROR, "Seek error." ) +ER2( PR_FILE_IS_BUSY_ERROR, "The file is busy." ) +ER2( PR_IN_PROGRESS_ERROR, +"Operation is still in progress (probably a non-blocking connect)." ) +ER2( PR_ALREADY_INITIATED_ERROR, +"Operation has already been initiated (probably a non-blocking connect)." ) + +#ifdef PR_GROUP_EMPTY_ERROR +ER2( PR_GROUP_EMPTY_ERROR, "The wait group is empty." ) +#endif + +#ifdef PR_INVALID_STATE_ERROR +ER2( PR_INVALID_STATE_ERROR, "Object state improper for request." ) +#endif + +#ifdef PR_NETWORK_DOWN_ERROR +ER2( PR_NETWORK_DOWN_ERROR, "Network is down." ) +#endif + +#ifdef PR_SOCKET_SHUTDOWN_ERROR +ER2( PR_SOCKET_SHUTDOWN_ERROR, "The socket was previously shut down." ) +#endif + +#ifdef PR_CONNECT_ABORTED_ERROR +ER2( PR_CONNECT_ABORTED_ERROR, "TCP Connection aborted." ) +#endif + +#ifdef PR_HOST_UNREACHABLE_ERROR +ER2( PR_HOST_UNREACHABLE_ERROR, "Host is unreachable." ) +#endif + +/* always last */ +ER2( PR_MAX_ERROR, "Placeholder for the end of the list" ) diff --git a/base/tps/src/include/httpClient/httpc/PSBuddy.h b/base/tps/src/include/httpClient/httpc/PSBuddy.h new file mode 100644 index 000000000..4d84b8727 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSBuddy.h @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_H__ +#define __PS_BUDDY_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddy.h 1.000 05/15/2002 + * + * Interface to store buddy online status attributes + * + * @author Surendra Rajam + * @version 1.000, 05/15/2002 + */ +class EXPORT_DECL PSBuddy { +public: + PSBuddy() { }; + virtual ~PSBuddy() { }; + /** + * Gets the buddy name + * + * @return name of the buddy + */ + virtual const char* GetName() = 0; + + /** + * Gets online status of the buddy + * + * @return true if online, false otherwise + */ + virtual bool IsOnline() = 0; + + /** + * Gets the value of the specified online status attribute + * + * @param attribute type + * @param attribute value upon success + * @return 0 on Success, error code otherwise + */ + virtual int GetStatus(const char*, char**) = 0; + + /** + * Returns a copy of the buddy + * + * @return A copy of the buddy + */ + virtual PSBuddy* Clone() = 0; +}; + +#endif // __PS_BUDDY_H__ + + + + + diff --git a/base/tps/src/include/httpClient/httpc/PSBuddyCache.h b/base/tps/src/include/httpClient/httpc/PSBuddyCache.h new file mode 100644 index 000000000..3c880074b --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSBuddyCache.h @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_CACHE_H__ +#define __PS_BUDDY_CACHE_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddyCache.h 1.000 04/30/2002 + * + * Cache of PSBuddy objects containing online status + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class PSBuddyCache +{ +public: + + /** + * Constructor - initializes the internal cache + */ + PSBuddyCache(); + + /** + * Destructor + */ + virtual ~PSBuddyCache(); + + /** + * Adds a buddy to the cache. The old entry, if exists, is deleted + * from the cache + * + * @param name name of the new buddy + * @param buddy object containing onlinestatus attributes + * @return 0 on success + */ + int AddBuddy(const char* name, PSBuddy* buddy); + + /** + * Removes a buddy from the cache + * + * @param name name of the buddy to be removed + * @return 0 on success + */ + int RemoveBuddy(const char* name); + + /** + * Gets the buddy object + * + * @param name name of the new buddy + * @return object containing onlinestatus attributes, NULL if not found + */ + PSBuddy* GetBuddy(const char* name); + + /** + * Gets count of buddies in the cache + * + * @return count of buddies + */ + int GetBuddyCount(); + + /** + * Gets all the screen names + * + * @param names On return, contains array of screen names + * @return number of screen names + */ + int GetAllBuddies(char*** names); + + /** + * Acquires a read lock on the cache. Multiple threads may simultaneously + * have a read lock, but attempts to acquire a read lock will block + * if another thread already has a write lock. It is illegal to request + * a read lock if the thread already has one. + */ + void ReadLock(); + + /** + * Releases a read lock that the thread has on the cache + */ + void Unlock(); + +private: + StringKeyCache* m_buddies; +}; + +#endif // __PS_BUDDY_CACHE_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSBuddyList.h b/base/tps/src/include/httpClient/httpc/PSBuddyList.h new file mode 100644 index 000000000..49155a8a5 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSBuddyList.h @@ -0,0 +1,373 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_LIST_H__ +#define __PS_BUDDY_LIST_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddyList.h 1.000 05/21/2002 + * + * This class maintains users information which are set for + * online status tracking. The online status of users are updated + * through a PSBuddyListener interface implemented by this class. + * + * @author Surendra Rajam + * @version 1.000, 05/21/2002 + */ +class PSBuddyList : + public PSBuddyListener +{ +private: + + /** + * Constructor + */ + PSBuddyList(); + + /** + * Destructor + */ + virtual ~PSBuddyList(); + +public: + + /** + * Gets an instance of the class + */ + static PSBuddyList* GetBuddyList(); + + public: + + /** + * Save the users maintain by an instance of presence server + * to a local file in the BLT format + * + * @return 0 on succcess, negative error code otherwise + */ + int SaveBuddyList(); + + /** + * Loads the users into an instance of presence server + * from a local file + * + * @return 0 on succcess, negative error code otherwise + */ + int LoadBuddyList(); + + /** + * Sets a service provider. We currently support only one service + * provider in a presence server instance. + * + * @return 0 on succcess, negative error code otherwise + */ + int RegisterService(PSBuddyService* service); + + /** + * Gets the online status of a user along with the + * requested additional attributes + * + * @param group group name to which the user belongs + * @param name the screen name of the user to query status for + * @param nAttributes number of attributes + * @param attributes the names of the attributes of the user to return + * @param user upon return, filled with user attributes + * @return 0 on success, a negative error code on failure + */ + int GetUserStatus( const char* group, + const char* name, + int nAttributes, + char** attributes, + PSUser** user ); + + /** + * Gets the online status of multiple users along with the requested + * additional attributes + * + * @param group group name to which the user belongs + * @param nUsers the number of screen names to status query for + * @param names the screen names of the users to query status for + * @param nAttributes number of attributes + * @param attributes the names of the attributes of the user to return + * @param user upon return, filled with user attributes + * @return 0 on success, a negative error code on failure + */ + int GetMultipleUserStatus( const char* group, + int nUsers, + char** names, + int nAttributes, + char** attributes, + PSUser*** users ); + + /** + * Gets the screen names and attributes of users that match + * certain search criteria + * + * @param group group name to query from + * @param filter an LDAP-like search expression on + * presence status attributes + * @param nAttrbiutes number of attributes + * @param attributes the names of the attributes of the user to return + * @param user upon return, an array of users with + * requested attributes + * @return number of users returned, or a negative error code + */ + int GetUsersByFilter( const char* group, + const char* filter, + int nAttributes, + char** attributes, + PSUser*** users ); + + /** + * Gets the screen names and attributes of users that match certain search + * criteria and sorts the results (currently only by entryId) + * + * @param group group name to query from + * @param filter an LDAP-like search expression on presence status + * attributes + * @param sortKey name of attribute to sort on + * @param sortKeyType 1 for numeric, 2 for string + * @param nAttributes number of attributes + * @param attributes the names of the attributes of the user to return + * @param user upon return, an array of users with requested + * attributes + * @return number of users returned, or a negative error code + */ + int GetSortedUsersByFilter( const char* group, + const char* filter, + const char *sortKey, + int sortKeyType, + int nAttributes, + char** attributes, + PSUser*** users ); + + /** + * Gets the number of users who are online or offline in a group + * + * @param group Name of group to query; NULL or empty for all groups + * @param bOnline true to return the count of online users, false for offline + * @return Number of users, or a negative error code on failure + * + * Error Code(s): + * PS_UNKOWN_GROUP + */ + int GetBuddyCount( const char* group, int bOnline ); + + /** + * Add a new group + * + * @param group name of the new group + * @param nAttributes number of attributes + * @param attributes attributes the group will support + * @return 0 on success, a negative error code on failure + */ + int AddGroup( const char* group, int nAttributes, char** attributes ); + + /** + * Adds a user to be tracked. + * + * @param group name of the group to add the user in + * @param name screen name of the user to track + * @param nAttributes number of attributes + * @param attributes the attributes of the users to be stored + * @return on success, 0 or an error code + */ + int AddUser( const char* group, + const char* name, + int nAttributes, + PSAttribute** attributes ); + + /** + * Adds a number of users to track. + * + * @param group name of the group to which the users belong + * @param nUsers number of users + * @param users names and attributes of users to track + * @return number of users added on success, + or a negative error code on failure + */ + int AddUsers( const char* group, + int nUsers, + PSUser** users ); + + /** + * Removes a user to be tracked. + * + * @param group name of the group to which the user belongs + * @param name screen name of the user to be removed + * @return 0 on success, or a negative error code on failure + */ + int RemoveUser( const char* group, const char* name ); + + /** + * Removes a number of users to be tracked. + * + * @param group name of the group to which the users belong + * @param nUsers number of users + * @param names screen name of the users to be removed + * @return number of users removed on success, + * or a negative error code on failure + */ + int RemoveUsers( const char* group, int nUsers, char** names ); + + /** + * Removes a group. + * + * @param group name of the group to be removed + * @return number of users removed on success, + * or a negative error code on failure + * + * Error Code(s): + * PS_UNKNOWN_GROUP + */ + int RemoveGroup(const char* group); + + /** + * Gets the list of groups. + * + * @param groups upon return, array containing group names + * @return number of groups or 0 if no group present + * + * Error Code(s): + * PS_NO_GROUPS + */ + int GetAllGroups(char*** groups); + + /** + * Gets the users in a group(s). + * + * @param group name of the group to query + * @param users upon return, array of User objects + * @return number of users returned, + * or a negative error code on failure + */ + int GetAllUsers( const char* group, PSUser*** users ); + + /** + * Gets the attributes supported by a group(s) + * + * @param group name of the group + * @param attributes upon return, array of attributes + * @return number of users removed on success, + * or a negative error code on failure + */ + int GetSearchableAttributes( const char* group, char*** attributes ); + + // PSBuddyListener interface + /** + * Callback to notify buddy changes + * + * @param service the reporting buddy service + * @param buddy buddy object containing online status attributes + * @return 0 on success + */ + int OnBuddyChanged(PSBuddyService* service, PSBuddy* buddy); + + /** + * Callback to refresh the list of screen names to the buddy queue + * + * @param the reporting buddy service + * @return 0 on success + */ + int OnRefreshList(PSBuddyService* service); + + /** + * Removes a user from a group based on its entry Id + * + * @param group name of the group + * @param entryId user's entry id + * @return 0 + */ + int RemoveUserByEntryId(const char* group, char* entryId); + +protected: + + /** + * Gets the max number of search results to return + * + * @return The max number of search results to return + */ + int GetMaxSearchResults(); + +private: + + /** + * Parses the LDAP like filter and create a map object containing + * filter in the form of name-value pair + * + * @param filter LDAP like filter + * @param map array containing break up of filter into name-value pair + * @return 0 on success + */ + int ParseFilter(const char* filter, PSAttribute*** map); + + /** + * Checks whether a given string is NULL or "" + * + * @param value a string to be tested for NULL or "" + * @return true if NULL, false otherwise + */ + bool IsNull(const char* value); + + /** + * Prints buddy information + * + * @param buddy a buddy object containing online status attributes + * @return 0 on success + */ + int DumpBuddy(PSBuddy* buddy); + + /** + * Sorts a list of users based on a "entryId" + * + * @param users array of users to be sorted + * @param nUsers number of users in the array + * @return 0 on success + */ + int SortUsersByEntryId(PSUser** users, int nUsers); + +private: + PSBuddyCache* m_buddies; + PSGroupCache* m_groups; + PSBuddyService* m_service; + + /* flag indicating if buddy list is loaded from the disk */ + bool m_loadedList; +}; + +#endif // __PS_BUDDY_LIST_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSBuddyListener.h b/base/tps/src/include/httpClient/httpc/PSBuddyListener.h new file mode 100644 index 000000000..87e701373 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSBuddyListener.h @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_LISTENER_H__ +#define __PS_BUDDY_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddyListener.h 1.000 05/15/2002 + * + * A listener interface for getting notifications from a buddy service. + * + * @author Surendra Rajam + * @version 1.000, 05/15/2002 + */ +class PSBuddyListener : + public PSListener +{ +public: + +/** + * Notifies the listener of the buddy status changes + * + * @param the reporting buddy service + * @param buddy object containing online status attributes + * @return 0 on success + */ +virtual int OnBuddyChanged(PSBuddyService*, PSBuddy*) = 0; + +/** + * Notifies the listener of the service to refresh the list + * of screen names to the buddy queue + * + * @param the reporting buddy service + * @return 0 on success + */ +virtual int OnRefreshList(PSBuddyService*) = 0; + +}; + +#endif // __PS_BUDDY_LISTENER_H__ + + + + diff --git a/base/tps/src/include/httpClient/httpc/PSBuddyService.h b/base/tps/src/include/httpClient/httpc/PSBuddyService.h new file mode 100644 index 000000000..2556420e9 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSBuddyService.h @@ -0,0 +1,121 @@ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_SERVICE_H__ +#define __PS_BUDDY_SERVICE_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddyService.h 1.000 05/16/2002 + * + * A pure virtual class defining Buddy Service interface + * to be implemented by the various IM presence service providers. + * + * @author Surendra Rajam + * @version 1.000, 05/16/2002 + */ +class EXPORT_DECL PSBuddyService { +public: + +/** + * Registers a listener with this class. The listener + * is notified of any changes to the buddies being tracked. + * + * @param a buddy service listener + * @return 0 on success + */ +virtual int RegisterListener(PSListener*) = 0; + +/** + * An entry point to start the service. This function is responsible + * for authentication with the backend service. + * + * @param config parameters for the service to start + * @return 0 on success + */ +virtual int SignOn(PSConfig*) = 0; + +/** + * Shutdown of the service. + * + * @return 0 on success + */ +virtual int SignOff() = 0; + +/** + * Sets a user name for online status tracking. + * + * @param user name to be tracked + * @return 0 on success + */ +virtual int WatchBuddy(const char*) = 0; + +/** + * Sets a number of users for online status tracking + * + * @param number of users to be tracked + * @param array of user names + * @return 0 on success + */ +virtual int WatchBuddies(int, char**) = 0; + +/** + * Unsets a user name from online status tracking. + * + * @param user name to be tracked + * @return 0 on success + */ +virtual int UnwatchBuddy(const char*) = 0; + +/** + * Unsets a number of users from online status tracking + * + * @param number of users to be tracked + * @param array of user names + * @return 0 on success + */ +virtual int UnwatchBuddies(int, char**) = 0; + +/** + * Gets the service config entry + * + * @return config object + */ +virtual PSConfig* GetServiceConfig() = 0; + +}; + +#endif // __PS_BUDDY_SERVICE_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSCertExtension.h b/base/tps/src/include/httpClient/httpc/PSCertExtension.h new file mode 100644 index 000000000..f528a54b4 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSCertExtension.h @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _PS_CERT_EXTENSION_H +#define _PS_CERT_EXTENSION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Presence Server cert extension. This extension contains customer + * specific information as per the contract apart from host and port + * used by BIG service provider to send user updates. + */ + +class EXPORT_DECL PSCertExtension { +public: + /** + * Constructor - + */ + PSCertExtension(); + + /** + * Destructor + */ + ~PSCertExtension(); + +public: + /** + * Loads the extension data from the specified cert. This function + * will also verify the validity these fields : + * HOST_NAME - should not be NULL or "" + * PORT_NUMBER - > 0 and <= 65535 + * MAX_USERS - >= 0 + * + * @param nickname cert nickname which contains the extension + * return 0 on success, + * -1 if nickname is missing from the argument + * -2 if unable to find the cert + * -3 if the presence extension is mising + * -4 if the required values (hostname, port, maxusers) are invalid + * -5 if the cert is expired + */ + int Load(const char* nickname); + + /** + * Gets the service version number from the cert ext + * + * return version number as specified in the cert + */ + int GetVersion(); + + /** + * Gets the street address from the cert + * + * return street address as specified in the cert ext + */ + const char* GetStreetAddress(); + + /** + * Gets the telephone number from the cert + * + * return telephone number as specified in the cert ext + */ + const char* GetTelephoneNumber(); + + /** + * Gets the RFC822 name from the cert + * + * return RFC822 name as specified in the cert ext + */ + const char* GetRFC822Name(); + + /** + * Gets the IM id from the cert + * + * return IM id as specified in the cert ext + */ + const char* GetID(); + + /** + * Gets the hostname from the cert ext + * + * return hostname as specified in the cert ext + */ + const char* GetHostName(); + + /** + * Gets the port number from the cert ext + * + * return port number as specified in the cert ext + */ + int GetPortNumber(); + + /** + * Gets the max users allowed from the cert ext + * + * return max users as specified in the cert ext + */ + int GetMaxUsers(); + + /** + * Gets the service level from the cert ext + * + * return service level as specified in the cert ext + */ + int GetServiceLevel(); + +private: + int m_version; + char* m_streetAddress; + char* m_telephoneNumber; + char* m_rfc822Name; + char* m_id; + char* m_hostName; + int m_portNumber; + int m_maxUsers; + int m_serviceLevel; +}; + +#endif // _PS_CERT_EXTENSION_H + diff --git a/base/tps/src/include/httpClient/httpc/PSCommonLib.h b/base/tps/src/include/httpClient/httpc/PSCommonLib.h new file mode 100644 index 000000000..09903b38f --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSCommonLib.h @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _PS_COMMON_LIB_H_ +#define _PS_COMMON_LIB_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#undef EXPORT_DECL +#ifdef _MSC_VER +#ifdef COMMON_LIB_DLL +#define EXPORT_DECL __declspec( dllexport ) +#else +#define EXPORT_DECL __declspec (dllimport ) +#endif // COMMON_LIB_DLL +#else +#define EXPORT_DECL +#endif // _MSC_VER + +#endif // _PS_COMMON_LIB_H_ diff --git a/base/tps/src/include/httpClient/httpc/PSConfig.h b/base/tps/src/include/httpClient/httpc/PSConfig.h new file mode 100644 index 000000000..897def3c9 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSConfig.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_CONFIG_H__ +#define __PS_CONFIG_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSConfig.h 1.000 04/30/2002 + * + * This class provides structure to store and fetch string type data. + * Typical usage of this class would be storing server config data. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSConfig { +public: + PSConfig(); + PSConfig( const char *name ); + virtual ~PSConfig(); + +public: + void SetAttribute( const char* key, char* value ); + char* GetAttribute( const char* key ); + void SetName( const char *name ); + const char *GetName(); + +private: + PLHashTable* m_entryData; + const char *m_name; +}; + +#endif // __PS_CONFIG_H__ diff --git a/base/tps/src/include/httpClient/httpc/PSConfigManager.h b/base/tps/src/include/httpClient/httpc/PSConfigManager.h new file mode 100644 index 000000000..d2f5d3335 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSConfigManager.h @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_CONFIG_MANAGER_H__ +#define __PS_CONFIG_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSConfigManager.h 1.000 04/30/2002 + * + * This class is a singleton that provides access to configuration parameters + * for the Presence Server. + * + * @author rweltman@netscape.com + * @version 1.0 + */ +class EXPORT_DECL PSConfigManager { +private: + PSConfigManager(); + virtual ~PSConfigManager(); + +public: + static PSConfigManager *GetConfigManager(); + +public: + void SetConfigEntry( PSConfig *entry ); + PSConfig *GetConfigEntry( const char *name ); + +private: + PLHashTable* m_configEntries; +}; + +#endif // __PS_CONFIG_MANAGER_H__ diff --git a/base/tps/src/include/httpClient/httpc/PSConfigReader.h b/base/tps/src/include/httpClient/httpc/PSConfigReader.h new file mode 100644 index 000000000..a507a26dc --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSConfigReader.h @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_CONFIG_READER_H__ +#define __PS_CONFIG_READER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSConfigReader.h 1.000 04/30/2002 + * + * This class provides access to the server configuration entries. The + * implementation of the config store is hidden from the user. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSConfigReader +{ +private: + PSConfigReader(); + virtual ~PSConfigReader(); + +public: + static PSConfigReader* GetConfigReader(); + +public: + int GetSubEntries(const char* root, char*** entries); + int GetEntryConfig(const char* entry, PSConfig** params); + +private: + int Init(); + +private: + LDAP* m_LD; + char* m_bindPassword; +}; + +#endif // __PS_CONFIG_READER_H__ diff --git a/base/tps/src/include/httpClient/httpc/PSCrypt.h b/base/tps/src/include/httpClient/httpc/PSCrypt.h new file mode 100644 index 000000000..bfd05788d --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSCrypt.h @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PSCRYPT_H__ +#define __PSCRYPT_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Encrypt/Decrypt + */ + +class EXPORT_DECL PSCrypt { +private: + /** + * Constructor + */ + PSCrypt( ); + /** + * Destructor + */ + virtual ~PSCrypt(); + +public: + /** + * Retuns the decrypted string + * Assumption: The input string is base64 encoded + * Assumption: Caller has to free the returned string using free + * @param base64 encoded string to be decrypted + * @param decrypted upon return, string in ascii + * @return 0 on success, -1 on failure + */ + static int Decrypt (const char* encrypted, char** decrypted); + + /** + * Retuns the encrypted string in base64 + * + * Assumption: Caller has to free the returned string using free + * @param text to encrypt + * @param encrypted upon return, text in base64 + * @return 0 on success, -1 on failure + */ + static int Encrypt(const char* text, char** encrypted); +}; + +#endif /* __PSCRYPT_H__ */ + diff --git a/base/tps/src/include/httpClient/httpc/PSDataSourceListener.h b/base/tps/src/include/httpClient/httpc/PSDataSourceListener.h new file mode 100644 index 000000000..36842904d --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSDataSourceListener.h @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_DATA_SOURCE_LISTENER_H__ +#define __PS_DATA_SOURCE_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/PSUser.h" + +/** + * PSDataSourceListener.h 1.000 04/30/2002 + * + * A listener class for data source type plugins. The plugins + * notify the data source service manager through the functions + * provided by this interface. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSDataSourceListener : + public PSListener +{ +public: + +/** + * Notifies the listener of any errors encountered by + * the data sources + * + * @param sourceId reporting source ID + * @param errCode error code + * @param errString error message + * @return 0 on success + */ +virtual int OnSourceError( const char* sourceId, + int errCode, + const char* errString) = 0; + +/** + * Notifies the listener of any new group + * + * @param group name of the group + * @param nAttrs number of attributes + * @param attrs array of attributes supported by the group + * @return 0 on success + */ +virtual int OnNewGroup( const char* group, int nAttrs, char** attrs ) = 0; + +/** + * Notifies the listener of any new users + * + * @param group name of the group + * @param nUsers number of users + * @param users array containing user objects + * @return 0 on success + */ +virtual int OnNewUsers( const char* group, int nUsers, PSUser** users ) = 0; + +/** + * Notifies the listener of any changes to the user being + * watched + * + * @param op operation to be performed ( add/replace/remove) + * @param group name of the group + * @param user the user object containing modified attributes + * @return 0 on success + */ +virtual int OnUserChanged(int op, const char* group, PSUser* user) = 0; + +}; + +#endif // __PS_DATA_SOURCE_LISTENER_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSDataSourceManager.h b/base/tps/src/include/httpClient/httpc/PSDataSourceManager.h new file mode 100644 index 000000000..1b0662b69 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSDataSourceManager.h @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_DATA_SOURCE_MANAGER_H__ +#define __PS_DATA_SOURCE_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSDataSourceManager.h 1.000 05/21/2002 + * + * This class manages presence server data sources plugins. + * + * @author Surendra Rajam + * @version 1.000, 05/21/2002 + */ +class PSDataSourceManager : + public PSDataSourceListener +{ +private: + + /** + * Constructor - creates a data source manager object + */ + PSDataSourceManager(); + + /** + * Destructor + */ + virtual ~PSDataSourceManager(); + +public: + + /** + * Gets an instance of this class. + */ + static PSDataSourceManager* GetDataSourceManager(); + +public: + + /** + * Registers a listener with this class. Only one listener is + * allowed to be registered. If an attempt is made to register + * more than one listener, then an error condition is raised. + * + * @param listener a server listener + * @return 0 on success, negative error upon failure + */ + int RegisterListener(PSServerListener* listener); + + /** + * Loads all data source type plugins. + * + * @return 0 for success, negative error code otherwise + */ + int LoadDataSources(); + + /** + * Unloads all data source type plugins. + * + * @return 0 for success, negative error code otherwise + */ + int UnloadDataSources(); + +// PSDataSourceListener interface +public: + + /** + * Callback function to notify the manager upon data source error. + * + * @param sourceid id of the source calling + * @param errorcode error code + * @param errorstring error string + * @return 0 on success + * + */ + int OnSourceError(const char* sourceid, int errorcode, const char* errorstring); + + /** + * Callback function to notify the manager upon new group. + * + * @param group name of the new group + * @param nAttrs number of attributes + * @param attrs attributes the group will support + * @return 0 on success + * + */ + int OnNewGroup(const char* group, int nAttrs, char** attrs); + + /** + * Callback function to notify the manager of new users + * + * @param group name of the group + * @param nUsers number of users + * @param users array containing user objects + * @return 0 on success, a negative error code on failure + */ + int OnNewUsers(const char* group, int nUsers, PSUser** users); + + /** + * Callback function to notify the manager of changes to a user. + * The valid operations are : + * PS_OPERATION_ADD + * PS_OPERATION_REPLACE + * PS_OPERATION_DELETE + * + * @param op operation to be performed + * @param group name of the group + * @param user the user object containing modified attributes + * @return 0 on success, a negative error code on failure + */ + int OnUserChanged(int op, const char* group, PSUser* user); + +private: + char* m_dataSourceDN; + PSServerListener* m_serverListener; + bool m_dataSourcesLoaded; +}; + +#endif // __PS_DATA_SOURCE_MANAGER_H__ diff --git a/base/tps/src/include/httpClient/httpc/PSGroup.h b/base/tps/src/include/httpClient/httpc/PSGroup.h new file mode 100644 index 000000000..8427c39c3 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSGroup.h @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_GROUP_H__ +#define __PS_GROUP_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +class PSUser; + +/** + * PSGroup.h 1.000 04/30/2002 + * + * This class stores information about the users belonging to a group. + * All the users must belong to at least one group in the server. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class PSGroup +{ +public: + PSGroup(const char* name, int nAttributes, char** attributes); + virtual ~PSGroup(); + +public: + char* GetName(); + int GetAttributeCount(); + char** GetAttributes(); + int GetAttributes(int offset, char** & attributes); + + int AddUser(PSUser* user); + int RemoveUser(const char* name); + PSUser* GetUser(const char* name); + bool UserExists(const char* name); + + int GetUserCount(); + int GetAllUsers(int offset, PSUser** & users, int maxcount); + int GetAllUsers(int offset, char** & names, int maxcount); + + int UpdateStatus(const char* name, bool changeToOnline); + int GetOnlineUsers(char*** names); + int GetOfflineUsers(char*** names); + int GetOnlineCount(); + int GetOfflineCount(); + + void ReadLock(); + void Unlock(); + +private: + char* m_name; + int m_count; + char** m_attributes; + + PRRWLock* m_psOnlineLock; + PRRWLock* m_psOfflineLock; + StringList* m_psOnlineUsers; + StringList* m_psOfflineUsers; + + StringKeyCache* m_users; +}; + +#endif // __PS_GROUP_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSGroupCache.h b/base/tps/src/include/httpClient/httpc/PSGroupCache.h new file mode 100644 index 000000000..6807e50e4 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSGroupCache.h @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_GROUP_CACHE_H__ +#define __PS_GROUP_CACHE_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSGroupCache.h 1.000 04/30/2002 + * + * This class provides caching of various groups maintained in the + * server. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class PSGroupCache +{ +public: + PSGroupCache(); + virtual ~PSGroupCache(); + + int AddGroup(const char* name, PSGroup* group); + int RemoveGroup(const char* name); + PSGroup* GetGroup(const char* name); + bool GroupExists(const char* name); + int GetAllGroups(char*** names); + + int GetAttributeCount(int nGroups, char** groups); + int GetUserCount(int nGroups, char** groups); + int GetOnlineCount(int nGroups, char** groups); + int GetOfflineCount(int nGroups, char** groups); + + void ReadLock(); + void Unlock(); + +private: + StringKeyCache* m_groups; +}; + +#endif // __PS_GROUP_CACHE_H__ diff --git a/base/tps/src/include/httpClient/httpc/PSHelper.h b/base/tps/src/include/httpClient/httpc/PSHelper.h new file mode 100644 index 000000000..7b9240b1b --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSHelper.h @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_HELPER_H__ +#define __PS_HELPER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSHelper.h 1.000 04/30/2002 + * + * A utility class used for logging, utility functions + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +// ??? SSR temporary logging solution +class EXPORT_DECL PSLogger +{ +public: + PSLogger(int level); + virtual ~PSLogger(); + +public: + void Log(int level, char* fmt, ...); +private: + int m_Level; +}; + +extern "C" { + EXPORT_DECL PSLogger* getServerLogger(); + EXPORT_DECL void toLower(char* str); + EXPORT_DECL void normalize(char* str); +} + +#endif // __PS_HELPER_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSListener.h b/base/tps/src/include/httpClient/httpc/PSListener.h new file mode 100644 index 000000000..1d85a9912 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSListener.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_LISTENER_H__ +#define __PS_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSListener.h 1.000 05/22/2002 + * + * A Generic base class for all listeners. + * + * @author Surendra Rajam + * @version 1.000, 05/22/2002 + */ +class EXPORT_DECL PSListener +{ +}; + +#endif // __PS_LISTENER_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSPRUtil.h b/base/tps/src/include/httpClient/httpc/PSPRUtil.h new file mode 100644 index 000000000..f3b104cc0 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSPRUtil.h @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _PS_PRUTIL_H +#define _PS_PRUTIL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * NSPR related Utility functions + */ + +// define a stuct to store the mesasge +struct tuple_str { + PRErrorCode errNum; + const char * errString; +}; + +typedef struct tuple_str tuple_str; + +#define ER2(a,b) {a, b}, +#define ER3(a,b,c) {a, c}, + + +class EXPORT_DECL PSPRUtil { + +private: + /** + * Constructor - can't be instantiated + */ + PSPRUtil() {} + + /** + * Destructor + */ + ~PSPRUtil() {} + +public: + /** + * Returns a string corresponding to an NSPR or NSS error code + * + * @param errNum Error number from PR_GetError() + * @retuns An immutable string, the empty string if the code is not known + */ + static const char * GetErrorString (PRErrorCode errCode); + + + /** + * Returns an error string for the latest NSPR or NSS error + * + * @return An error string, or the empty string if there is no current + * NSPR or NSS error + */ + static const char * GetErrorString(); + + +}; + +#endif // _PS_PRUTIL_H + diff --git a/base/tps/src/include/httpClient/httpc/PSPlugin.h b/base/tps/src/include/httpClient/httpc/PSPlugin.h new file mode 100644 index 000000000..f6655591e --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSPlugin.h @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_PLUGIN_H__ +#define __PS_PLUGIN_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSPlugin.h 1.000 04/30/2002 + * + * Pure virtual class defining the functions to be implemented by + * different types of plugins in the server. The listener object passed + * the Init function is used to notify the server. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSPlugin { +public: + +/** + * Initialize the plugin. + * + * @param a listener for this plugin + * @return 0 on success + */ +virtual int Init(PSListener*) = 0; + +/** + * Start the plugin. + * + * @param config params for the plugin + * @return 0 on success + */ +virtual int Start(PSConfig*) = 0; + +/** + * Stops the plugin. + * + * @return 0 on success + */ +virtual int Stop() = 0; + +}; + +#endif // __PSPLUGIN_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSPluginManager.h b/base/tps/src/include/httpClient/httpc/PSPluginManager.h new file mode 100644 index 000000000..7ea12829a --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSPluginManager.h @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_PLUGIN_MANAGER_H__ +#define __PS_PLUGIN_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSPluginManager.h 1.000 05/21/2002 + * + * This class manages loading and unloading of all server plugin modules. + * + * @author Surendra Rajam + * @version 1.000, 05/21/2002 + */ +class PSPluginManager +{ +private: + +/** + * Constructor - creates an instance of Plugin manager object + */ +PSPluginManager(); + +/** + * Destructor + */ +virtual ~PSPluginManager(); + +public: + +/** + * Gets an instance of the class + */ +static PSPluginManager* GetPluginManager(); + +public: + +/** + * Loads a group of plugins based on the type (dn) specified. If the loading + * is successful the specified listener is registered with the plugin and + * the plugin is started. + * + * @param dn root DN of the plugins + * @param listener listener associated with the specified type of plugins + * @return 0 on success, negative error code otherwise + */ +int LoadPlugin(const char* dn, PSListener* listener); + +/** + * Unloads a group of plugins based on the type ( dn ) specified. + * This function just issues a Stop on all the loaded plugins. + * It doesn't attempt to release any allocated data structures. + * + * @param dn root DN of the plugins + * @return 0 for success or error code for failure + */ +int UnloadPlugin(const char* dn); + +private: + StringKeyCache* m_serverPlugins; +}; + +#endif // __PS_PLUGIN_MANAGER_H__ + + + + + diff --git a/base/tps/src/include/httpClient/httpc/PSServer.h b/base/tps/src/include/httpClient/httpc/PSServer.h new file mode 100644 index 000000000..86d2ca326 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSServer.h @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVER_H__ +#define __PS_SERVER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <stdio.h> +#include <time.h> +#include <ctype.h> + +#include "nspr.h" +#include "plhash.h" +#include "plstr.h" + +#include "ldap.h" + +#define PRESENCESERVER_DLL +#include "httpClient/httpc/PSServerLib.h" +#include "httpClient/httpc/PresenceServer.h" + +#include "httpClient/httpc/Defines.h" +#include "httpClient/httpc/PSError.h" +#include "httpClient/httpc/PSHelper.h" +#include "httpClient/httpc/PSConfig.h" +#include "httpClient/httpc/PSConfigReader.h" +#include "httpClient/httpc/PSConfigManager.h" +#include "httpClient/httpc/Cache.h" +#include "httpClient/httpc/StringList.h" +#include "httpClient/httpc/StringUtil.h" +#include "httpClient/httpc/ScheduledTask.h" +#include "httpClient/httpc/PSCrypt.h" + +#include "httpClient/httpc/PSListener.h" +#include "httpClient/httpc/PSBuddy.h" +#include "httpClient/httpc/PSBuddyService.h" +#include "httpClient/httpc/PSBuddyListener.h" +#include "httpClient/httpc/PSServerListener.h" +#include "httpClient/httpc/PSServiceListener.h" +#include "httpClient/httpc/PSPluginManager.h" +#include "httpClient/httpc/PSServiceManager.h" +#include "httpClient/httpc/PSPlugin.h" +#include "httpClient/httpc/PSUser.h" +#include "httpClient/httpc/PSDataSourceListener.h" +#include "httpClient/httpc/PSDataSourceManager.h" +#include "httpClient/httpc/PSGroup.h" +#include "httpClient/httpc/PSGroupCache.h" +#include "httpClient/httpc/PSBuddyCache.h" +#include "httpClient/httpc/PSBuddyList.h" +#include "httpClient/httpc/PresenceManager.h" +#include "httpClient/httpc/PSServerManager.h" + +#include "httpClient/httpc/ErrorLogger.h" +#include "httpClient/httpc/DebugLogger.h" +#include "httpClient/httpc/ScheduledTask.h" +#include "httpClient/httpc/LogRotationTask.h" +#include "httpClient/httpc/TaskList.h" +#include "httpClient/httpc/Scheduler.h" + +#endif // __PS_SERVER_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSServerLib.h b/base/tps/src/include/httpClient/httpc/PSServerLib.h new file mode 100644 index 000000000..079134230 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSServerLib.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVER_LIB_H__ +#define __PS_SERVER_LIB_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServerLib.h 1.000 05/27/2002 + * + * @author Surendra Rajam + * @version 1.000, 05/27/2002 + */ + +#ifdef _MSC_VER + #ifdef PRESENCESERVER_DLL + #define EXPORT_DECL __declspec( dllexport ) + #else + #define EXPORT_DECL __declspec (dllimport ) + #endif // PRESENCESERVER_DLL +#else + #define EXPORT_DECL +#endif // _MSC_VER + +#endif // __PS_SERVER_LIB_H__ + + + + diff --git a/base/tps/src/include/httpClient/httpc/PSServerListener.h b/base/tps/src/include/httpClient/httpc/PSServerListener.h new file mode 100644 index 000000000..152fbf58f --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSServerListener.h @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVER_LISTENER_H__ +#define __PS_SERVER_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServerListener.h 1.000 04/30/2002 + * + * A listener class to report back into the server. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSServerListener : + public PSListener +{ +public: + +/** + * Callback to report startup of a service. + * + * @param reporting module ID + * @return 0 on success + */ +virtual int OnStartup(const char*) = 0; + +/** + * Callback to report shutdown of a service. + * + * @param reporting module ID + * @return 0 on success + */ +virtual int OnShutdown(const char*) = 0; + +/** + * Callback to report any errors encountered during service execution. + * + * @param reporting module ID + * @param error code + * @param error message + * @return 0 on success + */ +virtual int OnCriticalError(const char*, int, const char*) = 0; + +}; + +#endif // __PS_SERVER_LISTENER_H__ + + + diff --git a/base/tps/src/include/httpClient/httpc/PSServerManager.h b/base/tps/src/include/httpClient/httpc/PSServerManager.h new file mode 100644 index 000000000..6597ad605 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSServerManager.h @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVER_MANAGER_H__ +#define __PS_SERVER_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServerManager.h 1.000 05/21/2002 + * + * This class manages the server execution. It is responsible for loading + * of configurations, starting of services and proper shutdown of services. + * + * @author Surendra Rajam + * @version 1.000, 05/21/2002 + */ +class PSServerManager : + public PSServerListener +{ +private: + +/** + * Constructor - creates an instance of server manager object + */ +PSServerManager(); + +/** + * Destructor + */ +virtual ~PSServerManager(); + +public: + +/** + * Gets an instance of this class. + */ +static PSServerManager* GetServerManager(); + +public: + +/** + * Loads general configuration into the ConfigManager + * + * @return 0 on success, negative error code otherwise + */ +int InitServices(); + +/** + * Starts services after server startup. The presence services are + * started before anything else and if it fails then no attempt is + * made to start other services. + * + * @return 0 on success, negative error code otherwise + */ +int StartServices(); + +/** + * Stops services before server shutdown. + * + * @return 0 on success, negative error code otherwise + */ +int StopServices(); + +private: + +/** + * Loads one configuration entry + * + * @param configdn The DN of the LDAP entry containing the config + * @param configName The name of the config entry + * @param descr A description of the config entry + * @return 0 on success + */ +int LoadOneConfig(const char* configdn, const char* configName, const char* descr); + +// PSServerListener interface +public: + +/** + * Callback to notify server upon a service startup + * + * @param moduleid the notifying service id + * @return 0 on success + */ +int OnStartup(const char* moduleid); + +/** + * Callback to notify server upon a service shutdown + * + * @param moduleid the notifying service id + * @return 0 on success + */ +int OnShutdown(const char* moduleid); + +/** + * Callback to notify server upon a critical errors. The server immediately + * shuts down upon receipt of any such notification. + * + * @param moduleid the notifying service id + * @param errorcode negative error code + * @param errorstring negative error code + * @return 0 on success + */ +int OnCriticalError(const char* moduleid, int errorcode, const char* errorstring); + +private: + bool m_loadServiceDone; +}; + +#endif // __PS_SERVER_MANAGER_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PSServiceListener.h b/base/tps/src/include/httpClient/httpc/PSServiceListener.h new file mode 100644 index 000000000..358f0c295 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSServiceListener.h @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVICE_LISTENER_H__ +#define __PS_SERVICE_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServiceListener.h 1.000 05/16/2002 + * + * A listener interface for all the IM services to report back into + * service manager. + * + * @author Surendra Rajam + * @version 1.000, 05/16/2002 + */ +class EXPORT_DECL PSServiceListener : + public PSListener +{ +public: + +/** + * Callback to report start of a buddy service. + * + * @param reporting module + * @return 0 on success + */ +virtual int OnServiceStart(PSBuddyService*) = 0; + +/** + * Callback to report buddy service errors. + * + * @param reporting module + * @param error code + * @param error message + * @return 0 on success + */ +virtual int OnServiceError(PSBuddyService*, int, const char*) = 0; + + +/** + * Callback to report shutdown of a buddy service. + * + * @param reporting module + * @return 0 on success + */ +virtual int OnServiceStop(PSBuddyService*) = 0; + +}; + +#endif // __PS_SERVICE_LISTENER_H__ + + + diff --git a/base/tps/src/include/httpClient/httpc/PSServiceManager.h b/base/tps/src/include/httpClient/httpc/PSServiceManager.h new file mode 100644 index 000000000..1fd755c14 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSServiceManager.h @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVICE_MANAGER_H__ +#define __PS_SERVICE_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServiceManager.h 1.000 05/16/2002 + * + * A Singleton class to manage presence services. Currently we support + * only one service to be loaded. + * + * @author Surendra Rajam + * @version 1.000, 05/16/2002 + */ +class PSServiceManager : + public PSServiceListener +{ +private: + +/** + * Constructor - creates a service manager object + */ +PSServiceManager(); + +/** + * Destructor + */ +virtual ~PSServiceManager(); + +public: + +/** + * Gets an instance of this class. + */ +static PSServiceManager* GetServiceManager(); + +public: + +/** + * Registers a listener with this class. Only one listener is + * allowed to be registered. If an attempt is made to register + * more than one listener, then an error condition is raised. + * + * @param listener a server listener + * @return 0 on success, negative error upon failure + */ +int RegisterListener(PSServerListener* listener); + +/** + * Loads all providers type plugins. + * + * @return 0 for success, negative error code otherwise + */ +int LoadServices(); + +/** + * Unloads all providers type plugins. + * + * @return 0 for success, negative error code otherwise + */ +int UnloadServices(); + +/** + * Gets the service currently loaded. Only one service can + * be configured at a time. + * + * @return an im service + */ +PSBuddyService* GetService(); + +// PSServiceListener interface +public: + +/** + * Callback function to notify the manager of a service being started. + * + * @param service a buddy service + */ +int OnServiceStart(PSBuddyService* service); + +/** + * Callback function to notify the manager of a service error. + * + * @param service a buddy service + * @param errorcode a negative error code + * @param errorstring an error message + */ +int OnServiceError(PSBuddyService* service, int errorcode, const char* errorstring); + +/** + * Callback function to notify the manager of a service being stopped. + * + * @param service a buddy service + */ +int OnServiceStop(PSBuddyService* service); + +private: + char* m_serviceDN; + PSServerListener* m_serverListener; + PSBuddyService* m_service; + + bool m_servicesLoaded; +}; + +#endif // __PS_SERVICE_MANAGER_H__ + + + + + diff --git a/base/tps/src/include/httpClient/httpc/PSUser.h b/base/tps/src/include/httpClient/httpc/PSUser.h new file mode 100644 index 000000000..a66c4e32f --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSUser.h @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PSUSER_H__ +#define __PSUSER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "PresenceServer.h" + +/** + * PSUser.h 1.000 04/30/2002 + * + * This class represents one attribute of a user. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSAttribute +{ +public: + +/** + * Construts a new PSAttribute object. + * + * @param name name of the attribute + * @param value value of the attribute + */ +PSAttribute(const char* name, const char* value); + +/** + * Destructor + */ +virtual ~PSAttribute(); + +/** + * Gets the name of the attribute. + * + * @return name of the attribute + */ +char* GetName(); + +/** + * Gets the value of the specified attribute. + * + * @return value of the attribute + */ +char* GetValue(); + +private: + char* m_name; + char* m_value; +}; + +/** + * PSUser.h 1.000 04/30/2002 + * + * This class represents information about a single user. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSUser +{ +public: + +/** + * Construts a new PSUser object with just one attribute. + * + * @param name name of the user + * @param attribute a user attribute + */ +PSUser(const char* name, PSAttribute* attribute); + +/** + * Construts a new PSUser object with number of attributes. + * + * @param name name of the user + * @param nAttributes number of attributes + * @param attribute array containing user attributes + */ +PSUser(const char* name, int nAttributes, PSAttribute** attributes); + +/** + * Destructor + */ +virtual ~PSUser(); + +/** + * Gets the name of the user. + * + * @return user name + */ +char* GetName(); + +/** + * Get the count of user attributes. + * + * @return count of user attributes + */ +int GetCount(); + +/** + * Gets a list of attribute objects for the user. + * + * @return array of attribute objects + */ +PSAttribute** GetAttributes(); + +/** + * Gets the user attribute based on the specified attribute name. + * + * @return user attribute object on success, NULL otherwise + */ +PSAttribute* Lookup(char* key); + +/** + * Creates a new copy of the current user object. + * + * @return new user object + */ +void Clone(PSUser** user); + +private: + char* m_name; + int m_attrCount; + PSAttribute** m_attributes; +}; + +#endif + + diff --git a/base/tps/src/include/httpClient/httpc/PSWaspLib.h b/base/tps/src/include/httpClient/httpc/PSWaspLib.h new file mode 100644 index 000000000..8fdea6bcc --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PSWaspLib.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _PS_WASP_LIB_H_ +#define _PS_WASP_LIB_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#ifdef _MSC_VER +#undef EXPORT_DECL +#ifdef WASP_LIB_DLL +#define EXPORT_DECL __declspec( dllexport ) +#else +#define EXPORT_DECL __declspec (dllimport ) +#endif // EXPORT_LIB_DLL +#else +#define EXPORT_DECL +#endif // _MSC_VER + +// Key to hostname in WASP CallContext +#define CONTEXT_HOSTNAME_TOKEN "Hostname" + +#endif // _PS_WASP_LIB_H_ diff --git a/base/tps/src/include/httpClient/httpc/Pool.h b/base/tps/src/include/httpClient/httpc/Pool.h new file mode 100644 index 000000000..074b36b3b --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/Pool.h @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __POOL_H__ +#define __POOL_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#define AUTOTOOLS_CONFIG_H +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Utility classes for object pools + * + * @author rweltman@netscape.com + * @version 1.0 + */ + +class PoolNode; +class Pool; + +typedef int (*PoolEnumerator)(PoolNode *node); + +/** + * A node in a pool + */ +class EXPORT_DECL PoolNode { + friend class Pool; +public: + /** + * Constructor + * + * @param data The real data of the node + */ + PoolNode( void *data ); + /** + * Destructor + */ + virtual ~PoolNode(); + /** + * Returns the real data of the node + * + * @return The real data of the node + */ + void *GetData(); + /** + * Returns the next entry in the list + * + * @return The next entry in the list + */ + PoolNode *GetNext(); + /** + * Returns the previous entry in the list + * + * @return The previous entry in the list + */ + PoolNode *GetPrev(); +private: + void *m_data; + PoolNode *m_next; + PoolNode *m_prev; +}; + +/** + * A generic object pool + */ +class EXPORT_DECL Pool { +public: + /** + * Constructor - creates a pool with an internal list of nodes + * + * @param name Name of pool + * @param poolSize Max number of nodes kept + * @param enumerator Optional enumerator to be called on destruction + */ + Pool( const char *name, int poolSize, PoolEnumerator enumerator = NULL ); + /** + * Destructor - Empties the pool + */ + virtual ~Pool(); + /** + * Appends an entry to the end of the internal list + * + * @param node An entry to add + * @return The added entry + */ + PoolNode *Append( PoolNode *node ); + /** + * Retrieves the head of the internal list and removes it + * + * @return The head of the internal list + */ + PoolNode *RemoveHead(); + /** + * Returns true if the pool is empty + * + * @return true if the pool is empty + */ + bool IsEmpty(); + + /** + * Returns the number of entries in the pool + * + * @return The number of entries in the pool + */ + int GetCount(); + +protected: +private: + PoolNode *m_list; + char *m_name; + int m_maxNodes; + int m_count; + PoolEnumerator m_enumerator; + PRRWLock *m_lock; + PRLock *m_conditionLock; + PRCondVar *m_condition; +}; + +#endif // __POOL_H__ diff --git a/base/tps/src/include/httpClient/httpc/PresenceManager.h b/base/tps/src/include/httpClient/httpc/PresenceManager.h new file mode 100644 index 000000000..f7f4f753f --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PresenceManager.h @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PRESENCEMANAGER_H__ +#define __PRESENCEMANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#define AUTOTOOLS_CONFIG_H +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/PSUser.h" + +/** + * PresenceManager.h 1.000 04/30/2002 + * + * Wrapper class around the core buddylist management API. + * + * @author Rob Weltman + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PresenceManager { +public: + PresenceManager(); + virtual ~PresenceManager(); + + int GetUserStatus(const char* group, const char* name, int nAttributes, char** attributes, PSUser** user); + int GetMultipleUserStatus(const char* group, + int nUsers, + char** names, + int nAttributes, + char** attributes, + PSUser*** users); + int GetUsersByFilter(const char* group, const char* filter, int nAttributes, char** attributes, PSUser*** users); + int GetSortedUsersByFilter(const char* group, const char* filter, + const char *sortKey, int sortKeyType, + int nAttributes, char** attributes, PSUser*** users); + /** + * Gets the number of users who are online or offline in a group + * + * @param group Name of group to query; NULL or empty for all groups + * @param bOnline true to return the count of online users, false for + * offline + * @return Number of users, or a negative error code on failure + * + * Error Code(s): + * PS_UNKOWN_GROUP + */ + int GetUserCount( const char* group, int bOnline ); + int AddGroup(const char* group, int nAttributes, char** attributes); + int AddUser(const char* group, const char* name, int nAttributes, PSAttribute** attributes); + int AddUsers(const char* group, int nUsers, PSUser** users); + int RemoveUser(const char* group, const char* name); + int RemoveUsers(const char* group, int nUsers, char** names); + int RemoveGroup(const char* group); + int GetAllGroups(char*** groups); + int GetAllUsers(const char* group, PSUser*** users); + int GetSearchableAttributes(const char* group, char*** attributes); + +private: +}; + +#endif // __PRESENCEMANAGER_H__ diff --git a/base/tps/src/include/httpClient/httpc/PresenceServer.h b/base/tps/src/include/httpClient/httpc/PresenceServer.h new file mode 100644 index 000000000..1a9b259e9 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PresenceServer.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PRESENCE_SERVER_H__ +#define __PRESENCE_SERVER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/PSServerLib.h" + +/** + * PresenceServer.h 1.000 04/30/2002 + * + * Starts and stops presence services + * + * @author Rob Weltman + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ + +extern "C" { +EXPORT_DECL int presence_main( int argc, char* argv[] ); +EXPORT_DECL void presence_exit(); +} + +#endif // __PRESENCE_SERVER_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/PresenceServerImpl.h b/base/tps/src/include/httpClient/httpc/PresenceServerImpl.h new file mode 100644 index 000000000..8c07b9140 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/PresenceServerImpl.h @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PRESENCE_SERVER_IMPL_H__ +#define __PRESENCE_SERVER_IMPL_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +class PSUser; + +/** + * PresenceServerImpl.h 1.000 04/30/2002 + * + * Interface for WASP implementation of presence service + * + * @author Rob Weltman + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ + +class EXPORT_DECL PresenceServerImpl:public PresenceServiceImpl { +public: + PresenceServerImpl() {} + virtual ~PresenceServerImpl() {} + virtual int getAllGroups (ArrayOfstring *& groups); + virtual int getAllUsers (WASP_String * group, ArrayOfstring *& users); + virtual int removeGroup (WASP_String * group); + virtual int getUsersByFilter (WASP_String * group, WASP_String * filter, int nAttributes, ArrayOfstring * attributes, ArrayOfPresenceUser *& users); + virtual int getMultipleUserStatus (WASP_String * group, + int nUsers, + ArrayOfstring * names, + int nAttributes, + ArrayOfstring * attributes, + ArrayOfPresenceUser *& users); + virtual int removeUser (WASP_String * group, WASP_String * name); + virtual int getUserStatus (WASP_String * group, WASP_String * name, int nAttributes, ArrayOfstring * attributes, PresenceUser *& user); + /** + * Gets the number of users who are online or offline in a group + * + * @param group Name of group to query; NULL or empty for all groups + * @param bOnline true to return the count of online users, false for offline + * @return Number of users, or a negative error code on failure + * + * Error Code(s): + * PS_UNKOWN_GROUP + */ + virtual int getUserCount( WASP_String* group, int bOnline ); + virtual int addUsers (WASP_String * group, int nUsers, ArrayOfPresenceUser * users); + virtual int addGroup (WASP_String * group, int nAttributes, ArrayOfstring * attributes); + virtual int getSearchableAttributes (WASP_String * group, ArrayOfstring *& attributes); + virtual int addUser (WASP_String * group, WASP_String * name, int nAttributes, ArrayOfUserAttribute * attributes); + virtual int getSortedUsersByFilter (WASP_String * group, + WASP_String * filter, + WASP_String * sortKey, + int sortKeyType, + int nAttributes, + ArrayOfstring * attributes, + ArrayOfPresenceUser *& users); + virtual int removeUsers (WASP_String * group, int nUsers, ArrayOfstring * names); +protected: + void doLog(const char *func, int status); + static int parseUsers(int nUsers, PSUser** tusers, + ArrayOfPresenceUser*& users); + /** + * Decodes an array of Unicode strings from a WASP string array object; + * the result should be freed by deleting the individual strings as well as + * the array itself; nStrings is set to 0 if wStrings is NULL + * + * @param attributes WASP string array object to convert + * @param nAttributes Number of strings to process + * @return Array of strings + */ + char **DecodeStringArrayObject( ArrayOfstring* wStrings, + int& nStrings ); +}; + +#endif // __PRESENCE_SERVER_IMPL_H__ + + diff --git a/base/tps/src/include/httpClient/httpc/SECerrs.h b/base/tps/src/include/httpClient/httpc/SECerrs.h new file mode 100644 index 000000000..d7495ff28 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/SECerrs.h @@ -0,0 +1,522 @@ +/** BEGIN COPYRIGHT BLOCK + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1994-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * END COPYRIGHT BLOCK **/ + +/* Originally obtained from: + * + * CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot + * cvs export -r NSS_3_11_3_RTM -N mozilla/security/nss/cmd/lib/SECerrs.h + */ + +/* General security error codes */ +/* Caller must #include "secerr.h" */ + +ER3(SEC_ERROR_IO, SEC_ERROR_BASE + 0, +"An I/O error occurred during security authorization.") + +ER3(SEC_ERROR_LIBRARY_FAILURE, SEC_ERROR_BASE + 1, +"security library failure.") + +ER3(SEC_ERROR_BAD_DATA, SEC_ERROR_BASE + 2, +"security library: received bad data.") + +ER3(SEC_ERROR_OUTPUT_LEN, SEC_ERROR_BASE + 3, +"security library: output length error.") + +ER3(SEC_ERROR_INPUT_LEN, SEC_ERROR_BASE + 4, +"security library has experienced an input length error.") + +ER3(SEC_ERROR_INVALID_ARGS, SEC_ERROR_BASE + 5, +"security library: invalid arguments.") + +ER3(SEC_ERROR_INVALID_ALGORITHM, SEC_ERROR_BASE + 6, +"security library: invalid algorithm.") + +ER3(SEC_ERROR_INVALID_AVA, SEC_ERROR_BASE + 7, +"security library: invalid AVA.") + +ER3(SEC_ERROR_INVALID_TIME, SEC_ERROR_BASE + 8, +"Improperly formatted time string.") + +ER3(SEC_ERROR_BAD_DER, SEC_ERROR_BASE + 9, +"security library: improperly formatted DER-encoded message.") + +ER3(SEC_ERROR_BAD_SIGNATURE, SEC_ERROR_BASE + 10, +"Peer's certificate has an invalid signature.") + +ER3(SEC_ERROR_EXPIRED_CERTIFICATE, SEC_ERROR_BASE + 11, +"Peer's Certificate has expired.") + +ER3(SEC_ERROR_REVOKED_CERTIFICATE, SEC_ERROR_BASE + 12, +"Peer's Certificate has been revoked.") + +ER3(SEC_ERROR_UNKNOWN_ISSUER, SEC_ERROR_BASE + 13, +"Peer's Certificate issuer is not recognized.") + +ER3(SEC_ERROR_BAD_KEY, SEC_ERROR_BASE + 14, +"Peer's public key is invalid.") + +ER3(SEC_ERROR_BAD_PASSWORD, SEC_ERROR_BASE + 15, +"The security password entered is incorrect.") + +ER3(SEC_ERROR_RETRY_PASSWORD, SEC_ERROR_BASE + 16, +"New password entered incorrectly. Please try again.") + +ER3(SEC_ERROR_NO_NODELOCK, SEC_ERROR_BASE + 17, +"security library: no nodelock.") + +ER3(SEC_ERROR_BAD_DATABASE, SEC_ERROR_BASE + 18, +"security library: bad database.") + +ER3(SEC_ERROR_NO_MEMORY, SEC_ERROR_BASE + 19, +"security library: memory allocation failure.") + +ER3(SEC_ERROR_UNTRUSTED_ISSUER, SEC_ERROR_BASE + 20, +"Peer's certificate issuer has been marked as not trusted by the user.") + +ER3(SEC_ERROR_UNTRUSTED_CERT, SEC_ERROR_BASE + 21, +"Peer's certificate has been marked as not trusted by the user.") + +ER3(SEC_ERROR_DUPLICATE_CERT, (SEC_ERROR_BASE + 22), +"Certificate already exists in your database.") + +ER3(SEC_ERROR_DUPLICATE_CERT_NAME, (SEC_ERROR_BASE + 23), +"Downloaded certificate's name duplicates one already in your database.") + +ER3(SEC_ERROR_ADDING_CERT, (SEC_ERROR_BASE + 24), +"Error adding certificate to database.") + +ER3(SEC_ERROR_FILING_KEY, (SEC_ERROR_BASE + 25), +"Error refiling the key for this certificate.") + +ER3(SEC_ERROR_NO_KEY, (SEC_ERROR_BASE + 26), +"The private key for this certificate cannot be found in key database") + +ER3(SEC_ERROR_CERT_VALID, (SEC_ERROR_BASE + 27), +"This certificate is valid.") + +ER3(SEC_ERROR_CERT_NOT_VALID, (SEC_ERROR_BASE + 28), +"This certificate is not valid.") + +ER3(SEC_ERROR_CERT_NO_RESPONSE, (SEC_ERROR_BASE + 29), +"Cert Library: No Response") + +ER3(SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE, (SEC_ERROR_BASE + 30), +"The certificate issuer's certificate has expired. Check your system date and time.") + +ER3(SEC_ERROR_CRL_EXPIRED, (SEC_ERROR_BASE + 31), +"The CRL for the certificate's issuer has expired. Update it or check your system data and time.") + +ER3(SEC_ERROR_CRL_BAD_SIGNATURE, (SEC_ERROR_BASE + 32), +"The CRL for the certificate's issuer has an invalid signature.") + +ER3(SEC_ERROR_CRL_INVALID, (SEC_ERROR_BASE + 33), +"New CRL has an invalid format.") + +ER3(SEC_ERROR_EXTENSION_VALUE_INVALID, (SEC_ERROR_BASE + 34), +"Certificate extension value is invalid.") + +ER3(SEC_ERROR_EXTENSION_NOT_FOUND, (SEC_ERROR_BASE + 35), +"Certificate extension not found.") + +ER3(SEC_ERROR_CA_CERT_INVALID, (SEC_ERROR_BASE + 36), +"Issuer certificate is invalid.") + +ER3(SEC_ERROR_PATH_LEN_CONSTRAINT_INVALID, (SEC_ERROR_BASE + 37), +"Certificate path length constraint is invalid.") + +ER3(SEC_ERROR_CERT_USAGES_INVALID, (SEC_ERROR_BASE + 38), +"Certificate usages field is invalid.") + +ER3(SEC_INTERNAL_ONLY, (SEC_ERROR_BASE + 39), +"**Internal ONLY module**") + +ER3(SEC_ERROR_INVALID_KEY, (SEC_ERROR_BASE + 40), +"The key does not support the requested operation.") + +ER3(SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION, (SEC_ERROR_BASE + 41), +"Certificate contains unknown critical extension.") + +ER3(SEC_ERROR_OLD_CRL, (SEC_ERROR_BASE + 42), +"New CRL is not later than the current one.") + +ER3(SEC_ERROR_NO_EMAIL_CERT, (SEC_ERROR_BASE + 43), +"Not encrypted or signed: you do not yet have an email certificate.") + +ER3(SEC_ERROR_NO_RECIPIENT_CERTS_QUERY, (SEC_ERROR_BASE + 44), +"Not encrypted: you do not have certificates for each of the recipients.") + +ER3(SEC_ERROR_NOT_A_RECIPIENT, (SEC_ERROR_BASE + 45), +"Cannot decrypt: you are not a recipient, or matching certificate and \ +private key not found.") + +ER3(SEC_ERROR_PKCS7_KEYALG_MISMATCH, (SEC_ERROR_BASE + 46), +"Cannot decrypt: key encryption algorithm does not match your certificate.") + +ER3(SEC_ERROR_PKCS7_BAD_SIGNATURE, (SEC_ERROR_BASE + 47), +"Signature verification failed: no signer found, too many signers found, \ +or improper or corrupted data.") + +ER3(SEC_ERROR_UNSUPPORTED_KEYALG, (SEC_ERROR_BASE + 48), +"Unsupported or unknown key algorithm.") + +ER3(SEC_ERROR_DECRYPTION_DISALLOWED, (SEC_ERROR_BASE + 49), +"Cannot decrypt: encrypted using a disallowed algorithm or key size.") + + +/* Fortezza Alerts */ +ER3(XP_SEC_FORTEZZA_BAD_CARD, (SEC_ERROR_BASE + 50), +"Fortezza card has not been properly initialized. \ +Please remove it and return it to your issuer.") + +ER3(XP_SEC_FORTEZZA_NO_CARD, (SEC_ERROR_BASE + 51), +"No Fortezza cards Found") + +ER3(XP_SEC_FORTEZZA_NONE_SELECTED, (SEC_ERROR_BASE + 52), +"No Fortezza card selected") + +ER3(XP_SEC_FORTEZZA_MORE_INFO, (SEC_ERROR_BASE + 53), +"Please select a personality to get more info on") + +ER3(XP_SEC_FORTEZZA_PERSON_NOT_FOUND, (SEC_ERROR_BASE + 54), +"Personality not found") + +ER3(XP_SEC_FORTEZZA_NO_MORE_INFO, (SEC_ERROR_BASE + 55), +"No more information on that Personality") + +ER3(XP_SEC_FORTEZZA_BAD_PIN, (SEC_ERROR_BASE + 56), +"Invalid Pin") + +ER3(XP_SEC_FORTEZZA_PERSON_ERROR, (SEC_ERROR_BASE + 57), +"Couldn't initialize Fortezza personalities.") +/* end fortezza alerts. */ + +ER3(SEC_ERROR_NO_KRL, (SEC_ERROR_BASE + 58), +"No KRL for this site's certificate has been found.") + +ER3(SEC_ERROR_KRL_EXPIRED, (SEC_ERROR_BASE + 59), +"The KRL for this site's certificate has expired.") + +ER3(SEC_ERROR_KRL_BAD_SIGNATURE, (SEC_ERROR_BASE + 60), +"The KRL for this site's certificate has an invalid signature.") + +ER3(SEC_ERROR_REVOKED_KEY, (SEC_ERROR_BASE + 61), +"The key for this site's certificate has been revoked.") + +ER3(SEC_ERROR_KRL_INVALID, (SEC_ERROR_BASE + 62), +"New KRL has an invalid format.") + +ER3(SEC_ERROR_NEED_RANDOM, (SEC_ERROR_BASE + 63), +"security library: need random data.") + +ER3(SEC_ERROR_NO_MODULE, (SEC_ERROR_BASE + 64), +"security library: no security module can perform the requested operation.") + +ER3(SEC_ERROR_NO_TOKEN, (SEC_ERROR_BASE + 65), +"The security card or token does not exist, needs to be initialized, or has been removed.") + +ER3(SEC_ERROR_READ_ONLY, (SEC_ERROR_BASE + 66), +"security library: read-only database.") + +ER3(SEC_ERROR_NO_SLOT_SELECTED, (SEC_ERROR_BASE + 67), +"No slot or token was selected.") + +ER3(SEC_ERROR_CERT_NICKNAME_COLLISION, (SEC_ERROR_BASE + 68), +"A certificate with the same nickname already exists.") + +ER3(SEC_ERROR_KEY_NICKNAME_COLLISION, (SEC_ERROR_BASE + 69), +"A key with the same nickname already exists.") + +ER3(SEC_ERROR_SAFE_NOT_CREATED, (SEC_ERROR_BASE + 70), +"error while creating safe object") + +ER3(SEC_ERROR_BAGGAGE_NOT_CREATED, (SEC_ERROR_BASE + 71), +"error while creating baggage object") + +ER3(XP_JAVA_REMOVE_PRINCIPAL_ERROR, (SEC_ERROR_BASE + 72), +"Couldn't remove the principal") + +ER3(XP_JAVA_DELETE_PRIVILEGE_ERROR, (SEC_ERROR_BASE + 73), +"Couldn't delete the privilege") + +ER3(XP_JAVA_CERT_NOT_EXISTS_ERROR, (SEC_ERROR_BASE + 74), +"This principal doesn't have a certificate") + +ER3(SEC_ERROR_BAD_EXPORT_ALGORITHM, (SEC_ERROR_BASE + 75), +"Required algorithm is not allowed.") + +ER3(SEC_ERROR_EXPORTING_CERTIFICATES, (SEC_ERROR_BASE + 76), +"Error attempting to export certificates.") + +ER3(SEC_ERROR_IMPORTING_CERTIFICATES, (SEC_ERROR_BASE + 77), +"Error attempting to import certificates.") + +ER3(SEC_ERROR_PKCS12_DECODING_PFX, (SEC_ERROR_BASE + 78), +"Unable to import. Decoding error. File not valid.") + +ER3(SEC_ERROR_PKCS12_INVALID_MAC, (SEC_ERROR_BASE + 79), +"Unable to import. Invalid MAC. Incorrect password or corrupt file.") + +ER3(SEC_ERROR_PKCS12_UNSUPPORTED_MAC_ALGORITHM, (SEC_ERROR_BASE + 80), +"Unable to import. MAC algorithm not supported.") + +ER3(SEC_ERROR_PKCS12_UNSUPPORTED_TRANSPORT_MODE,(SEC_ERROR_BASE + 81), +"Unable to import. Only password integrity and privacy modes supported.") + +ER3(SEC_ERROR_PKCS12_CORRUPT_PFX_STRUCTURE, (SEC_ERROR_BASE + 82), +"Unable to import. File structure is corrupt.") + +ER3(SEC_ERROR_PKCS12_UNSUPPORTED_PBE_ALGORITHM, (SEC_ERROR_BASE + 83), +"Unable to import. Encryption algorithm not supported.") + +ER3(SEC_ERROR_PKCS12_UNSUPPORTED_VERSION, (SEC_ERROR_BASE + 84), +"Unable to import. File version not supported.") + +ER3(SEC_ERROR_PKCS12_PRIVACY_PASSWORD_INCORRECT,(SEC_ERROR_BASE + 85), +"Unable to import. Incorrect privacy password.") + +ER3(SEC_ERROR_PKCS12_CERT_COLLISION, (SEC_ERROR_BASE + 86), +"Unable to import. Same nickname already exists in database.") + +ER3(SEC_ERROR_USER_CANCELLED, (SEC_ERROR_BASE + 87), +"The user pressed cancel.") + +ER3(SEC_ERROR_PKCS12_DUPLICATE_DATA, (SEC_ERROR_BASE + 88), +"Not imported, already in database.") + +ER3(SEC_ERROR_MESSAGE_SEND_ABORTED, (SEC_ERROR_BASE + 89), +"Message not sent.") + +ER3(SEC_ERROR_INADEQUATE_KEY_USAGE, (SEC_ERROR_BASE + 90), +"Certificate key usage inadequate for attempted operation.") + +ER3(SEC_ERROR_INADEQUATE_CERT_TYPE, (SEC_ERROR_BASE + 91), +"Certificate type not approved for application.") + +ER3(SEC_ERROR_CERT_ADDR_MISMATCH, (SEC_ERROR_BASE + 92), +"Address in signing certificate does not match address in message headers.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_IMPORT_KEY, (SEC_ERROR_BASE + 93), +"Unable to import. Error attempting to import private key.") + +ER3(SEC_ERROR_PKCS12_IMPORTING_CERT_CHAIN, (SEC_ERROR_BASE + 94), +"Unable to import. Error attempting to import certificate chain.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_LOCATE_OBJECT_BY_NAME, (SEC_ERROR_BASE + 95), +"Unable to export. Unable to locate certificate or key by nickname.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_EXPORT_KEY, (SEC_ERROR_BASE + 96), +"Unable to export. Private Key could not be located and exported.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_WRITE, (SEC_ERROR_BASE + 97), +"Unable to export. Unable to write the export file.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_READ, (SEC_ERROR_BASE + 98), +"Unable to import. Unable to read the import file.") + +ER3(SEC_ERROR_PKCS12_KEY_DATABASE_NOT_INITIALIZED, (SEC_ERROR_BASE + 99), +"Unable to export. Key database corrupt or deleted.") + +ER3(SEC_ERROR_KEYGEN_FAIL, (SEC_ERROR_BASE + 100), +"Unable to generate public/private key pair.") + +ER3(SEC_ERROR_INVALID_PASSWORD, (SEC_ERROR_BASE + 101), +"Password entered is invalid. Please pick a different one.") + +ER3(SEC_ERROR_RETRY_OLD_PASSWORD, (SEC_ERROR_BASE + 102), +"Old password entered incorrectly. Please try again.") + +ER3(SEC_ERROR_BAD_NICKNAME, (SEC_ERROR_BASE + 103), +"Certificate nickname already in use.") + +ER3(SEC_ERROR_NOT_FORTEZZA_ISSUER, (SEC_ERROR_BASE + 104), +"Peer FORTEZZA chain has a non-FORTEZZA Certificate.") + +ER3(SEC_ERROR_CANNOT_MOVE_SENSITIVE_KEY, (SEC_ERROR_BASE + 105), +"A sensitive key cannot be moved to the slot where it is needed.") + +ER3(SEC_ERROR_JS_INVALID_MODULE_NAME, (SEC_ERROR_BASE + 106), +"Invalid module name.") + +ER3(SEC_ERROR_JS_INVALID_DLL, (SEC_ERROR_BASE + 107), +"Invalid module path/filename") + +ER3(SEC_ERROR_JS_ADD_MOD_FAILURE, (SEC_ERROR_BASE + 108), +"Unable to add module") + +ER3(SEC_ERROR_JS_DEL_MOD_FAILURE, (SEC_ERROR_BASE + 109), +"Unable to delete module") + +ER3(SEC_ERROR_OLD_KRL, (SEC_ERROR_BASE + 110), +"New KRL is not later than the current one.") + +ER3(SEC_ERROR_CKL_CONFLICT, (SEC_ERROR_BASE + 111), +"New CKL has different issuer than current CKL. Delete current CKL.") + +ER3(SEC_ERROR_CERT_NOT_IN_NAME_SPACE, (SEC_ERROR_BASE + 112), +"The Certifying Authority for this certificate is not permitted to issue a \ +certificate with this name.") + +ER3(SEC_ERROR_KRL_NOT_YET_VALID, (SEC_ERROR_BASE + 113), +"The key revocation list for this certificate is not yet valid.") + +ER3(SEC_ERROR_CRL_NOT_YET_VALID, (SEC_ERROR_BASE + 114), +"The certificate revocation list for this certificate is not yet valid.") + +ER3(SEC_ERROR_UNKNOWN_CERT, (SEC_ERROR_BASE + 115), +"The requested certificate could not be found.") + +ER3(SEC_ERROR_UNKNOWN_SIGNER, (SEC_ERROR_BASE + 116), +"The signer's certificate could not be found.") + +ER3(SEC_ERROR_CERT_BAD_ACCESS_LOCATION, (SEC_ERROR_BASE + 117), +"The location for the certificate status server has invalid format.") + +ER3(SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE, (SEC_ERROR_BASE + 118), +"The OCSP response cannot be fully decoded; it is of an unknown type.") + +ER3(SEC_ERROR_OCSP_BAD_HTTP_RESPONSE, (SEC_ERROR_BASE + 119), +"The OCSP server returned unexpected/invalid HTTP data.") + +ER3(SEC_ERROR_OCSP_MALFORMED_REQUEST, (SEC_ERROR_BASE + 120), +"The OCSP server found the request to be corrupted or improperly formed.") + +ER3(SEC_ERROR_OCSP_SERVER_ERROR, (SEC_ERROR_BASE + 121), +"The OCSP server experienced an internal error.") + +ER3(SEC_ERROR_OCSP_TRY_SERVER_LATER, (SEC_ERROR_BASE + 122), +"The OCSP server suggests trying again later.") + +ER3(SEC_ERROR_OCSP_REQUEST_NEEDS_SIG, (SEC_ERROR_BASE + 123), +"The OCSP server requires a signature on this request.") + +ER3(SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST, (SEC_ERROR_BASE + 124), +"The OCSP server has refused this request as unauthorized.") + +ER3(SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS, (SEC_ERROR_BASE + 125), +"The OCSP server returned an unrecognizable status.") + +ER3(SEC_ERROR_OCSP_UNKNOWN_CERT, (SEC_ERROR_BASE + 126), +"The OCSP server has no status for the certificate.") + +ER3(SEC_ERROR_OCSP_NOT_ENABLED, (SEC_ERROR_BASE + 127), +"You must enable OCSP before performing this operation.") + +ER3(SEC_ERROR_OCSP_NO_DEFAULT_RESPONDER, (SEC_ERROR_BASE + 128), +"You must set the OCSP default responder before performing this operation.") + +ER3(SEC_ERROR_OCSP_MALFORMED_RESPONSE, (SEC_ERROR_BASE + 129), +"The response from the OCSP server was corrupted or improperly formed.") + +ER3(SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE, (SEC_ERROR_BASE + 130), +"The signer of the OCSP response is not authorized to give status for \ +this certificate.") + +ER3(SEC_ERROR_OCSP_FUTURE_RESPONSE, (SEC_ERROR_BASE + 131), +"The OCSP response is not yet valid (contains a date in the future).") + +ER3(SEC_ERROR_OCSP_OLD_RESPONSE, (SEC_ERROR_BASE + 132), +"The OCSP response contains out-of-date information.") + +ER3(SEC_ERROR_DIGEST_NOT_FOUND, (SEC_ERROR_BASE + 133), +"The CMS or PKCS #7 Digest was not found in signed message.") + +ER3(SEC_ERROR_UNSUPPORTED_MESSAGE_TYPE, (SEC_ERROR_BASE + 134), +"The CMS or PKCS #7 Message type is unsupported.") + +ER3(SEC_ERROR_MODULE_STUCK, (SEC_ERROR_BASE + 135), +"PKCS #11 module could not be removed because it is still in use.") + +ER3(SEC_ERROR_BAD_TEMPLATE, (SEC_ERROR_BASE + 136), +"Could not decode ASN.1 data. Specified template was invalid.") + +ER3(SEC_ERROR_CRL_NOT_FOUND, (SEC_ERROR_BASE + 137), +"No matching CRL was found.") + +ER3(SEC_ERROR_REUSED_ISSUER_AND_SERIAL, (SEC_ERROR_BASE + 138), +"You are attempting to import a cert with the same issuer/serial as \ +an existing cert, but that is not the same cert.") + +ER3(SEC_ERROR_BUSY, (SEC_ERROR_BASE + 139), +"NSS could not shutdown. Objects are still in use.") + +ER3(SEC_ERROR_EXTRA_INPUT, (SEC_ERROR_BASE + 140), +"DER-encoded message contained extra unused data.") + +ER3(SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE, (SEC_ERROR_BASE + 141), +"Unsupported elliptic curve.") + +ER3(SEC_ERROR_UNSUPPORTED_EC_POINT_FORM, (SEC_ERROR_BASE + 142), +"Unsupported elliptic curve point form.") + +ER3(SEC_ERROR_UNRECOGNIZED_OID, (SEC_ERROR_BASE + 143), +"Unrecognized Object IDentifier.") + +ER3(SEC_ERROR_OCSP_INVALID_SIGNING_CERT, (SEC_ERROR_BASE + 144), +"Invalid OCSP signing certificate in OCSP response.") + +ER3(SEC_ERROR_REVOKED_CERTIFICATE_CRL, (SEC_ERROR_BASE + 145), +"Certificate is revoked in issuer's certificate revocation list.") + +ER3(SEC_ERROR_REVOKED_CERTIFICATE_OCSP, (SEC_ERROR_BASE + 146), +"Issuer's OCSP responder reports certificate is revoked.") + +ER3(SEC_ERROR_CRL_INVALID_VERSION, (SEC_ERROR_BASE + 147), +"Issuer's Certificate Revocation List has an unknown version number.") + +ER3(SEC_ERROR_CRL_V1_CRITICAL_EXTENSION, (SEC_ERROR_BASE + 148), +"Issuer's V1 Certificate Revocation List has a critical extension.") + +ER3(SEC_ERROR_CRL_UNKNOWN_CRITICAL_EXTENSION, (SEC_ERROR_BASE + 149), +"Issuer's V2 Certificate Revocation List has an unknown critical extension.") + +ER3(SEC_ERROR_UNKNOWN_OBJECT_TYPE, (SEC_ERROR_BASE + 150), +"Unknown object type specified.") + +ER3(SEC_ERROR_INCOMPATIBLE_PKCS11, (SEC_ERROR_BASE + 151), +"PKCS #11 driver violates the spec in an incompatible way.") + +ER3(SEC_ERROR_NO_EVENT, (SEC_ERROR_BASE + 152), +"No new slot event is available at this time.") + +ER3(SEC_ERROR_CRL_ALREADY_EXISTS, (SEC_ERROR_BASE + 153), +"CRL already exists.") + +ER3(SEC_ERROR_NOT_INITIALIZED, (SEC_ERROR_BASE + 154), +"NSS is not initialized.") + +ER3(SEC_ERROR_TOKEN_NOT_LOGGED_IN, (SEC_ERROR_BASE + 155), +"The operation failed because the PKCS#11 token is not logged in.") + diff --git a/base/tps/src/include/httpClient/httpc/SSLServerSocket.h b/base/tps/src/include/httpClient/httpc/SSLServerSocket.h new file mode 100644 index 000000000..a059d7279 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/SSLServerSocket.h @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SSL_SERVER_SOCKET_H +#define __SSL_SERVER_SOCKET_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * SSLServerSocket.h 1.000 06/12/2002 + * + * A Secure server socket implementation based on NSPR / NSS + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL SSLServerSocket : public ServerSocket { +public: + /** + * Constructor + */ + SSLServerSocket( const char* host, + int port, + const char* nickname, + int requestcert ); + + /** + * Destructor + */ + virtual ~SSLServerSocket(); + +public: + /** + * Initializes cert and private key before calling base class + * Accept function. + */ + Socket* Accept(); + +private: + /** + * Overrides base class function to create SSL sockets + * + * @return a newly accepted SSL socket + */ + Socket* InternalAccept(PRFileDesc* fd); + +private: + char* m_nickName; + int m_requestCert; + CERTCertificate* m_serverCert; + SECKEYPrivateKey* m_serverPrivKey; + SSLKEAType m_certKEA; +}; + +#endif // __SSL_SERVER_SOCKET_H + + + + + diff --git a/base/tps/src/include/httpClient/httpc/SSLSocket.h b/base/tps/src/include/httpClient/httpc/SSLSocket.h new file mode 100644 index 000000000..14d647c60 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/SSLSocket.h @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SSL_SOCKET_H +#define __SSL_SOCKET_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * SSLSocket.h 1.000 06/12/2002 + * + * A Secure socket implementation based on NSPR / NSS + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL SSLSocket : public Socket { + friend class SSLServerSocket; +public: + /** + * Constructor + */ + SSLSocket(); + + /** + * Destructor + */ + virtual ~SSLSocket(); + +private: + /** + * Sets up this socket to behave as a SSL server + * + * @param cert server certificate object + * @param privKey private key structure + * @param password password to access DB + * @param requestCert whether to request cert from the client + * @return 0 on success, negative error code otherwise + * + */ + int SetupSSLServer( CERTCertificate* serverCert, + SECKEYPrivateKey* privKey, + SSLKEAType certKEA, + int requestCert ); +private: + // server callbacks + /** + * Specifies a certificate authentication callback function called + * to authenticate an incoming certificate + * + * @param arg pointer supplied by the application + * (in the call to SSL_AuthCertificateHook) + * that can be used to pass state information + * @param socket pointer to the file descriptor for the SSL socket + * @param checksig PR_TRUE means signatures are to be checked and + * the certificate chain is to be validated + * @param isServer PR_TRUE means the callback function should + * evaluate the certificate as a server does, + * treating the remote end is a client + * @return SECSuccess on success, SECFailure otherwise + * + */ + static SECStatus AuthCertificate( void* arg, + PRFileDesc* socket, + PRBool checksig, + PRBool isServer ); + + /** + * Sets up a callback function to deal with a situation where the + * SSL_AuthCertificate callback function has failed. This callback + * function allows the application to override the decision made by + * the certificate authorization callback and authorize the certificate + * for use in the SSL connection. + * + * @param arg The arg parameter passed to SSL_BadCertHook + * @param socket pointer to the file descriptor for the SSL socket + * @return SECSuccess on success, SECFailure otherwise + */ + static SECStatus BadCertHandler( void* arg, + PRFileDesc* socket ); + + /** + * Sets up a callback function used by SSL to inform either a client + * application or a server application when the handshake is completed + * + * @param arg The arg parameter passed to SSL_HandshakeCallback + * @param socket pointer to the file descriptor for the SSL socket + * @return SECSuccess on success, SECFailure otherwise + */ + static SECStatus HandshakeCallback( PRFileDesc* socket, + void* arg ); + +private: + bool m_initializedAsServer; +}; + +#endif // __SSL_SOCKET_H + + diff --git a/base/tps/src/include/httpClient/httpc/SSLerrs.h b/base/tps/src/include/httpClient/httpc/SSLerrs.h new file mode 100644 index 000000000..818da3e87 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/SSLerrs.h @@ -0,0 +1,392 @@ +/** BEGIN COPYRIGHT BLOCK + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1994-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * END COPYRIGHT BLOCK **/ + +/* Originally obtained from: + * + * CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot + * cvs export -r NSS_3_11_3_RTM -N mozilla/security/nss/cmd/lib/SSLerrs.h + */ + +/* SSL-specific security error codes */ +/* caller must include "sslerr.h" */ + +ER3(SSL_ERROR_EXPORT_ONLY_SERVER, SSL_ERROR_BASE + 0, +"Unable to communicate securely. Peer does not support high-grade encryption.") + +ER3(SSL_ERROR_US_ONLY_SERVER, SSL_ERROR_BASE + 1, +"Unable to communicate securely. Peer requires high-grade encryption which is not supported.") + +ER3(SSL_ERROR_NO_CYPHER_OVERLAP, SSL_ERROR_BASE + 2, +"Cannot communicate securely with peer: no common encryption algorithm(s).") + +ER3(SSL_ERROR_NO_CERTIFICATE, SSL_ERROR_BASE + 3, +"Unable to find the certificate or key necessary for authentication.") + +ER3(SSL_ERROR_BAD_CERTIFICATE, SSL_ERROR_BASE + 4, +"Unable to communicate securely with peer: peers's certificate was rejected.") + +/* unused (SSL_ERROR_BASE + 5),*/ + +ER3(SSL_ERROR_BAD_CLIENT, SSL_ERROR_BASE + 6, +"The server has encountered bad data from the client.") + +ER3(SSL_ERROR_BAD_SERVER, SSL_ERROR_BASE + 7, +"The client has encountered bad data from the server.") + +ER3(SSL_ERROR_UNSUPPORTED_CERTIFICATE_TYPE, SSL_ERROR_BASE + 8, +"Unsupported certificate type.") + +ER3(SSL_ERROR_UNSUPPORTED_VERSION, SSL_ERROR_BASE + 9, +"Peer using unsupported version of security protocol.") + +/* unused (SSL_ERROR_BASE + 10),*/ + +ER3(SSL_ERROR_WRONG_CERTIFICATE, SSL_ERROR_BASE + 11, +"Client authentication failed: private key in key database does not match public key in certificate database.") + +ER3(SSL_ERROR_BAD_CERT_DOMAIN, SSL_ERROR_BASE + 12, +"Unable to communicate securely with peer: requested domain name does not match the server's certificate.") + +/* SSL_ERROR_POST_WARNING (SSL_ERROR_BASE + 13), + defined in sslerr.h +*/ + +ER3(SSL_ERROR_SSL2_DISABLED, (SSL_ERROR_BASE + 14), +"Peer only supports SSL version 2, which is locally disabled.") + + +ER3(SSL_ERROR_BAD_MAC_READ, (SSL_ERROR_BASE + 15), +"SSL received a record with an incorrect Message Authentication Code.") + +ER3(SSL_ERROR_BAD_MAC_ALERT, (SSL_ERROR_BASE + 16), +"SSL peer reports incorrect Message Authentication Code.") + +ER3(SSL_ERROR_BAD_CERT_ALERT, (SSL_ERROR_BASE + 17), +"SSL peer cannot verify your certificate.") + +ER3(SSL_ERROR_REVOKED_CERT_ALERT, (SSL_ERROR_BASE + 18), +"SSL peer rejected your certificate as revoked.") + +ER3(SSL_ERROR_EXPIRED_CERT_ALERT, (SSL_ERROR_BASE + 19), +"SSL peer rejected your certificate as expired.") + +ER3(SSL_ERROR_SSL_DISABLED, (SSL_ERROR_BASE + 20), +"Cannot connect: SSL is disabled.") + +ER3(SSL_ERROR_FORTEZZA_PQG, (SSL_ERROR_BASE + 21), +"Cannot connect: SSL peer is in another FORTEZZA domain.") + + +ER3(SSL_ERROR_UNKNOWN_CIPHER_SUITE , (SSL_ERROR_BASE + 22), +"An unknown SSL cipher suite has been requested.") + +ER3(SSL_ERROR_NO_CIPHERS_SUPPORTED , (SSL_ERROR_BASE + 23), +"No cipher suites are present and enabled in this program.") + +ER3(SSL_ERROR_BAD_BLOCK_PADDING , (SSL_ERROR_BASE + 24), +"SSL received a record with bad block padding.") + +ER3(SSL_ERROR_RX_RECORD_TOO_LONG , (SSL_ERROR_BASE + 25), +"SSL received a record that exceeded the maximum permissible length.") + +ER3(SSL_ERROR_TX_RECORD_TOO_LONG , (SSL_ERROR_BASE + 26), +"SSL attempted to send a record that exceeded the maximum permissible length.") + +/* + * Received a malformed (too long or short or invalid content) SSL handshake. + */ +ER3(SSL_ERROR_RX_MALFORMED_HELLO_REQUEST , (SSL_ERROR_BASE + 27), +"SSL received a malformed Hello Request handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CLIENT_HELLO , (SSL_ERROR_BASE + 28), +"SSL received a malformed Client Hello handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_SERVER_HELLO , (SSL_ERROR_BASE + 29), +"SSL received a malformed Server Hello handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CERTIFICATE , (SSL_ERROR_BASE + 30), +"SSL received a malformed Certificate handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_SERVER_KEY_EXCH , (SSL_ERROR_BASE + 31), +"SSL received a malformed Server Key Exchange handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CERT_REQUEST , (SSL_ERROR_BASE + 32), +"SSL received a malformed Certificate Request handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_HELLO_DONE , (SSL_ERROR_BASE + 33), +"SSL received a malformed Server Hello Done handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CERT_VERIFY , (SSL_ERROR_BASE + 34), +"SSL received a malformed Certificate Verify handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CLIENT_KEY_EXCH , (SSL_ERROR_BASE + 35), +"SSL received a malformed Client Key Exchange handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_FINISHED , (SSL_ERROR_BASE + 36), +"SSL received a malformed Finished handshake message.") + +/* + * Received a malformed (too long or short) SSL record. + */ +ER3(SSL_ERROR_RX_MALFORMED_CHANGE_CIPHER , (SSL_ERROR_BASE + 37), +"SSL received a malformed Change Cipher Spec record.") + +ER3(SSL_ERROR_RX_MALFORMED_ALERT , (SSL_ERROR_BASE + 38), +"SSL received a malformed Alert record.") + +ER3(SSL_ERROR_RX_MALFORMED_HANDSHAKE , (SSL_ERROR_BASE + 39), +"SSL received a malformed Handshake record.") + +ER3(SSL_ERROR_RX_MALFORMED_APPLICATION_DATA , (SSL_ERROR_BASE + 40), +"SSL received a malformed Application Data record.") + +/* + * Received an SSL handshake that was inappropriate for the state we're in. + * E.g. Server received message from server, or wrong state in state machine. + */ +ER3(SSL_ERROR_RX_UNEXPECTED_HELLO_REQUEST , (SSL_ERROR_BASE + 41), +"SSL received an unexpected Hello Request handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CLIENT_HELLO , (SSL_ERROR_BASE + 42), +"SSL received an unexpected Client Hello handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_SERVER_HELLO , (SSL_ERROR_BASE + 43), +"SSL received an unexpected Server Hello handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CERTIFICATE , (SSL_ERROR_BASE + 44), +"SSL received an unexpected Certificate handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_SERVER_KEY_EXCH , (SSL_ERROR_BASE + 45), +"SSL received an unexpected Server Key Exchange handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CERT_REQUEST , (SSL_ERROR_BASE + 46), +"SSL received an unexpected Certificate Request handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_HELLO_DONE , (SSL_ERROR_BASE + 47), +"SSL received an unexpected Server Hello Done handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CERT_VERIFY , (SSL_ERROR_BASE + 48), +"SSL received an unexpected Certificate Verify handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CLIENT_KEY_EXCH , (SSL_ERROR_BASE + 49), +"SSL received an unexpected Cllient Key Exchange handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_FINISHED , (SSL_ERROR_BASE + 50), +"SSL received an unexpected Finished handshake message.") + +/* + * Received an SSL record that was inappropriate for the state we're in. + */ +ER3(SSL_ERROR_RX_UNEXPECTED_CHANGE_CIPHER , (SSL_ERROR_BASE + 51), +"SSL received an unexpected Change Cipher Spec record.") + +ER3(SSL_ERROR_RX_UNEXPECTED_ALERT , (SSL_ERROR_BASE + 52), +"SSL received an unexpected Alert record.") + +ER3(SSL_ERROR_RX_UNEXPECTED_HANDSHAKE , (SSL_ERROR_BASE + 53), +"SSL received an unexpected Handshake record.") + +ER3(SSL_ERROR_RX_UNEXPECTED_APPLICATION_DATA, (SSL_ERROR_BASE + 54), +"SSL received an unexpected Application Data record.") + +/* + * Received record/message with unknown discriminant. + */ +ER3(SSL_ERROR_RX_UNKNOWN_RECORD_TYPE , (SSL_ERROR_BASE + 55), +"SSL received a record with an unknown content type.") + +ER3(SSL_ERROR_RX_UNKNOWN_HANDSHAKE , (SSL_ERROR_BASE + 56), +"SSL received a handshake message with an unknown message type.") + +ER3(SSL_ERROR_RX_UNKNOWN_ALERT , (SSL_ERROR_BASE + 57), +"SSL received an alert record with an unknown alert description.") + +/* + * Received an alert reporting what we did wrong. (more alerts above) + */ +ER3(SSL_ERROR_CLOSE_NOTIFY_ALERT , (SSL_ERROR_BASE + 58), +"SSL peer has closed this connection.") + +ER3(SSL_ERROR_HANDSHAKE_UNEXPECTED_ALERT , (SSL_ERROR_BASE + 59), +"SSL peer was not expecting a handshake message it received.") + +ER3(SSL_ERROR_DECOMPRESSION_FAILURE_ALERT , (SSL_ERROR_BASE + 60), +"SSL peer was unable to succesfully decompress an SSL record it received.") + +ER3(SSL_ERROR_HANDSHAKE_FAILURE_ALERT , (SSL_ERROR_BASE + 61), +"SSL peer was unable to negotiate an acceptable set of security parameters.") + +ER3(SSL_ERROR_ILLEGAL_PARAMETER_ALERT , (SSL_ERROR_BASE + 62), +"SSL peer rejected a handshake message for unacceptable content.") + +ER3(SSL_ERROR_UNSUPPORTED_CERT_ALERT , (SSL_ERROR_BASE + 63), +"SSL peer does not support certificates of the type it received.") + +ER3(SSL_ERROR_CERTIFICATE_UNKNOWN_ALERT , (SSL_ERROR_BASE + 64), +"SSL peer had some unspecified issue with the certificate it received.") + + +ER3(SSL_ERROR_GENERATE_RANDOM_FAILURE , (SSL_ERROR_BASE + 65), +"SSL experienced a failure of its random number generator.") + +ER3(SSL_ERROR_SIGN_HASHES_FAILURE , (SSL_ERROR_BASE + 66), +"Unable to digitally sign data required to verify your certificate.") + +ER3(SSL_ERROR_EXTRACT_PUBLIC_KEY_FAILURE , (SSL_ERROR_BASE + 67), +"SSL was unable to extract the public key from the peer's certificate.") + +ER3(SSL_ERROR_SERVER_KEY_EXCHANGE_FAILURE , (SSL_ERROR_BASE + 68), +"Unspecified failure while processing SSL Server Key Exchange handshake.") + +ER3(SSL_ERROR_CLIENT_KEY_EXCHANGE_FAILURE , (SSL_ERROR_BASE + 69), +"Unspecified failure while processing SSL Client Key Exchange handshake.") + +ER3(SSL_ERROR_ENCRYPTION_FAILURE , (SSL_ERROR_BASE + 70), +"Bulk data encryption algorithm failed in selected cipher suite.") + +ER3(SSL_ERROR_DECRYPTION_FAILURE , (SSL_ERROR_BASE + 71), +"Bulk data decryption algorithm failed in selected cipher suite.") + +ER3(SSL_ERROR_SOCKET_WRITE_FAILURE , (SSL_ERROR_BASE + 72), +"Attempt to write encrypted data to underlying socket failed.") + +ER3(SSL_ERROR_MD5_DIGEST_FAILURE , (SSL_ERROR_BASE + 73), +"MD5 digest function failed.") + +ER3(SSL_ERROR_SHA_DIGEST_FAILURE , (SSL_ERROR_BASE + 74), +"SHA-1 digest function failed.") + +ER3(SSL_ERROR_MAC_COMPUTATION_FAILURE , (SSL_ERROR_BASE + 75), +"MAC computation failed.") + +ER3(SSL_ERROR_SYM_KEY_CONTEXT_FAILURE , (SSL_ERROR_BASE + 76), +"Failure to create Symmetric Key context.") + +ER3(SSL_ERROR_SYM_KEY_UNWRAP_FAILURE , (SSL_ERROR_BASE + 77), +"Failure to unwrap the Symmetric key in Client Key Exchange message.") + +ER3(SSL_ERROR_PUB_KEY_SIZE_LIMIT_EXCEEDED , (SSL_ERROR_BASE + 78), +"SSL Server attempted to use domestic-grade public key with export cipher suite.") + +ER3(SSL_ERROR_IV_PARAM_FAILURE , (SSL_ERROR_BASE + 79), +"PKCS11 code failed to translate an IV into a param.") + +ER3(SSL_ERROR_INIT_CIPHER_SUITE_FAILURE , (SSL_ERROR_BASE + 80), +"Failed to initialize the selected cipher suite.") + +ER3(SSL_ERROR_SESSION_KEY_GEN_FAILURE , (SSL_ERROR_BASE + 81), +"Client failed to generate session keys for SSL session.") + +ER3(SSL_ERROR_NO_SERVER_KEY_FOR_ALG , (SSL_ERROR_BASE + 82), +"Server has no key for the attempted key exchange algorithm.") + +ER3(SSL_ERROR_TOKEN_INSERTION_REMOVAL , (SSL_ERROR_BASE + 83), +"PKCS#11 token was inserted or removed while operation was in progress.") + +ER3(SSL_ERROR_TOKEN_SLOT_NOT_FOUND , (SSL_ERROR_BASE + 84), +"No PKCS#11 token could be found to do a required operation.") + +ER3(SSL_ERROR_NO_COMPRESSION_OVERLAP , (SSL_ERROR_BASE + 85), +"Cannot communicate securely with peer: no common compression algorithm(s).") + +ER3(SSL_ERROR_HANDSHAKE_NOT_COMPLETED , (SSL_ERROR_BASE + 86), +"Cannot initiate another SSL handshake until current handshake is complete.") + +ER3(SSL_ERROR_BAD_HANDSHAKE_HASH_VALUE , (SSL_ERROR_BASE + 87), +"Received incorrect handshakes hash values from peer.") + +ER3(SSL_ERROR_CERT_KEA_MISMATCH , (SSL_ERROR_BASE + 88), +"The certificate provided cannot be used with the selected key exchange algorithm.") + +ER3(SSL_ERROR_NO_TRUSTED_SSL_CLIENT_CA , (SSL_ERROR_BASE + 89), +"No certificate authority is trusted for SSL client authentication.") + +ER3(SSL_ERROR_SESSION_NOT_FOUND , (SSL_ERROR_BASE + 90), +"Client's SSL session ID not found in server's session cache.") + +ER3(SSL_ERROR_DECRYPTION_FAILED_ALERT , (SSL_ERROR_BASE + 91), +"Peer was unable to decrypt an SSL record it received.") + +ER3(SSL_ERROR_RECORD_OVERFLOW_ALERT , (SSL_ERROR_BASE + 92), +"Peer received an SSL record that was longer than is permitted.") + +ER3(SSL_ERROR_UNKNOWN_CA_ALERT , (SSL_ERROR_BASE + 93), +"Peer does not recognize and trust the CA that issued your certificate.") + +ER3(SSL_ERROR_ACCESS_DENIED_ALERT , (SSL_ERROR_BASE + 94), +"Peer received a valid certificate, but access was denied.") + +ER3(SSL_ERROR_DECODE_ERROR_ALERT , (SSL_ERROR_BASE + 95), +"Peer could not decode an SSL handshake message.") + +ER3(SSL_ERROR_DECRYPT_ERROR_ALERT , (SSL_ERROR_BASE + 96), +"Peer reports failure of signature verification or key exchange.") + +ER3(SSL_ERROR_EXPORT_RESTRICTION_ALERT , (SSL_ERROR_BASE + 97), +"Peer reports negotiation not in compliance with export regulations.") + +ER3(SSL_ERROR_PROTOCOL_VERSION_ALERT , (SSL_ERROR_BASE + 98), +"Peer reports incompatible or unsupported protocol version.") + +ER3(SSL_ERROR_INSUFFICIENT_SECURITY_ALERT , (SSL_ERROR_BASE + 99), +"Server requires ciphers more secure than those supported by client.") + +ER3(SSL_ERROR_INTERNAL_ERROR_ALERT , (SSL_ERROR_BASE + 100), +"Peer reports it experienced an internal error.") + +ER3(SSL_ERROR_USER_CANCELED_ALERT , (SSL_ERROR_BASE + 101), +"Peer user canceled handshake.") + +ER3(SSL_ERROR_NO_RENEGOTIATION_ALERT , (SSL_ERROR_BASE + 102), +"Peer does not permit renegotiation of SSL security parameters.") + +ER3(SSL_ERROR_SERVER_CACHE_NOT_CONFIGURED , (SSL_ERROR_BASE + 103), +"SSL server cache not configured and not disabled for this socket.") + +ER3(SSL_ERROR_UNSUPPORTED_EXTENSION_ALERT , (SSL_ERROR_BASE + 104), +"SSL peer does not support requested TLS hello extension.") + +ER3(SSL_ERROR_CERTIFICATE_UNOBTAINABLE_ALERT , (SSL_ERROR_BASE + 105), +"SSL peer could not obtain your certificate from the supplied URL.") + +ER3(SSL_ERROR_UNRECOGNIZED_NAME_ALERT , (SSL_ERROR_BASE + 106), +"SSL peer has no certificate for the requested DNS name.") + +ER3(SSL_ERROR_BAD_CERT_STATUS_RESPONSE_ALERT , (SSL_ERROR_BASE + 107), +"SSL peer was unable to get an OCSP response for its certificate.") + +ER3(SSL_ERROR_BAD_CERT_HASH_VALUE_ALERT , (SSL_ERROR_BASE + 108), +"SSL peer reported bad certificate hash value.") diff --git a/base/tps/src/include/httpClient/httpc/ScheduledTask.h b/base/tps/src/include/httpClient/httpc/ScheduledTask.h new file mode 100644 index 000000000..cbb99ab61 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/ScheduledTask.h @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SCHEDULED_TASK_H__ +#define __SCHEDULED_TASK_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <time.h> + +class TaskList; + +/** + * Base class for scheduled tasks in Presence Server + */ + +class EXPORT_DECL ScheduledTask { + friend class TaskList; +public: + /** + * Constructor - creates an empty task + */ + ScheduledTask(); + /** + * Constructor - creates an empty task + * + * @param name Name of task + */ + ScheduledTask( const char *name ); + /** + * Destructor + */ + virtual ~ScheduledTask(); + /** + * Returns a copy of the task + * + * @return A copy of the task + */ + virtual ScheduledTask *Clone(); + /** + * Executes the task + * + * @return 0 on successfully starting the task + */ + virtual int Start(); +protected: + char *m_name; + ScheduledTask *m_next; + ScheduledTask *m_prev; + time_t m_time; + int m_interval; +}; + +#endif // __SCHEDULED_TASK_H__ diff --git a/base/tps/src/include/httpClient/httpc/Scheduler.h b/base/tps/src/include/httpClient/httpc/Scheduler.h new file mode 100644 index 000000000..a0e77ffb4 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/Scheduler.h @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SCHEDULER_H__ +#define __SCHEDULER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +class ScheduledTask; +class TaskList; + +/** + * Base class for scheduled tasks in Presence Server + */ + +class EXPORT_DECL Scheduler { +private: + /** + * Constructor - creates a scheduler object + */ + Scheduler(); + /** + * Destructor + */ + ~Scheduler(); +public: + /** + * Returns the single scheduler object + * + * @return The single scheduler object + */ + static Scheduler *GetScheduler(); + /** + * Starts executing a sleep and check task list loop + * + * @return 0 on success + */ + int Run(); + /** + * Shuts down the scheduler + */ + static void Shutdown(); + /** + * Launches a thread that executes Run() + * + * @param interval Interval in seconds between checking for task execution + * time + * @return 0 on success + */ + int Start( int interval ); + /** + * Adds a task to the list + * + * @param task A task to be executed + */ + void AddTask( ScheduledTask *task ); + /** + * Removes a task from the list + * + * @param taskName Name of a task to be removed + */ + void RemoveTask( const char *taskName ); +private: + TaskList *m_taskList; + int m_interval; + bool m_done; + bool m_running; +}; + +#endif /* __SCHEDULER_H__ */ + diff --git a/base/tps/src/include/httpClient/httpc/SecurityHeaders.h b/base/tps/src/include/httpClient/httpc/SecurityHeaders.h new file mode 100644 index 000000000..a54ecb1a2 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/SecurityHeaders.h @@ -0,0 +1,48 @@ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SECURITY_HEADERS_H__ +#define __SECURITY_HEADERS_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +// SOAP header elements defined by WS-SECURITY and used to transfer +// username and password +#define HEADER_FIELD_USERNAME "Username" +#define HEADER_FIELD_PASSWORD "Password" +#define HEADER_FIELD_SECURITY "Security" +#define HEADER_FIELD_NS "http://schemas.xmlsoap.org/ws/2002/04/secext" +#define HEADER_FIELD_TOKEN "UsernameToken" + +#endif /* __SECURITY_HEADERS_H__ */ + diff --git a/base/tps/src/include/httpClient/httpc/ServerConnection.h b/base/tps/src/include/httpClient/httpc/ServerConnection.h new file mode 100644 index 000000000..bc33aa216 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/ServerConnection.h @@ -0,0 +1,179 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SERVER_CONNECTION_H +#define __SERVER_CONNECTION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ServerConnection.h 1.000 06/12/2002 + * + * This class handles server side connections. The accept happens on + * a separate thread and newly accepted connection are polled for + * read ready state. Once data is available on one or more connections + * the listeners are notified about it. + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL ServerConnection { + friend class PollThread; + friend class AcceptThread; +public: + /** + * Constructor + */ + ServerConnection(); + + /** + * Destructor + */ + virtual ~ServerConnection(); + +public: + /** + * Registers a listener interface to notify on the connections + * + * @param listener listener object + * @return 0 on success, negative error code otherwise + */ + int RegisterListener(ConnectionListener* listener); + + /** + * Listens for connections on a specified socket + * + * @param host host name / ip + * @param port listen port + * @return 0 on success, negative error code otherwise + */ + + int Start(char* host, int port); + + /** + * Listens for connections on a specified socket for SSL connections + * + * @param host host name / ip + * @param port listen port + * @param nickename name of the server cert + * @param password password for DB + * @param requestCert request client certficate for authentication + * @return 0 on success, negative error code otherwise + */ + int Start( char* host, + int port, + const char* nickname, + int requestcert); + + /** + * Closes the server connection + * + * @return 0 on success, negative error code otherwise + */ + int Shutdown(); + + /** + * Releases the connection to the read pool. + * + * @param conn a connection object + */ + void PollRead(Connection* conn); + + /** + * Releases the connection to the write pool. + * + * @param conn a connection object + */ + void Release(Connection* conn); + + /** + * Gets a connection from the write pool. This connection should be + * returned to the pool after writing. + * + * @return 0 on success, negative error code otherwise + */ + Connection* GetConnection(); + + /** + * Returns the number of connections + * + * @return number of connections + */ + int GetCount(); + + static void Poll(void* arg); + static void Accept(void* arg); + +protected: + /** + * Protocol specific implementations should implement this + * function and return their own connection object + * + * @return a newly created connection + */ + virtual Connection* AcceptedConnection(); + + const char* GetPeerHost(Connection* conn); + int GetPeerPort(Connection* conn); + +private: + int InternalStart(); + void SetServerFlag(Connection* conn); + PRFileDesc* GetFD( Connection* conn ); + void SetSocket(Connection* conn, Socket* socket); + int UpdateWritePool(Connection* conn); + +private: + ServerSocket* m_server; + ConnectionListener* m_connectionListener; + + Pool* m_readPool; + Pool* m_writePool; + + PRLock* m_readLock; + PRLock* m_writeLock; + + PRBool m_threadInitialized; + PRLock* m_threadLock; + PRCondVar* m_threadCondv; + + int m_totalConnections; + bool m_serverRunning; +}; + +#endif // __SERVER_CONNECTION_H + + diff --git a/base/tps/src/include/httpClient/httpc/ServerHeaderProcessor.h b/base/tps/src/include/httpClient/httpc/ServerHeaderProcessor.h new file mode 100644 index 000000000..213d3b13b --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/ServerHeaderProcessor.h @@ -0,0 +1,72 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef __WASP_SERVER_HEADER_PROCESSOR_H +#define __WASP_SERVER_HEADER_PROCESSOR_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <waspc/config/config.h> +#include <waspc/util/exceptions.h> +#include <waspc/xmlprotocol/header/HeaderProcessor.h> + +class ServerHeaderProcessorItemConfiguration; + +/** + * Creates WS-Security header with a session token + */ +class EXPORT_DECL ServerHeaderProcessor : public WASP_HeaderProcessor { +protected: + virtual ~ServerHeaderProcessor(); +public: + ServerHeaderProcessor(); + + //inherited methods from WASP_Configurable + virtual void load (WASP_Configuration *, EXCENV_DECL); + virtual void init (EXCENV_DECL); + virtual void destroy (); + + //inherited from WASP_HeaderProcessor + virtual void processInput(WASP_XMLProtocolMessage *message, EXCENV_DECL); + virtual void processOutput(WASP_XMLProtocolMessage *message, EXCENV_DECL); + virtual void processInputFault(WASP_XMLProtocolMessage *message, EXCENV_DECL); + virtual void processOutputFault(WASP_XMLProtocolMessage *message, EXCENV_DECL); + virtual WASP_String **getUnderstandHeaders(int &count, EXCENV_DECL); + +protected: + WASP_String **mppsUnderstandHeaderNamesAndNs; + int miUnderstandHeaderCount; +}; + +#endif //__WASP_SERVER_HEADER_PROCESSOR_H diff --git a/base/tps/src/include/httpClient/httpc/ServerSocket.h b/base/tps/src/include/httpClient/httpc/ServerSocket.h new file mode 100644 index 000000000..3cec2444a --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/ServerSocket.h @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SERVER_SOCKET_H +#define __SERVER_SOCKET_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ServerSocket.h 1.000 06/12/2002 + * + * A NSPR implementation of ServerSocket + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL ServerSocket { +public: + + /** + * Constructor - Creates a new TCP socket + * + * @param host host name / ip + * @param port a listen port + */ + ServerSocket(const char* host, int port); + + /** + * Constructor - Creates a new TCP socket + * + * @param port a listen port + */ + ServerSocket(int port); + + /** + * Desstructor + */ + virtual ~ServerSocket(); + +public: + + /** + * Binds the socket to the specified port and starts listening for + * connections. The first connection is accepted from the queue of + * pending connections and creates a new socket for the newly accepted + * connection. The accept is blocked with no time out in its own thread. + * + * @return a new socket for the newly accepted connection + */ + virtual Socket* Accept(); + + /** + * Closes the server socket + */ + virtual void Shutdown(); + +protected: + /** + * Internal method to call accept. Sub classes should override this + * to provide their own implementation for returned sockets. + * + * @return a newly accepted socket + */ + virtual Socket* InternalAccept(PRFileDesc* fd); + +protected: + bool m_initialized; + +private: + PRFileDesc* m_fd; + PRNetAddr m_addr; + char* m_host; + int m_port; + int m_backlog; +}; + +#endif // __SERVER_SOCKET_H + + + diff --git a/base/tps/src/include/httpClient/httpc/Socket.h b/base/tps/src/include/httpClient/httpc/Socket.h new file mode 100644 index 000000000..c2ef4afd4 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/Socket.h @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SOCKET_H +#define __SOCKET_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Socket.h 1.000 06/12/2002 + * + * A NSPR implementation of socket + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL Socket { + friend class ServerSocket; + friend class ServerConnection; +public: + + /** + * Constructor + */ + Socket(); + + /** + * Constructor - creates a socket connecting to the host and port + * + * @param host hostname to connect to + * @param port port of the machine + */ + Socket(const char* host, int port); + + /** + * Destructor + */ + virtual ~Socket(); + +public: + + /** + * Reads specified number of bytes from the socket. This is a blocking + * socket read with timeout. + * + * @param buf buffer to read into + * @param size number of bytes to read + * @param timeout timeout before the read terminates + * @return number of bytes actually read + */ + int Read(void* buf, int size, long timeout); + + /** + * Writes specified number of bytes to the socket. This is a blocking + * socket write with timeout. + * + * @param buf buffer to write from + * @param size number of bytes to write + * @param timeout timeout before the write terminates + * @return number of bytes actually written + */ + int Write(void* buf, int size, long timeout); + + /** + * Gets ip address for a specified socket + * + * @return ip address + */ + const char* GetLocalIp(); + + /** + * Gets port for a specified socket + * + * @return port + */ + int GetLocalPort(); + + /** + * Gets ip address of a connected peer + * + * @return ip address + */ + const char* GetPeerIp(); + + /** + * Gets port of a connected peer + * + * @return ip address + */ + int GetPeerPort(); + + /** + * Shuts down part of a full-duplex connection on a specified socket + * + * @param how the kind of disallowed operations on the socket + * the possible values are : + * PR_SHUTDOWN_RCV + * PR_SHUTDOWN_SEND + * PR_SHUTDOWN_BOTH + */ + void Shutdown(PRShutdownHow how); + +protected: + int Init(PRFileDesc* fd); + +private: + void CancelIO(PRInt32 err); + +protected: + PRFileDesc* m_fd; + +private: + char* m_localIp; + char* m_peerIp; + int m_localPort; + int m_peerPort; + bool m_initialized; + PRLock* m_readLock; + PRLock* m_writeLock; +}; + +#endif // __SOCKET_H + + diff --git a/base/tps/src/include/httpClient/httpc/SocketINC.h b/base/tps/src/include/httpClient/httpc/SocketINC.h new file mode 100644 index 000000000..43b36c9a0 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/SocketINC.h @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _SOCKET_INC_H_ +#define _SOCKET_INC_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * SocketINC.h 1.000 06/12/2002 + * + * Public header file for Socket / Connection module + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +/************************************************** + * Imported header files + **************************************************/ +#include <time.h> +#include <string.h> + +#include "nspr.h" +#include "plhash.h" +#include "plstr.h" +#include "private/pprio.h" + +#include "pk11func.h" +#include "secitem.h" +#include "ssl.h" +#include "certt.h" +#include "nss.h" +#include "secrng.h" +#include "secder.h" +#include "key.h" +#include "sslproto.h" + +#include "httpClient/httpc/Defines.h" // ??? SSR should be spilt into respective modules +#include "httpClient/httpc/Pool.h" +#include "httpClient/httpc/DebugLogger.h" +#include "httpClient/httpc/ErrorLogger.h" +#include "httpClient/httpc/CERTUtil.h" +#include "httpClient/httpc/PSPRUtil.h" + +/************************************************** + * Socket / Connection module header files + **************************************************/ +#include "httpClient/httpc/Socket.h" +#include "httpClient/httpc/ServerSocket.h" +#include "httpClient/httpc/SSLSocket.h" +#include "httpClient/httpc/SSLServerSocket.h" +#include "httpClient/httpc/Connection.h" +#include "httpClient/httpc/ConnectionListener.h" +#include "httpClient/httpc/ServerConnection.h" + + +/************************************************* + * Error codes used by this module + *************************************************/ +// Socket errors +typedef enum { + SOCKET_ERROR_CREATE_SOCKET = -2001, + SOCKET_ERROR_SET_OPTION = -2002, + SOCKET_ERROR_BIND = -2003, + SOCKET_ERROR_LISTEN = -2004, + SOCKET_ERROR_CONNECTION_CLOSED = -2005, + SOCKET_ERROR_READ = -2006, + SOCKET_ERROR_WRITE = -2007, + SOCKET_ERROR_ACCEPT_THREAD = -2008, + SOCKET_ERROR_ALREADY_REGISTERED = -2009, + SOCKET_ERROR_ALREADY_LISTENING = -2010, + SOCKET_ERROR_POLL_THREAD = -2011, + SOCKET_ERROR_NO_LISTENER = -2012, + SOCKET_ERROR_POLL = -2013, + SOCKET_ERROR_POLL_TIMED_OUT = -2014, + SOCKET_ERROR_ALREADY_CONNECTED = -2015, + SOCKET_ERROR_INITIALIZATION_FAILED = -2016 +} SocketError; + +typedef enum { + SSL_ERROR_SERVER_CERT = -2016, + SSL_ERROR_SERVER_PRIVATE_KEY = -2017, + SSL_ERROR_IMPORT_FD = -2018, + SSL_ERROR_OPTION_SECURITY = -2019, + SSL_ERROR_OPTION_SERVER_HANDSHAKE = -2020, + SSL_ERROR_OPTION_REQUEST_CERTIFCATE = -2021, + SSL_ERROR_OPTION_REQUIRE_CERTIFCATE = -2022, + SSL_ERROR_CALLBACK_AUTH_CERTIFICATE = -2023, + SSL_ERROR_CALLBACK_BAD_CERT_HANDLER = -2024, + SSL_ERROR_CALLBACK_HAND_SHAKE = -2025, + SSL_ERROR_CALLBACK_PASSWORD_ARG = -2026, + SSL_ERROR_CONFIG_SECURE_SERVER = -2027, + SSL_ERROR_RESET_HAND_SHAKE = -2028, + SSL_ERROR_OPTION_ENABLE_FDX = -2029 +} SslError; + +/************************************************** + * Defines used by this module + **************************************************/ +#define SOCKET_DEFAULT_HOST_NAME "localhost" +#define SOCKET_DEFAULT_READ_TIME_OUT 1000UL // 1 sec +#define SOCKET_DEFAULT_WRITE_TIME_OUT 0xffffffffUL // infinte +#define SOCKET_DEFAULT_READ_BUFFER_SIZE 4096 // 4k +#define SOCKET_DEFAULT_WRITE_BUFFER_SIZE 4096 // 4k +#define SOCKET_DEFAULT_POLL_TIMEOUT 1000UL // 1 sec +#define SOCKET_DEFAULT_BACKLOG 50 // pending conns +#define SOCKET_DEFAULT_POOL_SIZE 100 // conn pool size + +typedef enum { + SOCKET_ERROR_SEVERE = 1, + SOCKET_ERROR_WARNING = 2, + SOCKET_ERROR_INFO = 3 +} SocketErrorLevel; + + +typedef enum { + REQUEST_CERT_NONE = 0, + REQUIRE_CERT_NONE = 1, + REQUEST_CERT_ONCE = 2, + REQUIRE_CERT_ONCE = 3, + REQUEST_CERT_ALL = 4, + REQUIRE_CERT_ALL = 5 +} RequireCert; + +#endif // _SOCKET_INC_H_ + + + + + diff --git a/base/tps/src/include/httpClient/httpc/SocketLib.h b/base/tps/src/include/httpClient/httpc/SocketLib.h new file mode 100644 index 000000000..5a00b2ecb --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/SocketLib.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _SOCKET_LIB_H_ +#define _SOCKET_LIB_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * SocketLib.h 1.000 06/12/2002 + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +#undef EXPORT_DECL +#ifdef _MSC_VER +#ifdef PS_SOCKET_LIB_INTERNAL + #define EXPORT_DECL __declspec( dllexport ) +#else + #define EXPORT_DECL __declspec (dllimport ) +#endif // PS_SOCKET_LIB_INTERNAL +#else + #define EXPORT_DECL +#endif // _MSC_VER + +#endif // _CONNECTION_LIB_H_ + + + diff --git a/base/tps/src/include/httpClient/httpc/StringList.h b/base/tps/src/include/httpClient/httpc/StringList.h new file mode 100644 index 000000000..80cd61dd6 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/StringList.h @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _STRING_LIST_H +#define _STRING_LIST_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Simple String list class using the STL List template + */ + +#include <list> +#ifdef HPUX +#include <iostream.h> +#else +#include <iostream> +#endif + +#include "httpClient/httpc/Iterator.h" + +#ifndef HPUX +using namespace std; +#endif + +typedef EXPORT_DECL list<const char *> LISTSTR; + +class EXPORT_DECL StringList { +public: + /** + * Constructor + */ + StringList(); + + /** + * Destructor + */ + ~StringList(); + + /** + * Appends a string to the end of the list + * + * @param value The string value to append + */ + void Add( const char *value ); + + /** + * Gets the string at a particular index in the list + * + * @param index Index of the string to retrieve + * @return The string at the specified index, or NULL if outside + * the range of the list + */ + const char *GetAt( int index ); + + /** + * Returns the index of a string in the list + * + * @param matchString The string to match + * @param startIndex The index to start searching from + * @return The index of the string, or -1 if not found + */ + int Find( const char *matchString, + int startIndex ); + + /** + * Returns the number of strings in the list + * + * @return The number of strings in the list + */ + int GetCount(); + + /** + * Inserts a string before the specified position + * + * @param index Position to insert the string + * @param value The string to insert + * @return The index of the string, or -1 if the requested index + * is beyond the end of the list + */ + int Insert( int index, const char *value ); + + /** + * Removes a string at the specified position + * + * @param index Position to remove the string + * @return 0 on sucess, or -1 if the requested index + * is beyond the end of the list + */ + int Remove( int index ); + + /** + * Removes all strings + */ + void RemoveAll(); + + /** + * Returns an iterator over strings in the list + * + * @return An iterator over strings in the list + */ + Iterator *GetIterator(); + + EXPORT_DECL friend ostream& operator<< ( ostream& os, StringList& list ); + +protected: + /** + * Gets the iterator for an indexed element + * + * @param index Position to get + * @return Iterator for the position (could be end()) + */ + LISTSTR::iterator GetIteratorAt( int index ); + +private: + LISTSTR m_list; +}; + +#endif // _STRING_LIST_H diff --git a/base/tps/src/include/httpClient/httpc/StringUtil.h b/base/tps/src/include/httpClient/httpc/StringUtil.h new file mode 100644 index 000000000..5c8955d37 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/StringUtil.h @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _STRING_UTIL_H +#define _STRING_UTIL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * String utility functions + */ + +class EXPORT_DECL StringUtil { +private: + /** + * Constructor - can't be instantiated + */ + StringUtil() {} + + /** + * Destructor + */ + ~StringUtil() {} + +public: + /** + * Normalizes a screen name + * + * @param raw The raw screen name + * @param normalized The normalized screen name (lower case, no spaces) + */ + static void NormalizeScreenName( const char *raw, char *normalized ); + + /** + * Converts the string to lower case + * + * @param raw string to be converted + */ + static void ToLower(char* raw); +}; + +#endif // _STRING_UTIL_H diff --git a/base/tps/src/include/httpClient/httpc/TaskList.h b/base/tps/src/include/httpClient/httpc/TaskList.h new file mode 100644 index 000000000..779d27ead --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/TaskList.h @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __TASK_LIST_H__ +#define __TASK_LIST_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Base class for scheduled tasks in Presence Server + */ + +class EXPORT_DECL TaskList { +public: + /** + * Constructor - creates an empty task list + * + * @param name Name of task list + */ + TaskList( const char *name ); + /** + * Destructor - Empties the task list, deleting each entry + */ + virtual ~TaskList(); + /** + * Returns true if the task list is empty + * + * @return true if the task list is empty + */ + bool IsEmpty(); + /** + * Adds a task to the list; the list is sorted by execution time + * + * @param node An entry to add + * @return The added entry + */ + ScheduledTask *Add( ScheduledTask *node ); + /** + * Removes a node from the list but does not delete it + * + * @param taskName The name of the node to remove + * @return The node with the name taskName, or NULL if not found + */ + ScheduledTask *Remove( const char *taskName ); + /** + * Executes each task for which the time is right in a separate thread; + * if the task is repeating, a new entry is created for it, otherwise + * it is removed from the list + * + * @return The number of tasks executed + */ + int ExecuteCurrent(); + /** + * Dumps the task list to the debug log + * + * @param logLevel Lowest debug level for which the log should be dumped + */ + void Dump( int logLevel ); +private: + /** + * Removes a node from the list but does not delete it; does not lock + * + * @param node The node to remove + * @return The node + */ + ScheduledTask *InternalRemove( ScheduledTask *node ); + /** + * Adds a task to the list; the list is sorted by execution time + * + * @param node An entry to add + * @return The added entry + */ + ScheduledTask *InternalAdd( ScheduledTask *node ); + + char *m_name; + ScheduledTask *m_next; + int m_interval; + PRLock *m_lock; +}; + +#endif /* __TASK_LIST_H__ */ + diff --git a/base/tps/src/include/httpClient/httpc/ThreadPool.h b/base/tps/src/include/httpClient/httpc/ThreadPool.h new file mode 100644 index 000000000..389d42606 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/ThreadPool.h @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __THREAD_POOL_H +#define __THREAD_POOL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ThreadPool.h 1.000 06/12/2002 + * + * A worker thread pool. + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL ThreadPool { + friend class WorkerThread; +public: + /** + * Constructor - creates the pool with default values + * + * @param name name of the threadpool + */ + ThreadPool(const char* name); + + /** + * Constructor + * + * @param name name of the threadpool + * @param min minimum threads in the pool + * @param max maximum threads that can be created + * @param timeout timeout for each thread + */ + ThreadPool(const char* name, int min, int max, int timeout); + + /** + * Destructor + */ + virtual ~ThreadPool(); + +public: + + /** + * Initializes the thread pool with minimum threads + */ + void Init(); + + /** + * Shutdown the thread pool + */ + void Shutdown(); + + /** + * Adds a task for future execution + * + * @param task a task to execute + */ + void AddTask(ScheduledTask* task); + + /** + * Executes the task immediately + * + * @param task a task to execute + */ + void ExecuteTask(ScheduledTask* task); + + /** + * Gets the number of active threads in the pool + * + * @return number of active threads + */ + int GetThreads(); + + /** + * Gets the number of pending tasks in the list + * + * @return number of pending tasks + */ + int GetPendingTasks(); + + /** + * Function to start a NSPR thread + */ + static void StartWorkerThread(void* arg); + +private: + /** + * Initializes constructor params + */ + void ConstructorInit(const char* name, int min, int max, int timeout); + + /** + * Creates a new thread + */ + void CreateNewThread(); + + /** + * Notify one of the threads waiting on a condition + */ + void Notify(); + +private: + char* m_name; + TaskList* m_taskList; + + int m_minThreads; + int m_maxThreads; + int m_timeout; + + int m_threads; + int m_activeThreads; + + PRBool m_threadWait; + PRLock* m_threadLock; + PRCondVar* m_threadCondVar; + + PRBool m_newThreadInitialized; + PRLock* m_newThreadLock; + PRCondVar* m_newThreadCondVar; + + bool m_keepRunning; +}; + +#endif // __THREAD_POOL_H + diff --git a/base/tps/src/include/httpClient/httpc/URLUtil.h b/base/tps/src/include/httpClient/httpc/URLUtil.h new file mode 100644 index 000000000..379986999 --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/URLUtil.h @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _URL_UTIL_H +#define _URL_UTIL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * URL utility functions + */ + +typedef enum { + URL_TYPE_HTTP = 1, + URL_TYPE_HTTPS = 2, + URL_TYPE_LDAP = 3, + URL_TYPE_LDAPS = 4, + URL_TYPE_UNKNOWN = 5 +} UrlType; + +class EXPORT_DECL URLUtil { +private: + /** + * Constructor - can't be instantiated + */ + URLUtil() {} + + /** + * Destructor + */ + ~URLUtil() {} + +public: + /** + * Parses the URL + * + * @param url url to parse + * @param type protocol header type + * @param host hostname from the url + * @param port port number from the url + * @param path uri from the url + * @return 0 on success, negative error code otherwise + */ + static int ParseURL( const char* url, + int* type, + char** host, + int* port, + char** path ); + +private: + static int ParseURLType(const char* url, int* type, int* hlen); + static int ParseAtPort(const char* url, int* port, char** path); + static int ParseAtPath(const char* url, char** path); + static int GetPort(const char* url, int* port); + static bool IsAsciiSpace(char c); + static bool IsAsciiDigit(char c); +}; + +#endif // _URL_UTIL_H + diff --git a/base/tps/src/include/httpClient/httpc/engine.h b/base/tps/src/include/httpClient/httpc/engine.h new file mode 100644 index 000000000..9a57b024e --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/engine.h @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _HTTP_ENGINE_ +#define _HTTP_ENGINE_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/http.h" +#include "httpClient/httpc/response.h" +#include "httpClient/httpc/request.h" + +class __EXPORT Engine { + public: + Engine() {}; + ~Engine() {}; + + PRFileDesc *_doConnect(PRNetAddr *addr, PRBool SSLOn = PR_FALSE, + const PRInt32* cipherSuite = NULL, + PRInt32 count = 0, const char* nickname = NULL, + PRBool handshake = PR_FALSE, + /*const SecurityProtocols& secprots = SecurityProtocols() ,*/ + const char *serverName ="localhost", + PRIntervalTime iv = PR_SecondsToInterval(30)); + static PRIntervalTime globaltimeout; +}; + + +class __EXPORT HttpEngine: public Engine { + public: + HttpEngine() {}; + ~HttpEngine() {}; + + PSHttpResponse *makeRequest( PSHttpRequest &request, + const PSHttpServer& server, + int timeout = 30, PRBool expectChunked = PR_FALSE); +}; + +PRBool __EXPORT InitSecurity(char* dbpath, char* certname, char* certpassword, + char * prefix ,int verify=1); +PRBool __EXPORT EnableCipher(const char* ciphername); +void __EXPORT EnableAllSSL3Ciphers(); +void __EXPORT EnableAllTLSCiphers(); +__EXPORT const char * nscperror_lookup(int error); + +#endif diff --git a/base/tps/src/include/httpClient/httpc/http.h b/base/tps/src/include/httpClient/httpc/http.h new file mode 100644 index 000000000..0dccfddbd --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/http.h @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _HTTP_SERVER_ +#define _HTTP_SERVER_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <stdlib.h> +#include <prnetdb.h> +#include <prio.h> +#include <time.h> +#include <plhash.h> +#include <nspr.h> +#include <plstr.h> + +#include "httpClient/httpc/PSCommonLib.h" +#include "httpClient/httpc/Cache.h" +#include "httpClient/httpc/Defines.h" +//#include "httpClient/httpc/DebugLogger.h" +//#include "httpClient/httpc/ErrorLogger.h" + +#ifdef WIN32 +#define __EXPORT __declspec(dllexport) +#else +#define __EXPORT +#endif + +class PSHttpRequest; + +class __EXPORT PSHttpServer +{ +public: + PSHttpServer(const char *addr, PRUint16 af); + ~PSHttpServer(); + + long getIp() const; + long getPort() const; + const char *getAddr() const; + void getAddr(PRNetAddr *addr) const; + void setSSL(PRBool SSLstate); + PRBool isSSL() const; + + // put a file on the server of size bytes + PRBool putFile(const char *uri, int size) const; + PRBool putFile(const char* uri, const char* localFile) const; + +private: + char *_addr; + PRNetAddr _netAddr; + PRBool SSLOn; + PRBool _putFile(PSHttpRequest& rq) const; +}; + +typedef __EXPORT enum HttpProtocol_e { HTTPNA = 0x0, + HTTP09 = 0x1, + HTTP10 = 0x2, + HTTP11 = 0x4, + HTTPBOGUS = 0x8 } HttpProtocol; + +#define NUM_PROTOS 5 // needed for arrays of tests + +__EXPORT const char *HttpProtocolToString(HttpProtocol); + +class __EXPORT HttpMessage +{ + public: + HttpMessage(long len = 0, const char* buf = NULL); + ~HttpMessage(); + + PRBool operator == (const HttpMessage& rhs); + + void addData(long len, const void* buf); + + // set data on the message + void setProtocol(HttpProtocol prot); + + // get data about the message + HttpProtocol getProtocol() const; + + + protected: + char* firstline; // first line - may be the request-line or server status + HttpProtocol proto; + long cl; +}; + + +#endif diff --git a/base/tps/src/include/httpClient/httpc/request.h b/base/tps/src/include/httpClient/httpc/request.h new file mode 100644 index 000000000..0399732ef --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/request.h @@ -0,0 +1,115 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef _REQUEST_H_ +#define _REQUEST_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/http.h" + +// abstract request class +class __EXPORT NetRequest +{ + public: + NetRequest(const PSHttpServer* server); + PRBool isSSL() const; + void setSSL(PRBool SSLstate); + void getAddr(PRNetAddr *addr); + const char* getAddr(); + const char* getHost(); + const PSHttpServer * getServer(); + void setServer(PSHttpServer* _server); + PRIntervalTime getTimeout() const; + const PRInt32* cipherSet; + PRInt32 cipherCount; + PRBool handshake; +// SecurityProtocols secprots; + + protected: + PRBool SSLOn; + const PSHttpServer * _server; + PRIntervalTime timeout; + +}; + +// Netscape-style request +class __EXPORT PSHttpRequest: public HttpMessage, public NetRequest +{ +public: + PSHttpRequest(const PSHttpServer* server, const char *uri, HttpProtocol proto, PRIntervalTime to); + virtual ~PSHttpRequest(); + + // connection related stuff + + // set data on the request + PRBool setMethod(const char *method); + PRBool addHeader(const char *name, const char *value); + PRBool addRandomBody(int size); + PRBool useLocalFileAsBody(const char* fileName); + PRBool setBody(int size, const char* body); + void setExpectedResponseLength(int size); + void setExpectStandardBody(); + void setExpectDynamicBody(); + void setHangupOk(); + PRBool isHangupOk(); + + // get data about the request + char *getMethod(); + //HttpProtocol getProtocol(); + const char *getHeader(const char *name); + int getExpectedResponseLength(); + PRBool getExpectStandardBody(); + PRBool getExpectDynamicBody(); + + PRBool send(PRFileDesc *sock); + void setCertNickName(const char *); + char *getCertNickName(); + +private: + char *_method; + char *_uri; + HttpProtocol _proto; + int _bodyLength; + char *_body; + char *nickName; + StringKeyCache *_headers; + int _expectedResponseLength; + PRBool _expectStandardBody; + PRBool _expectDynamicBody; + PRBool _hangupOk; + PRFileDesc* _fileFd; +}; + +#endif diff --git a/base/tps/src/include/httpClient/httpc/response.h b/base/tps/src/include/httpClient/httpc/response.h new file mode 100644 index 000000000..5c45d574c --- /dev/null +++ b/base/tps/src/include/httpClient/httpc/response.h @@ -0,0 +1,148 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _RESPONSE_H_ +#define _RESPONSE_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/http.h" +#include "httpClient/httpc/request.h" + +class __EXPORT RecvBuf +{ +public: + RecvBuf(const PRFileDesc *socket, int size, int timeout = 30); + virtual ~RecvBuf(); + + char getChar(); + void putBack(); + + void setChunkedMode(); + int getAllContent(); + int getTimeout(); + + char *get_content(); + int get_contentSize(); + + class EndOfFile {}; + class EndOfChunking {}; + +private: + char _getChar(); + PRBool _getBytes(int size); + + const PRFileDesc *_socket; + int _allocSize; + char *_buf; + int _curPos; + int _curSize; + + PRBool _chunkedMode; + int _currentChunkSize; + int _currentChunkBytesRead; + PRIntervalTime _timeout; + char *_content; + int _contentSize; +}; + + +class __EXPORT Response +{ + public: + Response(const PRFileDesc *sock, NetRequest *request); + + protected: + const PRFileDesc *_socket; + NetRequest *_request; +}; + + +class __EXPORT PSHttpResponse: public Response +{ + public: + PSHttpResponse( const PRFileDesc *sock, + PSHttpRequest *request ); + PSHttpResponse( const PRFileDesc *sock, + PSHttpRequest *request, + int timeout, PRBool expectChunked ); + virtual ~PSHttpResponse(); + virtual PRBool processResponse(); + + int getReturnCode(); + long getStatus(); + char *getStatusString(); + HttpProtocol getProtocol(); + char *getHeader(const char *name); + int getHeaders(char ***keys); + + PRBool checkKeepAlive(); // return true if we *expect* keepalive based on request + PRBool checkConnection(); // return true if connection is open + + long getBodyLength(); + char *getContent(); + void freeContent(); + int getContentSize(); + char *toString(); + + protected: + PSHttpRequest *_request; + int _verifyStandardBody(RecvBuf &, int, PRBool); + PRBool _handleBody(RecvBuf &buf); + void _checkResponseSanity(); + + HttpProtocol _proto; + char *_protocol; + int retcode; + char *_statusNum; + char *_statusString; + + int _keepAlive; + int _connectionClosed; + + long _bodyLength; + + PRBool _expectChunked; + PRBool _chunkedResponse; + + StringKeyCache *_headers; + + int _timeout; + char *_content; + int _contentSize; +}; + + +#endif |