Search in sources :

Example 1 with RequiredPermissionDTO

use of org.apache.nifi.web.api.dto.RequiredPermissionDTO in project nifi by apache.

the class StandardNiFiServiceFacade method getCurrentUser.

@Override
public CurrentUserEntity getCurrentUser() {
    final NiFiUser user = NiFiUserUtils.getNiFiUser();
    final CurrentUserEntity entity = new CurrentUserEntity();
    entity.setIdentity(user.getIdentity());
    entity.setAnonymous(user.isAnonymous());
    entity.setProvenancePermissions(dtoFactory.createPermissionsDto(authorizableLookup.getProvenance()));
    entity.setCountersPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getCounters()));
    entity.setTenantsPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getTenant()));
    entity.setControllerPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getController()));
    entity.setPoliciesPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getPolicies()));
    entity.setSystemPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getSystem()));
    entity.setCanVersionFlows(CollectionUtils.isNotEmpty(flowRegistryClient.getRegistryIdentifiers()));
    entity.setRestrictedComponentsPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getRestrictedComponents()));
    final Set<ComponentRestrictionPermissionDTO> componentRestrictionPermissions = new HashSet<>();
    Arrays.stream(RequiredPermission.values()).forEach(requiredPermission -> {
        final PermissionsDTO restrictionPermissions = dtoFactory.createPermissionsDto(authorizableLookup.getRestrictedComponents(requiredPermission));
        final RequiredPermissionDTO requiredPermissionDto = new RequiredPermissionDTO();
        requiredPermissionDto.setId(requiredPermission.getPermissionIdentifier());
        requiredPermissionDto.setLabel(requiredPermission.getPermissionLabel());
        final ComponentRestrictionPermissionDTO componentRestrictionPermissionDto = new ComponentRestrictionPermissionDTO();
        componentRestrictionPermissionDto.setRequiredPermission(requiredPermissionDto);
        componentRestrictionPermissionDto.setPermissions(restrictionPermissions);
        componentRestrictionPermissions.add(componentRestrictionPermissionDto);
    });
    entity.setComponentRestrictionPermissions(componentRestrictionPermissions);
    return entity;
}
Also used : ComponentRestrictionPermissionDTO(org.apache.nifi.web.api.dto.ComponentRestrictionPermissionDTO) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) RequiredPermissionDTO(org.apache.nifi.web.api.dto.RequiredPermissionDTO) CurrentUserEntity(org.apache.nifi.web.api.entity.CurrentUserEntity) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with RequiredPermissionDTO

use of org.apache.nifi.web.api.dto.RequiredPermissionDTO in project nifi by apache.

the class CurrentUserEndpointMergerTest method buildComponentRestriction.

private ComponentRestrictionPermissionDTO buildComponentRestriction(final RequiredPermission requiredPermission, final boolean canRead, final boolean canWrite) {
    final RequiredPermissionDTO requiredPermissionDto = new RequiredPermissionDTO();
    requiredPermissionDto.setId(requiredPermission.getPermissionIdentifier());
    requiredPermissionDto.setLabel(requiredPermission.getPermissionLabel());
    final ComponentRestrictionPermissionDTO componentRestrictionPermissionDto = new ComponentRestrictionPermissionDTO();
    componentRestrictionPermissionDto.setRequiredPermission(requiredPermissionDto);
    componentRestrictionPermissionDto.setPermissions(buildPermissions(canRead, canWrite));
    return componentRestrictionPermissionDto;
}
Also used : ComponentRestrictionPermissionDTO(org.apache.nifi.web.api.dto.ComponentRestrictionPermissionDTO) RequiredPermissionDTO(org.apache.nifi.web.api.dto.RequiredPermissionDTO)

Aggregations

ComponentRestrictionPermissionDTO (org.apache.nifi.web.api.dto.ComponentRestrictionPermissionDTO)2 RequiredPermissionDTO (org.apache.nifi.web.api.dto.RequiredPermissionDTO)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)1 PermissionsDTO (org.apache.nifi.web.api.dto.PermissionsDTO)1 CurrentUserEntity (org.apache.nifi.web.api.entity.CurrentUserEntity)1