Module: XmlSec

Defined in:
lib/xmlsec.rb,
lib/xmlsec/error.rb,
lib/xmlsec/version.rb,
ext/xmlsec/xmlsec_ext.c

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.0.7"

Class Method Summary collapse

Class Method Details

.sign(template, key_file, password, x509_file, node_name) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'ext/xmlsec/sign.c', line 157

static VALUE rb_xmlsec_sign(VALUE self, VALUE template, VALUE key_file, VALUE password, VALUE x509_file, VALUE node_name ) {
  xmlDocPtr doc;
  doc = xmlReadMemory(
      StringValuePtr(template),
      RSTRING_LEN(template),
      "noname.xml",
      NULL,
      0
    );
  if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
    rb_raise(rb_eRuntimeError, "Error: unable to parse  template.");
    return Qnil;
  }
  return xmlsec_sign(self, doc, key_file, password, x509_file, node_name );
}

.sign_file(template_file, key_file, password, x509_file, node_name) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
# File 'ext/xmlsec/sign.c', line 144

static VALUE rb_xmlsec_sign_file(VALUE self, VALUE template_file, VALUE key_file, VALUE password, VALUE x509_file, VALUE node_name) {
  xmlDocPtr doc;

  doc = xmlParseFile(StringValuePtr(template_file));

  if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)) {
    rb_raise(rb_eRuntimeError, "Error: unable to parse  template file.");
    return Qnil;
  }

  return xmlsec_sign(self, doc, key_file, password, x509_file, node_name );
}

.valid?(template, key_file, x509_file) ⇒ Boolean

Returns:

  • (Boolean)


212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'ext/xmlsec/verify.c', line 212

static VALUE rb_xmlsec_is_valid(VALUE self, VALUE template, VALUE key_file, VALUE x509_file ) {
  xmlDocPtr doc;

  if (TYPE(template) != T_STRING){
    rb_raise(rb_eRuntimeError, "Error: Wrong template type");
  }

  doc = xmlReadMemory(
      StringValuePtr(template),
      RSTRING_LEN(template),
      "noname.xml",
      NULL,
      0
    );

  if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
    rb_raise(rb_eRuntimeError, "Error: unable to parse template %s.", StringValuePtr(template));

    rb_raise(rb_eRuntimeError, "Error: unable to parse template.");
    return Qnil;
  }
  if (! NIL_P(x509_file)) return xmlsec_is_valid_by_x509_file(self, doc, x509_file );
  if (! NIL_P(key_file)) return xmlsec_is_valid_by_key(self, doc, key_file);
  //return xmlsec_is_valid(self, doc);
}

.valid_file?(template_file, key_file, x509_file) ⇒ Boolean

Returns:

  • (Boolean)


198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'ext/xmlsec/verify.c', line 198

static VALUE rb_xmlsec_is_valid_file(VALUE self, VALUE template_file, VALUE key_file, VALUE x509_file ) {
  xmlDocPtr doc;

  doc = xmlParseFile(StringValuePtr(template_file));

  if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)) {
    rb_raise(rb_eRuntimeError, "Error: unable to parse template file.");
    return Qnil;
  }
  if (! NIL_P(x509_file)) return xmlsec_is_valid_by_x509_file(self, doc, x509_file );
  if (! NIL_P(key_file)) return xmlsec_is_valid_by_key(self, doc, key_file);
  return xmlsec_is_valid(self, doc);
}