comparison flys-client/src/main/java/de/intevation/flys/client/server/LoginServlet.java @ 3696:a050cb5f303f

Cosmetics flys-client/trunk@5395 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Sat, 08 Sep 2012 11:26:30 +0000
parents 56f17c6c6288
children 2e12518ff5b4
comparison
equal deleted inserted replaced
3695:5e4d91304484 3696:a050cb5f303f
47 this.redirectFailure(resp); 47 this.redirectFailure(resp);
48 } 48 }
49 49
50 @Override 50 @Override
51 protected void doPost(HttpServletRequest req, HttpServletResponse resp) 51 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
52 throws ServletException, IOException { 52 throws ServletException, IOException
53 {
53 String encoding = req.getCharacterEncoding(); 54 String encoding = req.getCharacterEncoding();
54 String username = req.getParameter("username"); 55 String username = req.getParameter("username");
55 String password = req.getParameter("password"); 56 String password = req.getParameter("password");
56 57
57 logger.debug("Processing post request"); 58 logger.debug("Processing post request");
58 59
59 if (username == null || password == null) { 60 if (username == null || password == null) {
60 logger.debug("No username or password provided"); 61 logger.debug("No username or password provided");
61 this.redirectFailure(resp); 62 this.redirectFailure(resp);
63 return;
62 } 64 }
65
63 try { 66 try {
64 Authentication aresp = this.auth(username, password, encoding); 67 Authentication aresp = this.auth(username, password, encoding);
65 if (aresp == null || !aresp.isSuccess()) { 68 if (aresp == null || !aresp.isSuccess()) {
66 logger.debug("Athentication not successful"); 69 logger.debug("Authentication not successful");
67 this.redirectFailure(resp); 70 this.redirectFailure(resp);
68 } 71 }
69 User user = aresp.getUser(); 72 User user = aresp.getUser();
70 73
71 String url = getServletContext().getInitParameter("server-url"); 74 String url = getServletContext().getInitParameter("server-url");
89 this.redirectFailure(resp, e); 92 this.redirectFailure(resp, e);
90 } 93 }
91 } 94 }
92 95
93 private Authentication auth(String username, String password, String encoding) 96 private Authentication auth(String username, String password, String encoding)
94 throws AuthenticationException, IOException { 97 throws AuthenticationException, IOException
98 {
95 ServletContext sc = this.getServletContext(); 99 ServletContext sc = this.getServletContext();
96 Features features = (Features)sc.getAttribute(Features.CONTEXT_ATTRIBUTE); 100 Features features = (Features)sc.getAttribute(Features.CONTEXT_ATTRIBUTE);
97 String auth = sc.getInitParameter("authentication"); 101 String auth = sc.getInitParameter("authentication");
98 return AuthenticationFactory.getInstance(auth).auth(username, password, encoding, features); 102 return AuthenticationFactory.getInstance(auth).auth(username, password, encoding, features);
99 } 103 }

http://dive4elements.wald.intevation.org