summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/PeerIdentity.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/webrtc/PeerIdentity.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/webrtc/PeerIdentity.h')
-rw-r--r--dom/media/webrtc/PeerIdentity.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/dom/media/webrtc/PeerIdentity.h b/dom/media/webrtc/PeerIdentity.h
new file mode 100644
index 000000000..bdfa1d2b3
--- /dev/null
+++ b/dom/media/webrtc/PeerIdentity.h
@@ -0,0 +1,81 @@
+ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=2 sts=2 expandtab
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef PeerIdentity_h
+#define PeerIdentity_h
+
+#ifdef MOZILLA_INTERNAL_API
+#include "nsString.h"
+#else
+#include "nsStringAPI.h"
+#endif
+
+template <class T> class nsCOMPtr;
+class nsIIDNService;
+
+namespace mozilla {
+
+/**
+ * This class implements the identifier used in WebRTC identity. Peers are
+ * identified using a string in the form [<user>@]<domain>, for instance,
+ * "user@example.com'. The (optional) user portion is a site-controlled string
+ * containing any character other than '@'. The domain portion is a valid IDN
+ * domain name and is compared accordingly.
+ *
+ * See: http://tools.ietf.org/html/draft-ietf-rtcweb-security-arch-09#section-5.6.5.3.3.1
+ */
+class PeerIdentity final : public RefCounted<PeerIdentity>
+{
+public:
+ MOZ_DECLARE_REFCOUNTED_TYPENAME(PeerIdentity)
+
+ explicit PeerIdentity(const nsAString& aPeerIdentity)
+ : mPeerIdentity(aPeerIdentity) {}
+ ~PeerIdentity() {}
+
+ bool Equals(const PeerIdentity& aOther) const;
+ bool Equals(const nsAString& aOtherString) const;
+ const nsString& ToString() const { return mPeerIdentity; }
+
+private:
+ static void GetUser(const nsAString& aPeerIdentity, nsAString& aUser);
+ static void GetHost(const nsAString& aPeerIdentity, nsAString& aHost);
+
+ static void GetNormalizedHost(const nsCOMPtr<nsIIDNService>& aIdnService,
+ const nsAString& aHost,
+ nsACString& aNormalizedHost);
+
+ nsString mPeerIdentity;
+};
+
+inline bool
+operator==(const PeerIdentity& aOne, const PeerIdentity& aTwo)
+{
+ return aOne.Equals(aTwo);
+}
+
+inline bool
+operator==(const PeerIdentity& aOne, const nsAString& aString)
+{
+ return aOne.Equals(aString);
+}
+
+inline bool
+operator!=(const PeerIdentity& aOne, const PeerIdentity& aTwo)
+{
+ return !aOne.Equals(aTwo);
+}
+
+inline bool
+operator!=(const PeerIdentity& aOne, const nsAString& aString)
+{
+ return !aOne.Equals(aString);
+}
+
+
+} /* namespace mozilla */
+
+#endif /* PeerIdentity_h */