@Override public String getIdentifier() { return ResourceType.Flow.getValue(); }
/** * Get ResourceType from a raw resource value. * E.g. From "rovenance-data/processors/7ce897d6-0164-1000-fc87-caee3b08ba47", ProvenanceData will be returned. * @param rawValue the raw resource string representation * @return the type of the specified resource, or null if not found */ public static ResourceType fromRawValue(final String rawValue) throws IllegalArgumentException { for (final ResourceType rt : values()) { if (rt.getValue().equals(rawValue) || rawValue.startsWith(rt.getValue() + "/")) { return rt; } } return null; } }
@Override public Authorizable getAuthorizableFromResource(final String resource) { final ResourceType resourceType = ResourceType.fromRawValue(resource); if (resourceType == null) { throw new ResourceNotFoundException("Unrecognized resource: " + resource); final String baseResource = StringUtils.substringAfter(resource, resourceType.getValue()); final ResourceType baseResourceType = ResourceType.fromRawValue(baseResource); final String slashRequiredPermission = StringUtils.substringAfter(resource, resourceType.getValue());
/** * Authorizes access to data transfers. * <p> * Note: Protected for testing purposes */ protected void authorizeDataTransfer(final AuthorizableLookup lookup, final ResourceType resourceType, final String identifier) { final NiFiUser user = NiFiUserUtils.getNiFiUser(); // ensure the resource type is correct if (!ResourceType.InputPort.equals(resourceType) && !ResourceType.OutputPort.equals(resourceType)) { throw new IllegalArgumentException("The resource must be an Input or Output Port."); } // get the authorizable final RootGroupPortAuthorizable authorizable; if (ResourceType.InputPort.equals(resourceType)) { authorizable = lookup.getRootGroupInputPort(identifier); } else { authorizable = lookup.getRootGroupOutputPort(identifier); } // perform the authorization final AuthorizationResult authorizationResult = authorizable.checkAuthorization(user); if (!Result.Approved.equals(authorizationResult.getResult())) { throw new AccessDeniedException(authorizationResult.getExplanation()); } }
@Override public String getIdentifier() { return ResourceType.SiteToSite.getValue(); }
@Override public String getIdentifier() { return ResourceType.Controller.getValue(); }
@Override public String getIdentifier() { return ResourceType.ProvenanceData.getValue(); }
@Override public String getIdentifier() { return ResourceType.Resource.getValue(); }
@Override public String getIdentifier() { return ResourceType.System.getValue(); }
@Override public String getIdentifier() { return ResourceType.Tenant.getValue(); }
@Override public String getIdentifier() { return ResourceType.Policy.getValue(); }
@Override public String getIdentifier() { return ResourceType.Counters.getValue(); }
@Override public String getIdentifier() { return ResourceType.Provenance.getValue(); }
@Override public String getIdentifier() { return ResourceType.Data.getValue(); }
@Override public String getIdentifier() { return ResourceType.Proxy.getValue(); }
@Override public String getIdentifier() { return ResourceType.RestrictedComponents.getValue(); }
@Override public String getIdentifier() { return resourceType.getValue() + "/" + identifier; }
@Override public String getIdentifier() { return ResourceType.DataTransfer.getValue() + resource.getIdentifier(); }
@Override public String getIdentifier() { return ResourceType.Operation.getValue() + resource.getIdentifier(); }
private Authorizable getAccessPolicy(final ResourceType resourceType, final String resource) { final String slashComponentId = StringUtils.substringAfter(resource, resourceType.getValue()); if (slashComponentId.startsWith("/")) { return getAccessPolicyByResource(resourceType, slashComponentId.substring(1)); } else { return getAccessPolicyByResource(resourceType); } }