Sha256: 472a935faed41278d14d0dc2d9928995cafd0bb04ea693af7262340fa02a1cfe

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents


Dir.glob(File.join(File.dirname(__FILE__),'../../jars/*.jar')).each do |f|
	require_relative f
end

module PkernelJce
  module Provider
    
    DefProvider = org.bouncycastle.jce.provider.BouncyCastleProvider.new

    def Provider::add_default
      add_provider(DefProvider)
      DefProvider
    end

    def Provider::add_provider(prov)
			if prov != nil
				if prov.is_a?(String) and not prov.empty?
          PkernelJce::GConf.instance.glog.error "Unknown provider by string '#{prov}'. Please use provider object."
          raise Exception, "Unknown provider by string '#{prov}'. Please use provider object."
				elsif prov.is_a?(java.security.Provider)
					if prov != nil
						if not java.security.Security.get_providers.to_a.include?(prov)
              PkernelJce::GConf.instance.glog.debug "Adding security provider '#{prov.name}'" 
							java.security.Security.add_provider(prov)
						end
						prov
					else
						raise Exception, "Unknown provider object #{prov.inspect}"
					end

				end
			end
      
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pkernel_jce-0.3 lib/pkernel_jce/provider.rb
pkernel_jce-0.2 lib/pkernel_jce/provider.rb
pkernel_jce-0.1 lib/pkernel_jce/provider.rb