14.01.2013 Views

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

This JhsAuthorizationProxy instance will be invoked each and every time the<br />

application needs authorization information. So whether JAAS is used and/or custom<br />

authorization mechanism, whether permission-based authorization is enabled, and<br />

whether the information is needed in the View or in the Controller layer, this<br />

‘authorization proxy’ is the single point that all authorization questions are being routed<br />

through. The Authorization Proxy will determine whether standard JAAS and/or a<br />

custom security implementation is used, and will forward the ‘authorization question’<br />

accordingly.<br />

Reference: See the Javadoc of JhsAuthorizationProxy.<br />

10.6.3.1. Accessing the Authorization Proxy in the View layer<br />

For implementing security features in the View layer, for instance hiding tabs and<br />

buttons or making fields read-only based on authorization information, it would be very<br />

convenient if the Authorization Proxy could be accessed through EL expressions. For<br />

that reason, the JhsAuthorizationProxy implements the Map interface. We can use the<br />

managed bean "jhsUserRoles" that was mentioned in the previous section. For instance,<br />

to hide a menu item if the current user does not belong to the ‘ADMIN’ or<br />

‘HR_MANAGER’ roles, <strong>JHeadstart</strong> uses the following syntax:<br />

<br />

Note that you can use a comma-separated list of role and/or permission names. The<br />

Authentication Proxy will process them left-to-right until it finds a role or permission<br />

granted to the current user, and returns true in that case. If the user belongs to none of<br />

the roles, it will return false.<br />

10.6.3.2. Accessing the Authentication Proxy in the Controller layer<br />

As mentioned before, <strong>JHeadstart</strong> also performs a roles check in the JSF PageLifecycle.<br />

This is to prevent "URL-Hacking": the tab or button to go to a certain page might be<br />

hidden, but if the user knows the URL, he should still be denied access.<br />

This is implemented by the method checkRoles() in JhsPageLifecycle, which is<br />

called from the prepareModel() phase.<br />

This method knows which roles to check for which page, because <strong>JHeadstart</strong> generated a<br />

"roles" parameter into the Page Definition of the page.<br />

10 - 22 Application Security <strong>JHeadstart</strong> Developer’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!