Class: R509::ASN1::GeneralNames
- Inherits:
-
Object
- Object
- R509::ASN1::GeneralNames
- Includes:
- Cert::Extensions::ValidationMixin
- Defined in:
- lib/r509/asn1.rb
Overview
object to hold parsed sequences of generalnames these structures are used in SubjectAlternativeName, AuthorityInfoAccess, CRLDistributionPoints, etc
Instance Method Summary (collapse)
- - (Object) add_item(asn)
- - (Object) create_item(hash)
-
- (Array) directory_names
(also: #dir_names)
Array of directoryNames (R509::Subject objects).
-
- (Array) dns_names
Array of dnsName strings.
-
- (GeneralNames) initialize(data = nil)
constructor
A new instance of GeneralNames.
-
- (Array) ip_addresses
(also: #ips)
Array of IP address strings.
-
- (Array) names
order found in the extension.
-
- (Array) rfc_822_names
(also: #email_names)
Array of rfc822name strings.
-
- (Array) serialize_names
String of serialized names for OpenSSL extension creation.
- - (Hash) to_h
-
- (Array) uniform_resource_identifiers
(also: #uris)
Array of uri strings.
Constructor Details
- (GeneralNames) initialize(data = nil)
A new instance of GeneralNames
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/r509/asn1.rb', line 235 def initialize(data=nil) @types = { :otherName => [], # unimplemented :rfc822Name => [], :dNSName => [], :x400Address => [], # unimplemented :directoryName => [], :ediPartyName => [], # unimplemented :uniformResourceIdentifier => [], :iPAddress => [], :registeredID => [] # unimplemented } @ordered_names = [] if not data.nil? if data.kind_of?(self.class) data.names.each { |n| add_item(n) } else validate_general_name_hash_array(data) data.each do |n| create_item(n) end end end end |
Instance Method Details
- (Object) add_item(asn)
261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/r509/asn1.rb', line 261 def add_item(asn) # map general names into our hash of arrays if asn.kind_of?(R509::ASN1::GeneralName) @ordered_names << asn @types[asn.type] << asn.value else gn = R509::ASN1::GeneralName.new(asn) @ordered_names << gn @types[gn.type] << gn.value end end |
- (Object) create_item(hash)
275 276 277 278 279 280 281 |
# File 'lib/r509/asn1.rb', line 275 def create_item(hash) if not hash.respond_to?(:has_key?) or (not hash.has_key?(:tag) and not hash.has_key?(:type)) or not hash.has_key?(:value) raise ArgumentError, "Must be a hash with (:tag or :type) and :value nodes" end gn = R509::ASN1::GeneralName.new(:tag => hash[:tag], :type => hash[:type], :value => hash[:value]) add_item(gn) end |
- (Array) directory_names Also known as: dir_names
Array of directoryNames (R509::Subject objects)
318 319 320 |
# File 'lib/r509/asn1.rb', line 318 def directory_names @types[:directoryName] end |
- (Array) dns_names
Array of dnsName strings
301 302 303 |
# File 'lib/r509/asn1.rb', line 301 def dns_names @types[:dNSName] end |
- (Array) ip_addresses Also known as: ips
Array of IP address strings
312 313 314 |
# File 'lib/r509/asn1.rb', line 312 def ip_addresses @types[:iPAddress] end |
- (Array) names
order found in the extension
290 291 292 |
# File 'lib/r509/asn1.rb', line 290 def names @ordered_names end |
- (Array) rfc_822_names Also known as: email_names
Array of rfc822name strings
295 296 297 |
# File 'lib/r509/asn1.rb', line 295 def rfc_822_names @types[:rfc822Name] end |
- (Array) serialize_names
String of serialized names for OpenSSL extension creation
324 325 326 327 328 329 330 331 332 333 |
# File 'lib/r509/asn1.rb', line 324 def serialize_names confs = [] extension_strings = [] @ordered_names.each { |item| data = item.serialize_name confs << data[:conf] extension_strings << data[:extension_string] } { :conf => confs.join("\n"), :extension_string => extension_strings.join(",") } end |
- (Hash) to_h
284 285 286 |
# File 'lib/r509/asn1.rb', line 284 def to_h self.names.map { |n| n.to_h } end |
- (Array) uniform_resource_identifiers Also known as: uris
Array of uri strings
306 307 308 |
# File 'lib/r509/asn1.rb', line 306 def uniform_resource_identifiers @types[:uniformResourceIdentifier] end |