I am using Oracle ADF with JDeveloper 11g release 1, I'm crazy to configure application roles for the various groups. Let me explain, I have the following situation and I'm looking for some ideas: I want to enable the commit (RichCommandButton) Enterprise only certain role, what should I do? I decided to do an if statement in BackingBean get method in the page, correct? What is the proper way to proceed?
3 Answers
Checking for a role to determine whether or not allow a certain action is fine but may cause your application to have hardcoded dependencies to specific roles. What if you decide to add roles in the future?
A better way to do it is to check for permissions instead and provide permissions to roles. This way your policies aren't tied to specific roles. This approach is much, much more complex though since you need a way to grant permissions to roles.
{securityContext.userInRole ['role list']}
#{securityContext.userInAllRoles ['role list']}
from the docs: http://docs.oracle.com/cd/E16162_01/web.1112/e16182/adding_security.htm and http://adfcodebits.blogspot.com/2010/04/bit-12-accessing-authenticated-users.html
Actually checking against application roles is ok as it is an abstraction within the application. I agree however that a permission (you can create a custom ResourcePermission) is a better approach to take as it allows you to grant the commit operation to other roles later on (keep in mind that Enterprise Manager is an administration tool for ADF that also allows to change security grants).
Apparently you are new to ADF and ADF Security, so please watch the following video recording in which I explain ADF Security end-to-end
http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/AdfSecurity/AdfSecurity.html
Another useful resources is
http://www.oracle.com/technetwork/issue-archive/2012/12-jan/o12adf-1364748.html
which summarizes ADF security (including the before mentioned ResourcePermission) and allows you to download a sample application to look at and copy from)
Frank