aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-03-13 18:27:19 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-03-13 18:27:19 +0100
commit017f39d3bdda35f97c564cfb31f9dc34ef5708af (patch)
tree799218dd55912265c642ad9cc8ccd9f04e76be67 /sonar-server/src/main/webapp/WEB-INF
parent864e78743095d214311c6acdc73c195220b020c1 (diff)
downloadsonarqube-017f39d3bdda35f97c564cfb31f9dc34ef5708af.tar.gz
sonarqube-017f39d3bdda35f97c564cfb31f9dc34ef5708af.zip
SONAR-2084 draft of new page 'Password encryption'
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/encryption_controller.rb47
-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.erb12
3 files changed, 63 insertions, 0 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_controller.rb
new file mode 100644
index 00000000000..789b60972a6
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/encryption_controller.rb
@@ -0,0 +1,47 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2012 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# Sonar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class EncryptionController < ApplicationController
+
+ SECTION=Navigation::SECTION_CONFIGURATION
+ before_filter :admin_required
+ verify :method => :post, :only => [:generate_secret, :encrypt], :redirect_to => {:action => :index}
+
+ def index
+ @can_encrypt=java_facade.canEncrypt()
+ end
+
+ def generate_secret
+ begin
+ @secret=java_facade.generateRandomSecretKey()
+ rescue Exception => e
+ flash[:error]=e.message
+ redirect_to :action => :index
+ end
+ end
+
+ def encrypt
+ bad_request('No secret key') unless java_facade.canEncrypt()
+ @encrypted=java_facade.encrypt(params[:text])
+ end
+
+ private
+
+
+end
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
new file mode 100644
index 00000000000..7323895aedc
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/generate_secret.html.erb
@@ -0,0 +1,4 @@
+<p>
+ Secret is:
+ <input type="text" value="<%= @secret -%>"/>
+</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
new file mode 100644
index 00000000000..06fd70d605f
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/encryption/index.html.erb
@@ -0,0 +1,12 @@
+<p>bla bla</p>
+
+<% if @can_encrypt %>
+ <form action="<%= ApplicationController.root_context -%>/encryption/encrypt" method="POST">
+ <input type="text" name="text" id="text"/>
+ <input type="submit" value="Encrypt" id="submit_encrypt"/>
+ </form>
+<% 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