class Pkernel::Identity

Public Instance Methods

certificate() click to toggle source
# File lib/pkernel_jce/identity.rb, line 117
def certificate
  if not @certificate.nil? 
    @certificate = Certificate.ensure_java_cert(@certificate)
  end
  @certificate
end
Also aliased as: super_cert
certificate=(cert) click to toggle source
# File lib/pkernel_jce/identity.rb, line 20
def certificate=(cert)
  @certificate = cert
end
chain=(val) click to toggle source
# File lib/pkernel_jce/identity.rb, line 24
def chain=(val)
  @chain = val
end
key() click to toggle source
# 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
Also aliased as: super_key
key=(val) click to toggle source

alias_method :super_key=, :key=

# 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() click to toggle source
# 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) click to toggle source
# File lib/pkernel_jce/identity.rb, line 58
def keypair=(val)
  @keypair = val
end
post_init(opts) click to toggle source
# File lib/pkernel_jce/identity.rb, line 17
def post_init(opts)
end
privKey() click to toggle source
# 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
Also aliased as: super_privKey
provider() click to toggle source
# 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) click to toggle source

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

# 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() click to toggle source
# 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
Also aliased as: super_pubKey
super_cert()
Alias for: certificate
super_key()
Alias for: key
super_privKey()
Alias for: privKey
super_pubKey()
Alias for: pubKey