Class: Xml::Kit::KeyInfo
- Inherits:
-
Object
show all
- Includes:
- Templatable
- Defined in:
- lib/xml/kit/key_info.rb,
lib/xml/kit/key_info/key_value.rb,
lib/xml/kit/key_info/rsa_key_value.rb,
lib/xml/kit/key_info/retrieval_method.rb
Overview
Defined Under Namespace
Classes: KeyValue, RSAKeyValue, RetrievalMethod
Instance Attribute Summary collapse
Attributes included from Templatable
#digest_method, #embed_signature, #encrypt, #encryption_certificate, #signature_method, #signing_key_pair
Instance Method Summary
collapse
#encrypt_data_for, #encrypt_key_for, #encrypt_with, #encryption_for, #render, #sign_with, #signature_for, #to_xml
Constructor Details
#initialize(x509: nil, encrypted_key: nil) {|_self| ... } ⇒ KeyInfo
Returns a new instance of KeyInfo.
19
20
21
22
23
|
# File 'lib/xml/kit/key_info.rb', line 19
def initialize(x509: nil, encrypted_key: nil)
@encrypted_key = encrypted_key
@x509_data = x509
yield self if block_given?
end
|
Instance Attribute Details
#encrypted_key ⇒ Object
17
18
19
|
# File 'lib/xml/kit/key_info.rb', line 17
def encrypted_key
@encrypted_key
end
|
#key_name ⇒ Object
15
16
17
|
# File 'lib/xml/kit/key_info.rb', line 15
def key_name
@key_name
end
|
#x509_data ⇒ Object
16
17
18
|
# File 'lib/xml/kit/key_info.rb', line 16
def x509_data
@x509_data
end
|
Instance Method Details
#asymmetric_cipher(algorithm: Crypto::RsaCipher::ALGORITHM) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/xml/kit/key_info.rb', line 25
def asymmetric_cipher(algorithm: Crypto::RsaCipher::ALGORITHM)
return encrypted_key.asymmetric_cipher if encrypted_key
if x509_data
return Crypto.cipher_for(
derive_algorithm_from(x509_data.public_key),
x509_data.public_key
)
end
super(algorithm: algorithm)
end
|
#key_value ⇒ Object
44
45
46
|
# File 'lib/xml/kit/key_info.rb', line 44
def key_value
@key_value ||= KeyValue.new
end
|
#retrieval_method ⇒ Object
48
49
50
|
# File 'lib/xml/kit/key_info.rb', line 48
def retrieval_method
@retrieval_method ||= RetrievalMethod.new
end
|
#subject_key_identifier ⇒ Object
52
53
54
55
56
57
|
# File 'lib/xml/kit/key_info.rb', line 52
def subject_key_identifier
ski = x509_data.extensions.find { |x| x.oid == 'subjectKeyIdentifier' }
return if ski.nil?
Base64.strict_encode64(ski.value)
end
|
#symmetric_cipher ⇒ Object
38
39
40
41
42
|
# File 'lib/xml/kit/key_info.rb', line 38
def symmetric_cipher
return super if encrypted_key.nil?
encrypted_key.symmetric_cipher
end
|