/[resiprocate]/main/resip/stack/test/testIdentity.cxx
ViewVC logotype

Contents of /main/resip/stack/test/testIdentity.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4599 - (show annotations) (download)
Wed May 11 23:10:19 2005 UTC (14 years, 7 months ago) by derek
Original Path: main/sip/resiprocate/test/testIdentity.cxx
File size: 4116 byte(s)
set svn:eol-style to LF
1
2 #include <cassert>
3 #include <fstream>
4 #include <ostream>
5
6 #include "resiprocate/os/Logger.hxx"
7 #include "resiprocate/Security.hxx"
8
9
10 using namespace resip;
11 using namespace std;
12
13 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
14
15
16 int
17 main(int argc, char* argv[])
18 {
19 Log::initialize(Log::Cout, Log::Debug, Data::Empty);
20
21 #ifdef USE_SSL
22 Security* security=0;
23 try
24 {
25 security = new Security;
26 }
27 catch( ... )
28 {
29 security = 0;
30 ErrLog( << "Got a exception setting up Security" );
31 }
32
33 try
34 {
35 assert(security != 0);
36 security->preload();
37 }
38 catch( ... )
39 {
40 ErrLog( << "Got a exception loading certificates" );
41 }
42
43 assert( security );
44
45 Data in("sip:alice@atlanta.example.com"
46 ":a84b4c76e66710"
47 ":314159 INVITE"
48 ":Thu, 21 Feb 2002 13:02:03 GMT"
49 ":sip:alice@pc33.atlanta.example.com"
50 ":v=0\r\n"
51 "o=UserA 2890844526 2890844526 IN IP4 pc33.atlanta.example.com\r\n"
52 "s=Session SDP\r\n"
53 "c=IN IP4 pc33.atlanta.example.com\r\n"
54 "t=0 0\r\n"
55 "m=audio 49172 RTP/AVP 0\r\n"
56 "a=rtpmap:0 PCMU/8000\r\n");
57
58 ofstream strm("identiy-in", std::ios_base::trunc);
59 strm.write( in.data(), in.size() );
60 strm.flush();
61
62 Data res = security->computeIdentity( Data("localhost"), in );
63
64 //ErrLog( << "input is encoded " << in.charEncoded() );
65 //ErrLog( << "input is hex " << in.hex() );
66 //ErrLog( << "input is " << in );
67 //ErrLog( << "identity is " << res );
68
69 bool c = security->checkIdentity( Data("localhost"), in , res );
70
71 if ( !c )
72 {
73 ErrLog( << "Identity check failed" << res );
74 }
75
76
77 #endif // use_ssl
78
79 return 0;
80 }
81
82 /* ====================================================================
83 * The Vovida Software License, Version 1.0
84 *
85 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
86 *
87 * Redistribution and use in source and binary forms, with or without
88 * modification, are permitted provided that the following conditions
89 * are met:
90 *
91 * 1. Redistributions of source code must retain the above copyright
92 * notice, this list of conditions and the following disclaimer.
93 *
94 * 2. Redistributions in binary form must reproduce the above copyright
95 * notice, this list of conditions and the following disclaimer in
96 * the documentation and/or other materials provided with the
97 * distribution.
98 *
99 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
100 * and "Vovida Open Communication Application Library (VOCAL)" must
101 * not be used to endorse or promote products derived from this
102 * software without prior written permission. For written
103 * permission, please contact vocal@vovida.org.
104 *
105 * 4. Products derived from this software may not be called "VOCAL", nor
106 * may "VOCAL" appear in their name, without prior written
107 * permission of Vovida Networks, Inc.
108 *
109 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
110 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
111 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
112 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
113 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
114 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
115 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
116 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
117 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
118 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
119 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
120 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
121 * DAMAGE.
122 *
123 * ====================================================================
124 *
125 * This software consists of voluntary contributions made by Vovida
126 * Networks, Inc. and many individuals on behalf of Vovida Networks,
127 * Inc. For more information on Vovida Networks, Inc., please see
128 * <http://www.vovida.org/>.
129 *
130 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27