Partly working security: registration form, authorisaztion, simple authentication
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 6 Dec 2013 17:39:14 +0000 (17:39 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 6 Dec 2013 17:39:14 +0000 (17:39 +0000)
13 files changed:
WEB-INF/lib/aopalliance-1.0.jar [new file with mode: 0644]
datadb/compbio/cassandra/CassandraUserManager.java [new file with mode: 0644]
engine/compbio/engine/JobStatus.java [new file with mode: 0644]
engine/compbio/proteocache/users/User.java [new file with mode: 0644]
engine/compbio/proteocache/users/UserManager.java [new file with mode: 0644]
server/compbio/controllers/UserController.java [new file with mode: 0644]
webapp/view/Register.jsp [new file with mode: 0644]
webapp/view/fragments/mainmenu_and_figures.jsp [deleted file]
webapp/view/fragments/publicmenu.jsp [new file with mode: 0644]
webapp/view/hello.jsp [new file with mode: 0644]
webapp/view/login.jsp [new file with mode: 0644]
webapp/view/public.jsp [new file with mode: 0644]
webapp/view/support/Denied.jsp [new file with mode: 0644]

diff --git a/WEB-INF/lib/aopalliance-1.0.jar b/WEB-INF/lib/aopalliance-1.0.jar
new file mode 100644 (file)
index 0000000..578b1a0
Binary files /dev/null and b/WEB-INF/lib/aopalliance-1.0.jar differ
diff --git a/datadb/compbio/cassandra/CassandraUserManager.java b/datadb/compbio/cassandra/CassandraUserManager.java
new file mode 100644 (file)
index 0000000..4bcd4b9
--- /dev/null
@@ -0,0 +1,238 @@
+package compbio.cassandra;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.springframework.dao.DataIntegrityViolationException;
+
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.exceptions.QueryExecutionException;
+import com.datastax.driver.core.exceptions.QueryValidationException;
+
+import compbio.proteocache.users.User;
+import compbio.proteocache.users.UserManager;
+
+public class CassandraUserManager implements UserManager {
+       private Session session;
+       private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
+
+       public CassandraUserManager() {
+               Session inis = CassandraNativeConnector.getSession();
+               setSession(inis);
+       }
+
+       private void setSession(Session s) {
+               assert s != null;
+               session = s;
+       }
+
+       public boolean addUser(User user) throws DataIntegrityViolationException {
+               String chkcom = "SELECT * FROM Users WHERE email = '" + user.getEmail() + "';";
+               try {
+                       ResultSet users = session.execute(chkcom);
+                       if (0 < users.all().size()) {
+                               throw new DataIntegrityViolationException("A user with email " + user.getEmail() + " exists");
+                       }
+                       
+               } catch (QueryExecutionException e) {
+                       String mess = "CassandraUserManagerImpl.addUser: query execution exception...";
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return false;
+               } catch (QueryValidationException e) {
+                       String mess = "CassandraUserManagerImpl.addUser: query validation exception... Command: " + chkcom;
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return false;
+               }
+
+               long id = user.getId().longValue();
+               if (id < 1) {
+                       String com = "SELECT * FROM MainParameters WHERE Name = 'MaxUserId';";
+                       try {
+                               ResultSet values = session.execute(com);
+                               List<Row> list = values.all();
+                               /*
+                               if (1 != list.size()) {
+                                       return false;
+                               }
+                               */
+                               String test = list.get(0).getString("Value");
+                               id = Long.parseLong(test, 10);
+                               id++;
+                               com = "INSERT INTO MainParameters (name,value) VALUES ('MaxUserId','" + id + "');";
+                               session.execute(com);
+                       } catch (QueryExecutionException e) {
+                               String mess = "CassandraUserManagerImpl.addUser: query execution exception...";
+                               System.out.println(mess);
+                               log.error(mess);
+                               log.error(e.getLocalizedMessage(), e.getCause());
+                               return false;
+                       } catch (QueryValidationException e) {
+                               String mess = "CassandraUserManagerImpl.addUser: query validation exception... Command: " + com;
+                               System.out.println(mess);
+                               log.error(mess);
+                               log.error(e.getLocalizedMessage(), e.getCause());
+                               return false;
+                       }
+               }
+               
+               String incom = "INSERT INTO Users (name, id, email, password, organisation, position, signedtolist, registrationdate) VALUES ('"
+                               + user.getFullName() + "'," + id + ",'" + user.getEmail() + "','" + user.getPassword() + "','"
+                               + user.getOrganisation() + "','" + user.getPosition() + "'," + user.isUpdateByEmail() + ","
+                               + user.getRegistrationDate().getTime() + ");";
+               try {
+                       session.execute(incom);
+               } catch (QueryExecutionException e) {
+                       String mess = "CassandraUserManagerImpl.addUser: query execution exception...";
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return false;
+               } catch (QueryValidationException e) {
+                       String mess = "CassandraUserManagerImpl.addUser: query validation exception... Command: " + incom;
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return false;
+               }
+               return true;
+       }
+
+       public boolean saveUser(User user) {
+               boolean isSaved = false;
+               String com = "SELECT * FROM Users WHERE id = " + user.getId() + ";";
+               try {
+                       ResultSet users = session.execute(com);
+                       if (1 < users.all().size()) {
+                               return false;
+                       }
+                       isSaved = addUser(user);
+               } catch (QueryExecutionException e) {
+                       String mess = "CassandraUserManagerImpl.saveUser: query execution exception...";
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+               } catch (QueryValidationException e) {
+                       String mess = "CassandraUserManagerImpl.saveUser: query validation exception... Command: " + com;
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+               }
+               return isSaved;
+       }
+
+       public boolean deleteUser(long id) {
+               String com = "DELETE FROM Users WHERE id = " + id + ";";
+               try {
+                       session.execute(com);
+               } catch (QueryExecutionException e) {
+                       String mess = "CassandraUserManagerImpl.deleteUser: query execution exception...";
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return false;
+               } catch (QueryValidationException e) {
+                       String mess = "CassandraUserManagerImpl.deleteUser: query validation exception... Command: " + com;
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return false;
+               }
+               return true;
+       }
+
+       public User getUserById(long id) {
+               String com = "SELECT * FROM Users WHERE Id = " + id + ";";
+               User user = new User();
+               try {
+                       ResultSet users = session.execute(com);
+                       if (1 != users.all().size()) {
+                               return null;
+                       }
+                       user = buildUser(users.one());
+               } catch (QueryExecutionException e) {
+                       String mess = "CassandraUserManagerImpl.addUser: query execution exception...";
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return null;
+               } catch (QueryValidationException e) {
+                       String mess = "CassandraUserManagerImpl.addUser: query validation exception... Command: " + com;
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return null;
+               }
+               return user;
+       }
+
+       public User getUserByEmail(String email) {
+               String com = "SELECT * FROM Users WHERE Email = '" + email + "';";
+               User user = new User();
+               try {
+                       ResultSet users = session.execute(com);
+                       if (1 != users.all().size()) {
+                               return null;
+                       }
+                       user = buildUser(users.one());
+               } catch (QueryExecutionException e) {
+                       String mess = "CassandraUserManagerImpl.getUserByEmail: query execution exception...";
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return null;
+               } catch (QueryValidationException e) {
+                       String mess = "CassandraUserManagerImpl.getUserByEmail: query validation exception... Command: " + com;
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return null;
+               }
+               return user;
+       }
+
+       public List<User> findAllUsers() {
+               List<User> list = new ArrayList<User>();
+               String com = "SELECT * FROM Users;";
+               try {
+                       ResultSet results = session.execute(com);
+                       List<Row> rows = results.all();
+                       for (Row r : rows) {
+                               list.add(buildUser(r));
+                       }
+               } catch (QueryExecutionException e) {
+                       String mess = "CassandraUserManagerImpl.findAllUsers: query execution exception...";
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return null;
+               } catch (QueryValidationException e) {
+                       String mess = "CassandraUserManagerImpl.findAllUsers: query validation exception... Command: " + com;
+                       System.out.println(mess);
+                       log.error(mess);
+                       log.error(e.getLocalizedMessage(), e.getCause());
+                       return null;
+               }
+               return list;
+       }
+
+       private User buildUser(Row r) {
+               User u = new User();
+               u.setFullName(r.getString("Name"));
+               u.setId(new Long(r.getLong("Id")));
+               u.setEmail(r.getString("Email"));
+               u.setPassword(r.getString("Password"));
+               u.setOrganisation(r.getString("Organisation"));
+               u.setPosition(r.getString("Position"));
+               u.setUpdateByEmail(r.getBool("SignedToList"));
+               u.setRegistrationDate(new Date(r.getLong("RegistrationDate")));
+               return u;
+       }
+}
diff --git a/engine/compbio/engine/JobStatus.java b/engine/compbio/engine/JobStatus.java
new file mode 100644 (file)
index 0000000..393f401
--- /dev/null
@@ -0,0 +1,40 @@
+package compbio.engine;
+
+import java.util.Set;
+
+/**
+ * List of all posible final job statuses
+ * 
+ */
+public enum JobStatus {
+       OK, TIMEDOUT, STOPPED, JPREDERROR;
+
+       public static JobStatus getJobStatus(String status) {
+               status = status.trim().toLowerCase();
+               for (JobStatus st : JobStatus.values()) {
+                       if (st.toString().equalsIgnoreCase(status)) {
+                               return st;
+                       }
+               }
+               return null;
+       }
+
+       public static String toString(Set<JobStatus> statuses) {
+               if (statuses == null || statuses.isEmpty()) {
+                       return "No known services...\n";
+               }
+               String value = "";
+               for (JobStatus st : statuses) {
+                       if (null != st) {
+                               value += st + "\n";
+                       } else {
+                               value += "Unknown Job Status\n";
+                       }
+               }
+               return value;
+       }
+
+       public static void main(String[] args) {
+               System.out.println(OK);
+       }
+}
diff --git a/engine/compbio/proteocache/users/User.java b/engine/compbio/proteocache/users/User.java
new file mode 100644 (file)
index 0000000..5e300d6
--- /dev/null
@@ -0,0 +1,120 @@
+package compbio.proteocache.users;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+\r
+import org.springframework.format.annotation.DateTimeFormat;\r
+\r
+import static org.apache.commons.lang.builder.EqualsBuilder.*;\r
+import static org.apache.commons.lang.builder.HashCodeBuilder.*;\r
+import static org.apache.commons.lang.builder.ToStringBuilder.*;\r
+\r
+public class User implements Serializable {\r
+\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       private Long id = -1L;\r
+       private String email;\r
+       private String password;\r
+       private String fullName;\r
+       private boolean updateByEmail;\r
+       private String position;\r
+       private String organisation;\r
+\r
+       @DateTimeFormat(pattern = "hh:mma MMM d, YYYY")\r
+       private Date registrationDate;\r
+\r
+       public Long getId() {\r
+               return id;\r
+       }\r
+\r
+       public void setId(Long id) {\r
+               this.id = id;\r
+       }\r
+\r
+       public void setEmail(String email) {\r
+               this.email = email;\r
+       }\r
+\r
+       public String getEmail() {\r
+               return email;\r
+       }\r
+\r
+       public String getPassword() {\r
+               return this.password;\r
+       }\r
+\r
+       public void setPassword(String password) {\r
+               this.password = password;\r
+       }\r
+\r
+       public void setFullName(String fullName) {\r
+               this.fullName = fullName;\r
+       }\r
+\r
+       public String getFullName() {\r
+               return fullName;\r
+       }\r
+\r
+       public String getPosition() {\r
+               return position;\r
+       }\r
+\r
+       public void setPosition(String position) {\r
+               this.position = position;\r
+       }\r
+\r
+       public void setOrganisation(String organisation) {\r
+               this.organisation = organisation;\r
+       }\r
+\r
+       private String checkNoUTFsymbols(String s) {\r
+               if (null != s) {\r
+                       if (3 < s.length())\r
+                               if (s.substring(0, 2).matches("^&#")) {\r
+                                       return "Unknown organization";\r
+                               }\r
+               }\r
+               return s;\r
+       }\r
+\r
+       public String getOrganisation() {\r
+               return checkNoUTFsymbols(organisation);\r
+       }\r
+\r
+       public void setUpdateByEmail(boolean updateByEmail) {\r
+               this.updateByEmail = updateByEmail;\r
+       }\r
+\r
+       public boolean isUpdateByEmail() {\r
+               return updateByEmail;\r
+       }\r
+\r
+       public Date getRegistrationDate() {\r
+               return this.registrationDate;\r
+       }\r
+\r
+       public void setRegistrationDate(Date registrationDate) {\r
+               this.registrationDate = registrationDate;\r
+       }\r
+\r
+       // plumbing\r
+       @Override\r
+       public boolean equals(Object obj) {\r
+               return reflectionEquals(this, obj);\r
+       }\r
+\r
+       @Override\r
+       public int hashCode() {\r
+               return reflectionHashCode(this);\r
+       }\r
+\r
+       @Override\r
+       public String toString() {\r
+               return reflectionToString(this);\r
+       }\r
+\r
+}\r
diff --git a/engine/compbio/proteocache/users/UserManager.java b/engine/compbio/proteocache/users/UserManager.java
new file mode 100644 (file)
index 0000000..48f3fb3
--- /dev/null
@@ -0,0 +1,21 @@
+package compbio.proteocache.users;
+
+import java.util.List;
+
+import compbio.proteocache.users.User;
+
+public interface UserManager {
+
+       public boolean addUser(User user);
+
+       public boolean saveUser(User user);
+
+       public boolean deleteUser(long id);
+
+       public User getUserById(long id);
+
+       public User getUserByEmail(String email);
+
+       public List<User> findAllUsers();
+
+}
diff --git a/server/compbio/controllers/UserController.java b/server/compbio/controllers/UserController.java
new file mode 100644 (file)
index 0000000..94be377
--- /dev/null
@@ -0,0 +1,123 @@
+package compbio.controllers;
+
+import java.security.Principal;
+import java.util.Date;
+import java.util.regex.Pattern;
+
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.mail.SimpleMailMessage;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.ui.ModelMap;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import compbio.proteocache.users.User;
+import compbio.proteocache.users.UserManager;
+import compbio.cassandra.CassandraUserManager;
+
+@Controller
+public class UserController {
+
+       //@Inject
+       //JavaMailSender mailSender;
+       private final Pattern EMAIL = Pattern.compile("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}");
+
+       @RequestMapping(value = "/register/query", method = RequestMethod.GET)
+       public String printPublicHome(ModelMap model) {
+               User user = new User();
+               model.addAttribute(user);
+               return "Register";
+       }
+
+       @RequestMapping(value = "/register/do", method = RequestMethod.POST)
+       public String addUser(Model model, @ModelAttribute("user") User user, BindingResult bindingResult) {
+
+               if (bindingResult.hasErrors()) {
+                       return "Register";
+               }
+
+               int fullName = user.getFullName().length();
+               if (fullName < 6 || 50 < fullName) {
+                       bindingResult.addError(new FieldError("user", "fullName", "Your full name must be between 3 and 50 symbols long!"));
+                       model.addAttribute("error", "wrong password");
+                       return "Register";
+               }
+
+               if (!EMAIL.matcher(user.getEmail()).find()) {
+                       bindingResult.addError(new FieldError("user", "email", "Email is empty or in a wrong form!"));
+                       model.addAttribute("error", "wrong email");
+                       return "Register";
+               }
+
+               int password = user.getPassword().length();
+               if (password < 6 || 20 < password) {
+                       bindingResult.addError(new FieldError("user", "password", "The password must be at least 6 symbols long!"));
+                       model.addAttribute("error", "wrong password");
+                       return "Register";
+               }
+
+               int organisation = 0;
+               if (null != user.getOrganisation())
+                       organisation = user.getOrganisation().length();
+               if (organisation < 3 || 250 < organisation) {
+                       bindingResult.addError(new FieldError("user", "organisation", "The organisation must be between 3 and 250 symbols long!"));
+                       model.addAttribute("error", "wrong organisation name");
+                       return "Register";
+               }
+
+               user.setRegistrationDate(new Date());
+               UserManager cm = new CassandraUserManager(); 
+               try {
+                       cm.addUser(user);
+               } catch (DataIntegrityViolationException e) {
+                       bindingResult.addError(new FieldError("user", "email", "This email (username) is already in use!"));
+                       model.addAttribute("error", "used email");
+                       return "Register";
+               }
+               if (user.isUpdateByEmail()) {
+                       subscribeToList(user.getEmail());
+               }
+               /*
+               Account.autoLogin(user, request, authenticationManager);
+               */
+               return "redirect:/index";
+       }
+
+       @RequestMapping(value = "/register/edit/do", method = RequestMethod.POST)
+       public String editUser(Model model, @ModelAttribute("user") User user, BindingResult bindingResult) {
+
+               if (bindingResult.hasErrors()) {
+                       return "Register";
+               }
+               
+               user.setRegistrationDate(new Date());
+               UserManager cm = new CassandraUserManager(); 
+               try {
+                       cm.addUser(user);
+               } catch (DataIntegrityViolationException e) {
+                       bindingResult.addError(new FieldError("user", "email", "This email (username) is already in use!"));
+                       return "Register";
+               }
+               if (user.isUpdateByEmail()) {
+                       subscribeToList(user.getEmail());
+               }
+
+               return "redirect:/index";
+       }
+
+       private void subscribeToList(String email) {
+               SimpleMailMessage message = new SimpleMailMessage();
+               message.setFrom(email);
+               message.setTo("proteocache-discuss-subscribe@compbio.dundee.ac.uk");
+               message.setSubject("ProteoCache mailing list subscription");
+               message.setText("testing " + email);
+               //mailSender.send(message);
+       }
+
+}
diff --git a/webapp/view/Register.jsp b/webapp/view/Register.jsp
new file mode 100644 (file)
index 0000000..77584c2
--- /dev/null
@@ -0,0 +1,128 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
+
+<html>
+<jsp:include page="fragments/header.jsp" />
+<body>
+       <div class="container">
+       <jsp:include page="fragments/publicmenu.jsp" />
+       <spring:url value="/register/do" var="query"/>
+
+       <div class="panel panel-default">
+               <div class="panel-heading">
+                       <div style="font-weight:bold;">Create a new user account</div>
+               </div>
+               <div class="panel-body">
+
+               <form:form method="POST" modelAttribute="user" action="${query}">
+                       <div class="col-xs-4"><!-- make the field shorter -->
+                               <c:choose>
+                               <c:when test="${error == null}">
+                               <div class="form-group">
+                                       <form:input class="form-control" type="text" path="fullName" placeholder="Full name (3-50 symbols)" />
+                                       <p></p>
+                                       <form:input class="form-control" type="text" path="email" placeholder="Email (used as account name)" />
+                                       <p></p>
+                                       <form:input class="form-control" type="password" path="password" placeholder="Password (at least 6 symbols)" />
+                                       <p></p>
+                                       <form:input class="form-control" type="text" path="position" placeholder="Your position" />
+                                       <p></p>
+                                       <form:input class="form-control" type="text" path="organisation" placeholder="Your organisation (3-250 symbols)" />
+                                       <p></p>
+                                       <form:checkbox path="updateByEmail"/>
+                                       <form:label path="updateByEmail" >Subscribe to ProteoCache mailing list</form:label>
+                                       <p></p>
+                                       <button type="submit" class="btn btn-default">Login</button>
+                               </div>
+                               </c:when>
+                               <c:otherwise>
+                                       <div class="form-group has-error">
+                                       <form:input class="form-control" type="text" path="fullName" placeholder="Full name" />
+                                       <form:errors path="fullName" cssClass="error" />
+                                       <p></p>
+                                       <form:input class="form-control" type="text" path="email" placeholder="Email, used as account name" />
+                                       <form:errors path="email" cssClass="error" />
+                                       <p></p>
+                                       <form:input class="form-control" type="password" path="password" placeholder="Password" />
+                                       <form:errors path="password" cssClass="error" />
+                                       <p></p>
+                                       <form:input class="form-control" type="text" path="position" placeholder="Your position" />
+                                       <form:errors path="position" cssClass="error" />
+                                       <p></p>
+                                       <form:input class="form-control" type="text" path="organisation" placeholder="Your organisation" />
+                                       <form:errors path="organisation" cssClass="error" />
+                                       <p></p>
+                                       <form:checkbox path="updateByEmail"/>
+                                       <form:label path="updateByEmail" >Subscribe to ProteoCache mailing list</form:label>
+                                       <p></p>
+                                       <button type="submit" class="btn btn-default">Login</button>
+                               </div>
+                               </c:otherwise>
+                               </c:choose>
+                       </div>
+               </form:form>
+
+<!--
+       <sf:form method="POST" modelAttribute="user" action="/register/do">
+       <fieldset> 
+       <table cellspacing="0">
+               <tr>
+                       <td><sf:input path="fullName" size="15"/>
+                                <sf:errors path="fullName" cssClass="error" />
+                       </td>
+               </tr>
+               <tr>
+                       <td><sf:input path="email" size="30"/>
+                               <small>the email address is used as your JABAWS download username</small><br/> 
+                               <sf:errors path="email" cssClass="error" />
+                       </td>
+               </tr>
+               <tr>
+                       <th><sf:label path="password">Enter a password for JABAWS:</sf:label></th>
+                       <td><sf:password path="password" size="30" showPassword="true"/> 
+                               <small>6 characters or more</small><br/>
+                               
+                       </td>
+               </tr>
+               <tr>
+                       <th><sf:label path="position">Position:</sf:label></th>
+                       <td><sf:input path="position" size="20" maxlength="200" />
+                               <small>postdoc, PI, Staff scientists, Industry, etc</small><br/>
+                               <sf:errors path="position" cssClass="error" />
+                       </td>
+               </tr>
+               <tr>
+                       <th><sf:label path="organisation">Organisation:</sf:label></th>
+                       <td><sf:input path="organisation" size="20" maxlength="200" />
+                               <small>your organisation</small><br/>
+                               <sf:errors path="organisation" cssClass="error" />
+                       </td>
+               </tr>
+               <tr>
+                       <th></th>
+                       <td>
+                               <sf:checkbox path="updateByEmail"/>
+                               <sf:label path="updateByEmail" >Subscribe to ProteoCache mailing list</sf:label>
+                               <br/>
+                       </td>
+               </tr>
+               <tr>
+                       <th></th>
+                       <td><input name="commit" type="submit" value="I accept. Create my account." /></td>
+               </tr>
+               </table>
+       </fieldset>
+       </sf:form>
+-->
+
+               </div>
+       </div>
+       <jsp:include page="fragments/footer.jsp"/>
+       </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/webapp/view/fragments/mainmenu_and_figures.jsp b/webapp/view/fragments/mainmenu_and_figures.jsp
deleted file mode 100644 (file)
index b5d8e56..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
-
-<jsp:include page="logos.jsp" />
-
-<nav class="navbar navbar-default" role="navigation">
-       <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
-               <ul class="nav navbar-nav">
-                       <li style="width: 100px;">
-                               <a href="<spring:url value="/" htmlEscape="true" />"><span class="glyphicon glyphicon-home"></span> Home</a>
-                       </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>
-                               </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="/exectime" htmlEscape="true" />">Job Time Execution</a></li>
-                                       <li><a href="<spring:url value="/stat" htmlEscape="true" />">Daily Job Statistics</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>
-                               </ul>
-                       </li>
-                       <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>
-               </ul>
-               <ul class="nav navbar-nav navbar-right">
-                       <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>
-                                       <li><a href="<spring:url value="/help/howto" htmlEscape="true" />">How to</a></li>
-                                       <li><a href="<spring:url value="/help/doc" htmlEscape="true" />">Documentation</a></li>
-                                       <li><a href="<spring:url value="/help/javadoc" htmlEscape="true" />">Javadoc</a></li>
-                               </ul>
-                       </li>
-               </ul>
-       </div><!-- /.navbar-collapse -->
-</nav>
diff --git a/webapp/view/fragments/publicmenu.jsp b/webapp/view/fragments/publicmenu.jsp
new file mode 100644 (file)
index 0000000..8661af9
--- /dev/null
@@ -0,0 +1,30 @@
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
+
+<jsp:include page="logos.jsp" />
+
+<nav class="navbar navbar-default">
+       <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+               <ul class="nav navbar-nav">
+                       <li>
+                               <a href="<spring:url value="/" htmlEscape="true" />"><span class="glyphicon glyphicon-home"></span> Home</a>
+                       </li>
+                       <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-arrow-down"></span> Login<b class="caret"></b></a>
+                               <ul class="dropdown-menu">
+                                       <li><a href="<spring:url value="/login" htmlEscape="true" />">Login</a></li>
+                                       <li><a href="<spring:url value="/register/query" htmlEscape="true" />">Register</a></li>
+                               </ul>
+                       </li>
+               </ul>
+               <ul class="nav navbar-nav navbar-right">
+                       <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>
+                                       <li><a href="<spring:url value="/help/howto" htmlEscape="true" />">How to</a></li>
+                                       <li><a href="<spring:url value="/help/doc" htmlEscape="true" />">Documentation</a></li>
+                                       <li><a href="<spring:url value="/help/javadoc" htmlEscape="true" />">Javadoc</a></li>
+                               </ul>
+                       </li>
+               </ul>
+       </div><!-- /.navbar-collapse -->
+</nav>
diff --git a/webapp/view/hello.jsp b/webapp/view/hello.jsp
new file mode 100644 (file)
index 0000000..1c12555
--- /dev/null
@@ -0,0 +1,10 @@
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<html>
+<body>
+       <h3>Message : ${message}</h3>
+       <h3>Username : ${username}</h3>
+
+       <a href="<c:url value="/j_spring_security_logout" />"> Logout</a>
+
+</body>
+</html>
diff --git a/webapp/view/login.jsp b/webapp/view/login.jsp
new file mode 100644 (file)
index 0000000..37e1b3e
--- /dev/null
@@ -0,0 +1,52 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
+
+<spring:url value="/j_spring_security_check" var="scheck" />
+
+<html>
+<jsp:include page="fragments/header.jsp" />
+<body onload='document.f.j_username.focus();'>
+       <div class="container">
+               <jsp:include page="fragments/publicmenu.jsp" />
+               <spring:url value="/ip/query" var="query" />
+
+               <div class="panel panel-default">
+                       <div class="panel-heading">
+                               <div style="font-weight: bold;">Enter your username (email used during registration) and password</div>
+                       </div>
+                       <div class="panel-body">
+                               <form name='f' action="${scheck}" method='POST'>
+                                       <div class="col-xs-3"><!-- make the field shorter -->
+                                               <c:choose>
+                                               <c:when test="${error == null}">
+                                                       <div class="form-group">
+                                                               <input class="form-control" type="text" name="j_username" id="UserName" placeholder="Username (email)" />
+                                                               <p></p>
+                                                               <input class="form-control" type="password" name="j_password" id="UserPass" placeholder="Password" />
+                                                               <p></p>
+                                                               <button type="submit" class="btn btn-default">Login</button>
+                                                       </div>
+                                               </c:when>
+                                               <c:otherwise>
+                                                       <div class="form-group has-error">
+                                                               <input class="form-control" type="text" name="j_username" id="UserName" placeholder="Username (email)" />
+                                                               <p></p>
+                                                               <input class="form-control" type="password" name="j_password" id="UserPass" placeholder="Password" />
+                                                               <p class="help-block">${error}</p>
+                                                               <button type="submit" class="btn btn-default">Login</button>
+                                                       </div>
+                                               </c:otherwise>
+                                               </c:choose>
+                                       </div>
+                               </form>
+                       </div>
+               </div>
+               <jsp:include page="fragments/footer.jsp" />
+       </div>
+</body>
+</html>
diff --git a/webapp/view/public.jsp b/webapp/view/public.jsp
new file mode 100644 (file)
index 0000000..4017906
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
+
+<html>
+<jsp:include page="fragments/header.jsp" />
+<body>
+       <div class="container">
+               <jsp:include page="fragments/publicmenu.jsp" />
+               <div class="row">
+                       <div class="col-md-6">
+                       <div class="panel panel-default">
+                       <div class="panel-heading">Execution statistics for the last days</div>
+                       <div class="panel-body">
+                               bla-bla
+                       </div>
+                       </div>
+               </div>
+               <div class="col-md-6">
+                       <div class="panel panel-default">
+                       <div class="panel-heading">Overview</div>
+                       <div class="panel-body">
+                               ProteoCache is as a repository of the result of running all tools in the Dundee Resource on
+                               complete proteomes.  The data are updated on a regular basis as tools are improved and genomes newly
+                               sequenced or updated.
+                       </div>
+                       </div>
+               </div>
+               </div>
+               <jsp:include page="fragments/footer.jsp"/>
+       </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/webapp/view/support/Denied.jsp b/webapp/view/support/Denied.jsp
new file mode 100644 (file)
index 0000000..928cf35
--- /dev/null
@@ -0,0 +1,29 @@
+<%@ 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 don'h have enough permissions to view the page</p>
+                       </div>
+               </div>
+
+               <jsp:include page="../fragments/footer.jsp" />
+       </div>
+</body>
+</html>
\ No newline at end of file