0

GlassFish が複数の http セッションを作成するレルム認証について質問があります。これが例です

Web.xml:

<security-constraint>
    <web-resource-collection>
      <web-resource-name>AllPages</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>user</role-name>
    </auth-constraint>
  </security-constraint>
  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>FileRealm</realm-name>
  </login-config>
<security-constraint>

グラスフィッシュ-web.xml:

  <security-role-mapping>
    <role-name>user</role-name>
    <group-name>users</group-name>
  </security-role-mapping>

login.jsp:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome Page</title>
</head>
<body>
<p>You have successfully logged into the application.</p>
<a href="./home.jsp">go to home</a>
</body>
</html>

セッションリスナー:

@WebListener public class SessionListener は HttpSessionListener を実装します {

public void sessionCreated(HttpSessionEvent arg0) {

System.out.println("セッション作成 ID:"+arg0.getSession().getId());
}

public void sessionDestroyed(HttpSessionEvent arg0) {

  System.out.println("Session destroyed id:"+arg0.getSession().getId());

}

}

認証すると、glassfish は新しいセッションを作成します。

情報: セッションが作成されました id:29c5d904db0e40b9cfbdac40aa5e

「ホームに移動」リンクをクリックするか、ページを更新すると、glassfish は別の http セッションを作成します。

情報: セッションが作成されました id:2a67270137e38c150bf3690e2e46

また、glassfish が最初に作成されたセッションを破棄しないことにも気付きました。

ご協力いただきありがとうございます

4

1 に答える 1

2

これはおそらく Glassfish のバグです。このオプションを使用して、 context.xmlMETA-INFディレクトリに追加してみてください。

<?xml version='1.0' encoding='utf-8'?>
<Context>
<Valve className="org.apache.catalina.authenticator.BasicAuthenticator"
changeSessionIdOnAuthentication="false" />
</Context>

または (Web フォーム認証の場合):

<?xml version='1.0' encoding='utf-8'?>
<Context>
<Valve className="org.apache.catalina.authenticator.FormAuthenticator"
changeSessionIdOnAuthentication="false" />
</Context>

これで(一時的に)問題が解決するはずです!

于 2012-09-11T11:11:22.947 に答える