Class: Ccrypto::Java::JCEProvider

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/ccrypto/java/jce_provider.rb

Constant Summary collapse

BCProv =
org.bouncycastle.jce.provider.BouncyCastleProvider.new
DEFProv =
BCProv

Instance Method Summary collapse

Instance Method Details

#add_bc_providerObject



35
36
37
# File 'lib/ccrypto/java/jce_provider.rb', line 35

def add_bc_provider
  add_provider
end

#add_provider(prov = nil) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/ccrypto/java/jce_provider.rb', line 15

def add_provider(prov = nil)
  case prov
  when java.security.Provider
    java.security.Security.add_provider(prov) if not is_provider_registered?(prov)
  else
    java.security.Security.add_provider(DEFProv) if not is_provider_registered?(DEFProv)	
  end
end

#is_provider_registered?(prov) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
33
# File 'lib/ccrypto/java/jce_provider.rb', line 24

def is_provider_registered?(prov)
  case prov
  when String
    java.security.Security.providers.to_a.map { |v| v.name }.include?(prov)
  when java.security.Provider
    java.security.Security.get_providers.to_a.include?(prov)
  else
    false
  end
end