Data Access control in Java EE technologies

你。 提交于 2020-01-15 09:49:06

问题


I am working on a project that requires that i implement a mechanism for controlling data access to the content that displayed on the pages.

First off to clarify, i am not refering to the ability for different users to log on to a specific page and or view specific pages. That is a different type of access control. I am more interested in the "Data Access" i.e. where multiple users can view the same page but the data that is displayed depend on the data access control privileges they have.

I am intersted to know of the different approaches out there to implementing "data access" control. is there a framework out there for this kind of thing? I am currently using Struts.

I'm thinking to do this, i will need to somehow to categorize and store the kinds of data i keep and which configure which users can view/amend it. I want to try and avoid produce something completely from scratch so I'm wondering how the experts do this and what frameworks technologies assist them in doing it.


回答1:


I guess you need Spring Security Framework. With this framework, you assign different roles to different users. For example, we can define two roles: ROLE_USER, ROLE_ADMIN. Then we assign those roles to users. For example, a user A can have only one role, ROLE_USER and a user B can have both of the roles. Now if on a particular JSP, you want to show something to user B only, you can put the code into a pair of authorization tags:

<sec:authorize ifAllGranted="ROLE_USER, ROLE_ADMIN">
     <!-- html, jsp scriplets, jstl tags inside here will be visible to user B only --> 
</sec:authorize>

Similarly if you want to show something to both of them:

<sec:authorize ifAllGranted="ROLE_USER">
     <!-- anything inside here will be visible to both users --> 
</sec:authorize>

Hope it helps.




回答2:


You are looking for a authorization solution? Have you already checked JAAS, OSUser and similars? The authentication requirements can vary greatly, i think you need to be more specific, try adding a use case.




回答3:


I think he was pretty specific with his question, though I also do not yet know the answer for it.

In any well build Enterprise application, you have two levels of security: (a) Functionlity ACL. Can user search for other in facebook? (etc..

(b) Which data are you granted access to read and update. e.g. Which users profiles can you open and read in facebook? For some users, e.g. those in your firends list, you can see their profiles. For others you can't.

Thus, the fact that you can open a JSP that lists entities, does not mean that you will be able to sell the full set of entities in the system.

(a) Is easily solvable with Java EE users and roles security concepts.

(b) How do you associate your database data to specific JNDI users and roles?

do you alwas have to reinvent the wheel when it comes to data access ACL?



来源:https://stackoverflow.com/questions/3289386/data-access-control-in-java-ee-technologies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!