nsAuthInformationHolder.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef NSAUTHINFORMATIONHOLDER_H_
  5. #define NSAUTHINFORMATIONHOLDER_H_
  6. #include "nsIAuthInformation.h"
  7. #include "nsString.h"
  8. class nsAuthInformationHolder : public nsIAuthInformation {
  9. protected:
  10. virtual ~nsAuthInformationHolder() {}
  11. public:
  12. // aAuthType must be ASCII
  13. nsAuthInformationHolder(uint32_t aFlags, const nsString& aRealm,
  14. const nsCString& aAuthType)
  15. : mFlags(aFlags), mRealm(aRealm), mAuthType(aAuthType) {}
  16. NS_DECL_ISUPPORTS
  17. NS_DECL_NSIAUTHINFORMATION
  18. const nsString& User() const { return mUser; }
  19. const nsString& Password() const { return mPassword; }
  20. const nsString& Domain() const { return mDomain; }
  21. /**
  22. * This method can be used to initialize the username when the
  23. * ONLY_PASSWORD flag is set.
  24. */
  25. void SetUserInternal(const nsString& aUsername) {
  26. mUser = aUsername;
  27. }
  28. private:
  29. nsString mUser;
  30. nsString mPassword;
  31. nsString mDomain;
  32. uint32_t mFlags;
  33. nsString mRealm;
  34. nsCString mAuthType;
  35. };
  36. #endif