module R509::Cert::Extensions::ValidationMixin
Validation methods shared by multiple extensions
Private Instance Methods
validate_general_name_hash_array(arr)
click to toggle source
# File lib/r509/cert/extensions/validation_mixin.rb, line 33 def validate_general_name_hash_array(arr) arr.each do |l| if !l.is_a?(Hash) || l[:type].nil? || l[:value].nil? raise ArgumentError, "All elements of the array must be hashes with a :type and :value" end end unless arr.is_a?(R509::ASN1::GeneralNames) end
validate_location(type, location)
click to toggle source
# File lib/r509/cert/extensions/validation_mixin.rb, line 25 def validate_location(type, location) if location && !(location.is_a?(Array) || location.is_a?(R509::ASN1::GeneralNames)) raise ArgumentError, "#{type} must contain an array or R509::ASN1::GeneralNames object if provided" end validate_general_name_hash_array(location) unless location.nil? location end
validate_non_negative_integer(source, value)
click to toggle source
used by iap and pc validation methods
# File lib/r509/cert/extensions/validation_mixin.rb, line 10 def validate_non_negative_integer(source, value) if !value.is_a?(Integer) || value < 0 raise ArgumentError, "#{source} must be a non-negative integer" end value end
validate_usage(ku)
click to toggle source
validates key usage array
# File lib/r509/cert/extensions/validation_mixin.rb, line 18 def validate_usage(ku) if ku.nil? || !ku.is_a?(Hash) || !ku[:value].is_a?(Array) raise ArgumentError, 'You must pass a hash with a key :value that contains an array of strings (see README)' end ku end