Class: Puppet::Context::TrustedInformation Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/context/trusted_information.rb

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.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authenticated, certname, extensions, external = {}) ⇒ TrustedInformation

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 TrustedInformation


37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/puppet/context/trusted_information.rb', line 37

def initialize(authenticated, certname, extensions, external = {})
  @authenticated = authenticated.freeze
  @certname = certname.freeze
  @extensions = extensions.freeze
  if @certname
    hostname, domain = @certname.split('.', 2)
  else
    hostname = nil
    domain = nil
  end
  @hostname = hostname.freeze
  @domain = domain.freeze
  @external = external.freeze
end

Instance Attribute Details

#authenticatedString, Boolean (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.

one of 'remote', 'local', or false, where 'remote' is authenticated via cert, 'local' is trusted by virtue of running on the same machine (not a remote request), and false is an unauthenticated remote request.

Returns:

  • (String, Boolean)

10
11
12
# File 'lib/puppet/context/trusted_information.rb', line 10

def authenticated
  @authenticated
end

#certnameString (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.

The validated certificate name used for the request

Returns:

  • (String)

15
16
17
# File 'lib/puppet/context/trusted_information.rb', line 15

def certname
  @certname
end

#domainString (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.

The domain name derived from the validated certificate name

Returns:

  • (String)

25
26
27
# File 'lib/puppet/context/trusted_information.rb', line 25

def domain
  @domain
end

#extensionsHash{Object => Object} (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.

Extra information that comes from the trusted certificate's extensions.

Returns:


20
21
22
# File 'lib/puppet/context/trusted_information.rb', line 20

def extensions
  @extensions
end

#externalHash (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.

Additional external facts loaded through `trusted_external_command`.

Returns:

  • (Hash)

35
36
37
# File 'lib/puppet/context/trusted_information.rb', line 35

def external
  @external
end

#hostnameString (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.

The hostname derived from the validated certificate name

Returns:

  • (String)

30
31
32
# File 'lib/puppet/context/trusted_information.rb', line 30

def hostname
  @hostname
end

Class Method Details

.local(node) ⇒ Object

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.


70
71
72
73
74
75
# File 'lib/puppet/context/trusted_information.rb', line 70

def self.local(node)
  # Always trust local data by picking up the available parameters.
  client_cert = node ? node.parameters['clientcert'] : nil

  new('local', client_cert, {}, retrieve_trusted_external(client_cert))
end

.remote(authenticated, node_name, certificate) ⇒ Object

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.


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/puppet/context/trusted_information.rb', line 52

def self.remote(authenticated, node_name, certificate)
  external = retrieve_trusted_external(node_name)

  if authenticated
    extensions = {}
    if certificate.nil?
      Puppet.info(_('TrustedInformation expected a certificate, but none was given.'))
    else
      extensions = Hash[certificate.custom_extensions.collect do |ext|
        [ext['oid'].freeze, ext['value'].freeze]
      end]
    end
    new('remote', node_name, extensions, external)
  else
    new(false, nil, {}, external)
  end
end

Instance Method Details

#to_hObject

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.


104
105
106
107
108
109
110
111
112
113
# File 'lib/puppet/context/trusted_information.rb', line 104

def to_h
  {
    'authenticated'.freeze => authenticated,
    'certname'.freeze => certname,
    'extensions'.freeze => extensions,
    'hostname'.freeze => hostname,
    'domain'.freeze => domain,
    'external'.freeze => external,
  }.freeze
end