Class: Pkernel::Identity
- Inherits:
-
Object
- Object
- Pkernel::Identity
- Defined in:
- lib/pkernel_jce/identity.rb
Instance Method Summary collapse
- #certificate ⇒ Object
- #certificate=(cert) ⇒ Object
- #chain=(val) ⇒ Object
- #key ⇒ Object
-
#key=(val) ⇒ Object
alias_method :super_key=, :key=.
- #keypair ⇒ Object
- #keypair=(val) ⇒ Object
- #post_init(opts) ⇒ Object
- #privKey ⇒ Object
- #provider ⇒ Object
-
#provider=(val) ⇒ Object
In java world, JCE/JCA provides switchable engine to call if it is software/hardware This provider is tightly related to private key.
- #pubKey ⇒ Object
- #super_cert ⇒ Object
- #super_key ⇒ Object
- #super_privKey ⇒ Object
- #super_pubKey ⇒ Object
Instance Method Details
#certificate ⇒ Object
117 118 119 120 121 122 |
# File 'lib/pkernel_jce/identity.rb', line 117 def certificate if not @certificate.nil? @certificate = Certificate.ensure_java_cert(@certificate) end @certificate end |
#certificate=(cert) ⇒ Object
20 21 22 |
# File 'lib/pkernel_jce/identity.rb', line 20 def certificate=(cert) @certificate = cert end |
#chain=(val) ⇒ Object
24 25 26 |
# File 'lib/pkernel_jce/identity.rb', line 24 def chain=(val) @chain = val end |
#key ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pkernel_jce/identity.rb', line 38 def key if @key.nil? if not @privKey.nil? if not @pubKey.nil? @key = java.security.KeyPair.new(@pubKey,@privKey) elsif not @certificate.nil? @key = java.security.KeyPair.new(@certificate.public_key,@privKey) else # no possible to generate without public key end else # not possible to generate without private key end else # key is not nil... end @key end |
#key=(val) ⇒ Object
alias_method :super_key=, :key=
29 30 31 32 33 34 35 |
# File 'lib/pkernel_jce/identity.rb', line 29 def key=(val) @key = val if not @key.nil? @privKey = PkernelJce::KeyPair.private_key(@key) @pubKey = PkernelJce::KeyPair.public_key(@key) end end |
#keypair ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/pkernel_jce/identity.rb', line 62 def keypair if @keypair.nil? if not @key.nil? and @key.is_a?(java.security.KeyPair) @keypair = @key elsif not @key.nil? and @key.is_a?(java.security.PrivateKey) @privKey = @key if not @pubKey.nil? @keypair = java.security.KeyPair.new(@pubKey,@privKey) elsif not @certificate.nil? @keypair = java.security.KeyPair.new(PkernelJce::Certificate.public_key(@certificate),@privKey) else # no public key available end else if not @privKey.nil? if not @pubKey.nil? @keypair = java.security.KeyPair.new(@pubKey,@privKey) elsif not @certificate.nil? @keypair = java.security.KeyPair.new(@certificate.public_key,@privKey) else # no possible to generate without public key end else # not possible to generate without private key end end end @keypair end |
#keypair=(val) ⇒ Object
58 59 60 |
# File 'lib/pkernel_jce/identity.rb', line 58 def keypair=(val) @keypair = val end |
#post_init(opts) ⇒ Object
17 18 |
# File 'lib/pkernel_jce/identity.rb', line 17 def post_init(opts) end |
#privKey ⇒ Object
96 97 98 99 100 101 |
# File 'lib/pkernel_jce/identity.rb', line 96 def privKey if @privKey.nil? and not @key.nil? @privKey = PkernelJce::KeyPair.private_key(@key) end @privKey end |
#provider ⇒ Object
139 140 141 142 143 144 145 146 |
# File 'lib/pkernel_jce/identity.rb', line 139 def provider if @provider.nil? PkernelJce::GConf.instance.glog.debug "Provider is nil in Identity object. Setting it to default provider '#{PkernelJce::Provider::DefProvider.name}'" @provider = PkernelJce::Provider.add_default end @provider end |
#provider=(val) ⇒ Object
In java world, JCE/JCA provides switchable engine to call if it is software/hardware This provider is tightly related to private key. Since private key is encapsulated in this object, might as well keep the pointer here. Whoever want to use the private key, also should check the provider to load correct signing engine
129 130 131 132 133 134 135 136 137 |
# File 'lib/pkernel_jce/identity.rb', line 129 def provider=(val) if not val.nil? if val.is_a?(String) and not val.empty? @provider = PkernelJce::Provider.add_provider(val) else @provider = PkernelJce::Provider.add_provider(val) end end end |
#pubKey ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/pkernel_jce/identity.rb', line 104 def pubKey if @pubKey.nil? if not @key.nil? @pubKey = PkernelJce::KeyPair.public_key(@key) elsif not @certificate.nil? @pubKey = PkernelJce::KeyPair.public_key(@certificate) end end @pubKey end |
#super_cert ⇒ Object
116 |
# File 'lib/pkernel_jce/identity.rb', line 116 alias_method :super_cert, :certificate |
#super_key ⇒ Object
37 |
# File 'lib/pkernel_jce/identity.rb', line 37 alias_method :super_key, :key |
#super_privKey ⇒ Object
95 |
# File 'lib/pkernel_jce/identity.rb', line 95 alias_method :super_privKey, :privKey |
#super_pubKey ⇒ Object
103 |
# File 'lib/pkernel_jce/identity.rb', line 103 alias_method :super_pubKey, :pubKey |