Class: Puppet_X::Coi::Jboss::Internal::SecurityDomainAuditor

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb

Overview

Internal class to audits what is the state of securitydomain in Jboss instance Do not use outside of securitydomain provider

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, cli_executor, compilator, destroyer) ⇒ SecurityDomainAuditor

Standard constructor compilaton of command to be executed securitydomain

Parameters:



11
12
13
14
15
16
# File 'lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb', line 11

def initialize(resource, cli_executor, compilator, destroyer)
  @resource = resource
  @cli_executor = cli_executor
  @compilator = compilator
  @destroyer = destroyer
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



18
19
20
# File 'lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb', line 18

def state
  @state
end

Instance Method Details

#exists?Boolean

Method that checks if securitydomain exists

Returns:

  • (Boolean)

    returns true if security-domain exists in any state



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb', line 22

def exists?
  raw_result = read_resource_recursive

  unless raw_result[:result]
    Puppet.debug 'Security Domain does NOT exist'
    return false
  end
  Puppet.debug("Raw result: #{raw_result.inspect}")
  result = resolve_state(raw_result[:data], @resource)
  result
end

#fetch_securtydomain_stateObject

Internal mathod that saves current state of every subpath of securitydomain



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb', line 35

def fetch_securtydomain_state
  data = state
  if data['security-domain'][(@resource[:name]).to_s]
    fetched_state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new
    if data['security-domain'][(@resource[:name]).to_s]['cache-type'].nil?
      Puppet.debug('cache-type is nil')
      fetched_state.is_cache_default = false
    else
      fetched_state.is_cache_default = true
    end
    auth = data['security-domain'][(@resource[:name]).to_s]['authentication']
    if auth.nil?
      Puppet.debug('Authentication is nil')
      fetched_state.is_authentication = false
    else
      fetched_state.is_authentication = true
    end
    if !auth.nil? && (data['security-domain'][(@resource[:name]).to_s]['authentication']['classic']['login-modules'].nil? || data['security-domain'][(@resource[:name]).to_s]['authentication']['classic']['login-modules'][0]['module-options'].nil?)
      Puppet.debug('Login modules are nil')
      fetched_state. = false
    end
  else
    fetched_state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new
  end

  fetched_state
end