/[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 3433 - (hide annotations) (download)
Tue Nov 2 18:02:55 2004 UTC (15 years, 1 month ago) by jason
Original Path: main/sip/resiprocate/test/testIdentity.cxx
File size: 4222 byte(s)
reverting RESIP_ change to version 3429
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     security = new Security(false,true);
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     bool ok = security->loadAllCerts( "password" , Data::Empty );
37     if ( !ok )
38     {
39     ErrLog( << "Could not load the certificates" );
40     }
41     }
42     catch( ... )
43     {
44     ErrLog( << "Got a exception loading certificates" );
45     }
46    
47     assert( security );
48 fluffy 3328
49     Data in("sip:alice@atlanta.example.com"
50 fluffy 3330 ":a84b4c76e66710"
51 jason 3433 ":314159 INVITE"
52 fluffy 3328 ":Thu, 21 Feb 2002 13:02:03 GMT"
53 fluffy 3330 ":sip:alice@pc33.atlanta.example.com"
54 fluffy 3328 ":v=0\r\n"
55     "o=UserA 2890844526 2890844526 IN IP4 pc33.atlanta.example.com\r\n"
56     "s=Session SDP\r\n"
57 fluffy 3330 "c=IN IP4 pc33.atlanta.example.com\r\n"
58 fluffy 3328 "t=0 0\r\n"
59     "m=audio 49172 RTP/AVP 0\r\n"
60 fluffy 3330 "a=rtpmap:0 PCMU/8000\r\n");
61    
62     ofstream strm("identiy-in", std::ios_base::trunc);
63     strm.write( in.data(), in.size() );
64     strm.flush();
65 fluffy 3328
66 fluffy 3327 Data res = security->computeIdentity( in );
67    
68 fluffy 3330 //ErrLog( << "input is encoded " << in.charEncoded() );
69     //ErrLog( << "input is hex " << in.hex() );
70     //ErrLog( << "input is " << in );
71     //ErrLog( << "identity is " << res );
72 fluffy 3327
73     bool c = security->checkIdentity( in , res );
74    
75 fluffy 3330 if ( !c )
76     {
77     ErrLog( << "Identity check failed" << res );
78     }
79    
80    
81 fluffy 3327 #endif // use_ssl
82    
83 fluffy 3326 return 0;
84     }
85    
86     /* ====================================================================
87     * The Vovida Software License, Version 1.0
88     *
89     * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
90     *
91     * Redistribution and use in source and binary forms, with or without
92     * modification, are permitted provided that the following conditions
93     * are met:
94     *
95     * 1. Redistributions of source code must retain the above copyright
96     * notice, this list of conditions and the following disclaimer.
97     *
98     * 2. Redistributions in binary form must reproduce the above copyright
99     * notice, this list of conditions and the following disclaimer in
100     * the documentation and/or other materials provided with the
101     * distribution.
102     *
103     * 3. The names "VOCAL", "Vovida Open Communication Application Library",
104     * and "Vovida Open Communication Application Library (VOCAL)" must
105     * not be used to endorse or promote products derived from this
106     * software without prior written permission. For written
107     * permission, please contact vocal@vovida.org.
108     *
109     * 4. Products derived from this software may not be called "VOCAL", nor
110     * may "VOCAL" appear in their name, without prior written
111     * permission of Vovida Networks, Inc.
112     *
113     * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
114     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
115     * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
116     * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
117     * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
118     * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
119     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
120     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
121     * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
122     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
123     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
124     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
125     * DAMAGE.
126     *
127     * ====================================================================
128     *
129     * This software consists of voluntary contributions made by Vovida
130     * Networks, Inc. and many individuals on behalf of Vovida Networks,
131     * Inc. For more information on Vovida Networks, Inc., please see
132     * <http://www.vovida.org/>.
133     *
134     */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27