Added URI fields and added cookie authentication
This commit is contained in:
parent
99c67eaaba
commit
8e56ff406a
16 changed files with 133 additions and 71 deletions
|
|
@ -25,14 +25,21 @@ import zall.manager.AuthenticationManager;
|
|||
import zutil.db.DBConnection;
|
||||
import zutil.io.file.FileUtil;
|
||||
|
||||
import static zall.page.ContentServlet.URI_IMAGE;
|
||||
import static zall.page.ContentServlet.URI_VIDEO;
|
||||
|
||||
|
||||
/**
|
||||
* A headless page that provides media content.
|
||||
*/
|
||||
@WebServlet({"/image", "/video"})
|
||||
@WebServlet({URI_IMAGE, URI_VIDEO})
|
||||
public class ContentServlet extends ZalleryServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String URI_IMAGE = "/image";
|
||||
public static final String URI_VIDEO = "/video";
|
||||
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws ServletException, SQLException, IOException {
|
||||
String size = request.getParameter("size");
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,12 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@WebServlet("/gallery")
|
||||
|
||||
@WebServlet(GalleryServlet.URI)
|
||||
public class GalleryServlet extends ZalleryServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
public static final String URI = "/gallery";
|
||||
public static final String JSP_FILE = "page_gallery.jsp";
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,15 +15,29 @@ import java.io.IOException;
|
|||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@WebServlet("/login")
|
||||
|
||||
@WebServlet(LoginServlet.URI)
|
||||
public class LoginServlet extends ZalleryServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
public static final String URI = "/login";
|
||||
private static final String JSP_FILE = "page_login.jsp";
|
||||
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws ServletException, IOException {
|
||||
include(JSP_FILE, request, response);
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws ServletException, IOException, SQLException {
|
||||
// User already logged in?
|
||||
User user = AuthenticationManager.getUserSession(request.getSession());
|
||||
|
||||
// Authenticate with cookies
|
||||
if (user == null)
|
||||
user = AuthenticationManager.authenticate(db, request);
|
||||
|
||||
// Forward user
|
||||
if (user != null) {
|
||||
include(JSP_FILE, request, response);
|
||||
} else {
|
||||
redirect(GalleryServlet.URI, request, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ import java.sql.SQLException;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@WebServlet(urlPatterns = "/logout")
|
||||
@WebServlet(LogoutServlet.URI)
|
||||
public class LogoutServlet extends ZalleryServlet {
|
||||
|
||||
public static final String URI = "/logout";
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws SQLException, IOException {
|
||||
User user = AuthenticationManager.getUserSession(request.getSession());
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,11 @@ import java.sql.SQLException;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@WebServlet("/media")
|
||||
@WebServlet(MediaServlet.URI)
|
||||
public class MediaServlet extends ZalleryServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
public static final String URI = "/media";
|
||||
private static final String JSP_FILE = "page_media.jsp";
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ import java.io.IOException;
|
|||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@WebServlet("/profile")
|
||||
@WebServlet(ProfileServlet.URI)
|
||||
public class ProfileServlet extends ZalleryServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
public static final String URI = "/profile";
|
||||
private static final String JSP_FILE = "page_profile.jsp";
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@ import java.io.IOException;
|
|||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@WebServlet("/register")
|
||||
@WebServlet(RegisterServlet.URI)
|
||||
public class RegisterServlet extends ZalleryServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
public static final String URI = "/register";
|
||||
private static final String JSP_FILE = "page_register.jsp";
|
||||
|
||||
private static final String INPUT_ID_FIRST_NAME = "first-name";
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@WebServlet("/slideshow")
|
||||
@WebServlet(SlideshowServlet.URI)
|
||||
public class SlideshowServlet extends ZalleryServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
public static final String URI = "/slideshow";
|
||||
private static final String JSP_FILE = "page_slideshow.jsp";
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@WebServlet("/users")
|
||||
@WebServlet(UserListServlet.URI)
|
||||
public class UserListServlet extends ZalleryServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
public static final String URI = "/users";
|
||||
private static final String JSP_FILE = "page_users.jsp";
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue