Creating a login page and forcing the user to log in

The ability for a user to authenticate with an application is probably the most common requirement shared by all web applications. In this recipe, we will see how to leverage Wicket's security features to force the user to authenticate before they are able to access any page in the application.

Creating a login page and forcing the user to log in

Create a custom Session implementation that will track whether the user is logged in or not:

MySession.java

public class MySession extends WebSession { private String username; public MySession(Request request) { super(request); } public boolean login(String username, String password) { if (username.equals(password)) ...

Get Apache Wicket Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.