ruby-saml-mod 0.1.23 → 0.1.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/xml_sec.rb +23 -0
  2. data/ruby-saml-mod.gemspec +2 -2
  3. metadata +2 -2
data/lib/xml_sec.rb CHANGED
@@ -79,6 +79,9 @@ module XMLSecurity
79
79
  :xmlSecDSigStatusInvalid
80
80
  ]
81
81
 
82
+ XMLSEC_ERRORS_R_INVALID_DATA = 12
83
+ class XmlSecError < ::RuntimeError; end
84
+
82
85
  class XmlSecPtrList < FFI::Struct
83
86
  layout \
84
87
  :id, :string,
@@ -170,6 +173,12 @@ module XMLSecurity
170
173
  :reserved1, :pointer
171
174
  end
172
175
 
176
+ ErrorCallback = FFI::Function.new(:void,
177
+ [ :string, :int, :string, :string, :string, :int, :string ]
178
+ ) do |file, line, func, errorObject, errorSubject, reason, msg |
179
+ XMLSecurity.handle_xmlsec_error_callback(file, line, func, errorObject, errorSubject, reason, msg)
180
+ end
181
+
173
182
  # xmlsec functions
174
183
  attach_function :xmlSecInit, [], :int
175
184
  attach_function :xmlSecParseMemory, [ :pointer, :uint, :int ], :pointer
@@ -193,7 +202,9 @@ module XMLSecurity
193
202
  attach_function :xmlSecEncCtxDecrypt, [ :pointer, :pointer ], :int
194
203
  attach_function :xmlSecEncCtxDestroy, [ :pointer ], :void
195
204
 
205
+ attach_function :xmlSecErrorsDefaultCallback, [ :string, :int, :string, :string, :string, :int, :string ], :void
196
206
  attach_function :xmlSecErrorsDefaultCallbackEnableOutput, [ :bool ], :void
207
+ attach_function :xmlSecErrorsSetCallback, [:pointer], :void
197
208
 
198
209
  attach_function :xmlSecTransformExclC14NGetKlass, [], :pointer
199
210
  attach_function :xmlSecOpenSSLTransformRsaSha1GetKlass, [], :pointer
@@ -238,6 +249,18 @@ module XMLSecurity
238
249
  raise "Failed initializing XMLSec" if self.xmlSecInit < 0
239
250
  raise "Failed initializing app crypto" if self.xmlSecOpenSSLAppInit(nil) < 0
240
251
  raise "Failed initializing crypto" if self.xmlSecOpenSSLInit < 0
252
+ self.xmlSecErrorsSetCallback(ErrorCallback)
253
+
254
+ def self.handle_xmlsec_error_callback(*args)
255
+ raise_exception_if_necessary(*args)
256
+ xmlSecErrorsDefaultCallback(*args)
257
+ end
258
+
259
+ def self.raise_exception_if_necessary(file, line, func, errorObject, errorSubject, reason, msg)
260
+ if reason == XMLSEC_ERRORS_R_INVALID_DATA
261
+ raise XmlSecError.new(msg)
262
+ end
263
+ end
241
264
 
242
265
 
243
266
  def self.mute(&block)
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{ruby-saml-mod}
3
- s.version = "0.1.23"
3
+ s.version = "0.1.24"
4
4
 
5
5
  s.authors = ["OneLogin LLC", "Bracken", "Zach", "Cody", "Jeremy", "Paul"]
6
- s.date = %q{2014-01-25}
6
+ s.date = %q{2014-02-02}
7
7
  s.extra_rdoc_files = [
8
8
  "LICENSE"
9
9
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-saml-mod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.23
4
+ version: 0.1.24
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2014-01-25 00:00:00.000000000 Z
17
+ date: 2014-02-02 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: libxml-ruby