Frank Nimphius' Blogbuster: Cracking the nutshell on JavaServer Faces Security
少し前のFrank Nimphiusのブログに、JSFのコンポーネントから宣言的J2EEセキュリティを実現する方法について、かかれていました。
Expression Language (EL) in JavaServer Faces cannot directly access the isUserInRole() method on the request object, which is exposed through the JavaServer Faces ExternalContext object, to verify the group membership of the authenticated user to a particular security role. However, JavaServer Faces enables developers to configure Maps as managed beans in the Faces configuration file for an application. EL can be used to access a named key stored in a Map to obtain its value:
#{HashMapConfigName['key_name']}
This got me thinking and I created my own HashMap object
つまり、Mapを実装したクラスを自分で定義して、isUserInRoleの値をTrue/Falseで返してあげられるようにする、という方法です。
これにより、コンポーネントごとのレンダリングの可否をJ2EEセキュリティロールを使用して切り替えられるようになります。