Class: R509::Cert::Extensions::PolicyQualifiers

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

PolicyQualifierInfo ::= SEQUENCE {
     policyQualifierId  PolicyQualifierId,
     qualifier          ANY DEFINED BY policyQualifierId }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePolicyQualifiers

Returns a new instance of PolicyQualifiers



163
164
165
166
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 163

def initialize
  @cps_uris = []
  @user_notices = []
end

Instance Attribute Details

#cps_urisObject (readonly)

Returns the value of attribute cps_uris



162
163
164
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 162

def cps_uris
  @cps_uris
end

#user_noticesObject (readonly)

Returns the value of attribute user_notices



162
163
164
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 162

def user_notices
  @user_notices
end

Instance Method Details

#parse(data) ⇒ Object

parse each PolicyQualifier and store the results into the object array



169
170
171
172
173
174
175
176
177
178
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 169

def parse(data)
  oid = data.entries[0].value
  case
  when oid == 'id-qt-cps'
    # by RFC definition must be URIs
    @cps_uris << data.entries[1].value
  when oid == 'id-qt-unotice'
    @user_notices <<  UserNotice.new(data.entries[1])
  end
end

#to_hHash

Returns:

  • (Hash)


181
182
183
184
185
186
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 181

def to_h
  hash = {}
  hash[:cps_uris] = @cps_uris
  hash[:user_notices] = @user_notices.map { |notice| notice.to_h } unless @user_notices.empty?
  hash
end

#to_yamlYAML

Returns:

  • (YAML)


189
190
191
# File 'lib/r509/cert/extensions/certificate_policies.rb', line 189

def to_yaml
  self.to_h.to_yaml
end