Class: Puppet::SSL::CertificateRequestAttributes Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/ssl/certificate_request_attributes.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class transforms simple key/value pairs into the equivalent ASN1 structures. Values may be strings or arrays of strings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ CertificateRequestAttributes

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CertificateRequestAttributes.



12
13
14
15
16
# File 'lib/puppet/ssl/certificate_request_attributes.rb', line 12

def initialize(path)
  @path = path
  @custom_attributes = {}
  @extension_requests = {}
end

Instance Attribute Details

#custom_attributesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/puppet/ssl/certificate_request_attributes.rb', line 10

def custom_attributes
  @custom_attributes
end

#extension_requestsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/puppet/ssl/certificate_request_attributes.rb', line 10

def extension_requests
  @extension_requests
end

#pathObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/puppet/ssl/certificate_request_attributes.rb', line 10

def path
  @path
end

Instance Method Details

#loadObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Attempt to load a yaml file at the given @path.

Returns:

  • true if we are able to load the file, false otherwise

Raises:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/puppet/ssl/certificate_request_attributes.rb', line 21

def load
  Puppet.info(_("csr_attributes file loading from %{path}") % { path: path })
  if Puppet::FileSystem.exist?(path)
    hash = Puppet::Util::Yaml.load_file(path, {})
    if ! hash.is_a?(Hash)
      raise Puppet::Error, _("invalid CSR attributes, expected instance of Hash, received instance of %{klass}") % { klass: hash.class }
    end
    @custom_attributes = hash.delete('custom_attributes') || {}
    @extension_requests = hash.delete('extension_requests') || {}
    if not hash.keys.empty?
      raise Puppet::Error, _("unexpected attributes %{keys} in %{path}") % { keys: hash.keys.inspect, path: @path.inspect }
    end
    return true
  end
  return false
end