Class: R509::Cert::Extensions::NoticeReference

Inherits:
Object
  • Object
show all
Defined in:
lib/r509/cert/extensions/certificate_policies.rb

Overview

This class is used to help build the certificate policies extension

NoticeReference ::= SEQUENCE {
     organization     DisplayText,
     noticeNumbers    SEQUENCE OF INTEGER }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ NoticeReference

Returns a new instance of NoticeReference



232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 232

def initialize(data)
  data.each do |notice_reference|
    # if it's displaytext then it's the organization
    # if it's YET ANOTHER ASN1::Sequence, then it's noticeNumbers
    if notice_reference.is_a?(OpenSSL::ASN1::Sequence)
      @notice_numbers = []
      notice_reference.each do |ints|
        @notice_numbers << ints.value.to_i
      end
    else
      @organization = notice_reference.value
    end
  end
end

Instance Attribute Details

#notice_numbersObject (readonly)

Returns the value of attribute notice_numbers



231
232
233
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 231

def notice_numbers
  @notice_numbers
end

#organizationObject (readonly)

Returns the value of attribute organization



231
232
233
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 231

def organization
  @organization
end

Instance Method Details

#to_hHash

Returns:

  • (Hash)


248
249
250
251
252
253
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 248

def to_h
  hash = {}
  hash[:organization] = @organization unless @organization.nil?
  hash[:notice_numbers] = @notice_numbers unless @notice_numbers.empty?
  hash
end

#to_yamlYAML

Returns:

  • (YAML)


256
257
258
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 256

def to_yaml
  self.to_h.to_yaml
end