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

- (NoticeReference) initialize(data)

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.kind_of?(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

- (Object) notice_numbers (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

- (Object) organization (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

- (Hash) to_h

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

- (YAML) to_yaml

Returns:

  • (YAML)


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

def to_yaml
  self.to_h.to_yaml
end