|
reSIProcate/DialogUsageManager
9694
|
00001 #include "resip/stack/PlainContents.hxx" 00002 #include "resip/stack/Pkcs7Contents.hxx" 00003 #include "resip/stack/MultipartSignedContents.hxx" 00004 #include "resip/stack/MultipartAlternativeContents.hxx" 00005 #include "resip/stack/Mime.hxx" 00006 00007 #include "resip/stack/SecurityAttributes.hxx" 00008 #include "resip/stack/Helper.hxx" 00009 00010 #include "rutil/Log.hxx" 00011 #include "rutil/Logger.hxx" 00012 00013 #ifdef WIN32 00014 #include "resip/stack/XWinSecurity.hxx" 00015 #endif 00016 00017 #include <iostream> 00018 #include <string> 00019 #include <sstream> 00020 00021 using namespace std; 00022 using namespace resip; 00023 00024 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST 00025 00026 00027 int main(int argc, char *argv[]) 00028 { 00029 00030 //Log::initialize(Log::Cout, Log::Debug, argv[0]); 00031 Log::initialize(Log::Cout, Log::Info, argv[0]); 00032 00033 00034 #ifdef WIN32 00035 Security* security = new XWinSecurity; 00036 #else 00037 Security* security = new Security; 00038 #endif 00039 00040 Data aor("jdoe@internal.xten.net"); 00041 00042 security->preload(); 00043 security->hasUserPrivateKey(aor); 00044 security->hasUserCert(aor); 00045 00046 Contents* contents = new PlainContents(Data("v=0\r\n" 00047 "o=1900 369696545 369696545 IN IP4 192.168.2.15\r\n" 00048 "s=X-Lite\r\n" 00049 "c=IN IP4 192.168.2.15\r\n" 00050 "t=0 0\r\n" 00051 "m=audio 8001 RTP/AVP 8 3 98 97 101\r\n" 00052 "a=rtpmap:8 pcma/8000\r\n" 00053 "a=rtpmap:3 gsm/8000\r\n" 00054 "a=rtpmap:98 iLBC\r\n" 00055 "a=rtpmap:97 speex/8000\r\n" 00056 "a=rtpmap:101 telephone-event/8000\r\n" 00057 "a=fmtp:101 0-15\r\n")); 00058 00059 //Pkcs7Contents* encrypted = security->encrypt(contents, aor); 00060 //InfoLog(<< "Encrytped content: " << *encrypted ); 00061 //Contents* decrypted = security->decrypt(aor, encrypted); 00062 //if (decrypted) 00063 //{ 00064 // InfoLog(<< "Decrypted content: " << decrypted->getBodyData() ); 00065 //} 00066 MultipartSignedContents* msc = security->sign(aor, contents); 00067 InfoLog(<< "Signed: " << *msc); 00068 00069 00070 SecurityAttributes attr; 00071 Data signer; 00072 SignatureStatus sigStatus; 00073 Contents* ret = security->checkSignature(msc, &signer, &sigStatus); 00074 assert(ret); 00075 InfoLog(<< "Signature status:" << sigStatus); 00076 00077 delete contents; 00078 delete msc; 00079 //delete decrypted; 00080 //delete encrypted; 00081 delete security; 00082 return 0; 00083 } 00084 00085 /* ==================================================================== 00086 * The Vovida Software License, Version 1.0 00087 * 00088 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00089 * 00090 * Redistribution and use in source and binary forms, with or without 00091 * modification, are permitted provided that the following conditions 00092 * are met: 00093 * 00094 * 1. Redistributions of source code must retain the above copyright 00095 * notice, this list of conditions and the following disclaimer. 00096 * 00097 * 2. Redistributions in binary form must reproduce the above copyright 00098 * notice, this list of conditions and the following disclaimer in 00099 * the documentation and/or other materials provided with the 00100 * distribution. 00101 * 00102 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00103 * and "Vovida Open Communication Application Library (VOCAL)" must 00104 * not be used to endorse or promote products derived from this 00105 * software without prior written permission. For written 00106 * permission, please contact vocal@vovida.org. 00107 * 00108 * 4. Products derived from this software may not be called "VOCAL", nor 00109 * may "VOCAL" appear in their name, without prior written 00110 * permission of Vovida Networks, Inc. 00111 * 00112 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00113 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00114 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00115 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00116 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00117 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00118 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00119 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00120 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00122 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00123 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00124 * DAMAGE. 00125 * 00126 * ==================================================================== 00127 * 00128 * This software consists of voluntary contributions made by Vovida 00129 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00130 * Inc. For more information on Vovida Networks, Inc., please see 00131 * <http://www.vovida.org/>. 00132 * 00133 */
1.7.5.1