Sha256: 2302d79ea5a08c45211e1d630d292bb8ace88f4a1d9373032ba25dcd82ff1963

Contents?: true

Size: 820 Bytes

Versions: 1

Compression:

Stored size: 820 Bytes

Contents

require "java2ruby-xmldsig/version"
require "rjb"

ENV['JAVA_HOME'] ||= File.exist?("/usr/lib/jvm/java-6-sun/") ? "/usr/lib/jvm/java-6-sun/" : "/usr/java/default"

Rjb::load('.:'+Gem.bin_path('java2ruby-xmldsig'))

module Java2ruby
  module Xmldsig
    extend self

    Helper = Rjb::import('ru.atconsulting.xmldsig.Xmldsig')

    def sign(xml, reference)
      Helper.sign xml, reference
    end

    def signature(xml, reference)
      Helper.signature xml, reference
    end

    def verify(xml)
      silence_stream(STDERR) do
        Helper.verify xml
      end
    end
  end

  private

  def silence_stream(stream)
    old_stream = stream.dup
    stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
    stream.sync = true
    yield
  ensure
    stream.reopen(old_stream)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
java2ruby-xmldsig-0.2 lib/java2ruby-xmldsig.rb