@Transactional(rollbackFor = { Exception.class }) public void deleteGeodesk(Geodesk l) throws GeomajasSecurityException { if (((DeskmanagerSecurityContext) securityContext).deleteAllowed(l)) { factory.getCurrentSession().delete(l); } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Verwijderen Geodesk", securityContext.getUserName()); } }
private Geodesk getGeodesk() { if (geodesk == null) { try { geodesk = geodeskService.getGeodeskByPublicId(geodeskId); } catch (GeomajasSecurityException e) { e.printStackTrace(); } } return geodesk; }
@Override public String getUsernameFromToken(String authenticationSessionToken) throws GeomajasSecurityException { AuthenticationSession authenticationSession = getAuthenticationSessionFromToken(authenticationSessionToken); if (authenticationSession != null) { return authenticationSession.getUser().getEmail(); } throw new GeomajasSecurityException(new Exception("Authentication session token " + authenticationSessionToken + " is invalid or no longer active.")); }
public ClientMapInfo getMapInfo(String mapId, String applicationId) { try { // FIXME: code duplication from GetConfigurationCommand. move to service! String id = applicationId; Geodesk geodesk = geodeskService.getGeodeskByPublicId(id); // this checks if geodesk is allowed if (geodesk != null) { // request from cache ClientApplicationInfo geodeskConfig = getClonedGeodeskConfiguration(geodesk); for (ClientMapInfo map : geodeskConfig.getMaps()) { if (map.getId().equals(mapId)) { return map; } } } } catch (GeomajasSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
@Transactional(rollbackFor = { Exception.class }) public void deleteGeodesk(Geodesk l) throws GeomajasSecurityException { if (((DeskmanagerSecurityContext) securityContext).deleteAllowed(l)) { factory.getCurrentSession().delete(l); } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Verwijderen Geodesk", securityContext.getUserName()); } }
private void buildDeskmanagerAuthorizationInfo() { // Set basic authorization info (from configuration) deskmanagerAuthorizationInfo = (DeskmanagerAuthorizationInfo) deskmanagerAuthorizationInfos.get( profile.getRole().toString()).clone(); // Add geodesk specific authorization if (geodeskId != null && !RetrieveRolesRequest.MANAGER_ID.equals(geodeskId) && isGeodeskUseAllowed(geodeskId)) { try { LOG.debug("building deskmanagerAauthorizationInfo"); Geodesk geodesk = geodeskService.getGeodeskByPublicId(geodeskId); ClientApplicationInfo geodeskInfo = applicationContext.getBean(GeodeskConfigurationService.class) .createGeodeskConfiguration(geodesk, true); // Add all layers visible in this geodesk if (geodeskInfo != null) { for (ClientMapInfo map : geodeskInfo.getMaps()) { for (ClientLayerInfo layer : map.getLayers()) { // Add layers if they are public, or the user is not guest. if (!profile.getRole().equals(Role.GUEST) || layerModelService. getLayerModelByClientLayerIdInternal(layer.getId()).isPublic()) { deskmanagerAuthorizationInfo.getVisibleLayersInclude().add(layer.getServerLayerId()); } } } } } catch (GeomajasSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public void saveOrUpdateLayerModel(LayerModel lm) throws GeomajasSecurityException { if (((DeskmanagerSecurityContext) securityContext).saveAllowed(lm)) { factory.getCurrentSession().saveOrUpdate(lm); } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Save layermodel", securityContext.getUserName()); } }
public LayerModel getLayerModelById(String id) throws GeomajasSecurityException { LayerModel l = (LayerModel) factory.getCurrentSession().get(LayerModel.class, id); if (l != null) { if (((DeskmanagerSecurityContext) securityContext).readAllowed(l)) { return l; } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Read layermodel", securityContext.getUserName()); } } else { return null; } }
public LayerModel getLayerModelById(String id) throws GeomajasSecurityException { LayerModel l = (LayerModel) factory.getCurrentSession().get(LayerModel.class, id); if (l != null) { if (((DeskmanagerSecurityContext) securityContext).readAllowed(l)) { return l; } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Read layermodel", securityContext.getUserName()); } } else { return null; } }
public Geodesk getGeodeskById(String uuid) throws GeomajasSecurityException { Geodesk l = (Geodesk) factory.getCurrentSession().get(Geodesk.class, uuid); if (l != null) { if (((DeskmanagerSecurityContext) securityContext).readAllowed(l)) { return l; } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Read Geodesk", securityContext.getUserName()); } } else { return null; } }
public void saveOrUpdateLayerModel(LayerModel lm) throws GeomajasSecurityException { if (((DeskmanagerSecurityContext) securityContext).saveAllowed(lm)) { factory.getCurrentSession().saveOrUpdate(lm); } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Save layermodel", securityContext.getUserName()); } }
public Geodesk getGeodeskById(String uuid) throws GeomajasSecurityException { Geodesk l = (Geodesk) factory.getCurrentSession().get(Geodesk.class, uuid); if (l != null) { if (((DeskmanagerSecurityContext) securityContext).readAllowed(l)) { return l; } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Read Geodesk", securityContext.getUserName()); } } else { return null; } }
/** * Will throw a securityException if no accessrights, or not active. */ public Geodesk getGeodeskByPublicId(String id) throws GeomajasSecurityException { if (geodeskExists(id)) { if (((DeskmanagerSecurityContext) securityContext).isGeodeskUseAllowed(id)) { Query q = factory.getCurrentSession().createQuery( "FROM Geodesk l WHERE l.geodeskId = :id AND " + "l.deleted = false AND " + "l.active = true AND l.blueprint.geodesksActive = true"); q.setParameter("id", id); q.setResultTransformer(DistinctRootEntityResultTransformer.INSTANCE); Geodesk l = (Geodesk) q.uniqueResult(); if (l == null) { throw new GeomajasSecurityException(GdmLayout.EXCEPTIONCODE_GEODESKINACTIVE); } return l; } else { // FIXME: i18n throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Geodesk openen", securityContext.getUserName()); } } else { throw new GeomajasSecurityException(ExceptionCode.APPLICATION_NOT_FOUND, id); } }
public void deleteBlueprint(Blueprint bp) throws GeomajasSecurityException { if (((DeskmanagerSecurityContext) securityContext).deleteAllowed(bp)) { bp.setDeleted(true); factory.getCurrentSession().saveOrUpdate(bp); } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Delete blueprint", securityContext.getUserName()); } }
/** * Will throw a securityException if no accessrights, or not active. */ public Geodesk getGeodeskByPublicId(String id) throws GeomajasSecurityException { if (geodeskExists(id)) { if (((DeskmanagerSecurityContext) securityContext).isGeodeskUseAllowed(id)) { Query q = factory.getCurrentSession().createQuery( "FROM Geodesk l WHERE l.geodeskId = :id AND " + "l.deleted = false AND " + "l.active = true AND l.blueprint.geodesksActive = true"); q.setParameter("id", id); q.setResultTransformer(DistinctRootEntityResultTransformer.INSTANCE); Geodesk l = (Geodesk) q.uniqueResult(); if (l == null) { throw new GeomajasSecurityException(GdmLayout.EXCEPTIONCODE_GEODESKINACTIVE); } return l; } else { // FIXME: i18n throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Geodesk openen", securityContext.getUserName()); } } else { throw new GeomajasSecurityException(ExceptionCode.APPLICATION_NOT_FOUND, id); } }
@Override public String checkLogin(String email, String password) throws GeomajasSecurityException { User user = findByAddress(email); if (user != null && user.getPassword().equals(encodePassword(email, password))) { try { List<Profile> profileList = new ArrayList<Profile>(); for (GroupMember member : user.getGroups()) { profileList.add(converterService.toProfile(member)); } return profileService.registerProfilesForUser(new LoginSession(profileList)); } catch (GeomajasException ex) { throw new GeomajasSecurityException(ex); } } throw new GeomajasSecurityException(); }
public LayerModel getLayerModelByClientLayerId(String id) throws GeomajasSecurityException { LayerModel l = getLayerModelByClientLayerIdInternal(id); if (l != null) { if (((DeskmanagerSecurityContext) securityContext).readAllowed(l)) { return l; } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Read layermodel", securityContext.getUserName()); } } else { return null; } }
public Blueprint getBlueprintById(String uuid) throws GeomajasSecurityException { Blueprint bp = getBlueprintByIdInternal(uuid); if (bp != null) { if (((DeskmanagerSecurityContext) securityContext).readAllowed(bp)) { return bp; } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Read blueprint", securityContext.getUserName()); } } else { return null; } }
public LayerModel getLayerModelByClientLayerId(String id) throws GeomajasSecurityException { LayerModel l = getLayerModelByClientLayerIdInternal(id); if (l != null) { if (((DeskmanagerSecurityContext) securityContext).readAllowed(l)) { return l; } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Read layermodel", securityContext.getUserName()); } } else { return null; } }
public void deleteBlueprint(Blueprint bp) throws GeomajasSecurityException { if (((DeskmanagerSecurityContext) securityContext).deleteAllowed(bp)) { bp.setDeleted(true); factory.getCurrentSession().saveOrUpdate(bp); } else { throw new GeomajasSecurityException(ExceptionCode.COMMAND_ACCESS_DENIED, "Delete blueprint", securityContext.getUserName()); } }