2016-08-11 11 views
0

Postgres 9.4を使用して、Payaraで認証をしようとしています。私はいくつかのチュートリアルに従ってきましたが、うまくいきません。私はデータベースを作成し、パスワードをハッシュして(MD-5を使用して)、次にJDBC接続プール(pingが動作する)、次にjdbcリソース、領域を覚えていることを覚えておいて、次にJava Webアプリケーションを作成します。 xml、glassfish-web.xml、ログインとエラーページについて....アプリケーションをデプロイしてログインしようとすると、エラーページ(アプリケーションで作成したページ)が表示されます。Postgresを使用したGlassFish JDBC認証。アプリケーションにログインできない

は、ここで私が何を正確に何:

私は、「セキュリティ」と呼ばれるデータベースを作成しました:

私は「テスト」、私のパスワードを暗号化する暗号化のウェブサイトを使用して、次の値を得ました: 098f6bcd4621d373cade4e832627b4f6。私はその値を使用してデータベースにデータを設定しました:

私はPayara Serverを使用しています。 図のように、新しいJDBC接続プールを作成します。私は情報 "Ping Succeeded"を取得するので、これが一部であると仮定します。

JNDI名がjdbc/simplesec、プール名がsecuPoolのJDBCリソースを作成します。

「secuRealm」という名前の新しい領域を作成します。下の図を参照してください。私は何かそこに間違っているかもしれないと思いますか? realm part 1 realm part 2 次に、アプリケーション部分を書きます。 (私はWebアプリケーション、javaを選択します)。 のglassfish-web.xmlの:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd"> 
<glassfish-web-app error-url=""> 
    <security-role-mapping> 
    <role-name>admin</role-name> 
    <group-name>admin</group-name> 
    </security-role-mapping> 
    <security-role-mapping> 
    <role-name>guest</role-name> 
    <group-name>guest</group-name> 
    </security-role-mapping> 
    <class-loader delegate="true"/> 
    <jsp-config> 
    <property name="keepgenerated" value="true"> 
     <description>Keep a copy of the generated servlet class' java code.</description> 
    </property> 
    </jsp-config> 
</glassfish-web-app> 

のweb.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> 
    <session-config> 
     <session-timeout> 
      30 
     </session-timeout> 
    </session-config> 
    <login-config> 
     <auth-method>FORM</auth-method> 
     <realm-name>secuRealm</realm-name> 
     <form-login-config> 
      <form-login-page>/login.jsp</form-login-page> 
      <form-error-page>/error.jsp</form-error-page> 
     </form-login-config> 
    </login-config> 
</web-app> 

のlogin.jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>JSP Page</title> 
    </head> 
    <body> 
     <h1>Login</h1> 
     <form action="j_security_check" method="POST"> 
      Username:<input type="text" name="j_username"/><br/> 
      Password:<input type="password" name="j_password" /><br /> 
      <input type="submit" value="Login" /> 
      <br/>    
     </form> 
    </body> 
</html> 

error.jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>JSP Page</title> 
    </head> 
    <body> 
     <h1>Incorrect Credentials</h1> 
     Try again. <br/> 
     <a href="login.jsp">Login</a> 
    </body> 
</html> 

たindex.jsp :

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>JSP Page</title> 
    </head> 
    <body> 
     <h1>Hello World!</h1><br /> 
     <a href="login.jsp">Login</a> 
    </body> 
</html> 

アプリケーションのデプロイ後、私はログインしようとします。ユーザ名:1、パスワード:test。私はそれに応じてerror.jspページを取得します。なぜ私は正しいユーザーデータを使用してログインできないのか分かりません。 私は間違いをどこでやったのですか?

答えて

0

ダイエストアルゴリズムを指定しようとしました:領域設定ではなし

関連する問題