reSIProcate/repro  9694
PrivateKeyPublicationHandler.cxx
Go to the documentation of this file.
00001 #include "resip/stack/ssl/Security.hxx"
00002 #include "resip/stack/Pkcs8Contents.hxx"
00003 #include "resip/dum/ServerPublication.hxx"
00004 #include "repro/stateAgents/PrivateKeyPublicationHandler.hxx"
00005 
00006 using namespace repro;
00007 using namespace resip;
00008 
00009 PrivateKeyPublicationHandler::PrivateKeyPublicationHandler(Security& security) : mSecurity(security)
00010 {
00011 }
00012 
00013 void 
00014 PrivateKeyPublicationHandler::onInitial(ServerPublicationHandle h, 
00015                                         const Data& etag, 
00016                                         const SipMessage& pub, 
00017                                         const Contents* contents,
00018                                         const SecurityAttributes* attrs, 
00019                                         UInt32 expires)
00020 {
00021    add(h, contents);
00022 }
00023 
00024 void 
00025 PrivateKeyPublicationHandler::onExpired(ServerPublicationHandle h, const Data& etag)
00026 {
00027    mSecurity.removeUserPrivateKey(h->getPublisher());
00028 }
00029 
00030 void 
00031 PrivateKeyPublicationHandler::onRefresh(ServerPublicationHandle, 
00032                                         const Data& etag, 
00033                                         const SipMessage& pub, 
00034                                         const Contents* contents,
00035                                         const SecurityAttributes* attrs,
00036                                         UInt32 expires)
00037 {
00038 }
00039 
00040 void 
00041 PrivateKeyPublicationHandler::onUpdate(ServerPublicationHandle h, 
00042                                        const Data& etag, 
00043                                        const SipMessage& pub, 
00044                                        const Contents* contents,
00045                                        const SecurityAttributes* attrs,
00046                                        UInt32 expires)
00047 {
00048    add(h, contents);
00049 }
00050 
00051 void 
00052 PrivateKeyPublicationHandler::onRemoved(ServerPublicationHandle h, const Data& etag, const SipMessage& pub, UInt32 expires)
00053 {
00054    mSecurity.removeUserPrivateKey(h->getPublisher());
00055 }
00056 
00057 void 
00058 PrivateKeyPublicationHandler::add(ServerPublicationHandle h, const Contents* contents)
00059 {
00060    if (h->getDocumentKey() == h->getPublisher())
00061    {
00062       const Pkcs8Contents* pkcs8 = dynamic_cast<const Pkcs8Contents*>(contents);
00063       assert(pkcs8);
00064       mSecurity.addUserPrivateKeyDER(h->getPublisher(), pkcs8->getBodyData());
00065    }
00066    else
00067    {
00068       h->send(h->accept(403)); // !jf! is this the correct code? 
00069    }
00070 }
00071