aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/encryption_configuration_controller.rb (renamed from sonar-server/src/main/webapp/WEB-INF/app/controllers/encryption_controller.rb)28
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/encryption/encrypt.html.erb1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/encryption/generate_secret.html.erb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/encryption/index.html.erb14
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/encryption_configuration/generate_secret_form.html.erb22
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/encryption_configuration/index.html.erb14
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb2
8 files changed, 56 insertions, 31 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/encryption_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/encryption_configuration_controller.rb
index 46fa00700d6..d24569af8c4 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/encryption_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/encryption_configuration_controller.rb
@@ -17,32 +17,38 @@
# License along with Sonar; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
-class EncryptionController < ApplicationController
+class EncryptionConfigurationController < ApplicationController
SECTION=Navigation::SECTION_CONFIGURATION
before_filter :admin_required
+ before_filter :remove_layout
+
verify :method => :post, :only => [:generate_secret, :encrypt], :redirect_to => {:action => :index}
def index
- @has_secret_key=java_facade.hasSecretKey()
+ if java_facade.hasSecretKey()
+ render :action => 'index'
+ else
+ render :action => 'generate_secret_form'
+ end
+ end
+
+ def generate_secret_form
+
end
def generate_secret
- begin
- @secret=java_facade.generateRandomSecretKey()
- rescue Exception => e
- flash[:error]=e.message
- redirect_to :action => :index
- end
+ render :text => java_facade.generateRandomSecretKey()
end
def encrypt
bad_request('No secret key') unless java_facade.hasSecretKey()
- @encrypted=java_facade.encrypt(params[:text])
- render :action => 'encrypt', :layout => false
+ render :text => java_facade.encrypt(params[:text])
end
private
-
+ def remove_layout
+ params[:layout]='false'
+ end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
index 939c064ba40..653c42d81ab 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
@@ -21,7 +21,7 @@ class SettingsController < ApplicationController
SECTION=Navigation::SECTION_CONFIGURATION
- SPECIAL_CATEGORIES=['email', 'server_id']
+ SPECIAL_CATEGORIES=['email', 'encryption', 'server_id']
verify :method => :post, :only => ['update'], :redirect_to => {:action => :index}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/encrypt.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/encrypt.html.erb
deleted file mode 100644
index 83d55e7db1c..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/encrypt.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<code><%= @encrypted -%></code> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/generate_secret.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/generate_secret.html.erb
deleted file mode 100644
index 0ef07ca0301..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/generate_secret.html.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-<textarea rows="2" cols="80"><%= @secret -%></textarea>
-<p>
-<%= link_to 'Continue', {:action => 'index'}, {:class => 'link-action'} -%>
-</p> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/index.html.erb
deleted file mode 100644
index b81da062400..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/index.html.erb
+++ /dev/null
@@ -1,14 +0,0 @@
-<% if @has_secret_key %>
- <%= form_remote_tag :url => {:action => 'encrypt'},
- :update => { :success => 'encryption_result', :failure => 'encryption_error' },
- :failure => "$('encryption_error').show()" -%>
- <input type="text" name="text" id="text"/>
- <input type="submit" value="Encrypt" id="submit_encrypt"/>
- </form>
- <div id="encryption_result"></div>
- <div id="encryption_error" class="error" style="display:none"></div>
-<% else %>
- <form action="<%= ApplicationController.root_context -%>/encryption/generate_secret" method="POST">
- <input type="submit" value="Generate secret" id="submit_generate_secret"/>
- </form>
-<% end %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/encryption_configuration/generate_secret_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/encryption_configuration/generate_secret_form.html.erb
new file mode 100644
index 00000000000..8ef137857ef
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/encryption_configuration/generate_secret_form.html.erb
@@ -0,0 +1,22 @@
+<p>Secret key is required to be able to encrypt properties. Please follow those steps :</p>
+<ul class="bullet">
+ <li>
+ <%= button_to_remote 'Generate a random key',
+ :url => {:action => 'generate_secret'},
+ :update => {:success => 'secret', :failure => 'secret_error'},
+ :success => "$('secret').show()",
+ :failure => "$('secret_error').show()",
+ :method => 'POST',
+ :id => 'submit_generate_secret' -%>
+ <span id="secret" class="notice" style="display:none"></span>
+ <span id="secret_error" class="error" style="display:none"></span>
+ </li>
+ <li>Store this key in the file <code>~/.sonar/sonar-secret.txt</code> of the server. This file can be relocated
+ by defining the property <code>sonar.secretKeyPath</code> in <code>conf/sonar.properties</code></li>
+ <li>Restrict access to this file by making it readable and by owner only</li>
+ <li>Copy this file on all the machines that execute code inspection. Define the property <code>sonar.secretKeyPath</code> on those machines if needed.</li>
+ <li>For each property that you want to encrypt, <%= link_to 'generate the encrypted value', {:action => 'index'}, {:class => 'link-action'} -%>
+ and replace the original values where ever they are stored
+ (configuration files, command lines)
+ </li>
+</ul> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/encryption_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/encryption_configuration/index.html.erb
new file mode 100644
index 00000000000..636f0664385
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/encryption_configuration/index.html.erb
@@ -0,0 +1,14 @@
+<p class="spacer-bottom">Secret key is registered. You can encrypt any property value with the following form :</p>
+
+<%= form_remote_tag :url => {:action => 'encrypt'},
+ :update => {:success => 'encryption_result', :failure => 'encryption_error'},
+ :success => "$('encryption_result').show()",
+ :failure => "$('encryption_error').show()",
+ :html => {:class => 'spacer-bottom'} -%>
+<input type="text" name="text" id="text"/>
+<input type="submit" value="Encrypt" id="submit_encrypt"/>
+<span id="encryption_result" class="notice" style="display:none"></span>
+<span id="encryption_error" class="error" style="display:none"></span>
+</form>
+<p>Note that the <%= link_to 'secret key can be changed', {:action => 'generate_secret_form'}, :class => 'link-action' -%>
+ but all the encrypted properties will have to be updated.</p> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb
new file mode 100644
index 00000000000..0dc07f7c872
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb
@@ -0,0 +1,2 @@
+<input type="text" name="<%= h property.key -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.key-%>"/>
+<%= link_to_function(image_tag('zoom.png'), "enlargeTextInput('#{property.key}')", :class => 'nolink') -%> \ No newline at end of file