Class: RBoss::JMX

Inherits:
Object
  • Object
show all
Includes:
Component
Defined in:
lib/rboss/components/jmx.rb,
lib/rboss/components/org/jmx.rb,
lib/rboss/components/soa-p/jmx.rb

Overview

An extension to the base JXM class that secures the jmx-console for the JBoss.org servers.

author: Marcelo Guimarães <[email protected]>

Instance Method Summary collapse

Methods included from Component

#initialize, #load_yaml, #new_file_processor

Instance Method Details

#base_processObject



31
32
33
34
# File 'lib/rboss/components/org/jmx.rb', line 31

def process
  configure_users
  configure_roles
end

#configure(config) ⇒ Object



38
39
40
41
42
43
# File 'lib/rboss/components/jmx.rb', line 38

def configure config
  @config = config
  @password = config[:password]
  @user = config[:user]
  @roles = config[:roles]
end

#configure_rolesObject



68
69
70
71
72
73
74
75
76
# File 'lib/rboss/components/jmx.rb', line 68

def configure_roles
  processor = new_file_processor
  processor.with "#{@jboss.profile}/conf/props/#{roles_properties_file}" do |action|
    action.to_process do |content, jboss|
      [@user, @roles].join '='
    end
  end
  processor.process
end

#configure_usersObject



58
59
60
61
62
63
64
65
66
# File 'lib/rboss/components/jmx.rb', line 58

def configure_users
  processor = new_file_processor
  processor.with "#{@jboss.profile}/conf/props/#{users_properties_file}" do |action|
    action.to_process do |content, jboss|
      [@user, @password].join '='
    end
  end
  processor.process
end

#defaultsObject



45
46
47
48
49
50
51
# File 'lib/rboss/components/jmx.rb', line 45

def defaults
  {
    :user => "admin",
    :password => "admin",
    :roles => "JBossAdmin,HttpInvoker"
  }
end

#processObject



53
54
55
56
# File 'lib/rboss/components/jmx.rb', line 53

def process
  configure_users
  configure_roles
end

#roles_properties_fileObject



82
83
84
# File 'lib/rboss/components/jmx.rb', line 82

def roles_properties_file
  "jmx-console-roles.properties"
end

#secure_jmx_consoleObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rboss/components/org/jmx.rb', line 38

def secure_jmx_console
  processor = new_file_processor
  processor.with "#{@jboss.profile}/deploy/jmx-console.war/WEB-INF/jboss-web.xml", :xml do |action|
    action.to_process do |xml, jboss|
      xml.root << Document::new("<security-domain>java:/jaas/jmx-console</security-domain>")
      xml
    end
  end
  processor.with "#{@jboss.profile}/deploy/jmx-console.war/WEB-INF/web.xml" do |action|
    action.to_process do |content, jboss|
      content.gsub! /<security-constraint>/, "--> <security-constraint>"
      content.gsub! /<\/security-constraint>/, "</security-constraint><!--"
      content
    end
  end
  processor.process
end

#users_properties_fileObject



78
79
80
# File 'lib/rboss/components/jmx.rb', line 78

def users_properties_file
  "jmx-console-users.properties"
end