OW_HTTPServer.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00036 #ifndef OW_HTTPSERVER_HPP_INCLUDE_GUARD_
00037 #define OW_HTTPSERVER_HPP_INCLUDE_GUARD_
00038 #include "OW_config.h"
00039 #include "OW_Mutex.hpp"
00040 #include "OW_SocketAddress.hpp"
00041 #include "OW_Socket.hpp"
00042 #include "OW_ServiceIFC.hpp"
00043 #include "OW_URL.hpp"
00044 #include "OW_ThreadPool.hpp"
00045 #include "OW_Exception.hpp"
00046 #include "OW_SortedVectorSet.hpp"
00047 #include "OW_SSLCtxMgr.hpp"
00048 #include "OW_CommonFwd.hpp"
00049 #include "OW_ServicesHttpFwd.hpp"
00050 
00051 namespace OW_NAMESPACE
00052 {
00053 
00054 OW_DECLARE_EXCEPTION(HTTPServer)
00055 
00056 class OW_HTTPSVC_API HTTPServer : public ServiceIFC
00057 {
00058 public:
00059    HTTPServer();
00060    virtual ~HTTPServer();
00061    virtual String getName() const;
00062    virtual StringArray getDependencies() const;
00063 
00064    virtual void init(const ServiceEnvironmentIFCRef& env);
00065    virtual void start();
00070    virtual void shutdown();
00071 
00076    bool isShuttingDown();
00083    Array<URL> getURLs() const;
00084    ServiceEnvironmentIFCRef getEnvironment() const { return m_options.env; }
00089    void addURL(const URL& url);
00090    SocketAddress getLocalHTTPAddress();
00091    SocketAddress getLocalHTTPSAddress();
00092    
00093    enum EAuthenticationChallengeMethod
00094    {
00095       E_DIGEST,
00096       E_BASIC,
00097       E_OWLOCAL
00098    };
00099    
00100    struct Options
00101    {
00102       Int32 httpPort;
00103       Int32 httpsPort;
00104       String UDSFilename;
00105       Int32 maxConnections;
00106       bool isSepThread;
00107       bool enableDeflate;
00108       EAuthenticationChallengeMethod defaultAuthChallenge;
00109       bool allowDigestAuthentication;
00110       bool allowBasicAuthentication;
00111       bool allowLocalAuthentication;
00112       bool allowAnonymous;
00113       bool useUDS;
00114       bool reuseAddr;
00115       ServiceEnvironmentIFCRef env;
00116       Int32 timeout;
00117       String defaultContentLanguage;
00118    };
00119 private:
00120    bool authenticate(HTTPSvrConnection* pconn,
00121       String& userName, const String& info, OperationContext& context,
00122                  const Socket& socket);
00123    bool isAllowedUser(const String& user) const;
00124 
00125    Mutex m_guard;
00126    Options m_options;
00127 #ifdef OW_WIN32
00128 #pragma warning (push)
00129 #pragma warning (disable: 4251)
00130    HANDLE m_event;
00131 #else
00132    IntrusiveReference<UnnamedPipe> m_upipe;
00133 #endif
00134    Array<URL> m_urls;
00135    IntrusiveReference<ServerSocket> m_pHttpServerSocket;
00136    IntrusiveReference<ServerSocket> m_pHttpsServerSocket;
00137    IntrusiveReference<ServerSocket> m_pUDSServerSocket;
00138 #ifndef OW_DISABLE_DIGEST
00139    IntrusiveReference<DigestAuthentication> m_digestAuthentication;
00140 #endif
00141 #ifndef OW_WIN32
00142    IntrusiveReference<LocalAuthentication> m_localAuthentication;
00143 #endif
00144    Mutex m_authGuard;
00145    IntrusiveReference<ThreadPool> m_threadPool;
00146    SortedVectorSet<String> m_allowedUsers;
00147    bool m_allowAllUsers;
00148    SSLServerCtxRef m_sslCtx;
00149    Mutex m_shutdownGuard;
00150    bool m_shuttingDown;
00151 #ifndef OW_NO_SSL
00152    SSLOpts m_sslopts;
00153    SSLTrustStoreRef m_trustStore;
00154 #endif //  OW_HAVE_SSL
00155 
00156 #ifdef OW_WIN32
00157 #pragma warning (pop)
00158 #endif
00159 
00160    friend class HTTPSvrConnection;
00161    friend class HTTPListener;
00162    friend class IPCConnectionHandler;
00163    friend class HTTPServerSelectableCallback;
00164 };
00165 OW_EXPORT_TEMPLATE(OW_HTTPSVC_API, IntrusiveReference, HTTPServer);
00166 
00167 } // end namespace OW_NAMESPACE
00168 
00169 #endif

Generated on Thu Feb 9 08:47:59 2006 for openwbem by  doxygen 1.4.6