partly working security: registration form, authorization, simple authentification
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 6 Dec 2013 18:13:14 +0000 (18:13 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 6 Dec 2013 18:13:14 +0000 (18:13 +0000)
32 files changed:
.classpath
WEB-INF/spring-security.xml
WEB-INF/web.xml
conf/Proteocache.properties
datadb/compbio/cassandra/CassandraNativeConnector.java
server/compbio/controllers/DailyStatisticsController.java
server/compbio/controllers/HelpController.java
server/compbio/controllers/IPDataController.java
server/compbio/controllers/JobExecutionTimeController.java
server/compbio/controllers/JobLogController.java
server/compbio/controllers/MainController.java
server/compbio/controllers/SequenceController.java
server/compbio/listeners/ContextListener.java
server/compbio/spring/WebConfig.java
webapp/resources/index.jsp
webapp/view/fragments/mainmenu.jsp
webapp/view/queryIP.jsp
webapp/view/queryIPStatistics.jsp
webapp/view/queryJobLog.jsp
webapp/view/queryJobStatistics.jsp
webapp/view/queryProteinSequence.jsp
webapp/view/queryProteinSequenceCounter.jsp
webapp/view/queryTimeExecution.jsp
webapp/view/reportIP.jsp
webapp/view/reportIPstatistics.jsp
webapp/view/reportJobLog.jsp
webapp/view/reportJobStatistics.jsp
webapp/view/reportJobStatisticsOneDay.jsp
webapp/view/reportProteinSequences.jsp
webapp/view/reportProteinSequencesCounter.jsp
webapp/view/reportTimeExecution.jsp
webapp/view/support/Notpermitted.jsp [deleted file]

index 2816de8..039628b 100644 (file)
        <classpathentry kind="lib" path="WEB-INF/lib/spring-jms-3.2.3.RELEASE.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-orm-3.2.3.RELEASE.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-oxm-3.2.3.RELEASE.jar"/>
-       <classpathentry kind="lib" path="WEB-INF/lib/spring-tx-3.2.3.RELEASE.jar"/>
+       <classpathentry kind="lib" path="WEB-INF/lib/spring-tx-3.2.3.RELEASE.jar" sourcepath="/home/asherstnev/.m2/repository/org/springframework/spring-tx/3.2.3.RELEASE/spring-tx-3.2.3.RELEASE-sources.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-web-3.2.3.RELEASE.jar" sourcepath="/home/asherstnev/.m2/repository/org/springframework/spring-web/3.2.3.RELEASE/spring-web-3.2.3.RELEASE-sources.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-webmvc-3.2.3.RELEASE.jar" sourcepath="/home/asherstnev/.m2/repository/org/springframework/spring-webmvc/3.2.3.RELEASE/spring-webmvc-3.2.3.RELEASE-sources.jar"/>
-       <classpathentry kind="lib" path="WEB-INF/lib/spring-context-3.2.3.RELEASE.jar"/>
+       <classpathentry kind="lib" path="WEB-INF/lib/spring-context-3.2.3.RELEASE.jar" sourcepath="/home/asherstnev/.m2/repository/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE-sources.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-context-support-3.2.3.RELEASE.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-security-acl-3.1.4.RELEASE.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-security-config-3.1.4.RELEASE.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-security-core-3.1.4.RELEASE.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-security-taglibs-3.1.4.RELEASE.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/spring-security-web-3.1.4.RELEASE.jar"/>
+       <classpathentry kind="lib" path="WEB-INF/lib/aopalliance-1.0.jar"/>
        <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_45"/>
        <classpathentry kind="output" path="WEB-INF/classes"/>
index b5f0040..4e8b52c 100644 (file)
@@ -1,4 +1,5 @@
-<beans:beans xmlns="http://www.springframework.org/schema/security"
+<beans:beans 
+       xmlns="http://www.springframework.org/schema/security"
        xmlns:beans="http://www.springframework.org/schema/beans" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
@@ -6,17 +7,46 @@
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-3.1.xsd">
 
-       <http auto-config="true">
-               <intercept-url pattern="/home/*" access="ROLE_USER" />
-               <form-login login-page="/login" default-target-url="/welcome"
-                       authentication-failure-url="/loginfailed" />
+       <http auto-config="true" use-expressions="true" access-denied-page="/denied">
+               <intercept-url pattern="/stat/**" access="hasRole('ROLE_USER')" />
+               <intercept-url pattern="/sequence/**" access="hasRole('ROLE_USER')" />
+               <intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
+               <intercept-url pattern="/database/**" access="hasRole('ROLE_ADMIN')" />
+               <intercept-url pattern="/public*" access="permitAll"/>
+               <intercept-url pattern="/login*" access="permitAll"/>
+               <intercept-url pattern="/index*" access="permitAll"/>
+               <intercept-url pattern="/register*" access="permitAll"/>
+               <form-login 
+                       login-page="/login"
+                       default-target-url="/home"
+                       authentication-failure-url="/loginfailed"
+               />
                <logout logout-success-url="/logout" />
        </http>
 
+       <global-method-security secured-annotations="enabled">
+       </global-method-security>       
+
+<!-- 
+       <http access-denied-page="/denied.xhtml"  auto-config="true" use-expressions="false" >
+               <form-login 
+                       login-page="/login.xhtml"
+                       default-target-url="/"
+                       authentication-failure-url="/denied.xhtml"
+               login-processing-url="/static/j_spring_security_check"
+               />
+               <intercept-url pattern="/PANEL/**" access="ROLE_GENERALT"></intercept-url>
+               <logout invalidate-session="true" logout-url="/index.xhtml"/>
+       </http>
+
+       <global-method-security secured-annotations="enabled" jsr250-annotations="enabled"></global-method-security>
+-->
+
        <authentication-manager>
                <authentication-provider>
                        <user-service>
-                               <user name="sherstnev" password="sasha12345" authorities="ROLE_USER" />
+                               <user name="sherstnev" password="sasha" authorities="ROLE_USER" />
+                               <user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" />
                        </user-service>
                </authentication-provider>
        </authentication-manager>
index a3ec7a2..2032623 100644 (file)
                <welcome-file>index.jsp</welcome-file>\r
        </welcome-file-list>\r
 \r
+       <!-- ############################################################################################################ -->\r
+       <!-- Spring Security -->\r
+\r
+       <listener>\r
+               <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>\r
+       </listener>\r
+\r
+       <context-param>\r
+               <param-name>contextConfigLocation</param-name>\r
+               <param-value>\r
+                       /WEB-INF/spring-security.xml\r
+               </param-value>\r
+       </context-param>\r
+\r
+       <filter>\r
+               <filter-name>springSecurityFilterChain</filter-name>\r
+               <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>\r
+       </filter>\r
+\r
+       <filter-mapping>\r
+               <filter-name>springSecurityFilterChain</filter-name>\r
+               <url-pattern>/*</url-pattern>\r
+       </filter-mapping>\r
+\r
+       <!-- Main Spring Servlet: annotation based configuration -->\r
        <servlet>\r
                <servlet-name>proteocache</servlet-name>\r
                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>\r
index 2b2515a..b1730f4 100644 (file)
@@ -1,8 +1,8 @@
 #################################################################################
 # Cassandra host or IP
 # test server is 10.0.115.190
-#cassandra.host=localhost
-cassandra.host=gjb-www-1.cluster.lifesci.dundee.ac.uk
+cassandra.host=localhost
+#cassandra.host=gjb-www-1.cluster.lifesci.dundee.ac.uk
 
 cassandra.newtables.update=false
 
index 0a5a795..5e5cf5a 100644 (file)
@@ -3,6 +3,7 @@ package compbio.cassandra;
 import java.util.Calendar;
 
 import org.apache.log4j.Logger;
+import org.springframework.dao.DataIntegrityViolationException;
 
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Configuration;
@@ -17,6 +18,8 @@ import com.datastax.driver.core.Row;
 import com.datastax.driver.core.SocketOptions;
 
 import com.datastax.driver.core.Session;
+import com.datastax.driver.core.exceptions.QueryExecutionException;
+import com.datastax.driver.core.exceptions.QueryValidationException;
 import com.datastax.driver.core.policies.Policies;
 
 import compbio.engine.ProteoCachePropertyHelperManager;
@@ -82,14 +85,33 @@ public class CassandraNativeConnector {
                session.execute("CREATE TABLE IF NOT EXISTS JpredArchive "
                                + "(JobID ascii, Protein varchar, IP ascii, StartTime bigint, ExecTime int, FinalStatus ascii, ExecutionStatus ascii, alignment map<ascii,ascii>, "
                                + "predictions map<ascii,ascii>, ArchiveLink varchar, LOG varchar, PRIMARY KEY(JobID));");
-               
+
                session.execute("CREATE TABLE IF NOT EXISTS JobDateInfo "
                                + "(jobday bigint, Total bigint,  TotalOK bigint, TotalStopped bigint, TotalError bigint, TotalTimeOut bigint, Program varchar, Version varchar, PRIMARY KEY(jobday));");
 
+               String com = "CREATE TABLE IF NOT EXISTS Users "
+                               + "(name varchar, id bigint, email varchar, password varchar, organisation varchar, position varchar, signedtolist boolean, registrationdate bigint, PRIMARY KEY(id));";
+               
+               
+               try {
+                       session.execute(com);
+               } catch (QueryExecutionException e) {
+                       String mess = "CassandraNativeConnector.CreateMainTables: query execution exception...";
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+               } catch (QueryValidationException e) {
+                       String mess = "CassandraNativeConnector.CreateMainTables: query validation exception... Command: " + com;
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+               }
+
                session.execute("CREATE INDEX IF NOT EXISTS ProteinSeq ON ProteinRow (protein);");
                session.execute("CREATE INDEX IF NOT EXISTS ProteinIp ON ProteinLog (ip);");
                session.execute("CREATE INDEX IF NOT EXISTS ON ProteinLog (ExecutionStatus);");
                session.execute("CREATE INDEX IF NOT EXISTS ON FailLog (FinalStatus);");
+               session.execute("CREATE INDEX IF NOT EXISTS ON Users (email);");
        //      session.execute("CREATE INDEX IF NOT EXISTS JobDateStamp ON ProteinData (jobtime);");
        } 
 
index 142a298..d508c82 100644 (file)
@@ -1,5 +1,6 @@
 package compbio.controllers;
 
+import java.security.Principal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -24,8 +25,9 @@ import compbio.statistic.StatisticsProt;
 @Controller
 public class DailyStatisticsController {
 
-       @RequestMapping(value = "/stat", method = RequestMethod.GET)
-       public String initFindForm(Map<String, Object> model) {
+       @RequestMapping(value = "/stat/jobs/query", method = RequestMethod.GET)
+       public String initFindForm(Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                Calendar cal = Calendar.getInstance();
                String date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DATE);
                cal.add(Calendar.DATE, -3);
@@ -37,9 +39,10 @@ public class DailyStatisticsController {
                return "queryJobStatistics";
        }
 
-       @RequestMapping(value = "/stat/query", method = RequestMethod.GET)
+       @RequestMapping(value = "/stat/jobsdaily/results", method = RequestMethod.GET)
        public String findJobsInPeriod(@RequestParam("date1") String date1, @RequestParam("date2") String date2,
-                       @RequestParam("option") String option, Map<String, Object> model) {
+                       @RequestParam("option") String option, Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                final long startTime = System.currentTimeMillis();
 
                CassandraRequester cr = new CassandraRequester();
@@ -59,9 +62,10 @@ public class DailyStatisticsController {
                return "/reportJobStatistics";
        }
 
-       @RequestMapping(value = "/stat/oneday", method = RequestMethod.GET)
-       public String findJobsInOneDay(@RequestParam("date") String date, @RequestParam("status") String status, Map<String, Object> model) throws ParseException {
-
+       @RequestMapping(value = "/stat/jobsoneday/results", method = RequestMethod.GET)
+       public String findJobsInOneDay(@RequestParam("date") String date, @RequestParam("status") String status, Map<String, Object> model,
+                       Principal principal) throws ParseException {
+               model.put("username", principal.getName());
                final long startTime = System.currentTimeMillis();
 
                String realdate;
index e0345b1..96ae042 100644 (file)
@@ -1,5 +1,6 @@
 package compbio.controllers;
 
+import java.security.Principal;
 import java.util.Map;
 
 import org.springframework.stereotype.Controller;
@@ -16,22 +17,33 @@ import org.springframework.web.bind.annotation.RequestMethod;
 public class HelpController {
 
        @RequestMapping(value = "/help/overview", method = RequestMethod.GET)
-       public String formOverviewPage(Map<String, Object> model) {
+       public String formOverviewPage(Map<String, Object> model, Principal principal) {
+               model.put("username", getPrincipleName(principal));
                return "help/Overview";
        }
 
        @RequestMapping(value = "/help/howto", method = RequestMethod.GET)
-       public String formHowtoPage(Map<String, Object> model) {
+       public String formHowtoPage(Map<String, Object> model, Principal principal) {
+               model.put("username", getPrincipleName(principal));
                return "support/Notimplemented";
        }
 
        @RequestMapping(value = "/help/doc", method = RequestMethod.GET)
-       public String formDocPage(Map<String, Object> model) {
+       public String formDocPage(Map<String, Object> model, Principal principal) {
+               model.put("username", getPrincipleName(principal));
                return "support/Notimplemented";
        }
 
        @RequestMapping(value = "/help/javadoc", method = RequestMethod.GET)
-       public String formJavadoc(Map<String, Object> model) {
+       public String formJavadoc(Map<String, Object> model, Principal principal) {
+               model.put("username", getPrincipleName(principal));
                return "support/Notimplemented";
        }
+       
+       private String getPrincipleName (Principal principal) {
+               if (null != principal.getName()) {
+                       return principal.getName();
+               }
+               return "unknown";
+       }
 }
index 424a742..690c57e 100644 (file)
@@ -1,5 +1,6 @@
 package compbio.controllers;
 
+import java.security.Principal;
 import java.util.List;
 import java.util.Map;
 
@@ -8,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import compbio.cassandra.DataBase;
 import compbio.cassandra.TotalByCounterBean;
 import compbio.cassandra.UserBean;
 import compbio.statistic.CassandraRequester;
@@ -20,21 +20,23 @@ import compbio.statistic.CassandraRequester;
 @Controller
 public class IPDataController {
 
-       @RequestMapping(value = "/ip/stat", method = RequestMethod.GET)
-       public String initStatisticsForm(Map<String, Object> model) {
+       @RequestMapping(value = "/admin/ip/counts/query", method = RequestMethod.GET)
+       public String initStatisticsForm(Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                model.put("value", 5);
                return "queryIPStatistics";
        }
 
-       @RequestMapping(value = "/ip", method = RequestMethod.GET)
-       public String initOneIPForm(Map<String, Object> model) {
+       @RequestMapping(value = "/admin/ip/query", method = RequestMethod.GET)
+       public String initOneIPForm(Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                model.put("value", "127.0.0.1");
                return "queryIP";
        }
        
-       @RequestMapping(value = "/ip/stat/querycounter", method = RequestMethod.GET)
-       public String findIPwithCounter(@RequestParam("JobCounter") String counter, Map<String, Object> model) {
-
+       @RequestMapping(value = "/admin/ip/counts/results", method = RequestMethod.GET)
+       public String findIPwithCounter(@RequestParam("JobCounter") String counter, Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                if (counter.equals("")) {
                        model.put("error", "The value must not be empty");
                        model.put("value", counter);
@@ -70,8 +72,9 @@ public class IPDataController {
                return "reportIPstatistics";
        }
 
-       @RequestMapping(value = "/ip/query", method = RequestMethod.GET)
-       public String findIP(@RequestParam("ip") String ip, Map<String, Object> model) {
+       @RequestMapping(value = "/admin/ip/results", method = RequestMethod.GET)
+       public String findIP(@RequestParam("ip") String ip, Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                final long startTime = System.currentTimeMillis();
                CassandraRequester cr = new CassandraRequester();
                UserBean r = cr.readIp(ip);
index 6170078..71843a9 100644 (file)
@@ -1,5 +1,6 @@
 package compbio.controllers;
 
+import java.security.Principal;
 import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
@@ -21,8 +22,9 @@ import compbio.statistic.StatisticsProt;
 @Controller
 public class JobExecutionTimeController {
 
-       @RequestMapping(value = "/exectime", method = RequestMethod.GET)
-       public String initFindForm(Map<String, Object> model) {
+       @RequestMapping(value = "/stat/exectime/query", method = RequestMethod.GET)
+       public String initFindForm(Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                Calendar cal = Calendar.getInstance();
                String date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DATE);
                cal.add(Calendar.DATE, -3);
@@ -33,9 +35,10 @@ public class JobExecutionTimeController {
                return "queryTimeExecution";
        }
 
-       @RequestMapping(value = "/exectime/query", method = RequestMethod.GET)
+       @RequestMapping(value = "/stat/exectime/results", method = RequestMethod.GET)
        public String findSequence(@RequestParam("date1") String date1, @RequestParam("date2") String date2,
-                       @RequestParam(value="option", required=false) String option, Map<String, Object> model) {
+                       @RequestParam(value="option", required=false) String option, Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                final long startTime = System.currentTimeMillis();
 
                CassandraRequester sp = new CassandraRequester();
index db6981d..28d6961 100644 (file)
@@ -1,5 +1,6 @@
 package compbio.controllers;
 
+import java.security.Principal;
 import java.util.Map;
 
 import org.springframework.stereotype.Controller;
@@ -16,14 +17,16 @@ import compbio.statistic.CassandraRequester;
 @Controller
 public class JobLogController {
 
-       @RequestMapping(value = "/joblog", method = RequestMethod.GET)
-       public String initFindForm(Map<String, Object> model) {
+       @RequestMapping(value = "/job/query", method = RequestMethod.GET)
+       public String initFindForm(Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                model.put("value", "jp_NzBOJKo");
                return "queryJobLog";
        }
 
-       @RequestMapping(value = "/joblog/query", method = RequestMethod.GET)
-       public String findJob(@RequestParam("IdJob") String jobid, Map<String, Object> model) {
+       @RequestMapping(value = "/job/results", method = RequestMethod.GET)
+       public String findJob(@RequestParam("IdJob") String jobid, Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                final long startTime = System.currentTimeMillis();
                CassandraRequester cr = new CassandraRequester();
                model.put("result", cr.readJobLog(jobid));
index 7a8b926..f918c24 100644 (file)
@@ -1,15 +1,59 @@
 package compbio.controllers;
 
+import java.security.Principal;
 import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
+import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 
 @Controller
 public class MainController {
 
-       @RequestMapping("home")
-       public String loadHomePage(Model m) {
-               m.addAttribute("name", "Proteocache");
+       @RequestMapping(value = "/index", method = RequestMethod.GET)
+       public String printPublicHome(ModelMap model, Principal principal) {
+               String name = "";
+               // if (null != name ) {
+               // name = principal.getName();
+               // }
+               model.addAttribute("username", name);
+               model.addAttribute("message", "Spring Security Custom Form example");
+               return "public";
+       }
+
+       @RequestMapping(value = "/login", method = RequestMethod.GET)
+       public String login(ModelMap model) {
+               return "login";
+       }
+
+       @RequestMapping(value = "/loginfailed", method = RequestMethod.GET)
+       public String loginerror(ModelMap model) {
+               model.addAttribute("error", "Wrong user name or password");
+               return "login";
+       }
+
+       @RequestMapping(value = "/logout", method = RequestMethod.GET)
+       public String logout(ModelMap model) {
+               return "public";
+       }
+
+       @RequestMapping(value = "/denied", method = RequestMethod.GET)
+       public String denied(ModelMap model, Principal principal) {
+               String name = "unknown";
+               if (null != principal.getName())
+                       name = principal.getName();
+               model.put("username", name);
+               return "support/Denied";
+       }
+
+       @RequestMapping(value = "/home", method = RequestMethod.GET)
+       public String printHome(ModelMap model, Principal principal) {
+               String name = "unknown";
+               if (null != name) {
+                       name = principal.getName();
+               }
+               model.addAttribute("username", name);
+               model.addAttribute("message", "Spring Security Custom Form example");
                return "home";
        }
-}
\ No newline at end of file
+
+}
index 4bb9271..ee71258 100644 (file)
@@ -1,5 +1,6 @@
 package compbio.controllers;
 
+import java.security.Principal;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
@@ -10,13 +11,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import compbio.cassandra.ProteinBean;
-import compbio.cassandra.DataBase;
-import compbio.data.sequence.SequenceUtil;
 import compbio.cassandra.TotalByCounterBean;
 import compbio.statistic.CassandraRequester;
 
 /**
- * Spring controller for sequence search. This version works in the servlet
+ * Spring controller for sequence queries. This version works in the servlet
  * style.
  * 
  * @author Alexander Sherstnev
@@ -26,6 +25,7 @@ import compbio.statistic.CassandraRequester;
  * @version 1.0 December 2013
  */
 @Controller
+@RequestMapping("/sequence")
 public class SequenceController {
 
        /**
@@ -33,20 +33,23 @@ public class SequenceController {
         */
        private final Pattern NONPROTEIN = Pattern.compile("[^ARNDCQEGHILKMFPSTWYV]+", Pattern.CASE_INSENSITIVE);
 
-       @RequestMapping(value = "/sequence/query1", method = RequestMethod.GET)
-       public String formSequenceQuery(Map<String, Object> model) {
+       @RequestMapping(value = "query", method = RequestMethod.GET)
+       public String formSequenceQuery(Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                model.put("value", "AAAAA");
                return "queryProteinSequence";
        }
 
-       @RequestMapping(value = "/sequence/query2", method = RequestMethod.GET)
-       public String formCounterQuery(Map<String, Object> model) {
+       @RequestMapping(value = "counts/query", method = RequestMethod.GET)
+       public String formCounterQuery(Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                model.put("value", 5);
                return "queryProteinSequenceCounter";
        }
 
-       @RequestMapping(value = "/sequence/querysequence", method = RequestMethod.GET)
-       public String findSequence(@RequestParam("sequence") String sequence, @RequestParam("protein") String flag, Map<String, Object> model) {
+       @RequestMapping(value = "sequence/results", method = RequestMethod.GET)
+       public String findSequence(@RequestParam("sequence") String sequence, @RequestParam("protein") String flag, Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                final long startTime = System.currentTimeMillis();
 
                // input checks
@@ -82,8 +85,9 @@ public class SequenceController {
                return "reportProteinSequences";
        }
 
-       @RequestMapping(value = "/sequence/querycounter", method = RequestMethod.GET)
-       public String countSequences(@RequestParam("counterJob") String counter, Map<String, Object> model) {
+       @RequestMapping(value = "counts/results", method = RequestMethod.GET)
+       public String countSequences(@RequestParam("counterJob") String counter, Map<String, Object> model, Principal principal) {
+               model.put("username", principal.getName());
                final long startTime = System.currentTimeMillis();
 
                if (counter.equals("")) {
index aa2fa24..c3109a7 100644 (file)
@@ -11,8 +11,6 @@ import javax.servlet.annotation.WebListener;
 
 import org.apache.log4j.Logger;
 
-import com.datastax.driver.core.Session;
-
 import compbio.cassandra.CassandraNativeConnector;
 import compbio.cassandra.CassandraNewTableWriter;
 import compbio.cassandra.JpredParserHTTP;
index e7f0be2..0a0de7a 100644 (file)
@@ -3,6 +3,7 @@ package compbio.spring;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.ImportResource;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@@ -10,6 +11,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver;
 
 @Configuration
 @EnableWebMvc
+@ImportResource("WEB-INF/spring-security.xml")
 @ComponentScan(basePackages = "compbio.controllers")
 public class WebConfig extends WebMvcConfigurerAdapter {
 
index ec49fb6..97584c7 100644 (file)
@@ -2,10 +2,9 @@
 <html>
        <head>
                <title></title>
-               <script type="text/javascript">window.location.href='<%=request.getContextPath()%>/home'</script>
+               <script type="text/javascript">window.location.href='<%=request.getContextPath()%>/index'</script>
        </head>
        <body>
-               If you are not redirected automatically, click 
-                       <a href="<%=request.getContextPath()%>/home">here</a>.
+               If you are not redirected automatically, click <a href="<%=request.getContextPath()%>/index">here</a>.
        </body>
 </html>
index ed67bb7..1379729 100644 (file)
@@ -1,9 +1,10 @@
 <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
 
 <jsp:include page="logos.jsp" />
 
-<nav class="navbar navbar-default" role="navigation">
+<nav class="navbar navbar-default">
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                        <li>
                        </li>
                        <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-search"></span> Search Servlets <b class="caret"></b></a>
                                <ul class="dropdown-menu">
-                                       <li><a href="<spring:url value="/sequence/query1" htmlEscape="true" />">Protein Sequence</a></li>
-                                       <li><a href="<spring:url value="/joblog" htmlEscape="true" />">Job</a></li>
-                                       <li><a href="<spring:url value="/ip" htmlEscape="true" />">IP</a></li>
+                                       <li><a href="<spring:url value="/sequence/query" htmlEscape="true" />">Protein Sequence</a></li>
+                                       <li><a href="<spring:url value="/job/query" htmlEscape="true" />">Job</a></li>
+                                       <li><a href="<spring:url value="/admin/ip/query" htmlEscape="true" />">IP</a></li>
                                </ul>
                        </li>
                        <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-stats"></span> Statistics Servlets<b class="caret"></b></a>
                                <ul class="dropdown-menu">
-                                       <li><a href="<spring:url value="/stat" htmlEscape="true" />">Daily Job Statistics</a></li>
+                                       <li><a href="<spring:url value="/stat/jobs/query" htmlEscape="true" />">Daily Job Statistics</a></li>
                                        <li class="divider"></li>
-                                       <li><a href="<spring:url value="/exectime" htmlEscape="true" />">Job Time Execution</a></li>
-                                       <li><a href="<spring:url value="/ip/stat" htmlEscape="true" />">IPs by Job count</a></li>
-                                       <li><a href="<spring:url value="/sequence/query2" htmlEscape="true" />">Proteins by Job count</a></li>
+                                       <li><a href="<spring:url value="/stat/exectime/query" htmlEscape="true" />">Job Time Execution</a></li>
+                                       <li><a href="<spring:url value="/admin/ip/counts/query" htmlEscape="true" />">IPs by Job count</a></li>
+                                       <li><a href="<spring:url value="/sequence/counts/query" htmlEscape="true" />">Proteins by Job count</a></li>
                                </ul>
                        </li>
+<sec:authorize access="hasRole('ROLE_ADMIN')">
                        <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-edit"></span> Database Servlets<b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                        <li><a href="<spring:url value="/database/state" htmlEscape="true" />">DB state</a></li>
                                        <li><a href="<spring:url value="/database/remove" htmlEscape="true" />">Remove records</a></li>
                                </ul>
                        </li>
+</sec:authorize>
                </ul>
                <ul class="nav navbar-nav navbar-right">
+                       <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> ${username}<b class="caret"></b></a>
+                               <ul class="dropdown-menu">
+                                       <li><a href="<spring:url value="/logout" htmlEscape="true" />">Logout</a></li>
+                                       <li><a href="<spring:url value="/user/account" htmlEscape="true" />">User account</a></li>
+                               </ul>
+                       </li>
                        <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-question-sign"></span> Help<b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                        <li><a href="<spring:url value="/help/overview" htmlEscape="true" />">Overview</a></li>
index 95ca909..ca6540f 100644 (file)
@@ -10,7 +10,7 @@
 <body>
        <div class="container">
        <jsp:include page="fragments/mainmenu.jsp" />
-       <spring:url value="/ip/query" var="query"/>
+       <spring:url value="/admin/ip/results" var="query"/>
 
        <div class="panel panel-default">
                <div class="panel-heading">
index 9181754..bbd6840 100644 (file)
@@ -11,7 +11,7 @@
 <body>
        <div class="container">
        <jsp:include page="fragments/mainmenu.jsp" />
-       <spring:url value="/ip/stat/querycounter" var="query"/>
+       <spring:url value="/admin/ip/counts/results" var="query"/>
 
        <div class="panel panel-default">
                <div class="panel-heading">
index 7c5db0a..d101fc4 100644 (file)
 <body>
        <div class="container">
        <jsp:include page="fragments/mainmenu.jsp" />
+       <spring:url value="/job/query" var="query"/>
 
        <div class="panel panel-default">
                <div class="panel-heading">
                        <div style="font-weight:bold;">Enter Job Id</div>
                </div>
                <div class="panel-body">
-                       <spring:url value="/joblog/query" var="formurl"/>
-                       <form method="get" action="${fn:escapeXml(formurl)}">
+                       <form method="get" action="${query}">
                        <p><input type="text" name="IdJob" value="${value}"></p>
                        <input type="submit" name="Search" value="Search"/>
                </form>
index 35d813d..4160843 100644 (file)
 <body>
        <div class="container">
        <jsp:include page="fragments/mainmenu.jsp" />
+       <spring:url value="/stat/jobsdaily/results" var="query" />
 
        <div class="panel panel-default">
                <div class="panel-heading">
                        <div style="font-weight:bold;">Enter time period for daily job statistics</div>
                </div>
                <div class="panel-body">
-                       <spring:url value="/stat/query" var="formurl" />
-                       <form method="get" action="${fn:escapeXml(formurl)}">
+                       <form method="get" action="${query}">
                                <p><input type="checkbox" name="option" value="AllDates" checked="checked" onclick="hide(this, 'date');"> Query for all dates<br>
                                <div id='date' style="visibility:hidden;">
                                <p>
index 7feeb4e..1312265 100644 (file)
@@ -11,7 +11,7 @@
 <body>
        <div class="container">
        <jsp:include page="fragments/mainmenu.jsp" />
-       <spring:url value="/sequence/querysequence" var="query"/>
+       <spring:url value="/sequence/sequence/results" var="query"/>
 
        <div class="panel panel-default">
                <div class="panel-heading">
index c7d7ab6..6b864c5 100644 (file)
@@ -11,7 +11,7 @@
 <body>
        <div class="container">
        <jsp:include page="fragments/mainmenu.jsp" />
-       <spring:url value="/sequence/querycounter" var="query"/>
+       <spring:url value="/sequence/counts/results" var="query"/>
 
        <div class="panel panel-default">
                <div class="panel-heading">
index 3f5d1c6..3d7f7f2 100644 (file)
@@ -10,7 +10,7 @@
 <body>
        <div class="container">
        <jsp:include page="fragments/mainmenu.jsp" />
-       <spring:url value="/exectime/query" var="query"/>
+       <spring:url value="/stat/exectime/results" var="query"/>
 
        <div class="panel panel-default">
                <div class="panel-heading">
index dce9db8..0d87c6e 100644 (file)
@@ -10,7 +10,7 @@
 <body>
        <div class="container">
                <jsp:include page="fragments/mainmenu.jsp" />
-               <spring:url value="/joblog/query" var="jobqueryservlet" />
+               <spring:url value="/job/results" var="jobqueryservlet" />
 
        <div class="panel panel-default">
        <div class="panel-heading">
index 8c9a153..2a6c882 100644 (file)
@@ -11,7 +11,7 @@
 <body>
        <div class="container">
                <jsp:include page="fragments/mainmenu.jsp" />
-               <spring:url value="/ip/query" var="ipquery" />
+               <spring:url value="/admin/ip/results" var="ipquery" />
 
        <div class="panel panel-default">
        <div class="panel-heading">
index 91b7b8f..f82ed25 100644 (file)
@@ -11,8 +11,8 @@
 <body>
        <div class="container">
                <jsp:include page="fragments/mainmenu.jsp" />
-               <spring:url value="/sequence/querysequence" var="searchquery" />
-               <spring:url value="/ip/query" var="ipquery" />
+               <spring:url value="/sequence/sequence/results" var="sequence_query" />
+               <spring:url value="/admin/ip/results" var="ip_query" />
 
                <div class="panel panel-default">
                <div class="panel-heading">
                <div class="panel-body">
                        <p>Start timestamp : ${result.dateStart}</p>
                        <p>End timestamp : ${result.dateEnd}</p>
-                       <p>IP: <a title="Click to view other jobs" href="${ipquery}?ip=${result.ip}&Search=Search">${result.ip}</a></p>
+                       <p>IP: <a title="Click to view other jobs" href="${ip_query}?ip=${result.ip}&Search=Search">${result.ip}</a></p>
 
                        <table class="table table-striped table-hover table-bordered">
                        <tbody>
                                <tr>
                                        <td>Sequence</td>
                                        <td style="text-align: left; border-buttom: dotted; font-family: monospace">
-                                               <a title="Click to view other jobs" href="${searchquery}?sequence=${result.sequence}&protein=whole&Search=Search">${result.sequence}</a>
+                                               <a title="Click to view other jobs" href="${sequence_query}?sequence=${result.sequence}&protein=whole&Search=Search">${result.sequence}</a>
                                        </td>
                                </tr>
                                <c:forEach items="${result.prediction}" var="pred">
                                        <tr>
                                                <td>${pred.key}</td>
-                                               <td
-                                                       style="text-align: left; border-buttom: dotted; font-family: monospace">
-                                                       ${pred.value}</td>
+                                               <td style="text-align: left; border-buttom: dotted; font-family: monospace">${pred.value}</td>
                                        </tr>
                                </c:forEach>
                        </tbody>
index 5a833ec..185cbfc 100644 (file)
 <body>
        <div class="container">
                <jsp:include page="fragments/mainmenu.jsp" />
-               <spring:url value="/stat/oneday" var="onedayquery" />
-               <spring:url value="/stat/query?date1=${date1}&date2=${date2}&option=${option}" var="thequery" />
+               <spring:url value="/stat/jobsoneday/results" var="oneday_query" />
+               <spring:url value="/stat/jobsdaily/results?date1=${date1}&date2=${date2}&option=${option}" var="the_query" />
 
        <ul class="nav navbar-nav navbar-right">
                <li>
-               <a href="${thequery}" class="btn btn-default active">Reload</a>
+               <a href="${the_query}" class="btn btn-default active">Reload</a>
                </li>
        </ul>
 
                                                                <td style="text-align: center">${res.key}</td>
                                                                <c:set var="value" value="${res.value}"/>
                                                                <td style="text-align: right">${value.total}</td>
-                                                               <td style="text-align: right"><a href="${onedayquery}?date=${res.key}&status=OK">${value.totalOK}</a></td>
+                                                               <td style="text-align: right"><a href="${oneday_query}?date=${res.key}&status=OK">${value.totalOK}</a></td>
                                                                <td style="text-align: right">
                                                                        <c:choose>
                                                                        <c:when test="${value.totalStopped == 0}">0</c:when>
-                                                                       <c:otherwise><a href="${onedayquery}?date=${res.key}&status=Stopped">${value.totalStopped}</a></c:otherwise>
+                                                                       <c:otherwise><a href="${oneday_query}?date=${res.key}&status=Stopped">${value.totalStopped}</a></c:otherwise>
                                                                        </c:choose>
                                                                </td>
                                                                <td style="text-align: right">
                                                                        <c:choose>
                                                                        <c:when test="${value.totalError == 0}">0</c:when>
-                                                                       <c:otherwise><a href="${onedayquery}?date=${res.key}&status=JpredError">${value.totalError}</a></c:otherwise>
+                                                                       <c:otherwise><a href="${oneday_query}?date=${res.key}&status=JpredError">${value.totalError}</a></c:otherwise>
                                                                        </c:choose>
                                                                </td>
                                                                <td style="text-align: right">
                                                                        <c:choose>
                                                                        <c:when test="${value.totalTimeOut == 0}">0</c:when>
-                                                                       <c:otherwise><a href="${onedayquery}?date=${res.key}&status=TimedOut">${value.totalTimeOut}</a></c:otherwise>
+                                                                       <c:otherwise><a href="${oneday_query}?date=${res.key}&status=TimedOut">${value.totalTimeOut}</a></c:otherwise>
                                                                        </c:choose>
                                                                </td>
                                                        </tr>
index 1176913..82a3def 100644 (file)
 <body>
        <div class="container">
                <jsp:include page="fragments/mainmenu.jsp" />
-               <spring:url value="/joblog/query" var="jobquery" />
-               <spring:url value="/stat/oneday?date=${date}&status=${status}" var="thequery" />
+               <spring:url value="/job/results" var="job_query" />
+               <spring:url value="/stat/onedaystat?date=${date}&status=${status}" var="the_query" />
 
        <ul class="nav navbar-nav navbar-right">
                <li>
-               <a href="${thequery}" class="btn btn-default active">Reload</a>
+               <a href="${the_query}" class="btn btn-default active">Reload</a>
                </li>
        </ul>
 
@@ -42,7 +42,7 @@
                <tbody>
                        <c:forEach items="${results.jobidAndSeq}" var="res" varStatus="status">
                                <tr>
-                                       <td><a href="${jobquery}?IdJob=${res.key}">${res.key}</a></td>
+                                       <td><a href="${job_query}?IdJob=${res.key}">${res.key}</a></td>
                                        <c:choose>
                                        <c:when test="${res.value == ''}">
                                                        <td>Job with alignment</td>
index 29d7e36..45bd1e9 100644 (file)
@@ -11,8 +11,7 @@
 <body>
        <div class="container">
                <jsp:include page="fragments/mainmenu.jsp" />
-               <spring:url value="/sequence/query" var="searchquery" />
-               <spring:url value="/joblog/query" var="jobquery" />
+               <spring:url value="/job/results" var="job_query" />
 
        <div class="panel panel-default">
        <div class="panel-heading">
@@ -49,7 +48,7 @@
                                                                <tr>
                                                                        <th rowspan="${res.size + 2}"><a
                                                                                title="Click to view the job log"
-                                                                               href="${jobquery}?IdJob=${id}">${id}</a></th>
+                                                                               href="${job_query}?IdJob=${id}">${id}</a></th>
                                                                </tr>
                                                                <tr>
                                                                        <td
index 7944451..e11db1e 100644 (file)
@@ -13,8 +13,7 @@
 <body>
        <div class="container">
                <jsp:include page="fragments/mainmenu.jsp" />
-               <spring:url value="/sequence/querysequence" var="searchquery" />
-               <spring:url value="/joblog/query" var="jobquery" />
+               <spring:url value="/sequence/sequence/results" var="sequence_query" />
 
        <div class="panel panel-default">
        <div class="panel-heading">
@@ -41,7 +40,7 @@
                                        <tr>
                                                <td>${res.totaljobs}</td>
                                                <td style="text-align: left; border-buttom: dotted; font-family: monospace">
-                                                       <a title="Click to view all jobs" href="${searchquery}?sequence=${res.name}&protein=whole&Search=Search">${res.name}</a>
+                                                       <a title="Click to view all jobs" href="${sequence_query}?sequence=${res.name}&protein=whole&Search=Search">${res.name}</a>
                                                </td>
                                        </tr>
                                </c:forEach>
index fceb06e..64cef89 100644 (file)
 <body>
        <div class="container">
                <jsp:include page="fragments/mainmenu.jsp" />
-               <spring:url value="/exectime/query?date1=${date1}&date2=${date2}&option=${option}" var="thequery" />
+               <spring:url value="/stat/exectime/query?date1=${date1}&date2=${date2}&option=${option}" var="the_query" />
 
        <!-- reload button  -->
        <ul class="nav navbar-nav navbar-right">
                <li>
-               <a href="${thequery}" class="btn btn-default active">Reload</a>
+               <a href="${the_query}" class="btn btn-default active">Reload</a>
                </li>
        </ul>
 
diff --git a/webapp/view/support/Notpermitted.jsp b/webapp/view/support/Notpermitted.jsp
deleted file mode 100644 (file)
index 260ecbb..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
-       pageEncoding="UTF-8"%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
-<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@page import="java.util.ArrayList"%>
-
-<html>
-<jsp:include page="../fragments/header.jsp" />
-<body>
-       <div class="container">
-               <jsp:include page="../fragments/mainmenu.jsp" />
-
-               <div class="panel panel-default">
-                       <div class="panel-heading">
-                               <div style="font-weight:bold;">The page is not available...</div>
-                       </div>
-                       <div class="panel-body">
-                               <p>You do not have unough permissions to view the page</p>
-                       </div>
-               </div>
-
-               <jsp:include page="../fragments/footer.jsp" />
-       </div>
-</body>
-</html>
\ No newline at end of file