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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4599 - (hide 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 fluffy 3326
2 fluffy 3327 #include <cassert>
3 fluffy 3330 #include <fstream>
4     #include <ostream>
5 fluffy 3327
6     #include "resiprocate/os/Logger.hxx"
7 fluffy 3326 #include "resiprocate/Security.hxx"
8    
9 fluffy 3327
10 fluffy 3326 using namespace resip;
11     using namespace std;
12    
13 fluffy 3327 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
14 fluffy 3326
15    
16     int
17     main(int argc, char* argv[])
18     {
19     Log::initialize(Log::Cout, Log::Debug, Data::Empty);
20 fluffy 3327
21     #ifdef USE_SSL
22     Security* security=0;
23     try
24     {
25 fluffy 3587 security = new Security;
26 fluffy 3327 }
27     catch( ... )
28     {
29     security = 0;
30     ErrLog( << "Got a exception setting up Security" );
31     }
32    
33     try
34     {
35     assert(security != 0);
36 fluffy 3587 security->preload();
37 fluffy 3327 }
38     catch( ... )
39     {
40     ErrLog( << "Got a exception loading certificates" );
41     }
42    
43     assert( security );
44 fluffy 3328
45     Data in("sip:alice@atlanta.example.com"
46 fluffy 3330 ":a84b4c76e66710"
47 jason 3433 ":314159 INVITE"
48 fluffy 3328 ":Thu, 21 Feb 2002 13:02:03 GMT"
49 fluffy 3330 ":sip:alice@pc33.atlanta.example.com"
50 fluffy 3328 ":v=0\r\n"
51     "o=UserA 2890844526 2890844526 IN IP4 pc33.atlanta.example.com\r\n"
52     "s=Session SDP\r\n"
53 fluffy 3330 "c=IN IP4 pc33.atlanta.example.com\r\n"
54 fluffy 3328 "t=0 0\r\n"
55     "m=audio 49172 RTP/AVP 0\r\n"
56 fluffy 3330 "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 fluffy 3328
62 fluffy 3600 Data res = security->computeIdentity( Data("localhost"), in );
63 fluffy 3327
64 fluffy 3330 //ErrLog( << "input is encoded " << in.charEncoded() );
65     //ErrLog( << "input is hex " << in.hex() );
66     //ErrLog( << "input is " << in );
67     //ErrLog( << "identity is " << res );
68 fluffy 3327
69 fluffy 3600 bool c = security->checkIdentity( Data("localhost"), in , res );
70 fluffy 3327
71 fluffy 3330 if ( !c )
72     {
73     ErrLog( << "Identity check failed" << res );
74     }
75    
76    
77 fluffy 3327 #endif // use_ssl
78    
79 fluffy 3326 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