コード例 #1
0
 protected void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   // Get all parameters
   String newUserID = request.getParameter("newUID");
   String newPassword = request.getParameter("newPassword");
   if (newUserID == null || newPassword == null) {
     usernameTaken(response);
     return;
   }
   // check if the username already exists
   User check = UserPersister.getUser(newUserID);
   if (check != null) {
     usernameTaken(response);
   } else {
     // TODO - maybe move this logic somewhere else
     List<IBlock> generatedBlocks = PasswordMatcher.generatePassword(newPassword);
     User newUser = new User(newUserID, generatedBlocks);
     // TODO - possibly check for the success of the PUT into the DB. Maybe return a different code
     // depending on what needs to be done
     boolean success = UserPersister.putUser(newUser);
     userAdded(response);
   }
 }
コード例 #2
0
 private void returnBlockClassInfoTest(HttpServletResponse response) throws IOException {
   response.setContentType("application/xml");
   StringBuffer responseBody = new StringBuffer();
   responseBody.append(PasswordMatcher.getAvailableBlocksXML());
   response.getWriter().write(responseBody.toString());
 }