Method: PkernelJce::IdentityFactory#build_from_components

Defined in:
lib/pkernel_jce/identity.rb

#build_from_components(key, cert = nil, chain = [], provider = nil) ⇒ Object Also known as: build



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/pkernel_jce/identity.rb', line 161

def build_from_components(key, cert = nil, chain = [], provider = nil)
  if key.nil?
    raise PkernelJce::Error, "Key cannot be nil to build identity"
  end

  id = Pkernel::Identity.new( { key: key, certificate: cert, chain: chain } )
  if cert.nil?
    class_eval do
      include PkernelJce::IdentityManagement
    end 
  else
    c = PkernelJce::Certificate.ensure_java_cert(cert)
    if PkernelJce::Certificate.is_issuer_cert?(c)
      class_eval do
        include PkernelJce::IdentityIssuer
        include PkernelJce::IdentityManagement
      end 
    else
      class_eval do
        include PkernelJce::IdentityManagement
      end 
    end
  end

  id.provider = provider
  
  id
end