/[resiprocate]/branches/b-smime-0605/dum/test/testSecurity.cxx
ViewVC logotype

Contents of /branches/b-smime-0605/dum/test/testSecurity.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5037 - (show annotations) (download)
Thu Jul 7 18:33:00 2005 UTC (14 years, 6 months ago) by daniel
File size: 4656 byte(s)
simple unit test for security class.
1 #include "resiprocate/PlainContents.hxx"
2 #include "resiprocate/Pkcs7Contents.hxx"
3 #include "resiprocate/MultipartSignedContents.hxx"
4 #include "resiprocate/Mime.hxx"
5
6 #include "resiprocate/SecurityAttributes.hxx"
7 #include "resiprocate/Helper.hxx"
8
9 #include "resiprocate/os/Log.hxx"
10 #include "resiprocate/os/Logger.hxx"
11
12 #ifdef WIN32
13 #include "resiprocate/XWinSecurity.hxx"
14 #endif
15
16 #include <iostream>
17 #include <string>
18 #include <sstream>
19
20 using namespace std;
21 using namespace resip;
22
23 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
24
25
26 int main(int argc, char *argv[])
27 {
28
29 //Log::initialize(Log::Cout, Log::Debug, argv[0]);
30 Log::initialize(Log::Cout, Log::Info, argv[0]);
31
32
33 #ifdef WIN32
34 Security* security = new XWinSecurity;
35 #else
36 Security* security = new Security;
37 #endif
38
39 Data aor = "daniel@internal.xten.net";
40
41 security->preload();
42 security->hasUserPrivateKey(aor);
43 security->hasUserCert(aor);
44
45 Contents* contents = new PlainContents(Data("v=0\r\n"
46 "o=1900 369696545 369696545 IN IP4 192.168.2.15\r\n"
47 "s=X-Lite\r\n"
48 "c=IN IP4 192.168.2.15\r\n"
49 "t=0 0\r\n"
50 "m=audio 8001 RTP/AVP 8 3 98 97 101\r\n"
51 "a=rtpmap:8 pcma/8000\r\n"
52 "a=rtpmap:3 gsm/8000\r\n"
53 "a=rtpmap:98 iLBC\r\n"
54 "a=rtpmap:97 speex/8000\r\n"
55 "a=rtpmap:101 telephone-event/8000\r\n"
56 "a=fmtp:101 0-15\r\n"));
57 //Pkcs7Contents* encrypted = security->encrypt(contents, aor);
58 //InfoLog(<< "Encrytped content: " << *encrypted );
59 //Contents* decrypted = security->decrypt(aor, encrypted);
60 //if (decrypted)
61 //{
62 // InfoLog(<< "Decrypted content: " << decrypted->getBodyData() );
63 //}
64 MultipartSignedContents* msc = security->sign(aor, contents);
65 InfoLog(<< "Signed: " << *msc);
66
67
68 SecurityAttributes attr;
69 Data signer;
70 SignatureStatus sigStatus;
71 Contents* ret = security->checkSignature(msc, &signer, &sigStatus);
72 assert(ret);
73 InfoLog(<< "Signature status:" << sigStatus);
74
75 delete contents;
76 delete msc;
77 //delete decrypted;
78 //delete encrypted;
79 delete security;
80 return 0;
81 }
82
83 /* ====================================================================
84 * The Vovida Software License, Version 1.0
85 *
86 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
87 *
88 * Redistribution and use in source and binary forms, with or without
89 * modification, are permitted provided that the following conditions
90 * are met:
91 *
92 * 1. Redistributions of source code must retain the above copyright
93 * notice, this list of conditions and the following disclaimer.
94 *
95 * 2. Redistributions in binary form must reproduce the above copyright
96 * notice, this list of conditions and the following disclaimer in
97 * the documentation and/or other materials provided with the
98 * distribution.
99 *
100 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
101 * and "Vovida Open Communication Application Library (VOCAL)" must
102 * not be used to endorse or promote products derived from this
103 * software without prior written permission. For written
104 * permission, please contact vocal@vovida.org.
105 *
106 * 4. Products derived from this software may not be called "VOCAL", nor
107 * may "VOCAL" appear in their name, without prior written
108 * permission of Vovida Networks, Inc.
109 *
110 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
111 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
112 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
113 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
114 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
115 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
116 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
117 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
118 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
119 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
120 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
121 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
122 * DAMAGE.
123 *
124 * ====================================================================
125 *
126 * This software consists of voluntary contributions made by Vovida
127 * Networks, Inc. and many individuals on behalf of Vovida Networks,
128 * Inc. For more information on Vovida Networks, Inc., please see
129 * <http://www.vovida.org/>.
130 *
131 */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27