reSIProcate/DialogUsageManager  9694
Defines | Functions
testSecurity.cxx File Reference
#include "resip/stack/PlainContents.hxx"
#include "resip/stack/Pkcs7Contents.hxx"
#include "resip/stack/MultipartSignedContents.hxx"
#include "resip/stack/MultipartAlternativeContents.hxx"
#include "resip/stack/Mime.hxx"
#include "resip/stack/SecurityAttributes.hxx"
#include "resip/stack/Helper.hxx"
#include "rutil/Log.hxx"
#include "rutil/Logger.hxx"
#include <iostream>
#include <string>
#include <sstream>
Include dependency graph for testSecurity.cxx:

Go to the source code of this file.

Defines

#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST

Functions

int main (int argc, char *argv[])

Define Documentation

#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST

Definition at line 24 of file testSecurity.cxx.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 27 of file testSecurity.cxx.

References resip::BaseSecurity::checkSignature(), resip::BaseSecurity::hasUserCert(), resip::BaseSecurity::hasUserPrivateKey(), InfoLog, resip::Security::preload(), and resip::BaseSecurity::sign().

{

   //Log::initialize(Log::Cout, Log::Debug, argv[0]);
   Log::initialize(Log::Cout, Log::Info, argv[0]);


#ifdef WIN32
   Security* security = new XWinSecurity;
#else
   Security* security = new Security;
#endif

   Data aor("jdoe@internal.xten.net");

   security->preload();
   security->hasUserPrivateKey(aor);
   security->hasUserCert(aor);

   Contents* contents = new PlainContents(Data("v=0\r\n"
                        "o=1900 369696545 369696545 IN IP4 192.168.2.15\r\n"
                        "s=X-Lite\r\n"
                        "c=IN IP4 192.168.2.15\r\n"
                        "t=0 0\r\n"
                        "m=audio 8001 RTP/AVP 8 3 98 97 101\r\n"
                        "a=rtpmap:8 pcma/8000\r\n"
                        "a=rtpmap:3 gsm/8000\r\n"
                        "a=rtpmap:98 iLBC\r\n"
                        "a=rtpmap:97 speex/8000\r\n"
                        "a=rtpmap:101 telephone-event/8000\r\n"
                        "a=fmtp:101 0-15\r\n"));

   //Pkcs7Contents* encrypted = security->encrypt(contents, aor);
   //InfoLog(<< "Encrytped content: " << *encrypted );
   //Contents* decrypted = security->decrypt(aor, encrypted);
   //if (decrypted) 
   //{
   //   InfoLog(<< "Decrypted content: " << decrypted->getBodyData() );
   //}
   MultipartSignedContents* msc = security->sign(aor, contents);
   InfoLog(<< "Signed: " << *msc);


   SecurityAttributes attr;
   Data signer;
   SignatureStatus sigStatus;
   Contents* ret = security->checkSignature(msc, &signer, &sigStatus);
   assert(ret);
   InfoLog(<< "Signature status:" << sigStatus);   
   
   delete contents;
   delete msc;
   //delete decrypted;
   //delete encrypted;
   delete security;
   return 0;
}

Here is the call graph for this function: