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;
}
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;
}
Aggregations