Search in sources :

Example 6 with UserGroup

use of org.apache.nifi.registry.authorization.UserGroup in project nifi-registry by apache.

the class AuthorizationService method userGroupToDTO.

private UserGroup userGroupToDTO(final org.apache.nifi.registry.security.authorization.Group userGroup) {
    if (userGroup == null) {
        return null;
    }
    Collection<Tenant> userTenants = userGroup.getUsers() != null ? userGroup.getUsers().stream().map(this::tenantIdToDTO).collect(Collectors.toSet()) : null;
    Collection<AccessPolicySummary> accessPolicySummaries = getAccessPolicySummariesForUserGroup(userGroup.getIdentifier());
    UserGroup userGroupDTO = new UserGroup(userGroup.getIdentifier(), userGroup.getName());
    userGroupDTO.setConfigurable(AuthorizerCapabilityDetection.isGroupConfigurable(authorizer, userGroup));
    userGroupDTO.setResourcePermissions(getTopLevelPermissions(userGroupDTO.getIdentifier()));
    userGroupDTO.addUsers(userTenants);
    userGroupDTO.addAccessPolicies(accessPolicySummaries);
    return userGroupDTO;
}
Also used : Tenant(org.apache.nifi.registry.authorization.Tenant) AccessPolicySummary(org.apache.nifi.registry.authorization.AccessPolicySummary) UserGroup(org.apache.nifi.registry.authorization.UserGroup)

Example 7 with UserGroup

use of org.apache.nifi.registry.authorization.UserGroup in project nifi-registry by apache.

the class TenantResource method getUserGroup.

/**
 * Retrieves the specified user group.
 *
 * @param identifier The id of the user group to retrieve
 * @return An userGroupEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("user-groups/{id}")
@ApiOperation(value = "Gets a user group", notes = NON_GUARANTEED_ENDPOINT, response = UserGroup.class, extensions = { @Extension(name = "access-policy", properties = { @ExtensionProperty(name = "action", value = "read"), @ExtensionProperty(name = "resource", value = "/tenants") }) })
@ApiResponses({ @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400), @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getUserGroup(@ApiParam(value = "The user group id.", required = true) @PathParam("id") final String identifier) {
    verifyAuthorizerIsManaged();
    authorizeAccess(RequestAction.READ);
    final UserGroup userGroup = authorizationService.getUserGroup(identifier);
    if (userGroup == null) {
        logger.warn("The specified user group id [{}] does not exist.", identifier);
        throw new ResourceNotFoundException("The specified user group ID does not exist in this registry.");
    }
    return generateOkResponse(userGroup).build();
}
Also used : ResourceNotFoundException(org.apache.nifi.registry.exception.ResourceNotFoundException) UserGroup(org.apache.nifi.registry.authorization.UserGroup) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

UserGroup (org.apache.nifi.registry.authorization.UserGroup)7 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 Consumes (javax.ws.rs.Consumes)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 ResourceNotFoundException (org.apache.nifi.registry.exception.ResourceNotFoundException)3 Tenant (org.apache.nifi.registry.authorization.Tenant)2 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 Response (javax.ws.rs.core.Response)1 AccessPolicySummary (org.apache.nifi.registry.authorization.AccessPolicySummary)1 ResourcePermissions (org.apache.nifi.registry.authorization.ResourcePermissions)1 ConfigurableUserGroupProvider (org.apache.nifi.registry.security.authorization.ConfigurableUserGroupProvider)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1