reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Pkcs7Contents.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
7#include "rutil/Logger.hxx"
10
11using namespace resip;
12using namespace std;
13
14#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
15
18
19bool
21{
22 static ContentsFactory<Pkcs7Contents> factory;
23 (void)factory;
24 return true;
25}
26
27bool
29{
31 (void)factory;
32 return true;
33}
34
36 : Contents(getStaticType()),
37 mText()
38{
39}
40
44
46 : Contents(getStaticType()),
47 mText(txt)
48{
49}
50
52 : Pkcs7Contents(txt, getStaticType())
53{
54}
55
56Pkcs7Contents::Pkcs7Contents(const Data& txt, const Mime& contentsType)
57 : Contents(contentsType),
58 mText(txt)
59{
60}
61
62Pkcs7Contents::Pkcs7Contents(const HeaderFieldValue& hfv, const Mime& contentsType)
63 : Contents(hfv, contentsType),
64 mText()
65{
66}
67
69 : Pkcs7Contents(hfv, contentsType)
70{
71}
72
74 : Contents(rhs),
75 mText(rhs.mText)
76{
77}
78
83
87
91
94{
95 if (this != &rhs)
96 {
98 mText = rhs.mText;
99 }
100 return *this;
101}
102
103Contents*
105{
106 return new Pkcs7Contents(*this);
107}
108
109Contents*
111{
112 return new Pkcs7SignedContents(*this);
113}
114
115const Mime&
117{
118 static Mime type("application","pkcs7-mime");
119 return type;
120}
121
122const Mime&
124{
125 static Mime type("application","pkcs7-signature");
126 return type;
127}
128
129
131Pkcs7Contents::encodeParsed(EncodeStream& str) const
132{
133 //DebugLog(<< "Pkcs7Contents::encodeParsed " << mText);
134 str << mText;
135 return str;
136}
137
138
139void
141{
142 const char* anchor = pb.position();
143 pb.skipToEnd();
144 pb.data(mText, anchor);
145
146 if ( mTransferEncoding )
147 {
148 InfoLog( << "Transfer Encoding is " << mTransferEncoding->value() );
149 if ( mTransferEncoding->value() == Data("base64") )
150 {
151 Data bin = mText.base64decode();
152 mText = bin;
153 InfoLog( << "Base64 decoded to " << mText.escaped() );
154 }
155 }
156
157 DebugLog(<< "Pkcs7Contents::parsed <" << mText.escaped() << ">" );
158}
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 */
#define DebugLog(args_)
Definition Logger.hxx:128
#define InfoLog(args_)
Definition Logger.hxx:131
Base class for all SIP body types.
Definition Contents.hxx:51
Contents & operator=(const Contents &rhs)
Assignment operator.
Definition Contents.cxx:71
H_ContentTransferEncoding::Type * mTransferEncoding
Definition Contents.hxx:346
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Data base64decode() const
Performs RFC 3548 Base 64 decoding of the contents of this data.
Definition Data.cxx:2607
Data escaped() const
Returns a representation of the contents of the data with any non-printable characters escaped.
Definition Data.cxx:1199
Represents the "media-type" element in the RFC 3261 grammar.
Definition Mime.hxx:20
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipToEnd()
CurrentPosition position() const
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
SIP body type for holding PKCS7 contents (MIME content-type application/pkcs7-mime).
virtual void parse(ParseBuffer &pb)
virtual Contents * clone() const
duplicate an Pkcs7Contents object
virtual EncodeStream & encodeParsed(EncodeStream &str) const
Pkcs7Contents & operator=(const Pkcs7Contents &rhs)
static const Mime & getStaticType()
static const Pkcs7Contents Empty
SIP body type for holding PKCS7 Signed contents (MIME content-type application/pkcs7-signature).
static const Mime & getStaticType()
static const Pkcs7SignedContents Empty
virtual Contents * clone() const
duplicate an Pkcs7SignedContents object
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream