Sha256: a56f7c292480bfb2887f2bdfd87c80c99870fbfe8e28303a00b6384b378210bd

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

require_relative 'provider'

class Array
	def to_vector
		v = Java::JavaUtil::Vector.new
		self.each do |rec|
			v.add_element rec
		end
		v
	end
end

class Java::JavaUtil::Date
	def to_ruby_date
		Time.at(self.getTime/1000)
	end
end

class Time
	def to_java_date
		java.util.Date.new(self.to_i*1000)
	end
end

#class DateTime
#	def to_java_date
#		java.util.Date.new(self.to_i*1000)
#	end
#end


# bouncycastle has those annoying intermediary object which translation
# is PITA
class Java::OrgBouncycastleCert::X509CertificateHolder
  def to_java_cert
    org.bouncycastle.cert.jcajce.JcaX509CertificateConverter.new.setProvider(PkernelJce::Provider::DefProvider).getCertificate(self)
  end  

  def subject_to_x500
    org.bouncycastle.asn1.x500.X500Name.getInstance(self.subject.encoded)
  end
end

class Java::JavaSecurityCert::Certificate
  def to_bc_cert_holder
    org.bouncycastle.cert.X509CertificateHolder.new(self.encoded)
  end
  alias_method :to_bc_cert, :to_bc_cert_holder
end


class Converter
  def self.java_bytes_to_hex(bytes)
    String.from_java_bytes(org.bouncycastle.util.encoders.Hex.encode(bytes))
  end
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pkernel_jce-0.7.0 lib/pkernel_jce/utils.rb
pkernel_jce-0.3 lib/pkernel_jce/utils.rb
pkernel_jce-0.2 lib/pkernel_jce/utils.rb
pkernel_jce-0.1 lib/pkernel_jce/utils.rb