JavaのWebアプリで認証画面を作成しております。
暗号化をしない状況では認証は成功したのですが、
●server.xmlに↓を追記
<CredentialHandler algorithm="sha-256" className="org.apache.catalina.realm.MessageDigestCredentialHandler"/>
●ログイン画面(login.jsp)を
<form method="post" action='<%= response.encodeURL("j_security_check")%>'> ↓ <form method="post" action="${fn:escapeXml('j_security_check') }"> に書き換え●DBにユーザーパスを暗号化したデータをインサート
↓インサート文
insert into auth_users values('004307', sha2('tenma116',256));
正常にインサートされました。
上記3点を行ったところログインエラーになってしまいました。
コンソールにはエラーの表示はありません。
暗号化をしないで認証することはできているので、暗号化の方法に誤りがあるのではないかと考えております。
以下にソースコードを添付いたしますので、お気づきの点がございましたらご教示いただけると幸いです。
よろしくお願いいたします。
↓server.xmlのRealmタグ
<Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <!-- <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>--> <Realm className="org.apache.catalina.realm.JDBCRealm" connectionName="10ma" connectionPassword="tenma116" connectionURL="jdbc:mariadb://localhost:3306/bsdb" driverName="org.mariadb.jdbc.Driver" roleNameCol="role" userCredCol="pass" userNameCol="id" userRoleTable="auth_roles" userTable="auth_users" > <CredentialHandler algorithm="sha-256" className="org.apache.catalina.realm.MessageDigestCredentialHandler"/> </Realm> </Realm>
↓login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <font size="7">B-Suppport</font><br> <font size="5">Login</font><br> <form method="post" action="${fn:escapeXml('j_security_check') }"> <table> <tr> <td>ID</td> <td> <input type="text" name="j_username"></td> </tr> <tr> <td>Pass</td> <td><input type="password" name="j_password"></td> </tr> </table> <br> <input type="submit" value="Login" name="submit"> <input type="reset" value="Reset" name="reset"> </form> </body> </html>
追加で情報が必要な場合には対応いたします。