reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
UserAuthData.cxx
Go to the documentation of this file.
1#include "UserAuthData.hxx"
2
5
6#include "ReTurnSubsystem.hxx"
7
8#define RESIPROCATE_SUBSYSTEM ReTurnSubsystem::RETURN
9
10using namespace std;
11using namespace resip;
12
13namespace reTurn {
14
15UserAuthData::UserAuthData(const resip::Data& userName, const resip::Data& realm, const resip::Data& ha1) :
16 mUserName(userName),
17 mRealm(realm),
18 mHa1(ha1)
19{
20}
21
25
27UserAuthData::createFromPassword(const resip::Data& userName, const resip::Data& realm, const resip::Data& password)
28{
30 r << userName << ":" << realm << ":" << password;
31 Data ha1(r.getBin());
32 return UserAuthData(userName, realm, ha1);
33}
34
36UserAuthData::createFromHex(const resip::Data& userName, const resip::Data& realm, const resip::Data& ha1Hex)
37{
38 if(ha1Hex.size() != 32)
39 {
40 throw ConfigParse::Exception("H(A1) password field must contain 32 character hex string", __FILE__, __LINE__);
41 }
42 return UserAuthData(userName, realm, ha1Hex.fromHex());
43}
44
45} // namespace
46
47
48/* ====================================================================
49
50 Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
51 Copyright (c) 2012, Ready Technology (UK) Limited
52 All rights reserved.
53
54 Redistribution and use in source and binary forms, with or without
55 modification, are permitted provided that the following conditions are
56 met:
57
58 1. Redistributions of source code must retain the above copyright
59 notice, this list of conditions and the following disclaimer.
60
61 2. Redistributions in binary form must reproduce the above copyright
62 notice, this list of conditions and the following disclaimer in the
63 documentation and/or other materials provided with the distribution.
64
65 3. Neither the name of Ready Technology nor the names of its contributors
66 may be used to endorse or promote products derived from this
67 software without specific prior written permission.
68
69 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
70 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
71 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
72 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
73 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
74 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
75 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
76 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
77 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
79 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
80
81 ==================================================================== */
UserAuthData(const resip::Data &userName, const resip::Data &realm, const resip::Data &ha1)
static UserAuthData createFromHex(const resip::Data &userName, const resip::Data &realm, const resip::Data &ha1Hex)
static UserAuthData createFromPassword(const resip::Data &userName, const resip::Data &realm, const resip::Data &password)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
size_type size() const noexcept
Returns the number of bytes in this Data.
Definition Data.hxx:599
Data fromHex() const
Returns the binary form of the hexadecimal string in this Data.
Definition Data.cxx:1599
Used to accumlate data written to the stream in a DigestBuffer and convert the data to Digest.
const Data & getBin()
dcm! – add UnusedChecking(_enum) below;