/src/resiprocate/resip/stack/Pkcs7Contents.cxx
Line | Count | Source |
1 | | #if defined(HAVE_CONFIG_H) |
2 | | #include "config.h" |
3 | | #endif |
4 | | |
5 | | #include "resip/stack/Pkcs7Contents.hxx" |
6 | | #include "resip/stack/SipMessage.hxx" |
7 | | #include "rutil/Logger.hxx" |
8 | | #include "rutil/ParseBuffer.hxx" |
9 | | #include "rutil/WinLeakCheck.hxx" |
10 | | |
11 | | using namespace resip; |
12 | | using namespace std; |
13 | | |
14 | | #define RESIPROCATE_SUBSYSTEM Subsystem::SIP |
15 | | |
16 | | const Pkcs7Contents Pkcs7Contents::Empty; |
17 | | const Pkcs7SignedContents Pkcs7SignedContents::Empty; |
18 | | |
19 | | bool |
20 | | Pkcs7Contents::init() |
21 | 6 | { |
22 | 6 | static ContentsFactory<Pkcs7Contents> factory; |
23 | 6 | (void)factory; |
24 | 6 | return true; |
25 | 6 | } |
26 | | |
27 | | bool |
28 | | Pkcs7SignedContents::init() |
29 | 6 | { |
30 | 6 | static ContentsFactory<Pkcs7SignedContents> factory; |
31 | 6 | (void)factory; |
32 | 6 | return true; |
33 | 6 | } |
34 | | |
35 | | Pkcs7Contents::Pkcs7Contents() |
36 | 4 | : Contents(getStaticType()), |
37 | 4 | mText() |
38 | 4 | { |
39 | 4 | } |
40 | | |
41 | | Pkcs7SignedContents::Pkcs7SignedContents() |
42 | 2 | { |
43 | 2 | } |
44 | | |
45 | | Pkcs7Contents::Pkcs7Contents(const Data& txt) |
46 | 0 | : Contents(getStaticType()), |
47 | 0 | mText(txt) |
48 | 0 | { |
49 | 0 | } |
50 | | |
51 | | Pkcs7SignedContents::Pkcs7SignedContents(const Data& txt) |
52 | 0 | : Pkcs7Contents(txt, getStaticType()) |
53 | 0 | { |
54 | 0 | } |
55 | | |
56 | | Pkcs7Contents::Pkcs7Contents(const Data& txt, const Mime& contentsType) |
57 | 0 | : Contents(contentsType), |
58 | 0 | mText(txt) |
59 | 0 | { |
60 | 0 | } |
61 | | |
62 | | Pkcs7Contents::Pkcs7Contents(const HeaderFieldValue& hfv, const Mime& contentsType) |
63 | 6.02k | : Contents(hfv, contentsType), |
64 | 6.02k | mText() |
65 | 6.02k | { |
66 | 6.02k | } |
67 | | |
68 | | Pkcs7SignedContents::Pkcs7SignedContents(const HeaderFieldValue& hfv, const Mime& contentsType) |
69 | 0 | : Pkcs7Contents(hfv, contentsType) |
70 | 0 | { |
71 | 0 | } |
72 | | |
73 | | Pkcs7Contents::Pkcs7Contents(const Pkcs7Contents& rhs) |
74 | 0 | : Contents(rhs), |
75 | 0 | mText(rhs.mText) |
76 | 0 | { |
77 | 0 | } |
78 | | |
79 | | Pkcs7SignedContents::Pkcs7SignedContents(const Pkcs7SignedContents& rhs) |
80 | 0 | : Pkcs7Contents(rhs) |
81 | 0 | { |
82 | 0 | } |
83 | | |
84 | | Pkcs7Contents::~Pkcs7Contents() |
85 | 6.02k | { |
86 | 6.02k | } |
87 | | |
88 | | Pkcs7SignedContents::~Pkcs7SignedContents() |
89 | | { |
90 | | } |
91 | | |
92 | | Pkcs7Contents& |
93 | | Pkcs7Contents::operator=(const Pkcs7Contents& rhs) |
94 | 0 | { |
95 | 0 | if (this != &rhs) |
96 | 0 | { |
97 | 0 | Contents::operator=(rhs); |
98 | 0 | mText = rhs.mText; |
99 | 0 | } |
100 | 0 | return *this; |
101 | 0 | } |
102 | | |
103 | | Contents* |
104 | | Pkcs7Contents::clone() const |
105 | 0 | { |
106 | 0 | return new Pkcs7Contents(*this); |
107 | 0 | } |
108 | | |
109 | | Contents* |
110 | | Pkcs7SignedContents::clone() const |
111 | 0 | { |
112 | 0 | return new Pkcs7SignedContents(*this); |
113 | 0 | } |
114 | | |
115 | | const Mime& |
116 | | Pkcs7Contents::getStaticType() |
117 | 6 | { |
118 | 6 | static Mime type("application","pkcs7-mime"); |
119 | 6 | return type; |
120 | 6 | } |
121 | | |
122 | | const Mime& |
123 | | Pkcs7SignedContents::getStaticType() |
124 | 2 | { |
125 | 2 | static Mime type("application","pkcs7-signature"); |
126 | 2 | return type; |
127 | 2 | } |
128 | | |
129 | | |
130 | | EncodeStream& |
131 | | Pkcs7Contents::encodeParsed(EncodeStream& str) const |
132 | 0 | { |
133 | | //DebugLog(<< "Pkcs7Contents::encodeParsed " << mText); |
134 | 0 | str << mText; |
135 | 0 | return str; |
136 | 0 | } |
137 | | |
138 | | |
139 | | void |
140 | | Pkcs7Contents::parse(ParseBuffer& pb) |
141 | 6.02k | { |
142 | 6.02k | const char* anchor = pb.position(); |
143 | 6.02k | pb.skipToEnd(); |
144 | 6.02k | pb.data(mText, anchor); |
145 | | |
146 | 6.02k | if ( mTransferEncoding ) |
147 | 0 | { |
148 | 0 | InfoLog( << "Transfer Encoding is " << mTransferEncoding->value() ); |
149 | 0 | if ( mTransferEncoding->value() == Data("base64") ) |
150 | 0 | { |
151 | 0 | Data bin = mText.base64decode(); |
152 | 0 | mText = bin; |
153 | 0 | InfoLog( << "Base64 decoded to " << mText.escaped() ); |
154 | 0 | } |
155 | 0 | } |
156 | | |
157 | 6.02k | DebugLog(<< "Pkcs7Contents::parsed <" << mText.escaped() << ">" ); |
158 | 6.02k | } |
159 | | |
160 | | |
161 | | /* ==================================================================== |
162 | | * The Vovida Software License, Version 1.0 |
163 | | * |
164 | | * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. |
165 | | * |
166 | | * Redistribution and use in source and binary forms, with or without |
167 | | * modification, are permitted provided that the following conditions |
168 | | * are met: |
169 | | * |
170 | | * 1. Redistributions of source code must retain the above copyright |
171 | | * notice, this list of conditions and the following disclaimer. |
172 | | * |
173 | | * 2. Redistributions in binary form must reproduce the above copyright |
174 | | * notice, this list of conditions and the following disclaimer in |
175 | | * the documentation and/or other materials provided with the |
176 | | * distribution. |
177 | | * |
178 | | * 3. The names "VOCAL", "Vovida Open Communication Application Library", |
179 | | * and "Vovida Open Communication Application Library (VOCAL)" must |
180 | | * not be used to endorse or promote products derived from this |
181 | | * software without prior written permission. For written |
182 | | * permission, please contact vocal@vovida.org. |
183 | | * |
184 | | * 4. Products derived from this software may not be called "VOCAL", nor |
185 | | * may "VOCAL" appear in their name, without prior written |
186 | | * permission of Vovida Networks, Inc. |
187 | | * |
188 | | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
189 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
190 | | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
191 | | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA |
192 | | * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES |
193 | | * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, |
194 | | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
195 | | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
196 | | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
197 | | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
198 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
199 | | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
200 | | * DAMAGE. |
201 | | * |
202 | | * ==================================================================== |
203 | | * |
204 | | * This software consists of voluntary contributions made by Vovida |
205 | | * Networks, Inc. and many individuals on behalf of Vovida Networks, |
206 | | * Inc. For more information on Vovida Networks, Inc., please see |
207 | | * <http://www.vovida.org/>. |
208 | | * |
209 | | */ |