xmlsig 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/README.rdoc +0 -0
  2. data/ext/xmlsig/BioWrap.h +98 -0
  3. data/ext/xmlsig/DSig.cpp +109 -0
  4. data/ext/xmlsig/DSig.h +81 -0
  5. data/ext/xmlsig/DSigCtx.h +72 -0
  6. data/ext/xmlsig/Exceptions.cpp +151 -0
  7. data/ext/xmlsig/Exceptions.h +214 -0
  8. data/ext/xmlsig/Key.cpp +582 -0
  9. data/ext/xmlsig/Key.h +338 -0
  10. data/ext/xmlsig/KeyInfoCtx.h +67 -0
  11. data/ext/xmlsig/KeyStore.cpp +180 -0
  12. data/ext/xmlsig/KeyStore.h +157 -0
  13. data/ext/xmlsig/KeysMngrWrap.h +62 -0
  14. data/ext/xmlsig/NodeSet.h +60 -0
  15. data/ext/xmlsig/Signer.cpp +691 -0
  16. data/ext/xmlsig/Signer.h +373 -0
  17. data/ext/xmlsig/TrustVerifier.cpp +145 -0
  18. data/ext/xmlsig/TrustVerifier.h +174 -0
  19. data/ext/xmlsig/Verifier.cpp +677 -0
  20. data/ext/xmlsig/Verifier.h +313 -0
  21. data/ext/xmlsig/X509Certificate.cpp +362 -0
  22. data/ext/xmlsig/X509Certificate.h +146 -0
  23. data/ext/xmlsig/XPath.cpp +173 -0
  24. data/ext/xmlsig/XPath.h +156 -0
  25. data/ext/xmlsig/XPathCtx.h +68 -0
  26. data/ext/xmlsig/XmlCharBuf.h +60 -0
  27. data/ext/xmlsig/XmlDoc.cpp +278 -0
  28. data/ext/xmlsig/XmlDoc.h +157 -0
  29. data/ext/xmlsig/XmlElement.cpp +151 -0
  30. data/ext/xmlsig/XmlElement.h +134 -0
  31. data/ext/xmlsig/countptr.h +260 -0
  32. data/ext/xmlsig/extconf.rb +58 -0
  33. data/ext/xmlsig/runtests.rb +23 -0
  34. data/ext/xmlsig/swig/countptr.i +27 -0
  35. data/ext/xmlsig/swig/exceptions.i +79 -0
  36. data/ext/xmlsig/swig/ruby.i +17 -0
  37. data/ext/xmlsig/swig/xmlsig.i +405 -0
  38. data/ext/xmlsig/t/tc_cert.rb +34 -0
  39. data/ext/xmlsig/t/tc_interface.rb +158 -0
  40. data/ext/xmlsig/t/tc_signer.rb +501 -0
  41. data/ext/xmlsig/t/tc_tsik.rb +490 -0
  42. data/ext/xmlsig/t/tc_verifier.rb +151 -0
  43. data/ext/xmlsig/t/tsik_interop/sign.rb +48 -0
  44. data/ext/xmlsig/t/tsik_interop/verify.rb +31 -0
  45. data/ext/xmlsig/t/tsik_interop/verify_own.rb +46 -0
  46. data/ext/xmlsig/xmlsig.cpp +13363 -0
  47. data/lib/xmlsig.rb +1 -0
  48. metadata +113 -0
@@ -0,0 +1,214 @@
1
+ /*
2
+ * (C) Copyright 2006 VeriSign, Inc.
3
+ * Developed by Sxip Identity
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ #ifndef _EXCEPTIONS_H
18
+ #define _EXCEPTIONS_H
19
+
20
+ #include <string>
21
+ #ifndef NDEBUG
22
+ #ifndef DEBUG_EXCEPTIONS
23
+ #define DEBUG_EXCEPTIONS
24
+ #endif // DEBUG_EXCEPTIONS
25
+ #endif // NDEBUG
26
+
27
+ #ifdef DEBUG_EXCEPTIONS
28
+ #include <iostream>
29
+ #endif // DEBUG_EXCEPTIONS
30
+
31
+ using namespace std;
32
+
33
+ /**
34
+ * Base class for all exceptions thrown by this library
35
+ */
36
+ class DsigException
37
+ {
38
+ public:
39
+ /**
40
+ * Create an empty exception. The description will be "Unknown
41
+ * exception".
42
+ */
43
+ DsigException () : what_str("Unknown exception")
44
+ {}
45
+ /**
46
+ * Create an exception with the given description string.
47
+ * @param what_str Description string
48
+ */
49
+ DsigException (string what_str) : what_str(what_str)
50
+ {}
51
+ /**
52
+ * Copy another exception, duplicating the description string.
53
+ * @param excp Exception to copy
54
+ */
55
+ DsigException (const DsigException& excp)
56
+ {
57
+ if (this != &excp)
58
+ {
59
+ what_str = excp.what_str;
60
+ }
61
+ }
62
+ virtual ~DsigException ()
63
+ {}
64
+
65
+ /**
66
+ * Describe the exception.
67
+ * @return Description string
68
+ */
69
+ const char* what () const
70
+ {
71
+ return what_str.c_str();
72
+ }
73
+
74
+ protected:
75
+ string what_str;
76
+ };
77
+
78
+
79
+ /**
80
+ * Macro to declare a generic exception derived from one similar to DsigException.
81
+ */
82
+ #define DERIVED_EXCEPTION(newclass,baseclass) \
83
+ class newclass : public baseclass \
84
+ { \
85
+ public: \
86
+ newclass() : baseclass() {} \
87
+ newclass (string what_str) : baseclass(what_str) {} \
88
+ newclass (const newclass& excp) : baseclass(excp) {} \
89
+ virtual ~newclass () {} \
90
+ }
91
+
92
+ /*
93
+ TSIK Java exceptions:
94
+
95
+ SignatureException
96
+ InvalidKeyException
97
+ NoSuchAlgorithmException
98
+ XPathException
99
+ */
100
+
101
+
102
+ // Generic exceptions (with Swig analogs)
103
+
104
+ /** \class IOError
105
+ * Generic I/O exception class.
106
+ */
107
+ DERIVED_EXCEPTION(IOError, DsigException); // SWIG_IOError
108
+ /** \class MemoryError
109
+ * Generic memory error exception class.
110
+ */
111
+ DERIVED_EXCEPTION(MemoryError, DsigException); // SWIG_MemoryError
112
+ /** \class ValueError
113
+ * Generic value error exception class.
114
+ */
115
+ DERIVED_EXCEPTION(ValueError, DsigException); // SWIG_ValueError
116
+
117
+ // Exception classes specific to DSIG
118
+
119
+ /** \class XMLError
120
+ * Error parsing XML, or elements not found.
121
+ */
122
+ DERIVED_EXCEPTION(XMLError, DsigException);
123
+ /** \class KeyError
124
+ * Key missing or invalid.
125
+ */
126
+ DERIVED_EXCEPTION(KeyError, DsigException);
127
+ /** \class DocError
128
+ * Document missing, invalid or malformed
129
+ */
130
+ DERIVED_EXCEPTION(DocError, DsigException);
131
+ /** \class XPathError
132
+ * XPath expression syntax or result set issue.
133
+ */
134
+ DERIVED_EXCEPTION(XPathError, DsigException);
135
+ /** \class TrustVerificationError
136
+ * Indicates that trust verification failed.
137
+ */
138
+ DERIVED_EXCEPTION(TrustVerificationError, DsigException);
139
+ //DERIVED_EXCEPTION(SignatureError, DsigException);
140
+
141
+
142
+ /**
143
+ * Encapsulates errors reported by libraries: xmlsec, libxml, libxslt, openssl.
144
+ * Error messages logged by libraries are saved and returned as part of the
145
+ * description string.
146
+ */
147
+ class LibError : public DsigException
148
+ {
149
+ public:
150
+ LibError();
151
+ LibError(string what_str);
152
+ LibError(const LibError& excp) : DsigException(excp)
153
+ {}
154
+ virtual ~LibError ()
155
+ {}
156
+ /**
157
+ * Erase any library errors that have already been logged.
158
+ */
159
+ static void clearErrorLogs ();
160
+
161
+ protected:
162
+ void appendAll ();
163
+ void appendWhat (char* str);
164
+ };
165
+
166
+
167
+ /**
168
+ * \def THROW_NORET(e,what)
169
+ * Throws an exception or returns with no value, based on whether
170
+ * exceptions are enabled.
171
+ * Throws the exception class "e", with the string parameter "what"
172
+ * unless NO_EXCEPTIONS is defined, in which case it just returns
173
+ * (with no return value). If DEBUG_EXCEPTIONS is not defined, THROW
174
+ * spits out debug info to stderr.
175
+ */
176
+
177
+ /**
178
+ * \def THROW(e,what,ret)
179
+ * Throws an exception or returns a value, based on whether
180
+ * exceptions are enabled.
181
+ * Throws the exception class "e", with the string parameter "what"
182
+ * unless NO_EXCEPTIONS is defined, in which case it just returns "ret".
183
+ * If DEBUG_EXCEPTIONS is not defined, THROW spits out debug info to stderr.
184
+ */
185
+
186
+ #ifndef NO_EXCEPTIONS
187
+ #define THROW_NORET(e,what) THROW(e,what,void)
188
+ #ifndef DEBUG_EXCEPTIONS
189
+ #define THROW(e,what,ret) throw e(what)
190
+ #else
191
+ #define THROW(e,what,ret) do \
192
+ { fprintf(stderr, "%s:%d:%s: %s\n", __FILE__, __LINE__, #e, what); \
193
+ throw e(what); } while(0)
194
+ #endif // DEBUG_EXCEPTIONS
195
+ #else
196
+ #ifndef DEBUG_EXCEPTIONS
197
+ #define THROW_NORET(e,what) return
198
+ #define THROW(e,what,ret) return (ret)
199
+ #else
200
+ #define THROW_NORET(e,what) do \
201
+ { fprintf(stderr, "%s:%d:%s: %s\n", __FILE__, __LINE__, #e, what); \
202
+ return; } while(0)
203
+ #define THROW(e,what,ret) do \
204
+ { fprintf(stderr, "%s:%d:%s: %s\n", __FILE__, __LINE__, #e, what); \
205
+ return ret; } while(0)
206
+ #endif // DEBUG_EXCEPTIONS
207
+ #endif // NO_EXCEPTIONS
208
+
209
+ /**
210
+ * Initialize the error handlers for xmlsec1, libxml2, libxslt
211
+ */
212
+ void initErrorHandler ();
213
+
214
+ #endif