reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
IdentityHandler.cxx
Go to the documentation of this file.
1
2#if defined(HAVE_CONFIG_H)
3 #include "config.h"
4#endif
5
6#include "rutil/Logger.hxx"
13
14#ifdef USE_SSL
16#endif
17
18using namespace resip;
19using namespace std;
20
21#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
22
23// TODO !SLG! RFC4474 has been deprecated by RFC8224 (Authenticated Identity Management). We should remove/adjust this code.
24
29
31{
32 for (RequiresCerts::iterator it = mRequiresCerts.begin(); it != mRequiresCerts.end(); ++it)
33 {
34 delete it->second;
35 }
36}
37
40{
41 SipMessage* sipMsg = dynamic_cast<SipMessage*>(msg);
42 if (sipMsg)
43 {
44 if (queueForIdentityCheck(sipMsg))
45 {
46 return EventTaken;
47 }
48 else
49 {
50 return FeatureDone;
51 }
52 }
53
54 HttpGetMessage* httpMsg = dynamic_cast<HttpGetMessage*>(msg);
55 if (httpMsg)
56 {
57 processIdentityCheckResponse(*httpMsg);
59 }
60
61 return FeatureDone;
62}
63
64bool
65IdentityHandler::queueForIdentityCheck(SipMessage* sipMsg)
66{
67#if defined(USE_SSL)
68 if (sipMsg->exists(h_Identities) &&
69 sipMsg->header(h_Identities).size() > 0 &&
70 sipMsg->exists(h_IdentityInfo) &&
71 sipMsg->exists(h_Date))
72 {
73 if (mDum.getSecurity()->hasDomainCert(sipMsg->header(h_From).uri().host()))
74 {
76 return false;
77 }
78 else
79 {
81 {
82 return false;
83 }
84
85 try
86 {
87 mRequiresCerts[sipMsg->getTransactionId()] = sipMsg;
88 InfoLog( << "Dum::queueForIdentityCheck, sending http request to: "
89 << sipMsg->header(h_IdentityInfo));
90
91 HttpProvider::instance()->get(sipMsg->header(h_IdentityInfo),
92 sipMsg->getTransactionId(),
93 mDum,
95 return true;
96 }
97 catch (BaseException&)
98 {
99 }
100 }
101 }
102#endif
103
104 std::unique_ptr<SecurityAttributes> sec(new SecurityAttributes);
105 sec->setIdentity(sipMsg->header(h_From).uri().getAor());
106 sec->setIdentityStrength(SecurityAttributes::From);
107 sipMsg->setSecurityAttributes(std::move(sec));
108 return false;
109}
110
111void
112IdentityHandler::processIdentityCheckResponse(const HttpGetMessage& msg)
113{
114#if defined(USE_SSL)
115 InfoLog(<< "DialogUsageManager::processIdentityCheckResponse: " << msg.brief());
116 RequiresCerts::iterator it = mRequiresCerts.find(msg.getTransactionId());
117 if (it != mRequiresCerts.end())
118 {
119 mDum.getSecurity()->checkAndSetIdentity( *it->second, msg.getBodyData() );
120 postCommand(unique_ptr<Message>(it->second));
121 mRequiresCerts.erase(it);
122 }
123#endif
124}
#define InfoLog(args_)
Definition Logger.hxx:131
The abstract base-class for all exceptions thrown by resip code.
void checkAndSetIdentity(SipMessage &msg, const Data &derCert=Data::Empty) const
bool hasDomainCert(const Data &domainName, bool logErrors=true) const
TargetCommand::Target & dumIncomingTarget()
virtual const Data & getTransactionId() const
DialogUsageManager & mDum
virtual void postCommand(std::unique_ptr< Message > message)
const Data & getBodyData() const
virtual void get(const GenericUri &target, const Data &tid, TransactionUser &tu, TargetCommand::Target &commandTarget)=0
static HttpProvider * instance()
virtual ProcessingResult process(Message *msg)
IdentityHandler(DialogUsageManager &dum, TargetCommand::Target &target)
The base-class used for message-passing.
Definition Message.hxx:21
virtual Brief brief() const
return a facet for brief encoding of message
Definition Message.cxx:16
const Uri & uri() const
Represents a SIP message.
void setSecurityAttributes(std::unique_ptr< SecurityAttributes >) noexcept
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
virtual const Data & getTransactionId() const
Returns the transaction id from the branch or if 2543, the computed hash.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
Data getAor() const
Definition Uri.cxx:1095
Data & host()
Definition Uri.hxx:40
dcm! – add UnusedChecking(_enum) below;
H_Identitys h_Identities
Definition Headers.cxx:315