Search in sources :

Example 1 with GuiComponentsPermissionMapData

use of org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData in project geo-platform by geosdi.

the class GPAclDelegate method getApplicationPermission.

@Override
public GuiComponentsPermissionMapData getApplicationPermission(String appID) throws ResourceNotFoundFault {
    // Retrieve the account
    GPApplication application = accountDao.findByAppID(appID);
    if (application == null) {
        throw new ResourceNotFoundFault("Application not found with appID \"" + appID + "\"");
    }
    GuiComponentsPermissionMapData mapComponentPermission = new GuiComponentsPermissionMapData();
    Map<String, Boolean> permissionMap = mapComponentPermission.getPermissionMap();
    // Retrieve the Sid corresponding to the Application ID
    AclSid sid = this.findSid(appID, true, null);
    // Retrieve the ACEs of the Sid
    List<AclEntry> entries = entryDao.findBySid(sid.getId());
    logger.trace("\n*** #Entries: {} ***", entries.size());
    // because there is a singe Permission)
    for (AclEntry entry : entries) {
        logger.trace("\n*** AclEntry:\n{}\n***", entry);
        if (entry.getMask().equals(GeoPlatformPermission.ENABLE.getMask())) {
            AclObjectIdentity objectIdentity = entry.getAclObject();
            logger.trace("\n*** AclObjectIdentity:\n{}\n***", objectIdentity);
            GuiComponent gc = guiComponentDao.find(objectIdentity.getObjectId());
            logger.trace("\n*** GuiComponent:\n{}\n***", gc);
            logger.debug("\n*** ComponentId: {} ***\n*** Granting: {} ***", gc.getComponentId(), entry.isGranting());
            permissionMap.put(gc.getComponentId(), entry.isGranting());
        }
    }
    return mapComponentPermission;
}
Also used : GuiComponentsPermissionMapData(org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPApplication(org.geosdi.geoplatform.core.model.GPApplication)

Example 2 with GuiComponentsPermissionMapData

use of org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData in project geo-platform by geosdi.

the class GPAclDelegate method getAccountPermission.

@Override
public GuiComponentsPermissionMapData getAccountPermission(Long accountID) throws ResourceNotFoundFault {
    // Retrieve the account
    GPAccount account = accountDao.find(accountID);
    if (account == null) {
        throw new ResourceNotFoundFault("Account not found", accountID);
    }
    GuiComponentsPermissionMapData mapComponentPermission = new GuiComponentsPermissionMapData();
    // Retrieve the Authorities of the Account
    List<GPAuthority> authorities = authorityDao.findByAccountNaturalID(account.getNaturalID());
    logger.trace("\n*** #Authorities: {} ***", authorities.size());
    // For each Autorities (disjoined)
    for (GPAuthority authority : authorities) {
        String nameAuthority = authority.getAuthority();
        logger.trace("\n*** nameAuthority: {} ***", nameAuthority);
        this.elaborateGuiComponentACEs(nameAuthority, account.getOrganization().getName(), mapComponentPermission.getPermissionMap());
    }
    return mapComponentPermission;
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GuiComponentsPermissionMapData(org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPAuthority(org.geosdi.geoplatform.core.model.GPAuthority)

Example 3 with GuiComponentsPermissionMapData

use of org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData in project geo-platform by geosdi.

the class UserService method updateRolePermission.

@Override
public boolean updateRolePermission(String role, String organization, HashMap<String, Boolean> permissionMap, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    GuiComponentsPermissionMapData rolePermission = new GuiComponentsPermissionMapData();
    rolePermission.setPermissionMap(permissionMap);
    try {
        return geoPlatformServiceClient.updateRolePermission(new WSPutRolePermissionRequest(rolePermission, role, organization));
    } catch (ResourceNotFoundFault ex) {
        logger.error(this.getClass().getSimpleName(), ex.getMessage());
        throw new GeoPlatformException("Unable to find \"" + role + "\" role");
    }
}
Also used : GuiComponentsPermissionMapData(org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData) WSPutRolePermissionRequest(org.geosdi.geoplatform.request.organization.WSPutRolePermissionRequest) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 4 with GuiComponentsPermissionMapData

use of org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData in project geo-platform by geosdi.

the class GPAclDelegate method updateRolePermission.

@Override
public Boolean updateRolePermission(WSPutRolePermissionRequest putRolePermissionReq) throws ResourceNotFoundFault {
    if (putRolePermissionReq == null) {
        throw new IllegalArgumentException("The WSPutRolePermissionRequest " + "must not be null.");
    }
    String role = putRolePermissionReq.getRole();
    String organization = putRolePermissionReq.getOrganization();
    GuiComponentsPermissionMapData mapComponentPermission = putRolePermissionReq.getMapComponentPermission();
    logger.debug("\n*** Role: {} ***", role);
    // Retrieve the Sid corresponding to the Role (Authority) name
    AclSid sid = this.findSid(role, false, organization);
    AclClass clazz = classDao.findByClass(GuiComponent.class.getName());
    Permission permission = GeoPlatformPermission.ENABLE;
    Map<String, Boolean> permissionMap = mapComponentPermission.getPermissionMap();
    for (Map.Entry<String, Boolean> entry : permissionMap.entrySet()) {
        String componentId = entry.getKey();
        Boolean granting = entry.getValue();
        logger.info("\n*** Entry to manage: {} - {} ***", componentId, granting);
        GuiComponent gc = guiComponentDao.findByComponentId(componentId);
        if (gc == null) {
            throw new ResourceNotFoundFault("GuiComponent \"" + componentId + "\" not found");
        }
        logger.trace("\n\n**************** GuiComponent:\n{}\n***", gc);
        AclObjectIdentity obj = objectIdentityDao.findByObjectId(clazz.getId(), gc.getId());
        List<AclEntry> aces = entryDao.findByObjectIdentity(obj.getId());
        boolean managed = this.manageExistingEntry(aces, sid, permission, // UPDATE or DELETE the entry
        granting);
        if (!managed) {
            // ADD new entry
            Integer aceOrder = ((aces != null) && (aces.size() > 0)) ? (aces.get(aces.size() - 1).getAceOrder() + 1) : 0;
            logger.trace("\n\n#############################ACE_ORDER : {}\n\n", aceOrder);
            AclEntry e = new AclEntry(obj, aceOrder, sid, permission.getMask(), granting);
            entryDao.persist(e);
            logger.debug("\n*** ACE added ***");
        }
    }
    return TRUE;
}
Also used : ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GuiComponentsPermissionMapData(org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData) Permission(org.springframework.security.acls.model.Permission) Map(java.util.Map)

Example 5 with GuiComponentsPermissionMapData

use of org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData in project geo-platform by geosdi.

the class GPAclDelegate method getRolePermission.

@Override
public GuiComponentsPermissionMapData getRolePermission(String role, String organization) throws ResourceNotFoundFault {
    GuiComponentsPermissionMapData mapComponentPermission = new GuiComponentsPermissionMapData();
    this.elaborateGuiComponentACEs(role, organization, mapComponentPermission.getPermissionMap());
    return mapComponentPermission;
}
Also used : GuiComponentsPermissionMapData(org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData)

Aggregations

GuiComponentsPermissionMapData (org.geosdi.geoplatform.response.collection.GuiComponentsPermissionMapData)9 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)5 Test (org.junit.Test)3 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)2 WSPutRolePermissionRequest (org.geosdi.geoplatform.request.organization.WSPutRolePermissionRequest)2 Map (java.util.Map)1 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)1 GPApplication (org.geosdi.geoplatform.core.model.GPApplication)1 GPAuthority (org.geosdi.geoplatform.core.model.GPAuthority)1 Permission (org.springframework.security.acls.model.Permission)1