This class is used to analyze and store LDAP-Urls as returned by a LDAP-Server as Referrals and Search References. More...
#include <LDAPUrl.h>
Public Member Functions | |
LDAPUrl (const std::string &url="") | |
Create a new object from a string that contains a LDAP-Url. | |
~LDAPUrl () | |
Destructor. | |
int | getPort () const |
void | setPort (int port) |
Set the port value of the URL. | |
int | getScope () const |
void | setScope (const std::string &scope) |
Set the Scope part of the URL. | |
const std::string & | getURLString () const |
void | setURLString (const std::string &url) |
Set the URL member attribute. | |
const std::string & | getHost () const |
void | setHost (const std::string &host) |
Set the Host part of the URL. | |
const std::string & | getScheme () const |
void | setScheme (const std::string &scheme) |
Set the Protocol Scheme of the URL. | |
const std::string & | getDN () const |
void | setDN (const std::string &dn) |
Set the DN part of the URL. | |
const std::string & | getFilter () const |
void | setFilter (const std::string &filter) |
Set the Filter part of the URL. | |
const StringList & | getAttrs () const |
void | setAttrs (const StringList &attrs) |
Set the Attributes part of the URL. | |
void | setExtensions (const StringList &ext) |
const StringList & | getExtensions () const |
void | percentDecode (const std::string &src, std::string &dest) |
Percent-decode a string. | |
std::string & | percentEncode (const std::string &src, std::string &dest, int flags=0) const |
Percent-encoded a string. | |
Protected Types | |
enum | mode { base, attrs, scope, filter, extensions } |
Protected Member Functions | |
void | parseUrl () |
Split the url string that is associated with this Object into it components. | |
void | components2Url () const |
Generate an URL string from the components that were set with the various set. | |
void | string2list (const std::string &src, StringList &sl, bool percentDecode=false) |
Protected Attributes | |
bool | regenerate |
int | m_Port |
int | m_Scope |
std::string | m_Host |
std::string | m_DN |
std::string | m_Filter |
StringList | m_Attrs |
StringList | m_Extensions |
std::string | m_urlString |
std::string | m_Scheme |
This class is used to analyze and store LDAP-Urls as returned by a LDAP-Server as Referrals and Search References.
LDAP-URLs are defined in RFC1959 and have the following format:
ldap://host:port/baseDN[?attr[?scope[?filter]]]
enum LDAPUrl::mode [protected] |
LDAPUrl::LDAPUrl | ( | const std::string & | url = "" |
) |
Create a new object from a string that contains a LDAP-Url.
url | The URL String |
References DEBUG, LDAP_DEBUG_CONSTRUCT, LDAP_DEBUG_PARAMETER, m_Filter, m_Port, m_Scheme, m_Scope, m_urlString, parseUrl(), and regenerate.
LDAPUrl::~LDAPUrl | ( | ) |
Destructor.
References StringList::clear(), DEBUG, LDAP_DEBUG_DESTROY, and m_Attrs.
void LDAPUrl::components2Url | ( | ) | const [protected] |
Generate an URL string from the components that were set with the various set.
..() methods (this function is mostly for internal use and gets called automatically whenever necessary)
References StringList::begin(), StringList::empty(), StringList::end(), m_Attrs, m_DN, m_Extensions, m_Filter, m_Host, m_Port, m_Scheme, m_Scope, m_urlString, PCT_ENCFLAG_SLASH, and percentEncode().
Referenced by getURLString().
const StringList & LDAPUrl::getAttrs | ( | ) | const |
References m_Attrs.
const string & LDAPUrl::getDN | ( | ) | const |
References m_DN.
const StringList & LDAPUrl::getExtensions | ( | ) | const |
References m_Extensions.
const string & LDAPUrl::getFilter | ( | ) | const |
References m_Filter.
const string & LDAPUrl::getHost | ( | ) | const |
References m_Host.
Referenced by LDAPAsynConnection::getHost().
int LDAPUrl::getPort | ( | ) | const |
References m_Port.
Referenced by LDAPAsynConnection::getPort().
const std::string & LDAPUrl::getScheme | ( | ) | const |
References m_Scheme.
int LDAPUrl::getScope | ( | ) | const |
References m_Scope.
const string & LDAPUrl::getURLString | ( | ) | const |
References components2Url(), m_urlString, and regenerate.
Referenced by LDAPAsynConnection::initialize().
void LDAPUrl::parseUrl | ( | ) | [protected] |
Split the url string that is associated with this Object into it components.
The compontens of the URL can be access via the get...() methods. (this function is mostly for internal use and gets called automatically whenever necessary)
References attrs, base, DEBUG, extensions, filter, LDAPUrlException::INVALID_PORT, LDAPUrlException::INVALID_SCHEME, LDAPUrlException::INVALID_SCOPE, LDAPUrlException::INVALID_URL, LDAP_DEBUG_TRACE, LDAP_DEFAULT_PORT, LDAPS_DEFAULT_PORT, m_Attrs, m_DN, m_Extensions, m_Filter, m_Host, m_Port, m_Scheme, m_Scope, m_urlString, percentDecode(), scope, and string2list().
Referenced by LDAPUrl(), and setURLString().
void LDAPUrl::percentDecode | ( | const std::string & | src, | |
std::string & | dest | |||
) |
Percent-decode a string.
src | The string that is to be decoded | |
dest | The decoded result string |
References DEBUG, LDAP_DEBUG_TRACE, and LDAPUrlException::URL_DECODING_ERROR.
Referenced by parseUrl(), and string2list().
std::string & LDAPUrl::percentEncode | ( | const std::string & | src, | |
std::string & | dest, | |||
int | flags = 0 | |||
) | const |
Percent-encoded a string.
src | The string that is to be encoded | |
dest | The encoded result string | |
flags |
References PCT_ENCFLAG_COMMA, and PCT_ENCFLAG_SLASH.
Referenced by components2Url().
void LDAPUrl::setAttrs | ( | const StringList & | attrs | ) |
Set the Attributes part of the URL.
attrs | StringList constaining the List of Attributes |
References m_Attrs, and regenerate.
void LDAPUrl::setDN | ( | const std::string & | dn | ) |
void LDAPUrl::setExtensions | ( | const StringList & | ext | ) |
References m_Extensions, and regenerate.
void LDAPUrl::setFilter | ( | const std::string & | filter | ) |
Set the Filter part of the URL.
filter | The new Filter |
References m_Filter, and regenerate.
void LDAPUrl::setHost | ( | const std::string & | host | ) |
void LDAPUrl::setPort | ( | int | port | ) |
void LDAPUrl::setScheme | ( | const std::string & | scheme | ) |
Set the Protocol Scheme of the URL.
host | The Protcol scheme. Allowed values are ldap,ldapi,ldaps and cldap |
References LDAPUrlException::INVALID_SCHEME, m_Scheme, and regenerate.
void LDAPUrl::setScope | ( | const std::string & | scope | ) |
Set the Scope part of the URL.
scope | The new scope |
References LDAPUrlException::INVALID_SCOPE, m_Scope, and regenerate.
void LDAPUrl::setURLString | ( | const std::string & | url | ) |
Set the URL member attribute.
url | The URL String |
References m_urlString, parseUrl(), and regenerate.
Referenced by LDAPAsynConnection::initialize().
void LDAPUrl::string2list | ( | const std::string & | src, | |
StringList & | sl, | |||
bool | percentDecode = false | |||
) | [protected] |
References StringList::add(), and percentDecode().
Referenced by parseUrl().
StringList LDAPUrl::m_Attrs [protected] |
Referenced by components2Url(), getAttrs(), parseUrl(), setAttrs(), and ~LDAPUrl().
std::string LDAPUrl::m_DN [protected] |
Referenced by components2Url(), getDN(), parseUrl(), and setDN().
StringList LDAPUrl::m_Extensions [protected] |
Referenced by components2Url(), getExtensions(), parseUrl(), and setExtensions().
std::string LDAPUrl::m_Filter [protected] |
Referenced by components2Url(), getFilter(), LDAPUrl(), parseUrl(), and setFilter().
std::string LDAPUrl::m_Host [protected] |
Referenced by components2Url(), getHost(), parseUrl(), and setHost().
int LDAPUrl::m_Port [protected] |
Referenced by components2Url(), getPort(), LDAPUrl(), parseUrl(), and setPort().
std::string LDAPUrl::m_Scheme [protected] |
Referenced by components2Url(), getScheme(), LDAPUrl(), parseUrl(), and setScheme().
int LDAPUrl::m_Scope [protected] |
Referenced by components2Url(), getScope(), LDAPUrl(), parseUrl(), and setScope().
std::string LDAPUrl::m_urlString [mutable, protected] |
Referenced by components2Url(), getURLString(), LDAPUrl(), parseUrl(), and setURLString().
bool LDAPUrl::regenerate [mutable, protected] |
Referenced by getURLString(), LDAPUrl(), setAttrs(), setDN(), setExtensions(), setFilter(), setHost(), setPort(), setScheme(), setScope(), and setURLString().