Module: PkernelJce::Provider

Defined in:
lib/pkernel_jce/provider.rb

Constant Summary collapse

BCProvider =
org.bouncycastle.jce.provider.BouncyCastleProvider.new
DefProvider =
BCProvider

Class Method Summary collapse

Class Method Details

.add_defaultObject



13
14
15
16
# File 'lib/pkernel_jce/provider.rb', line 13

def Provider::add_default
  add_provider(DefProvider)
  DefProvider
end

.add_provider(prov) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pkernel_jce/provider.rb', line 18

def Provider::add_provider(prov)
			if prov != nil
if prov.is_a?(String) and not prov.empty?
      case prov
      when BCProvider.name
        provInst = BCProvider
		if not java.security.Security.get_providers.to_a.include?(provInst)
          PkernelJce::GConf.instance.glog.debug "Adding security provider '#{provInst.name}'" 
			java.security.Security.add_provider(provInst)
		end
		prov
      else
        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."
      end
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

.supported_algo(&block) ⇒ Object

add_provider



49
50
51
52
53
54
55
56
57
58
# File 'lib/pkernel_jce/provider.rb', line 49

def Provider::supported_algo(&block)
  prov = DefProvider
  prov.services.each do |ser|
    if block
      block.call(ser)
    else
      STDOUT.puts "Algorithm : #{ser.algorithm}"
    end
  end
end