/[resiprocate]/main/resip/dum/test/testSecurity.cxx
ViewVC logotype

Annotation of /main/resip/dum/test/testSecurity.cxx

Parent Directory Parent Directory | Revision Log Revision Log


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

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27