reSIProcate/repro  9694
CertSubscriptionHandler.cxx
Go to the documentation of this file.
00001 #include "resip/stack/ssl/Security.hxx"
00002 #include "resip/stack/X509Contents.hxx"
00003 #include "repro/stateAgents/CertSubscriptionHandler.hxx"
00004 
00005 using namespace repro;
00006 using namespace resip;
00007 
00008 CertSubscriptionHandler::CertSubscriptionHandler(Security& security) : mSecurity(security)
00009 {
00010 }
00011 
00012 void 
00013 CertSubscriptionHandler::onNewSubscription(ServerSubscriptionHandle h, const SipMessage& sub)
00014 {
00015    if (!mSecurity.hasUserCert(h->getDocumentKey()))
00016    {
00017       // !jf! really need to do this async. send neutral state in the meantime,
00018       // blah blah blah
00019       mSecurity.generateUserCert(h->getDocumentKey());
00020    }
00021 
00022    if (mSecurity.hasUserCert(h->getDocumentKey()))
00023    {
00024       X509Contents x509(mSecurity.getUserCertDER(h->getDocumentKey()));
00025       h->send(h->update(&x509));
00026    }
00027    else
00028    {
00029       h->reject(404);
00030    }
00031 }
00032 
00033 void 
00034 CertSubscriptionHandler::onPublished(ServerSubscriptionHandle associated, 
00035                                      ServerPublicationHandle publication, 
00036                                      const Contents* contents,
00037                                      const SecurityAttributes* attrs)
00038 {
00039    associated->send(associated->update(contents));
00040 }
00041 
00042 
00043 void 
00044 CertSubscriptionHandler::onTerminated(ServerSubscriptionHandle)
00045 {
00046 }
00047 
00048 void 
00049 CertSubscriptionHandler::onError(ServerSubscriptionHandle, const SipMessage& msg)
00050 {
00051 }
00052