end
def generate_secret
- render :text => java_facade.generateRandomSecretKey()
+ @secret = java_facade.generateRandomSecretKey()
+ render :partial => 'encryption_configuration/generate_secret_key'
end
def encrypt
bad_request('No secret key') unless java_facade.hasSecretKey()
- render :text => java_facade.encrypt(params[:text])
+ @encrypted = java_facade.encrypt(params[:text])
+ render :partial => 'encryption_configuration/encrypt'
end
private
--- /dev/null
+<p class="spacer-bottom">Encrypted value: <input type="text" id="encrypted_text" size="40" readonly="readonly" class="notice" value="<%= @encrypted -%>"></p>
\ No newline at end of file
--- /dev/null
+<ul class="bullet">
+ <li>Store the secret key <input type="text" size="40" readonly="readonly" id="secret" value="<%= @secret -%>" class="notice"/> 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>Restart the server if the property <code>sonar.secretKeyPath</code> has been set or changed.</li>
+ <li>Copy this file on all the machines that execute code inspection. Define the property <code>sonar.secretKeyPath</code> on those machines if the path is not <code>~/.sonar/sonar-secret.txt</code>.</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
-<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',
+<h3 class="spacer-bottom">Encryption</h3>
+<p class="spacer-bottom">Secret key is required to be able to encrypt properties. <a href="http://docs.codehaus.org/display/SONAR/Settings+Encryption" class="external">More information</a>.</p>
+<div id="secret_content">
+ <%= button_to_remote 'Generate secret key',
:url => {:action => 'generate_secret'},
- :update => {:success => 'secret', :failure => 'secret_error'},
- :success => "$('secret').show()",
+ :update => {:success => 'secret_content', :failure => 'secret_error'},
: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
+ <span id="secret_error" class="error" style="display:none"></span>
+</div>
\ No newline at end of file
+<h3 class="spacer-bottom">Encryption</h3>
<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 => 'encrypted_text', :failure => 'encryption_error'},
- :success => "$('encrypted_text').show()",
+ :update => {:success => 'encrypted_section', :failure => 'encryption_error'},
+ :success => "$('encrypted_section').show();$('encryption_error').hide();",
:failure => "$('encryption_error').show()",
:html => {:class => 'spacer-bottom'} -%>
<input type="text" name="text" id="clear_text"/>
<input type="submit" value="Encrypt" id="submit_encrypt"/>
-<span id="encrypted_text" class="notice" style="display:none"></span>
-<span id="encryption_error" class="error" style="display:none"></span>
</form>
+
+<div id="encrypted_section" style="display:none"></div>
+<span id="encryption_error" class="error" style="display:none"></span>
+
<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>
+ but all the encrypted properties will have to be updated. <a href="http://docs.codehaus.org/display/SONAR/Settings+Encryption" class="external">More information</a>.</p>
<script>
$('clear_text').focus();
</script>
\ No newline at end of file