class RestPki::DigestAlgorithm
Attributes
api_model[R]
byte_length[R]
crypto_digest[R]
name[R]
oid[R]
xml_uri[R]
Public Class Methods
MD5()
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 16 def self.MD5; MD5DigestAlgorithm.new end
SHA1()
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 17 def self.SHA1; SHA1DigestAlgorithm.new end
SHA256()
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 18 def self.SHA256; SHA256DigestAlgorithm.new end
SHA384()
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 19 def self.SHA384; SHA384DigestAlgorithm.new end
SHA512()
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 20 def self.SHA512; SHA512DigestAlgorithm.new end
algorithms()
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 38 def self.algorithms [ DigestAlgorithm.MD5, DigestAlgorithm.SHA1, DigestAlgorithm.SHA256, DigestAlgorithm.SHA384, DigestAlgorithm.SHA512 ] end
get_instance_by_api_model(algorithm)
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 75 def self.get_instance_by_api_model(algorithm) case algorithm.upcase when 'MD5' DigestAlgorithm.MD5 when 'SHA1' DigestAlgorithm.SHA1 when 'SHA256' DigestAlgorithm.SHA256 when 'SHA384' DigestAlgorithm.SHA384 when 'SHA512' DigestAlgorithm.SHA512 else raise "Unsupported digest algorithm: #{algorithm}" end end
get_instance_by_name(name)
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 48 def self.get_instance_by_name(name) begin alg = DigestAlgorithm.algorithms.find{|a| a.name == name} rescue raise "Unrecognized digest algorithm name: #{name}" end alg end
get_instance_by_oid(oid)
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 57 def self.get_instance_by_oid(oid) begin alg = DigestAlgorithm.algorithms.find{|a| a.oid == oid} rescue raise "Unrecognized digest algorithm oid: #{oid}" end alg end
get_instance_by_xml_uri(xml_uri)
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 66 def self.get_instance_by_xml_uri(xml_uri) begin alg = DigestAlgorithm.algorithms.find{|a| a.xml_uri == xml_uri} rescue raise "Unrecognized digest algorithm xml_uri: #{xml_uri}" end alg end
new(name, oid, byte_length, api_model, xml_uri, crypto_digest)
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 7 def initialize(name, oid, byte_length, api_model, xml_uri, crypto_digest) @name = name @oid = oid @byte_length = byte_length @api_model = api_model @xml_uri = xml_uri @crypto_digest = crypto_digest end
Public Instance Methods
==(comparison_object)
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 22 def ==(comparison_object) if comparison_object.equal?(self) return true end unless comparison_object.instance_of?(self.class) return false end self.oid == comparison_object.oid end
check_length(digest_value)
click to toggle source
# File lib/rest_pki/digest_algorithm.rb, line 32 def check_length(digest_value) unless digest_value.length == @byte_length raise "A #{@name} digest should contain #{@byte_length} bytes, but a value with #{digest_value.length} bytes was given" end end