1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #include "nsLDAPURL.h"
8 #include "netCore.h"
9 #include "plstr.h"
10 #include "nsCOMPtr.h"
11 #include "nsNetCID.h"
12 #include "nsComponentManagerUtils.h"
13 #include "nsIStandardURL.h"
14 #include "nsMsgUtils.h"
15 #include "mozilla/Encoding.h"
16 #include "ldap.h"
17
18 // The two schemes we support, LDAP and LDAPS
19 //
20 constexpr auto LDAP_SCHEME = "ldap"_ns;
21 constexpr auto LDAP_SSL_SCHEME = "ldaps"_ns;
22
NS_IMPL_ISUPPORTS(nsLDAPURL,nsILDAPURL,nsIURI)23 NS_IMPL_ISUPPORTS(nsLDAPURL, nsILDAPURL, nsIURI)
24
25 nsLDAPURL::nsLDAPURL() : mScope(SCOPE_BASE), mOptions(0) {}
26
~nsLDAPURL()27 nsLDAPURL::~nsLDAPURL() {}
28
Init(uint32_t aUrlType,int32_t aDefaultPort,const nsACString & aSpec,const char * aOriginCharset,nsIURI * aBaseURI)29 nsresult nsLDAPURL::Init(uint32_t aUrlType, int32_t aDefaultPort,
30 const nsACString& aSpec, const char* aOriginCharset,
31 nsIURI* aBaseURI) {
32 nsresult rv;
33 nsCOMPtr<nsIURI> base(aBaseURI);
34 rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
35 .Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
36 nsIStandardURL::URLTYPE_STANDARD,
37 aDefaultPort, PromiseFlatCString(aSpec),
38 aOriginCharset, base, nullptr))
39 .Finalize(mBaseURL);
40 NS_ENSURE_SUCCESS(rv, rv);
41
42 // Now get the spec from the mBaseURL in case it was a relative one
43 nsCString spec;
44 rv = mBaseURL->GetSpec(spec);
45 NS_ENSURE_SUCCESS(rv, rv);
46
47 return SetSpecInternal(spec);
48 }
49
GetPathInternal(nsCString & aPath)50 void nsLDAPURL::GetPathInternal(nsCString& aPath) {
51 aPath.Assign('/');
52
53 if (!mDN.IsEmpty()) aPath.Append(mDN);
54
55 if (!mAttributes.IsEmpty()) aPath.Append('?');
56
57 // If mAttributes isn't empty, cut off the internally stored commas at start
58 // and end, and append to the path.
59 if (!mAttributes.IsEmpty())
60 aPath.Append(Substring(mAttributes, 1, mAttributes.Length() - 2));
61
62 if (mScope || !mFilter.IsEmpty()) {
63 aPath.Append((mAttributes.IsEmpty() ? "??" : "?"));
64 if (mScope) {
65 if (mScope == SCOPE_ONELEVEL)
66 aPath.Append("one");
67 else if (mScope == SCOPE_SUBTREE)
68 aPath.Append("sub");
69 }
70 if (!mFilter.IsEmpty()) {
71 aPath.Append('?');
72 aPath.Append(mFilter);
73 }
74 }
75 }
76
SetPathInternal(const nsCString & aPath)77 nsresult nsLDAPURL::SetPathInternal(const nsCString& aPath) {
78 LDAPURLDesc* desc;
79
80 // This is from the LDAP C-SDK, which currently doesn't
81 // support everything from RFC 2255... :(
82 //
83 int err = ldap_url_parse(aPath.get(), &desc);
84 switch (err) {
85 case LDAP_SUCCESS: {
86 // The base URL can pick up the host & port details and deal with them
87 // better than we can
88 mDN = desc->lud_dn;
89 mScope = desc->lud_scope;
90 mFilter = desc->lud_filter;
91 mOptions = desc->lud_options;
92 nsresult rv = SetAttributeArray(desc->lud_attrs);
93 if (NS_FAILED(rv)) return rv;
94
95 ldap_free_urldesc(desc);
96 return NS_OK;
97 }
98
99 case LDAP_URL_ERR_NOTLDAP:
100 case LDAP_URL_ERR_NODN:
101 case LDAP_URL_ERR_BADSCOPE:
102 return NS_ERROR_MALFORMED_URI;
103
104 case LDAP_URL_ERR_MEM:
105 NS_ERROR("nsLDAPURL::SetSpec: out of memory ");
106 return NS_ERROR_OUT_OF_MEMORY;
107
108 case LDAP_URL_ERR_PARAM:
109 return NS_ERROR_INVALID_POINTER;
110 }
111
112 // This shouldn't happen...
113 return NS_ERROR_UNEXPECTED;
114 }
115
116 // A string representation of the URI. Setting the spec
117 // causes the new spec to be parsed, initializing the URI. Setting
118 // the spec (or any of the accessors) causes also any currently
119 // open streams on the URI's channel to be closed.
120
121 NS_IMETHODIMP
GetSpec(nsACString & _retval)122 nsLDAPURL::GetSpec(nsACString& _retval) {
123 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
124
125 return mBaseURL->GetSpec(_retval);
126 }
127
SetSpecInternal(const nsACString & aSpec)128 nsresult nsLDAPURL::SetSpecInternal(const nsACString& aSpec) {
129 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
130
131 // Cache the original spec in case we don't like what we've been passed and
132 // need to reset ourselves.
133 nsCString originalSpec;
134 nsresult rv = mBaseURL->GetSpec(originalSpec);
135 NS_ENSURE_SUCCESS(rv, rv);
136
137 rv = NS_MutateURI(mBaseURL).SetSpec(aSpec).Finalize(mBaseURL);
138 NS_ENSURE_SUCCESS(rv, rv);
139
140 rv = SetPathInternal(PromiseFlatCString(aSpec));
141 if (NS_FAILED(rv)) {
142 nsresult rv2 =
143 NS_MutateURI(mBaseURL).SetSpec(originalSpec).Finalize(mBaseURL);
144 NS_ENSURE_SUCCESS(rv2, rv2);
145 }
146
147 return rv;
148 }
149
GetPrePath(nsACString & _retval)150 NS_IMETHODIMP nsLDAPURL::GetPrePath(nsACString& _retval) {
151 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
152
153 return mBaseURL->GetPrePath(_retval);
154 }
155
GetScheme(nsACString & _retval)156 NS_IMETHODIMP nsLDAPURL::GetScheme(nsACString& _retval) {
157 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
158
159 return mBaseURL->GetScheme(_retval);
160 }
161
SetScheme(const nsACString & aScheme)162 nsresult nsLDAPURL::SetScheme(const nsACString& aScheme) {
163 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
164
165 if (aScheme.Equals(LDAP_SCHEME, nsCaseInsensitiveCStringComparator))
166 mOptions &= !OPT_SECURE;
167 else if (aScheme.Equals(LDAP_SSL_SCHEME, nsCaseInsensitiveCStringComparator))
168 mOptions |= OPT_SECURE;
169 else
170 return NS_ERROR_MALFORMED_URI;
171
172 return NS_MutateURI(mBaseURL).SetScheme(aScheme).Finalize(mBaseURL);
173 }
174
175 NS_IMETHODIMP
GetUserPass(nsACString & _retval)176 nsLDAPURL::GetUserPass(nsACString& _retval) {
177 _retval.Truncate();
178 return NS_OK;
179 }
180
SetUserPass(const nsACString & aUserPass)181 nsresult nsLDAPURL::SetUserPass(const nsACString& aUserPass) { return NS_OK; }
182
183 NS_IMETHODIMP
GetUsername(nsACString & _retval)184 nsLDAPURL::GetUsername(nsACString& _retval) {
185 _retval.Truncate();
186 return NS_OK;
187 }
188
SetUsername(const nsACString & aUsername)189 nsresult nsLDAPURL::SetUsername(const nsACString& aUsername) { return NS_OK; }
190
191 NS_IMETHODIMP
GetPassword(nsACString & _retval)192 nsLDAPURL::GetPassword(nsACString& _retval) {
193 _retval.Truncate();
194 return NS_OK;
195 }
196
SetPassword(const nsACString & aPassword)197 nsresult nsLDAPURL::SetPassword(const nsACString& aPassword) { return NS_OK; }
198
199 NS_IMETHODIMP
GetHostPort(nsACString & _retval)200 nsLDAPURL::GetHostPort(nsACString& _retval) {
201 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
202
203 return mBaseURL->GetHostPort(_retval);
204 }
205
SetHostPort(const nsACString & aHostPort)206 nsresult nsLDAPURL::SetHostPort(const nsACString& aHostPort) {
207 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
208
209 return NS_MutateURI(mBaseURL).SetHostPort(aHostPort).Finalize(mBaseURL);
210 }
211
212 NS_IMETHODIMP
GetHost(nsACString & _retval)213 nsLDAPURL::GetHost(nsACString& _retval) {
214 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
215
216 return mBaseURL->GetHost(_retval);
217 }
218
SetHost(const nsACString & aHost)219 nsresult nsLDAPURL::SetHost(const nsACString& aHost) {
220 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
221
222 return NS_MutateURI(mBaseURL).SetHost(aHost).Finalize(mBaseURL);
223 }
224
225 NS_IMETHODIMP
GetPort(int32_t * _retval)226 nsLDAPURL::GetPort(int32_t* _retval) {
227 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
228
229 return mBaseURL->GetPort(_retval);
230 }
231
SetPort(int32_t aPort)232 nsresult nsLDAPURL::SetPort(int32_t aPort) {
233 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
234
235 return NS_MutateURI(mBaseURL).SetPort(aPort).Finalize(mBaseURL);
236 }
237
GetPathQueryRef(nsACString & _retval)238 NS_IMETHODIMP nsLDAPURL::GetPathQueryRef(nsACString& _retval) {
239 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
240
241 return mBaseURL->GetPathQueryRef(_retval);
242 }
243
SetPathQueryRef(const nsACString & aPath)244 nsresult nsLDAPURL::SetPathQueryRef(const nsACString& aPath) {
245 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
246
247 nsresult rv = SetPathInternal(PromiseFlatCString(aPath));
248 NS_ENSURE_SUCCESS(rv, rv);
249
250 return NS_MutateURI(mBaseURL).SetPathQueryRef(aPath).Finalize(mBaseURL);
251 }
252
GetAsciiSpec(nsACString & _retval)253 NS_IMETHODIMP nsLDAPURL::GetAsciiSpec(nsACString& _retval) {
254 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
255
256 // XXX handle extra items?
257 return mBaseURL->GetAsciiSpec(_retval);
258 }
259
GetAsciiHost(nsACString & _retval)260 NS_IMETHODIMP nsLDAPURL::GetAsciiHost(nsACString& _retval) {
261 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
262
263 return mBaseURL->GetAsciiHost(_retval);
264 }
265
266 NS_IMETHODIMP
GetAsciiHostPort(nsACString & _retval)267 nsLDAPURL::GetAsciiHostPort(nsACString& _retval) {
268 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
269
270 return mBaseURL->GetAsciiHostPort(_retval);
271 }
272
273 // boolean equals (in nsIURI other)
274 // (based on nsSimpleURI::Equals)
Equals(nsIURI * other,bool * _retval)275 NS_IMETHODIMP nsLDAPURL::Equals(nsIURI* other, bool* _retval) {
276 *_retval = false;
277 if (other) {
278 nsresult rv;
279 nsCOMPtr<nsILDAPURL> otherURL(do_QueryInterface(other, &rv));
280 if (NS_SUCCEEDED(rv)) {
281 nsAutoCString thisSpec, otherSpec;
282 uint32_t otherOptions;
283
284 rv = GetSpec(thisSpec);
285 NS_ENSURE_SUCCESS(rv, rv);
286
287 rv = otherURL->GetSpec(otherSpec);
288 NS_ENSURE_SUCCESS(rv, rv);
289
290 rv = otherURL->GetOptions(&otherOptions);
291 NS_ENSURE_SUCCESS(rv, rv);
292
293 if (thisSpec == otherSpec && mOptions == otherOptions) *_retval = true;
294 }
295 }
296 return NS_OK;
297 }
298
299 // boolean schemeIs(in const char * scheme);
300 //
SchemeIs(const char * aScheme,bool * aEquals)301 NS_IMETHODIMP nsLDAPURL::SchemeIs(const char* aScheme, bool* aEquals) {
302 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
303
304 return mBaseURL->SchemeIs(aScheme, aEquals);
305 }
306
307 // nsIURI clone ();
308 //
Clone(nsIURI ** aResult)309 nsresult nsLDAPURL::Clone(nsIURI** aResult) {
310 NS_ENSURE_ARG_POINTER(aResult);
311
312 nsLDAPURL* clone = new nsLDAPURL();
313
314 if (!clone) return NS_ERROR_OUT_OF_MEMORY;
315
316 clone->mDN = mDN;
317 clone->mScope = mScope;
318 clone->mFilter = mFilter;
319 clone->mOptions = mOptions;
320 clone->mAttributes = mAttributes;
321
322 nsresult rv = NS_MutateURI(mBaseURL).Finalize(clone->mBaseURL);
323 NS_ENSURE_SUCCESS(rv, rv);
324
325 NS_ADDREF(*aResult = clone);
326 return NS_OK;
327 }
328
329 // string resolve (in string relativePath);
330 //
Resolve(const nsACString & relativePath,nsACString & _retval)331 NS_IMETHODIMP nsLDAPURL::Resolve(const nsACString& relativePath,
332 nsACString& _retval) {
333 return NS_ERROR_NOT_IMPLEMENTED;
334 }
335
336 // The following attributes come from nsILDAPURL
337
338 // attribute AUTF8String dn;
339 //
GetDn(nsACString & _retval)340 NS_IMETHODIMP nsLDAPURL::GetDn(nsACString& _retval) {
341 _retval.Assign(mDN);
342 return NS_OK;
343 }
SetDn(const nsACString & aDn)344 NS_IMETHODIMP nsLDAPURL::SetDn(const nsACString& aDn) {
345 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
346
347 mDN.Assign(aDn);
348
349 // Now get the current path
350 nsCString newPath;
351 GetPathInternal(newPath);
352
353 // and update the base url
354 return NS_MutateURI(mBaseURL).SetPathQueryRef(newPath).Finalize(mBaseURL);
355 }
356
GetAttributes(nsACString & aAttributes)357 NS_IMETHODIMP nsLDAPURL::GetAttributes(nsACString& aAttributes) {
358 if (mAttributes.IsEmpty()) {
359 aAttributes.Truncate();
360 return NS_OK;
361 }
362
363 NS_ASSERTION(
364 mAttributes[0] == ',' && mAttributes[mAttributes.Length() - 1] == ',',
365 "mAttributes does not begin and end with a comma");
366
367 // We store the string internally with comma before and after, so strip
368 // them off here.
369 aAttributes = Substring(mAttributes, 1, mAttributes.Length() - 2);
370 return NS_OK;
371 }
372
SetAttributes(const nsACString & aAttributes)373 NS_IMETHODIMP nsLDAPURL::SetAttributes(const nsACString& aAttributes) {
374 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
375
376 if (aAttributes.IsEmpty())
377 mAttributes.Truncate();
378 else {
379 // We need to make sure we start off the string with a comma.
380 if (aAttributes[0] != ',') mAttributes = ',';
381
382 mAttributes.Append(aAttributes);
383
384 // Also end with a comma if appropriate.
385 if (mAttributes[mAttributes.Length() - 1] != ',') mAttributes.Append(',');
386 }
387
388 // Now get the current path
389 nsCString newPath;
390 GetPathInternal(newPath);
391
392 // and update the base url
393 return NS_MutateURI(mBaseURL).SetPathQueryRef(newPath).Finalize(mBaseURL);
394 }
395
SetAttributeArray(char ** aAttributes)396 nsresult nsLDAPURL::SetAttributeArray(char** aAttributes) {
397 mAttributes.Truncate();
398
399 while (aAttributes && *aAttributes) {
400 // Always start with a comma as that's what we store internally.
401 mAttributes.Append(',');
402 mAttributes.Append(*aAttributes);
403 ++aAttributes;
404 }
405
406 // Add a comma on the end if we have something.
407 if (!mAttributes.IsEmpty()) mAttributes.Append(',');
408
409 return NS_OK;
410 }
411
AddAttribute(const nsACString & aAttribute)412 NS_IMETHODIMP nsLDAPURL::AddAttribute(const nsACString& aAttribute) {
413 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
414
415 if (mAttributes.IsEmpty()) {
416 mAttributes = ',';
417 mAttributes.Append(aAttribute);
418 mAttributes.Append(',');
419 } else {
420 // Wrap the attribute in commas, so that we can do an exact match.
421 nsAutoCString findAttribute(",");
422 findAttribute.Append(aAttribute);
423 findAttribute.Append(',');
424
425 // Check to see if the attribute is already stored. If it is, then also
426 // check to see if it is the last attribute in the string, or if the next
427 // character is a comma, this means we won't match substrings.
428 int32_t pos = mAttributes.Find(findAttribute, /* ignoreCase = */ true);
429 if (pos != -1) return NS_OK;
430
431 mAttributes.Append(Substring(findAttribute, 1));
432 }
433
434 // Now get the current path
435 nsCString newPath;
436 GetPathInternal(newPath);
437
438 // and update the base url
439 return NS_MutateURI(mBaseURL).SetPathQueryRef(newPath).Finalize(mBaseURL);
440 }
441
RemoveAttribute(const nsACString & aAttribute)442 NS_IMETHODIMP nsLDAPURL::RemoveAttribute(const nsACString& aAttribute) {
443 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
444
445 if (mAttributes.IsEmpty()) return NS_OK;
446
447 nsAutoCString findAttribute(",");
448 findAttribute.Append(aAttribute);
449 findAttribute.Append(',');
450
451 if (mAttributes.Equals(findAttribute, nsCaseInsensitiveCStringComparator))
452 mAttributes.Truncate();
453 else {
454 int32_t pos = mAttributes.Find(findAttribute, /* ignoreCase = */ true);
455 if (pos == -1) return NS_OK;
456
457 mAttributes.Cut(pos, findAttribute.Length() - 1);
458 }
459
460 // Now get the current path
461 nsCString newPath;
462 GetPathInternal(newPath);
463
464 // and update the base url
465 return NS_MutateURI(mBaseURL).SetPathQueryRef(newPath).Finalize(mBaseURL);
466 }
467
HasAttribute(const nsACString & aAttribute,bool * _retval)468 NS_IMETHODIMP nsLDAPURL::HasAttribute(const nsACString& aAttribute,
469 bool* _retval) {
470 NS_ENSURE_ARG_POINTER(_retval);
471
472 nsAutoCString findAttribute(",");
473 findAttribute.Append(aAttribute);
474 findAttribute.Append(',');
475
476 *_retval = mAttributes.Find(findAttribute, /* ignoreCase = */ true) != -1;
477 return NS_OK;
478 }
479
GetScope(int32_t * _retval)480 NS_IMETHODIMP nsLDAPURL::GetScope(int32_t* _retval) {
481 NS_ENSURE_ARG_POINTER(_retval);
482 *_retval = mScope;
483 return NS_OK;
484 }
485
SetScope(int32_t aScope)486 NS_IMETHODIMP nsLDAPURL::SetScope(int32_t aScope) {
487 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
488
489 // Only allow scopes supported by the C-SDK
490 if ((aScope != SCOPE_BASE) && (aScope != SCOPE_ONELEVEL) &&
491 (aScope != SCOPE_SUBTREE))
492 return NS_ERROR_MALFORMED_URI;
493
494 mScope = aScope;
495
496 // Now get the current path
497 nsCString newPath;
498 GetPathInternal(newPath);
499
500 // and update the base url
501 return NS_MutateURI(mBaseURL).SetPathQueryRef(newPath).Finalize(mBaseURL);
502 }
503
GetFilter(nsACString & _retval)504 NS_IMETHODIMP nsLDAPURL::GetFilter(nsACString& _retval) {
505 _retval.Assign(mFilter);
506 return NS_OK;
507 }
SetFilter(const nsACString & aFilter)508 NS_IMETHODIMP nsLDAPURL::SetFilter(const nsACString& aFilter) {
509 if (!mBaseURL) return NS_ERROR_NOT_INITIALIZED;
510
511 mFilter.Assign(aFilter);
512
513 if (mFilter.IsEmpty()) mFilter.AssignLiteral("(objectclass=*)");
514
515 // Now get the current path
516 nsCString newPath;
517 GetPathInternal(newPath);
518
519 // and update the base url
520 return NS_MutateURI(mBaseURL).SetPathQueryRef(newPath).Finalize(mBaseURL);
521 }
522
GetOptions(uint32_t * _retval)523 NS_IMETHODIMP nsLDAPURL::GetOptions(uint32_t* _retval) {
524 NS_ENSURE_ARG_POINTER(_retval);
525 *_retval = mOptions;
526 return NS_OK;
527 }
528
SetOptions(uint32_t aOptions)529 NS_IMETHODIMP nsLDAPURL::SetOptions(uint32_t aOptions) {
530 // Secure is the only option supported at the moment
531 if ((mOptions & OPT_SECURE) == (aOptions & OPT_SECURE)) return NS_OK;
532
533 mOptions = aOptions;
534
535 if ((aOptions & OPT_SECURE) == OPT_SECURE) return SetScheme(LDAP_SSL_SCHEME);
536
537 return SetScheme(LDAP_SCHEME);
538 }
539
SetRef(const nsACString & aRef)540 nsresult nsLDAPURL::SetRef(const nsACString& aRef) {
541 return NS_MutateURI(mBaseURL).SetRef(aRef).Finalize(mBaseURL);
542 }
543
544 NS_IMETHODIMP
GetRef(nsACString & result)545 nsLDAPURL::GetRef(nsACString& result) { return mBaseURL->GetRef(result); }
546
EqualsExceptRef(nsIURI * other,bool * result)547 NS_IMETHODIMP nsLDAPURL::EqualsExceptRef(nsIURI* other, bool* result) {
548 return mBaseURL->EqualsExceptRef(other, result);
549 }
550
551 NS_IMETHODIMP
GetSpecIgnoringRef(nsACString & result)552 nsLDAPURL::GetSpecIgnoringRef(nsACString& result) {
553 return mBaseURL->GetSpecIgnoringRef(result);
554 }
555
556 NS_IMETHODIMP
GetDisplaySpec(nsACString & aUnicodeSpec)557 nsLDAPURL::GetDisplaySpec(nsACString& aUnicodeSpec) {
558 return mBaseURL->GetDisplaySpec(aUnicodeSpec);
559 }
560
561 NS_IMETHODIMP
GetDisplayHostPort(nsACString & aUnicodeHostPort)562 nsLDAPURL::GetDisplayHostPort(nsACString& aUnicodeHostPort) {
563 return mBaseURL->GetDisplayHostPort(aUnicodeHostPort);
564 }
565
566 NS_IMETHODIMP
GetDisplayHost(nsACString & aUnicodeHost)567 nsLDAPURL::GetDisplayHost(nsACString& aUnicodeHost) {
568 return mBaseURL->GetDisplayHost(aUnicodeHost);
569 }
570
571 NS_IMETHODIMP
GetDisplayPrePath(nsACString & aPrePath)572 nsLDAPURL::GetDisplayPrePath(nsACString& aPrePath) {
573 return mBaseURL->GetDisplayPrePath(aPrePath);
574 }
575
576 NS_IMETHODIMP
GetHasRef(bool * result)577 nsLDAPURL::GetHasRef(bool* result) { return mBaseURL->GetHasRef(result); }
578
579 NS_IMETHODIMP
GetFilePath(nsACString & aFilePath)580 nsLDAPURL::GetFilePath(nsACString& aFilePath) {
581 return mBaseURL->GetFilePath(aFilePath);
582 }
583
SetFilePath(const nsACString & aFilePath)584 nsresult nsLDAPURL::SetFilePath(const nsACString& aFilePath) {
585 return NS_MutateURI(mBaseURL).SetFilePath(aFilePath).Finalize(mBaseURL);
586 }
587
588 NS_IMETHODIMP
GetQuery(nsACString & aQuery)589 nsLDAPURL::GetQuery(nsACString& aQuery) { return mBaseURL->GetQuery(aQuery); }
590
SetQuery(const nsACString & aQuery)591 nsresult nsLDAPURL::SetQuery(const nsACString& aQuery) {
592 return NS_MutateURI(mBaseURL).SetQuery(aQuery).Finalize(mBaseURL);
593 }
594
SetQueryWithEncoding(const nsACString & aQuery,const mozilla::Encoding * aEncoding)595 nsresult nsLDAPURL::SetQueryWithEncoding(const nsACString& aQuery,
596 const mozilla::Encoding* aEncoding) {
597 return NS_MutateURI(mBaseURL)
598 .SetQueryWithEncoding(aQuery, aEncoding)
599 .Finalize(mBaseURL);
600 }
601
NS_IMETHODIMP_(void)602 NS_IMETHODIMP_(void)
603 nsLDAPURL::Serialize(mozilla::ipc::URIParams& aParams) {
604 mBaseURL->Serialize(aParams);
605 }
606
NS_IMPL_ISUPPORTS(nsLDAPURL::Mutator,nsIURISetters,nsIURIMutator)607 NS_IMPL_ISUPPORTS(nsLDAPURL::Mutator, nsIURISetters, nsIURIMutator)
608
609 NS_IMETHODIMP
610 nsLDAPURL::Mutate(nsIURIMutator** aMutator) {
611 RefPtr<nsLDAPURL::Mutator> mutator = new nsLDAPURL::Mutator();
612 nsresult rv = mutator->InitFromURI(this);
613 if (NS_FAILED(rv)) {
614 return rv;
615 }
616 mutator.forget(aMutator);
617 return NS_OK;
618 }
619