The JSF Security EL resolver is automatically registered once you copy the JAR file into your web application. No other setup is required!
UsageCurrently the JSF Security Resolver exports the following properties:
And the following methods:
It is very easy to check if we are currently logged in. The 'loggedIn' property of the resolver needs to be accessed to determine that. The code snippet below shows you how to do that in your page.
Are we logged in: <h:outputText value="#{security.loggedIn}"/>
Determine the current username
You also have access to the current username. The 'username' property is available for that. See the code snippet below.
What is our username: <h:outputText value="#{security.username}"/>
Checking against a specific user role
A normal thing is to only show specific controls or portions of your page to a user that has particular role. For this purpose you can use the userInRole method, note that this mimics the isUserInRole method found in another API. Look at the code snippet for more details.
Is the user in the DEMO_USER role: <h:outputText value="#{security.userInRole['DEMO_USER']}"/>