4 * @author Martin Corino <mcorino@remedy.nl>
7 #ifndef ACE_INET_URL_BASE_H
8 #define ACE_INET_URL_BASE_H
10 #include /**/ "ace/pre.h"
12 #include "ace/SString.h"
13 #include "ace/Map_Manager.h"
14 #include "ace/Singleton.h"
15 #include "ace/Null_Mutex.h"
16 #include "ace/Recursive_Thread_Mutex.h"
17 #include "ace/Refcounted_Auto_Ptr.h"
18 #include "ace/INet/INet_Export.h"
19 #include "ace/INet/AuthenticationBase.h"
20 #include "ace/INet/ClientRequestHandler.h"
23 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 * @class ACE_INet_URLStream
32 * @brief Provides abstracted wrapper class for the resulting
33 * stream of an URL <open> operation.
35 * Provides proper life cycle management for either factory provided
36 * or user provided request handlers.
38 class ACE_INET_Export URLStream
41 URLStream (const URLStream
& url_stream
);
48 std::istream
& operator * ();
50 std::istream
* operator -> ();
53 friend class URL_Base
;
55 URLStream (ClientRequestHandler
& rh
);
56 URLStream (ClientRequestHandler
* rh
);
58 typedef ACE_Refcounted_Auto_Ptr
<ClientRequestHandler
,
59 ACE_Null_Mutex
> TRequestHandlerRef
;
61 TRequestHandlerRef request_handler_ref_
;
62 ClientRequestHandler
* request_handler_
;
66 * @class ACE_INet_URL_Base
68 * @brief Base class for URL/URI addresses conforming to RFC3986.
71 class ACE_INET_Export URL_Base
77 virtual bool parse (const ACE_CString
& url_string
);
79 void set_path (const ACE_CString
& path
);
81 virtual void set_query (const ACE_CString
& query
);
83 virtual void set_fragment (const ACE_CString
& fragment
);
85 virtual const ACE_CString
& get_scheme () const = 0;
87 const ACE_CString
& get_protocol () const;
89 virtual ACE_CString
get_authority () const;
91 const ACE_CString
& get_path () const;
93 virtual const ACE_CString
& get_query () const;
95 virtual const ACE_CString
& get_fragment () const;
97 virtual URLStream
open () const;
99 virtual URLStream
open (ClientRequestHandler
& rh
) const;
101 virtual ACE_CString
to_string () const = 0;
103 static URL_Base
* create_from_string (const ACE_CString
& url_string
);
105 #if defined (ACE_HAS_WCHAR)
106 virtual bool parse (const ACE_WString
& url_string
);
108 virtual ACE_WString
to_wstring () const;
110 static URL_Base
* create_from_wstring (const ACE_WString
& url_string
);
113 virtual bool validate ();
116 static const ACE_CString empty_
;
118 bool strip_scheme (ACE_CString
& url_string
);
120 virtual int parse_authority (std::istream
& is
);
122 virtual bool has_authority ();
124 virtual ClientRequestHandler
* create_default_request_handler () const = 0;
130 class ACE_INET_Export Factory
135 virtual const ACE_CString
& protocol () = 0;
136 virtual URL_Base
* create_from_string (const ACE_CString
& url_string
) = 0;
139 static void register_factory (Factory
* url_factory
);
140 static void deregister_factory (Factory
* url_factory
);
143 typedef ACE_Map_Manager
<ACE_CString
,
145 ACE_SYNCH::MUTEX
> TURLFactoryMap
;
146 typedef ACE_Singleton
<TURLFactoryMap
,
147 ACE_SYNCH::NULL_MUTEX
> TURLFactorySingleton
;
148 static TURLFactoryMap
* factories_
;
152 * @class ACE_INet_URL_INetBase
154 * @brief Base class for internet protocol based URL/URI
155 * addresses supporting host(name) and port specification.
158 class ACE_INET_Export URL_INetBase
162 URL_INetBase(u_short port
);
163 virtual ~URL_INetBase ();
165 void set_host (const ACE_CString
& host
);
167 void set_port (u_short port
);
169 const ACE_CString
& get_host () const;
171 u_short
get_port () const;
173 virtual u_short
default_port () const = 0;
175 virtual ACE_CString
get_authority () const;
177 virtual bool validate ();
180 virtual int parse_authority (std::istream
& is
);
182 virtual bool has_authority ();
184 int parse_authority_i (std::istream
& is
,
195 * @class ACE_INet_URL_INetAuthBase
197 * @brief Base class for internet protocol based URL/URI
198 * addresses supporting authentication information.
200 * This implementation does *not* support the specification
201 * of passwords in user_info field of the URL (deprecated as
204 class ACE_INET_Export URL_INetAuthBase
205 : public URL_INetBase
208 URL_INetAuthBase(u_short port
);
209 virtual ~URL_INetAuthBase ();
211 const ACE_CString
& get_user_info () const;
213 void set_user_info (const ACE_CString
& userinfo
);
215 virtual ACE_CString
get_authority () const;
218 virtual int parse_authority (std::istream
& is
);
221 ACE_CString userinfo_
;
224 static bool add_authenticator (const ACE_CString
& auth_id
, AuthenticatorBase
* authenticator
);
226 static bool has_authenticator (const ACE_CString
& auth_id
);
228 static AuthenticatorBase
* remove_authenticator (const ACE_CString
& auth_id
);
230 static bool authenticate (AuthenticationBase
& authentication
);
233 typedef ACE_Refcounted_Auto_Ptr
<AuthenticatorBase
,
234 ACE_SYNCH::NULL_MUTEX
> authenticator_ptr
;
235 typedef ACE_Map_Manager
<ACE_CString
,
237 ACE_SYNCH::RECURSIVE_MUTEX
> authenticator_map
;
239 static authenticator_map authenticators_
;
244 ACE_END_VERSIONED_NAMESPACE_DECL
246 #if defined (__ACE_INLINE__)
247 #include "ace/INet/URLBase.inl"
250 #include /**/ "ace/post.h"
251 #endif /* ACE_INET_URL_BASE_H */