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,157 @@
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 _KEYSTORE_H
18
+ #define _KEYSTORE_H
19
+ #include <string>
20
+ #include <xmlsec/keysmngr.h>
21
+ #include "Exceptions.h"
22
+ #include "X509Certificate.h"
23
+ using namespace std;
24
+
25
+ /**
26
+ * Storage of keys and certificates.
27
+ * Keys and certificates in objects of this class may be used by the
28
+ * Signer and Verifier to create and validate signatures.
29
+ */
30
+ class KeyStore
31
+ {
32
+ public:
33
+ /**
34
+ * Create an empty KeyStore.
35
+ * @throws MemoryError if a null key manager is created
36
+ * @throws KeyError if the key manager can't be initialized
37
+ */
38
+ KeyStore ();
39
+ /**
40
+ * Destroy the key manager.
41
+ */
42
+ ~KeyStore ();
43
+ /**
44
+ * Add a trusted certificate.
45
+ * @param cert A trusted X509Certificate
46
+ * @return 0 on success, -1 on error
47
+ * @throws LibError if the certificate can't be adopted or the key store is bad
48
+ */
49
+ int addTrustedCert (X509CertificatePtr cert);
50
+ /**
51
+ * Add an untrusted certificate.
52
+ * @param cert An untrusted X509Certificate
53
+ * @return 0 on success, -1 on error
54
+ * @throws LibError if the certificate can't be adopted or the key store is bad
55
+ */
56
+ int addUntrustedCert (X509CertificatePtr cert);
57
+ /**
58
+ * Add a trusted certificate from a file.
59
+ * @param fileName The file name
60
+ * @param format Key data format string (see Key::loadFromFile() for format list)
61
+ * @return 0 on success, -1 on error
62
+ * @throws IOError if the file can't be read
63
+ */
64
+ int addTrustedCertFromFile (string fileName, string format);
65
+ /**
66
+ * Add an untrusted certificate from a file.
67
+ * @param fileName The file name
68
+ * @param format Key data format string (see Key::loadFromFile() for format list)
69
+ * @return 0 on success, -1 on error
70
+ * @throws IOError if the file can't be read
71
+ */
72
+ int addUntrustedCertFromFile (string fileName, string format);
73
+ /**
74
+ * Add a key to the store.
75
+ * @param key The key to add
76
+ * @return 0 on success, -1 on error
77
+ * @throws LibError on key manager adoption error
78
+ */
79
+ int addKey (KeyPtr key);
80
+ /**
81
+ * Add a key from a file.
82
+ * @param fileName The file name
83
+ * @param format Key data format string (see Key::loadFromFile() for format list)
84
+ * @param name Name of key
85
+ * @return 0 on success, -1 on error
86
+ * @throws IOError if the file can't be read
87
+ * @throws LibError on key manager adoption error
88
+ */
89
+ int addKeyFromFile (string fileName, string format, string name);
90
+ /**
91
+ * @overload
92
+ * @param fileName The file name
93
+ * @param format Key data format string (see Key::loadFromFile() for format list)
94
+ * @param name Name of key
95
+ * @param password Password for key, empty string if unnecessary
96
+ */
97
+ int addKeyFromFile (string fileName, string format, string name, string password);
98
+ /**
99
+ * Save keys/certs to an XML file.
100
+ * @param fileName The file name
101
+ * @return 0 on success, -1 on error
102
+ * @throws IOError if the file can't be written
103
+ */
104
+ int saveToFile (string fileName);
105
+ /**
106
+ * Add keys/certs from an XML file.
107
+ * @param fileName The file name
108
+ * @return 0 on success, -1 on error
109
+ * @throws IOError if the file can't be read
110
+ */
111
+ int loadFromFile (string fileName);
112
+
113
+ /// @cond NO_INTERFACE
114
+ /**
115
+ * Get the internal representation of the KeyStore.
116
+ * @return A pointer to the KeyStore.
117
+ */
118
+ xmlSecKeysMngrPtr getKeyStore ();
119
+ xmlSecKeysMngrPtr operator-> ()
120
+ {
121
+ return getKeyStore();
122
+ }
123
+ operator xmlSecKeysMngrPtr ()
124
+ {
125
+ return getKeyStore();
126
+ }
127
+
128
+ protected:
129
+ /**
130
+ * Internal representation of the KeyStore.
131
+ */
132
+ xmlSecKeysMngrPtr mMngr;
133
+
134
+ /**
135
+ * General certificate addition.
136
+ * @param fileName The file name
137
+ * @param format Key format
138
+ * @param isTrusted Flag, true if the key is trusted
139
+ * @return 0 on success, -1 on error
140
+ */
141
+ int addCertFromFile (string fileName, string format, int isTrusted);
142
+ /**
143
+ * General certificate addition.
144
+ * @param cert The X509Certificate
145
+ * @param isTrusted Flag, true if the key is trusted
146
+ * @return 0 on success, -1 on error
147
+ */
148
+ int addCert (X509CertificatePtr cert, int isTrusted);
149
+
150
+ /// @endcond
151
+ };
152
+
153
+ #include "countptr.h"
154
+ typedef CountPtrTo<KeyStore> KeyStorePtr;
155
+
156
+ #endif
157
+
@@ -0,0 +1,62 @@
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 _KEYSMNGRWRAP_H
18
+ #define _KEYSMNGRWRAP_H
19
+
20
+ #include <xmlsec/keysmngr.h>
21
+ #include <assert.h>
22
+
23
+ class KeysMngr
24
+ {
25
+ public:
26
+ KeysMngr ()
27
+ : keysMngr (0)
28
+ {
29
+ keysMngr = xmlSecKeysMngrCreate();
30
+ }
31
+
32
+ ~KeysMngr ()
33
+ {
34
+ if (keysMngr)
35
+ {
36
+ xmlSecKeysMngrDestroy(keysMngr);
37
+ }
38
+ }
39
+
40
+ operator int ()
41
+ {
42
+ return keysMngr != NULL;
43
+ }
44
+ int operator! ()
45
+ {
46
+ return keysMngr == NULL;
47
+ }
48
+ xmlSecKeysMngrPtr operator-> ()
49
+ {
50
+ assert(keysMngr);
51
+ return keysMngr;
52
+ }
53
+ operator xmlSecKeysMngrPtr ()
54
+ {
55
+ return keysMngr;
56
+ }
57
+
58
+ protected:
59
+ xmlSecKeysMngrPtr keysMngr;
60
+ };
61
+
62
+ #endif
@@ -0,0 +1,60 @@
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 _NODESETCTX_H
18
+ #define _NODESETCTX_H
19
+
20
+ #include <xmlsec/nodeset.h>
21
+ #include <assert.h>
22
+
23
+ class NodeSet
24
+ {
25
+ public:
26
+ NodeSet (xmlSecNodeSetPtr nodeSet)
27
+ : nodes (nodeSet)
28
+ {}
29
+
30
+ ~NodeSet ()
31
+ {
32
+ if (nodes)
33
+ {
34
+ xmlSecNodeSetDestroy(nodes);
35
+ }
36
+ }
37
+
38
+ operator int ()
39
+ {
40
+ return nodes != NULL;
41
+ }
42
+ int operator! ()
43
+ {
44
+ return nodes == NULL;
45
+ }
46
+ xmlSecNodeSetPtr operator-> ()
47
+ {
48
+ assert(nodes);
49
+ return nodes;
50
+ }
51
+ operator xmlSecNodeSetPtr ()
52
+ {
53
+ return nodes;
54
+ }
55
+
56
+ protected:
57
+ xmlSecNodeSetPtr nodes;
58
+ };
59
+
60
+ #endif