Commit 96013117 by Tuomas Riihimäki

Added rights components to resources/tools

1 parent 88dd770a
...@@ -7,6 +7,9 @@ import java.util.Set; ...@@ -7,6 +7,9 @@ import java.util.Set;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.RolePermission; import fi.insomnia.bortal.RolePermission;
import fi.insomnia.bortal.SessionHandlerBeanLocal; import fi.insomnia.bortal.SessionHandlerBeanLocal;
import fi.insomnia.bortal.facade.UserFacade; import fi.insomnia.bortal.facade.UserFacade;
...@@ -22,7 +25,7 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal { ...@@ -22,7 +25,7 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal {
@EJB @EJB
private UserFacade userfacade; private UserFacade userfacade;
private static final Logger logger = LoggerFactory.getLogger(SessionHandlerBean.class);
/** /**
* Default constructor. * Default constructor.
*/ */
...@@ -40,6 +43,7 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal { ...@@ -40,6 +43,7 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal {
} }
} }
return false; return false;
} }
......
...@@ -10,17 +10,23 @@ ...@@ -10,17 +10,23 @@
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"> xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:interface> <composite:interface>
<composite:attribute name="target" required="true" />
<composite:attribute name="permission" required="true" />
<composite:facet name="errormessage" />
</composite:interface> </composite:interface>
<composite:implementation> <composite:implementation>
<c:choose> <c:choose>
<c:when test='#{sessionHandler.hasPermission("userList", "read") }'> <c:when test='#{sessionHandler.hasPermission(target, permission) }'>
<composite:insertChildren /> <composite:insertChildren />
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<h:outputText value="#i18n['authorization.notAuthorized']" /> <c:if test="#{not empty compositeComponent.facets.errormessage}">
<composite:insertFacet name="errormessage" />
</c:if>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</composite:implementation> </composite:implementation>
......
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:interface>
<composite:attribute name="target" required="true" />
<composite:facet name="errormessage" />
</composite:interface>
<composite:implementation>
<c:choose>
<c:when test='#{sessionHandler.canExecute(target) }'>
<composite:insertChildren />
</c:when>
<c:otherwise>
<c:if test="#{not empty compositeComponent.facets.errormessage}">
<composite:insertFacet name="errormessage" />
</c:if>
</c:otherwise>
</c:choose>
</composite:implementation>
</html>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:interface>
<composite:attribute name="target" required="true" />
<composite:facet name="errormessage" />
</composite:interface>
<composite:implementation>
<c:choose>
<c:when test='#{sessionHandler.canRead(target) }'>
<composite:insertChildren />
</c:when>
<c:otherwise>
<c:if test="#{not empty compositeComponent.facets.errormessage}">
<composite:insertFacet name="errormessage" />
</c:if>
</c:otherwise>
</c:choose>
</composite:implementation>
</html>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:interface>
<composite:attribute name="target" required="true" />
<composite:facet name="errormessage" />
</composite:interface>
<composite:implementation>
<c:choose>
<c:when test='#{sessionHandler.canWrite(target) }'>
<composite:insertChildren />
</c:when>
<c:otherwise>
<c:if test="#{not empty compositeComponent.facets.errormessage}">
<composite:insertFacet name="errormessage" />
</c:if>
</c:otherwise>
</c:choose>
</composite:implementation>
</html>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!