Commit 1ad3bfcb by Antti Tonkyra

Merge branch 'devel' of codecrew.fi:bortal into devel

2 parents 3bd71466 ce16315e
...@@ -6,6 +6,7 @@ import java.util.List; ...@@ -6,6 +6,7 @@ import java.util.List;
import javax.annotation.security.DeclareRoles; import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.EJBAccessException;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
...@@ -14,17 +15,14 @@ import javax.persistence.PersistenceContext; ...@@ -14,17 +15,14 @@ import javax.persistence.PersistenceContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.clientutils.BortalLocalContextHolder;
import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.facade.EventFacade; import fi.codecrew.moya.facade.EventFacade;
import fi.codecrew.moya.facade.EventOrganiserFacade; import fi.codecrew.moya.facade.EventOrganiserFacade;
import fi.codecrew.moya.facade.LanEventDomainFacade; import fi.codecrew.moya.facade.LanEventDomainFacade;
import fi.codecrew.moya.facade.LanEventPrivatePropertyFacade; import fi.codecrew.moya.facade.LanEventPrivatePropertyFacade;
import fi.codecrew.moya.facade.LanEventPropertyFacade; import fi.codecrew.moya.facade.LanEventPropertyFacade;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.LoggingBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.clientutils.BortalLocalContextHolder;
import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.model.EventOrganiser; import fi.codecrew.moya.model.EventOrganiser;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LanEventDomain; import fi.codecrew.moya.model.LanEventDomain;
...@@ -40,7 +38,7 @@ import fi.codecrew.moya.model.LanEventPropertyKey; ...@@ -40,7 +38,7 @@ import fi.codecrew.moya.model.LanEventPropertyKey;
@LocalBean @LocalBean
@DeclareRoles({ EventPermission.S_MANAGE_PRIVATE_PROPERTIES, @DeclareRoles({ EventPermission.S_MANAGE_PRIVATE_PROPERTIES,
EventPermission.S_MANAGE_PROPERTIES, EventPermission.S_MANAGE_PROPERTIES,
SpecialPermission.S_ORGANISATION_ADMIN, EventPermission.S_MANAGE_EVENT,
SpecialPermission.S_SUPERADMIN, SpecialPermission.S_SUPERADMIN,
}) })
public class EventBean implements EventBeanLocal { public class EventBean implements EventBeanLocal {
...@@ -138,14 +136,16 @@ public class EventBean implements EventBeanLocal { ...@@ -138,14 +136,16 @@ public class EventBean implements EventBeanLocal {
} }
@Override @Override
@RolesAllowed({ SpecialPermission.S_SUPERADMIN, SpecialPermission.S_ORGANISATION_ADMIN }) @RolesAllowed({ SpecialPermission.S_SUPERADMIN, EventPermission.S_MANAGE_EVENT })
public LanEvent mergeChanges(LanEvent event) { public LanEvent mergeChanges(LanEvent event) {
if (!permbean.hasPermission(SpecialPermission.SUPERADMIN) && getCurrentEvent().equals(event)) {
throw new EJBAccessException("Trying to save another event.");
}
return eventFacade.merge(event); return eventFacade.merge(event);
} }
@Override @Override
@RolesAllowed({ SpecialPermission.S_SUPERADMIN, SpecialPermission.S_ORGANISATION_ADMIN }) @RolesAllowed({ SpecialPermission.S_SUPERADMIN })
public void create(LanEvent event) { public void create(LanEvent event) {
eventFacade.create(event); eventFacade.create(event);
...@@ -159,9 +159,8 @@ public class EventBean implements EventBeanLocal { ...@@ -159,9 +159,8 @@ public class EventBean implements EventBeanLocal {
} }
@Override @Override
@RolesAllowed({ EventPermission.S_MANAGE_PRIVATE_PROPERTIES, SpecialPermission.S_ORGANISATION_ADMIN }) @RolesAllowed({ EventPermission.S_MANAGE_PRIVATE_PROPERTIES, EventPermission.S_MANAGE_EVENT })
public List<LanEventPrivateProperty> getPrivateProperties() public List<LanEventPrivateProperty> getPrivateProperties() {
{
return eventPrivatePropertyFacade.findAllForEvent(); return eventPrivatePropertyFacade.findAllForEvent();
} }
...@@ -203,7 +202,7 @@ public class EventBean implements EventBeanLocal { ...@@ -203,7 +202,7 @@ public class EventBean implements EventBeanLocal {
} }
@Override @Override
@RolesAllowed({ SpecialPermission.S_SUPERADMIN, SpecialPermission.S_ORGANISATION_ADMIN }) @RolesAllowed({ SpecialPermission.S_SUPERADMIN, EventPermission.S_MANAGE_EVENT })
public LanEventProperty saveOrCreateProperty(LanEventProperty property) { public LanEventProperty saveOrCreateProperty(LanEventProperty property) {
LanEventProperty ret = null; LanEventProperty ret = null;
logger.info("Saving property {}, eventorg {}, key {}", new Object[] { property.getEvent(), property.getEventorg(), property.getKey() }); logger.info("Saving property {}, eventorg {}, key {}", new Object[] { property.getEvent(), property.getEventorg(), property.getKey() });
...@@ -229,13 +228,13 @@ public class EventBean implements EventBeanLocal { ...@@ -229,13 +228,13 @@ public class EventBean implements EventBeanLocal {
} }
@Override @Override
@RolesAllowed({ SpecialPermission.S_SUPERADMIN, SpecialPermission.S_ORGANISATION_ADMIN }) @RolesAllowed({ SpecialPermission.S_SUPERADMIN, EventPermission.S_MANAGE_EVENT })
public EventOrganiser mergeChanges(EventOrganiser eventorg) { public EventOrganiser mergeChanges(EventOrganiser eventorg) {
return eventOrganiserFacade.merge(eventorg); return eventOrganiserFacade.merge(eventorg);
} }
@Override @Override
@RolesAllowed({ EventPermission.S_MANAGE_PRIVATE_PROPERTIES, SpecialPermission.S_ORGANISATION_ADMIN }) @RolesAllowed({ EventPermission.S_MANAGE_PRIVATE_PROPERTIES, EventPermission.S_MANAGE_EVENT })
public LanEventPrivateProperty saveOrCreatePrivateProperty(LanEventPrivateProperty privateProperty) { public LanEventPrivateProperty saveOrCreatePrivateProperty(LanEventPrivateProperty privateProperty) {
LanEventPrivateProperty ret = null; LanEventPrivateProperty ret = null;
logger.info("Saving property {}, eventorg {}, key {}", new Object[] { privateProperty.getEvent(), privateProperty.getEventorg(), privateProperty.getKey() }); logger.info("Saving property {}, eventorg {}, key {}", new Object[] { privateProperty.getEvent(), privateProperty.getEventorg(), privateProperty.getKey() });
......
...@@ -117,10 +117,17 @@ public class PermissionBean implements PermissionBeanLocal { ...@@ -117,10 +117,17 @@ public class PermissionBean implements PermissionBeanLocal {
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
@Override @Override
public boolean hasPermission(SpecialPermission perm) {
if (perm == null) {
return false;
}
return context.isCallerInRole(perm.toString());
}
@Override
public boolean hasPermission(IAppPermission perm) { public boolean hasPermission(IAppPermission perm) {
if (perm == null) if (perm == null) {
{
return false; return false;
} }
return context.isCallerInRole(perm.getFullName()); return context.isCallerInRole(perm.getFullName());
...@@ -207,4 +214,5 @@ public class PermissionBean implements PermissionBeanLocal { ...@@ -207,4 +214,5 @@ public class PermissionBean implements PermissionBeanLocal {
throw new IllegalStateException("Current security principal has no CN"); throw new IllegalStateException("Current security principal has no CN");
} }
} }
...@@ -19,12 +19,10 @@ import javax.ejb.Stateless; ...@@ -19,12 +19,10 @@ import javax.ejb.Stateless;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.facade.RoleFacade;
import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.enums.apps.IAppPermission; import fi.codecrew.moya.enums.apps.IAppPermission;
import fi.codecrew.moya.enums.apps.UserPermission; import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.facade.RoleFacade;
import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.model.ApplicationPermission; import fi.codecrew.moya.model.ApplicationPermission;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Role; import fi.codecrew.moya.model.Role;
...@@ -53,8 +51,9 @@ public class RoleBean implements RoleBeanLocal { ...@@ -53,8 +51,9 @@ public class RoleBean implements RoleBeanLocal {
@EJB @EJB
private UserFacade userFacade; private UserFacade userFacade;
// VIEW_ALL pitää olla että voidaan hakea roolien perusteella.
@Override @Override
@RolesAllowed(UserPermission.S_READ_ROLES) @RolesAllowed({ UserPermission.S_READ_ROLES, UserPermission.S_VIEW_ALL })
public List<Role> listRoles() { public List<Role> listRoles() {
return roleFacade.findAll(); return roleFacade.findAll();
} }
......
...@@ -4,6 +4,7 @@ import javax.ejb.Local; ...@@ -4,6 +4,7 @@ import javax.ejb.Local;
import javax.resource.spi.IllegalStateException; import javax.resource.spi.IllegalStateException;
import fi.codecrew.moya.enums.apps.IAppPermission; import fi.codecrew.moya.enums.apps.IAppPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
...@@ -39,6 +40,8 @@ public interface PermissionBeanLocal { ...@@ -39,6 +40,8 @@ public interface PermissionBeanLocal {
boolean isCurrentUser(EventUser user); boolean isCurrentUser(EventUser user);
boolean hasPermission(SpecialPermission superadmin);
// boolean hasPermission(String perm); // boolean hasPermission(String perm);
} }
...@@ -3,7 +3,8 @@ package fi.codecrew.moya.model; ...@@ -3,7 +3,8 @@ package fi.codecrew.moya.model;
public enum ProductFlag { public enum ProductFlag {
// FOODWAVE_ITEM, Äy... Ei kai tämän täällä tarvitse olla.... // FOODWAVE_ITEM, Äy... Ei kai tämän täällä tarvitse olla....
PREPAID_CREDIT, PREPAID_CREDIT, // Tämä ei ole missään käytössä. Poistetaas jossain
// vaiheessa --tuomari
CREATE_NEW_PLACE_WHEN_BOUGHT, CREATE_NEW_PLACE_WHEN_BOUGHT,
RESERVE_PLACE_WHEN_BOUGHT, RESERVE_PLACE_WHEN_BOUGHT,
PREPAID_INSTANT_CREATE, USER_SHOPPABLE; PREPAID_INSTANT_CREATE, USER_SHOPPABLE;
......
...@@ -6,11 +6,13 @@ public enum EventPermission implements IAppPermission { ...@@ -6,11 +6,13 @@ public enum EventPermission implements IAppPermission {
MANAGE_PROPERTIES, MANAGE_PROPERTIES,
MANAGE_PRIVATE_PROPERTIES, MANAGE_PRIVATE_PROPERTIES,
MANAGE_EVENT
; ;
public static final String S_MANAGE_PROPERTIES = "EVENT/MANAGE_PROPERTIES"; public static final String S_MANAGE_PROPERTIES = "EVENT/MANAGE_PROPERTIES";
public static final String S_MANAGE_PRIVATE_PROPERTIES = "EVENT/MANAGE_PRIVATE_PROPERTIES"; public static final String S_MANAGE_PRIVATE_PROPERTIES = "EVENT/MANAGE_PRIVATE_PROPERTIES";
public static final String S_MANAGE_EVENT = "EVENT/MANAGE_EVENT";
private final String fullName; private final String fullName;
private final String key; private final String key;
......
...@@ -4,14 +4,14 @@ public enum SpecialPermission { ...@@ -4,14 +4,14 @@ public enum SpecialPermission {
SUPERADMIN, SUPERADMIN,
USER, USER,
ANONYMOUS, ANONYMOUS,
ORGANISATION_ADMIN, // ORGANISATION_ADMIN,
VERKKOMAKSU_CHECKER VERKKOMAKSU_CHECKER
; ;
public static final String S_USER = "USER"; public static final String S_USER = "USER";
public static final String S_SUPERADMIN = "SUPERADMIN"; public static final String S_SUPERADMIN = "SUPERADMIN";
public static final String S_ANONYMOUS = "ANONYMOUS"; public static final String S_ANONYMOUS = "ANONYMOUS";
public static final String S_ORGANISATION_ADMIN = "ORGANISATION_ADMIN"; //public static final String S_ORGANISATION_ADMIN = "ORGANISATION_ADMIN";
public static final String S_VERKKOMAKSU_CHECK = "VERKKOMAKSU_CHECKER"; public static final String S_VERKKOMAKSU_CHECK = "VERKKOMAKSU_CHECKER";
} }
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
TÄTÄ EI KÄYTETÄ MISSÄÄN! (Toivottavasti... )
Ilmoita tuomarille jos asia on toisin...
<h:form id="shoppingcartform"> <h:form id="shoppingcartform">
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
<img src="#{request.contextPath}/resources/templates/insomnia2/img/devel_logo.png" /> <img src="#{request.contextPath}/resources/templates/insomnia2/img/devel_logo.png" />
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<p:graphicImage rendered="#{!empty layoutView.headerimage}" value="#{layoutView.headerimage}" /> <p:graphicImage rendered="#{layoutView.isHeaderImage}" value="#{layoutView.headerimage}" />
<ui:fragment rendered="#{empty layoutView.headerimage}"> <ui:fragment rendered="#{!layoutView.isHeaderImage}">
<h1> <h1>
<h:outputText value="#{layoutView.headertext}" /> <h:outputText value="#{layoutView.headertext}" />
</h1> </h1>
......
package fi.codecrew.moya.rest;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/rest")
public class RestApplicationEntrypoint extends Application {
}
...@@ -75,9 +75,9 @@ public class LayoutView { ...@@ -75,9 +75,9 @@ public class LayoutView {
{ {
selectedSet = new HashSet<>(); selectedSet = new HashSet<>();
selectedTop = menubean.findNavigation(getPagepath()); selectedTop = menubean.findNavigation(getPagepath());
while (selectedTop != null && selectedTop.getParent() != null) { while (selectedTop != null) {
selectedTop = selectedTop.getParent();
selectedSet.add(selectedTop); selectedSet.add(selectedTop);
selectedTop = selectedTop.getParent();
} }
List<MenuNavigation> tops = menubean.getTopmenus(); List<MenuNavigation> tops = menubean.getTopmenus();
...@@ -150,6 +150,11 @@ public class LayoutView { ...@@ -150,6 +150,11 @@ public class LayoutView {
// return ""; // return "";
// } // }
public boolean getIsHeaderImage()
{
return getHeaderimage() != null;
}
public StreamedContent getHeaderimage() { public StreamedContent getHeaderimage() {
if (headertext == null && headerimage == null) if (headertext == null && headerimage == null)
{ {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!