I have a web application that will have two methods within a form to login.
- Username and Password + a Login Button.
- smart card login button.
Currently, we only have the Username and Password login. At some point, we will need to implement a smart card login. Most of our users already exist and will need to login with their username and password and then "register" their smart card to associate the username to the smart card via the database. I assume the smart card will utilize x509 certificates and I don't want to be prompted for the certificate as soon as the login page is visited. I would prefer that the certificates prompt appears after the smartcard login button has been clicked. I've seen this implemented at government sites like https://mypay.dfas.mil/#/. Anyway I can produce this approach using JSP, Spring Security and Java?
The following link is how I build the login application: https://howtodoinjava.com/spring-security/login-form-based-spring-3-security-example/
I've been told if I add the following to the security configuration I could use X.509 authentication with other options such as a form-based login.
<http>
...
<x509 subject-principal-regex="CN=(.*?)," user-service-ref="userService"/>
...
</http>
Unfortunately, I don't know how to tie this to the login-form.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<html>
<body>
<h1 id="banner">Login to Security Demo</h1>
<form name="f" action="<c:url value='j_spring_security_check'/>"
method="POST">
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='j_username' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='j_password'></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan='2'><input name="submit" type="submit"> <input name="reset" type="reset"></td>
</tr>
<tr>
<td colspan='2'><input name="Smart Card Login" type="submit"></td>
</tr>
</table>
</form>
</body>
</html>