/[resiprocate]/main/resip/dum/IdentityHandler.cxx
ViewVC logotype

Contents of /main/resip/dum/IdentityHandler.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9485 - (show annotations) (download)
Sat Apr 7 00:34:03 2012 UTC (7 years, 7 months ago) by dpocock
File MIME type: text/plain
File size: 3123 byte(s)
Switch over to autotools build system from dpocock-autotools branch
1
2 #if defined(HAVE_CONFIG_H)
3 #include "config.h"
4 #endif
5
6 #include "rutil/Logger.hxx"
7 #include "resip/stack/SipMessage.hxx"
8 #include "resip/dum/IdentityHandler.hxx"
9 #include "resip/dum/HttpProvider.hxx"
10 #include "resip/dum/HttpGetMessage.hxx"
11 #include "resip/dum/DialogUsageManager.hxx"
12 #include "rutil/WinLeakCheck.hxx"
13
14 #ifdef USE_SSL
15 #include "resip/stack/ssl/Security.hxx"
16 #endif
17
18 using namespace resip;
19 using namespace std;
20
21 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM
22
23 IdentityHandler::IdentityHandler(DialogUsageManager& dum, TargetCommand::Target& target)
24 : DumFeature(dum, target)
25 {
26 }
27
28 IdentityHandler::~IdentityHandler()
29 {
30 for (RequiresCerts::iterator it = mRequiresCerts.begin(); it != mRequiresCerts.end(); ++it)
31 {
32 delete it->second;
33 }
34 }
35
36 DumFeature::ProcessingResult
37 IdentityHandler::process(Message* msg)
38 {
39 SipMessage* sipMsg = dynamic_cast<SipMessage*>(msg);
40 if (sipMsg)
41 {
42 if (queueForIdentityCheck(sipMsg))
43 {
44 return EventTaken;
45 }
46 else
47 {
48 return FeatureDone;
49 }
50 }
51
52 HttpGetMessage* httpMsg = dynamic_cast<HttpGetMessage*>(msg);
53 if (httpMsg)
54 {
55 processIdentityCheckResponse(*httpMsg);
56 return FeatureDoneAndEventDone;
57 }
58
59 return FeatureDone;
60 }
61
62 bool
63 IdentityHandler::queueForIdentityCheck(SipMessage* sipMsg)
64 {
65 #if defined(USE_SSL)
66 if (sipMsg->exists(h_Identity) &&
67 sipMsg->exists(h_IdentityInfo) &&
68 sipMsg->exists(h_Date))
69 {
70 if (mDum.getSecurity()->hasDomainCert(sipMsg->header(h_From).uri().host()))
71 {
72 mDum.getSecurity()->checkAndSetIdentity(*sipMsg);
73 return false;
74 }
75 else
76 {
77 if (!HttpProvider::instance())
78 {
79 return false;
80 }
81
82 try
83 {
84 mRequiresCerts[sipMsg->getTransactionId()] = sipMsg;
85 InfoLog( << "Dum::queueForIdentityCheck, sending http request to: "
86 << sipMsg->header(h_IdentityInfo));
87
88 HttpProvider::instance()->get(sipMsg->header(h_IdentityInfo),
89 sipMsg->getTransactionId(),
90 mDum,
91 mDum.dumIncomingTarget());
92 return true;
93 }
94 catch (BaseException&)
95 {
96 }
97 }
98 }
99 #endif
100
101 std::auto_ptr<SecurityAttributes> sec(new SecurityAttributes);
102 sec->setIdentity(sipMsg->header(h_From).uri().getAor());
103 sec->setIdentityStrength(SecurityAttributes::From);
104 sipMsg->setSecurityAttributes(sec);
105 return false;
106 }
107
108 void
109 IdentityHandler::processIdentityCheckResponse(const HttpGetMessage& msg)
110 {
111 #if defined(USE_SSL)
112 InfoLog(<< "DialogUsageManager::processIdentityCheckResponse: " << msg.brief());
113 RequiresCerts::iterator it = mRequiresCerts.find(msg.getTransactionId());
114 if (it != mRequiresCerts.end())
115 {
116 mDum.getSecurity()->checkAndSetIdentity( *it->second, msg.getBodyData() );
117 postCommand(auto_ptr<Message>(it->second));
118 mRequiresCerts.erase(it);
119 }
120 #endif
121 }

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27