nokogiri-xmlsec 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/nokogiri_ext_xmlsec/nokogiri_helpers_set_attribute_id.c +43 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_init.c +3 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_verify_signature_certificates.c +1 -1
- data/ext/nokogiri_ext_xmlsec/xmlsecrb.h +1 -0
- data/lib/xmlsec.rb +1 -1
- data/lib/xmlsec/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 071248ba595e25283ee6987fb5ac39a111a86eab
|
4
|
+
data.tar.gz: 48e03d326c3b0b65e4dc4980c9a59836591c3d9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ba83c44cd6e92e403639d093cec53678bf2ffc3afaa284b8cbfd7a5da752ee81b0b140e41f83408fc4e07166ec783a2badbfa5841adab9a0789a734ea211ced
|
7
|
+
data.tar.gz: 697783269c10f6114b47af84e124b58ed7ff746f79ce86d2429c5b7e9268e8eece8273679b646a0438e2b5b49d28fa8d267a5616ac67eaa9c95d939744d5823a
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#include "xmlsecrb.h"
|
2
|
+
|
3
|
+
VALUE set_id_attribute(VALUE self, VALUE rb_attr_name) {
|
4
|
+
xmlNodePtr node;
|
5
|
+
xmlAttrPtr attr;
|
6
|
+
xmlAttrPtr tmp;
|
7
|
+
xmlChar *name;
|
8
|
+
const xmlChar *idName;
|
9
|
+
|
10
|
+
Data_Get_Struct(self, xmlNode, node);
|
11
|
+
Check_Type(rb_attr_name, T_STRING);
|
12
|
+
idName = (const xmlChar *)RSTRING_PTR(rb_attr_name);
|
13
|
+
|
14
|
+
// find pointer to id attribute
|
15
|
+
attr = xmlHasProp(node, idName);
|
16
|
+
if((attr == NULL) || (attr->children == NULL)) {
|
17
|
+
rb_raise(rb_eRuntimeError, "Can't find attribute to add register as id");
|
18
|
+
return Qfalse;
|
19
|
+
}
|
20
|
+
|
21
|
+
// get the attribute (id) value
|
22
|
+
name = xmlNodeListGetString(node->doc, attr->children, 1);
|
23
|
+
if(name == NULL) {
|
24
|
+
rb_raise(rb_eRuntimeError, "Attribute %s has no value", idName);
|
25
|
+
return Qfalse;
|
26
|
+
}
|
27
|
+
|
28
|
+
// check that we don't have that id already registered
|
29
|
+
tmp = xmlGetID(node->doc, name);
|
30
|
+
if(tmp != NULL) {
|
31
|
+
// rb_raise(rb_eRuntimeError, "Attribute %s is already an ID", idName);
|
32
|
+
xmlFree(name);
|
33
|
+
return Qfalse;
|
34
|
+
}
|
35
|
+
|
36
|
+
// finally register id
|
37
|
+
xmlAddID(NULL, node->doc, name, attr);
|
38
|
+
|
39
|
+
// and do not forget to cleanup
|
40
|
+
xmlFree(name);
|
41
|
+
|
42
|
+
return Qtrue;
|
43
|
+
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "xmlsecrb.h"
|
2
2
|
|
3
3
|
VALUE rb_cNokogiri_XML_Document = T_NIL;
|
4
|
+
VALUE rb_cNokogiri_XML_Node = T_NIL;
|
4
5
|
VALUE rb_eSigningError = T_NIL;
|
5
6
|
VALUE rb_eVerificationError = T_NIL;
|
6
7
|
VALUE rb_eKeystoreError = T_NIL;
|
@@ -12,6 +13,7 @@ void Init_Nokogiri_ext() {
|
|
12
13
|
VALUE Nokogiri = rb_define_module("Nokogiri");
|
13
14
|
VALUE Nokogiri_XML = rb_define_module_under(Nokogiri, "XML");
|
14
15
|
rb_cNokogiri_XML_Document = rb_const_get(Nokogiri_XML, rb_intern("Document"));
|
16
|
+
rb_cNokogiri_XML_Node = rb_const_get(Nokogiri_XML, rb_intern("Node"));
|
15
17
|
|
16
18
|
rb_define_method(rb_cNokogiri_XML_Document, "sign_with_key", sign_with_key, 2);
|
17
19
|
rb_define_method(rb_cNokogiri_XML_Document, "sign_with_certificate", sign_with_certificate, 3);
|
@@ -20,6 +22,7 @@ void Init_Nokogiri_ext() {
|
|
20
22
|
rb_define_method(rb_cNokogiri_XML_Document, "verify_with_certificates", verify_signature_with_certificates, 1);
|
21
23
|
rb_define_method(rb_cNokogiri_XML_Document, "encrypt_with_key", encrypt_with_key, 2);
|
22
24
|
rb_define_method(rb_cNokogiri_XML_Document, "decrypt_with_key", decrypt_with_key, 2);
|
25
|
+
rb_define_method(rb_cNokogiri_XML_Node, "set_id_attribute", set_id_attribute, 1);
|
23
26
|
|
24
27
|
rb_eSigningError = rb_define_class_under(XMLSec, "SigningError", rb_eRuntimeError);
|
25
28
|
rb_eVerificationError = rb_define_class_under(XMLSec, "VerificationError", rb_eRuntimeError);
|
@@ -75,7 +75,7 @@ VALUE verify_signature_with_certificates(VALUE self, VALUE rb_certs) {
|
|
75
75
|
|
76
76
|
// verify signature
|
77
77
|
if(xmlSecDSigCtxVerify(dsigCtx, node) < 0) {
|
78
|
-
rb_raise(rb_eVerificationError, "
|
78
|
+
rb_raise(rb_eVerificationError, "error occurred during signature verification");
|
79
79
|
goto done;
|
80
80
|
}
|
81
81
|
|
@@ -25,6 +25,7 @@ VALUE verify_signature_with_named_keys(VALUE self, VALUE rb_keys);
|
|
25
25
|
VALUE verify_signature_with_certificates(VALUE self, VALUE rb_certs);
|
26
26
|
VALUE encrypt_with_key(VALUE self, VALUE rb_key_name, VALUE rb_key);
|
27
27
|
VALUE decrypt_with_key(VALUE self, VALUE rb_key_name, VALUE rb_key);
|
28
|
+
VALUE set_id_attribute(VALUE self, VALUE rb_attr_name);
|
28
29
|
|
29
30
|
void Init_Nokogiri_ext(void);
|
30
31
|
|
data/lib/xmlsec.rb
CHANGED
data/lib/xmlsec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokogiri-xmlsec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin MacKenzie IV
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- ext/nokogiri_ext_xmlsec/init.c
|
133
133
|
- ext/nokogiri_ext_xmlsec/nokogiri_decrypt_with_key.c
|
134
134
|
- ext/nokogiri_ext_xmlsec/nokogiri_encrypt_with_key.c
|
135
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_helpers_set_attribute_id.c
|
135
136
|
- ext/nokogiri_ext_xmlsec/nokogiri_init.c
|
136
137
|
- ext/nokogiri_ext_xmlsec/nokogiri_sign_certificate.c
|
137
138
|
- ext/nokogiri_ext_xmlsec/nokogiri_sign_rsa.c
|