Class: UcbDeployer::ConfigTasks::Jira::ConfigCasAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ConfigCasAuth

Returns a new instance of ConfigCasAuth.



5
6
7
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 5

def initialize(config)
  @config = config
end

Instance Method Details

#cas_authenticator_classObject



27
28
29
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 27

def cas_authenticator_class()
  "org.soulwing.cas.apps.atlassian.JiraCasAuthenticator"
end

#cas_logout_urlObject



31
32
33
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 31

def cas_logout_url()
  "/casLogout.action"
end

#executeObject



9
10
11
12
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 9

def execute()
  self.update_seraph_config_xml()
  self.update_web_xml()
end

#seraph_config_auth_tokenObject



19
20
21
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 19

def seraph_config_auth_token()
  "com.atlassian.jira.security.login.JiraSeraphAuthenticator"
end

#seraph_config_logout_url_tokenObject



23
24
25
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 23

def seraph_config_logout_url_token()
  "/secure/Logout!default.jspa"
end

#seraph_config_pathObject



15
16
17
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 15

def seraph_config_path()
  "#{@config.build_dir()}/src/webapp/WEB-INF/classes/seraph-config.xml"
end

#update_seraph_config_xmlObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 43

def update_seraph_config_xml()
  seraph_xml_data = File.readlines(self.seraph_config_path()).map do |line|
    if m = /(#{Regexp.quote(self.seraph_config_auth_token())})/.match(line)
      "#{m.pre_match}#{self.cas_authenticator_class()}#{m.post_match}"
    elsif m = /(#{Regexp.quote(self.seraph_config_logout_url_token())})/.match(line)
      "#{m.pre_match}#{@config.cas_server_url()}/logout#{m.post_match}"
    else
      line
    end
  end

  File.open(self.seraph_config_path(), "w") do |io|
    seraph_xml_data.each { |line| io.puts(line) }
  end
end

#update_web_xmlObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 59

def update_web_xml()
  web_xml_data = File.readlines(self.web_xml_path()).map do |line|
    if line =~ /#{web_xml_token}/
      template = File.open("#{@config.resources_dir()}/jira_cas_web.xml") { |f| f.read() }
      line + ERB.new(template).result(@config.send(:binding))
    else
      line
    end
  end

  File.open(self.web_xml_path(), "w") do |io|
    web_xml_data.each { |line| io.puts(line) }
  end
end

#web_xml_pathObject



35
36
37
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 35

def web_xml_path()
  "#{@config.build_dir()}/src/webapp/WEB-INF/web.xml"
end

#web_xml_tokenObject



39
40
41
# File 'lib/ucb_deployer/config_tasks/jira/config_cas_auth.rb', line 39

def web_xml_token()
  "<!--This filter is used to determine is there are any Application Errors before any pages are accessed"
end