I have two kinds of users in my application - customers and sellers. I use PhaseListenerin JSF to prevent users from accessing pages without logging in, but after they logged in, I don’t know how to prevent the user from changing the URL in the location bar and accessing pages that he is not allowed to For example, preventing customers from accessing merchant pages.
PhaseListener
Does anyone have an idea on how I can prevent such illegal treatment?
/ ( , , , 't URL-, JSF).
, URL-, /seller/, , SELLER:
/seller/
SELLER
if (url.startsWith("/seller/") && user.getRoles().contains(Role.SELLER)) { // Allow access. } else { // Block access. }
, / , Java EE Apache Shiro. , , web.xml <security-constraint> , INI Shiro.
web.xml
<security-constraint>
Filter. , javax.servlet.Filter doFilter() , , - . web.xml :
Filter
javax.servlet.Filter
doFilter()
<filter> <filter-name>MyFilter</filter-name> <filter-class>mypackage.MyFilter</filter-class> </filter> <filter-mapping> <filter-name>MyFilter</filter-name> <url-pattern>*.xhtml</url-pattern> </filter-mapping>
-, ( 1 :
<entry key="acl_page_sub/page1">client,seller</entry> <entry key="acl_page_sub2/page1">client</entry> <entry key="acl_page_sub2/page2">seller</entry>
- LoginController, currentuserrole (url) . , - .
logincontroller faceconfig.
, . prerenderview jsf2 post post jsf1.2