この情報を使用して、Web アプリケーションの API をプログラマチックに保護します。
Web クライアントが保護された URI および保護されていない URI とどのように 相互作用するかを決定する Web 認証のいくつかのオプションを構成することができます。 また、HTTPS クライアントの証明書認証が失敗した場合に、WebSphere Application Server が Web クライアントに 基本認証情報を要求するかどうかを指定できます。 詳しくは、認証メカニズム を参照してください。
isUserInRole メソッドが使用されている場合は、このメソッドに渡された役割名を含んでいる role-name サブエレメントを持つデプロイメント記述子で、security-role-ref エレメントを宣言します。 実際の役割はアプリケーションの アセンブリー段階で作成されるため、論理的役割を役割名として使用して、security-role-ref エレメントの 記述において、アセンブラーに十分なヒントを提供し、 その役割を実際の役割にリンクすることができます。アセンブリー時に、 アセンブラーは role-link サブエレメントを作成して、役割名を実際の役割にリンク します。Rational Application Developer (RAD) などのアセンブリー・ツールを使用すれば、security-role-ref エレメントを作成することができます。 また、アセンブリー・ツールを使用して、 アセンブリー段階で security-role-ref エレメントを作成することもできます。
<security-role-ref> <description>Provide hints to assembler for linking this role name to an actual role here<¥description> <role-name>Mgr<¥role-name> </security-role-ref>
<security-role-ref> <description>Hints provided by developer to map the role name to the role-link</description> <role-name>Mgr</role-name> <role-link>Manager</role-link> </security-role-ref>
public void doGet(HttpServletRequest request, HttpServletResponse response) { .... // to get remote user using getUserPrincipal() java.security.Principal principal = request.getUserPrincipal(); String remoteUser = principal.getName(); // to get remote user using getRemoteUser() remoteUser = request.getRemoteUser(); // to check if remote user is granted Mgr role boolean isMgr = request.isUserInRole("Mgr"); // use the above information in any way as needed by // the application .... }