Cosminexus V9 アプリケーションサーバ 機能解説 セキュリティ管理機能編
HttpSessionに設定するオブジェクトは,java.io.Serializableインタフェースを継承したオブジェクトになります。そのため,HttpSessionにはログイン時に生成したLoginContextインスタンスではなく,java.io.Serializableインタフェースを継承しているSubjectを格納してください。格納したSubjectは,ログアウトの実装で必要になります。SubjectをHttpSessionに格納する実装例(太字部分)を次に示します。
<% LoginContext lc = new LoginContext("Portal", new WebPasswordHandler(request, response, null, "login.html", true)); try { lc.login(); session.setAttribute("ExampleSubject", lc.getSubject()); } catch (LoginException e) { ... }% > ... |
なお,ログイン後にSubjectに関連づけられるユーザ属性(UserAttributes)をセッションフェイルオーバで引き継がせる場合は,Subjectとユーザ属性をHttpSessionに格納する必要があります。Subjectとユーザ属性をHttpSessionに格納する実装例(太字部分)を次に示します。
<% LoginContext lc = new LoginContext("Portal", new WebPasswordHandler(request, response, null, "login.html", true)); try { lc.login(); session.setAttribute("ExampleSubject", lc.getSubject()); session.setAttribute("ExampleCredential", lc.getSubject().getPublicCredentials().iterator().next()); } catch (LoginException e) { ... }% > ... |
All Rights Reserved. Copyright (C) 2012, 2015, Hitachi, Ltd.