Prepare the database:
Table name
Users
Column Name value
Username User11
Password 698d51a19d8a121ce581499d7b701668
is the MD5 32-bit http://md5jiami.51240.com/of password 111
Table name
Users-roles
Column Name value
Username User11
RoleName Roles22
===================================================================================
Modify Apache configuration file, enable JDBC database realm, Support MD5 Digest encryption password
D:\apache-tomcat-7.0.62\conf\context.xml
<realm classname= "Org.apache.catalina.realm.JDBCRealm"
drivername= "Com.mysql.jdbc.Driver
" Connectionurl= "Jdbc:mysql://xxxxxx:3306/spiis"
connectionname= "root" connectionpassword= "1q2w3e4r"
usertable= "Users" usernamecol= "Usercode"
usercredcol= "password"
userroletable= "Users-roles"
digest= "MD5"
rolenamecol= "RoleName"/>
Modified Apache example application examples, using Basic authentication, role ROLES22 users can access/jsp/security/protected/* resources
Web. XML changed to Basic,role to Roles22
<auth-constraint> <!--Anyone with one of the listed roles could access this area--and
<role-name>t omcat</role-name>
<role-name>roles22</role-name>
</auth-constraint>
</ Security-constraint>
<!--Default Login configuration uses form-based Authentication--
< login-config>
<auth-method>BASIC</auth-method>
<realm-name>example form-based Authentication area</realm-name>
</login-config>
<!--Security roles referenced by the This web Application-
<security-role>
<role-name>roles22</role-name>
</ security-role>
<security-role>
<role-name>tomcat</role-name>
</ Security-role>
Copy Mysql-connector-java-5.1.34-bin.jar to
D:\apache-tomcat-7.0.62-authentication-mysql\lib
Browser access URL, enter user name password user11/111 for identity authentication
http://localhost:8088/examples/jsp/security/protected/