Class: PkiExpress::SignatureAlgorithm

Inherits:
Object
  • Object
show all
Defined in:
lib/pki_express/pk_algorithms.rb

Direct Known Subclasses

RSASignatureAlgorithm

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, oid, xml_uri, digest_algorithm, pk_algorithm) ⇒ SignatureAlgorithm

Returns a new instance of SignatureAlgorithm.



17
18
19
20
21
22
23
# File 'lib/pki_express/pk_algorithms.rb', line 17

def initialize(name, oid, xml_uri, digest_algorithm, pk_algorithm)
  @name = name
  @oid = oid
  @xml_uri = xml_uri
  @digest_algorithm = digest_algorithm
  @pk_algorithm = pk_algorithm
end

Instance Attribute Details

#digest_algorithmObject

Returns the value of attribute digest_algorithm.



15
16
17
# File 'lib/pki_express/pk_algorithms.rb', line 15

def digest_algorithm
  @digest_algorithm
end

#nameObject

Returns the value of attribute name.



15
16
17
# File 'lib/pki_express/pk_algorithms.rb', line 15

def name
  @name
end

#oidObject

Returns the value of attribute oid.



15
16
17
# File 'lib/pki_express/pk_algorithms.rb', line 15

def oid
  @oid
end

#pk_algorithmObject

Returns the value of attribute pk_algorithm.



15
16
17
# File 'lib/pki_express/pk_algorithms.rb', line 15

def pk_algorithm
  @pk_algorithm
end

#xml_uriObject

Returns the value of attribute xml_uri.



15
16
17
# File 'lib/pki_express/pk_algorithms.rb', line 15

def xml_uri
  @xml_uri
end

Class Method Details

.get_instance_by_api_model(api_model) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/pki_express/pk_algorithms.rb', line 89

def get_instance_by_api_model(api_model)
  algorithms
  unless @algorithms.select{|v| v.api_model.downcase == api_model.downcase}.empty?
    return @algorithms.select{|v| v.api_model.downcase == api_model.downcase}.first
  end
  raise 'Unrecognized signature algorithm: ' + api_model
end

.get_instance_by_name(name) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/pki_express/pk_algorithms.rb', line 65

def get_instance_by_name(name)
  algorithms
  unless @algorithms.select{|v| v.name == name}.empty?
    return @algorithms.select{|v| v.name == name}.first
  end
  raise 'Unrecognized signature algorithm name: ' + name
end

.get_instance_by_oid(oid) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/pki_express/pk_algorithms.rb', line 73

def get_instance_by_oid(oid)
  algorithms
  unless @algorithms.select{|v| v.oid == oid}.empty?
    return @algorithms.select{|v| v.oid == oid}.first
  end
  raise 'Unrecognized signature algorithm oid: ' + oid
end

.get_instance_by_xml_uri(xml_uri) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/pki_express/pk_algorithms.rb', line 81

def get_instance_by_xml_uri(xml_uri)
  algorithms
  unless @algorithms.select{|v| v.xml_uri == xml_uri}.empty?
    return @algorithms.select{|v| v.xml_uri == xml_uri}.first
  end
  raise 'Unrecognized signature algorithm XML URI: ' + xml_uri
end

Instance Method Details

#md5_with_rsaObject



25
26
27
28
29
# File 'lib/pki_express/pk_algorithms.rb', line 25

def md5_with_rsa
  unless @md5_with_rsa
    @md5_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.md5)
  end
end

#sha1_with_rsaObject



31
32
33
34
35
# File 'lib/pki_express/pk_algorithms.rb', line 31

def sha1_with_rsa
  unless @sha1_with_rsa
    @sha1_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.sha1)
  end
end

#sha256_with_rsaObject



37
38
39
40
41
# File 'lib/pki_express/pk_algorithms.rb', line 37

def sha256_with_rsa
  unless @sha256_with_rsa
    @sha256_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.sha256)
  end
end

#sha384_with_rsaObject



43
44
45
46
47
# File 'lib/pki_express/pk_algorithms.rb', line 43

def sha384_with_rsa
  unless @sha384_with_rsa
    @sha384_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.sha384)
  end
end

#sha512_with_rsaObject



49
50
51
52
53
# File 'lib/pki_express/pk_algorithms.rb', line 49

def sha512_with_rsa
  unless @sha512_with_rsa
    @sha512_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.sha512)
  end
end