class StandardManagedAuthorizer implements ManagedAuthorizer {

    @Override
    public AuthorizationResult authorize(AuthorizationRequest request) throws AuthorizationAccessException {
        if (isAdmin(request.getIdentity())) {
            //if user is admin, gives all access rights.
            return AuthorizationResult.approved();
        }
        String resourceIdentifier = request.getResource().getIdentifier();
        //Resolve bug which provenance data not shown,it's from https://issues.apache.org/jira/browse/NIFI-5804
        if(resourceIdentifier.startsWith(ResourceType.ProvenanceData.getValue())){
            resourceIdentifier = ResourceType.Provenance.getValue();
        }
        final AccessPolicy policy = accessPolicyProvider.getAccessPolicy(resourceIdentifier, request.getAction());
        if (policy == null) {
            return AuthorizationResult.resourceNotFound();
        }

        final UserAndGroups userAndGroups = userGroupProvider.getUserAndGroups(request.getIdentity());

        final User user = userAndGroups.getUser();
        if (user == null) {
            if (request.isAnonymous()) {
                if (request.getRequestedResource().getName().equals("HandleHttpRequest")) {
                    //该请求可能是请求api的swagger信息，没有携带authentication信息，为匿名用户，给予通过
                    return AuthorizationResult.approved();
                }
                return AuthorizationResult.denied(String.format("user identity can't be '%s'.", request.getIdentity()));
            }
            User newUser = new User.Builder().identifier(generateUuid(request.getIdentity())).identity(request.getIdentity()).build();

            if(!autoGenerateUser(newUser)){
                return AuthorizationResult.denied("Unable to access!");
            }
            // create new user and add to userGroup
            ((ConfigurableUserGroupProvider)userGroupProvider).addUser(newUser);
            //set access pilicy for the new user
            ((ConfigurableAccessPolicyProvider) accessPolicyProvider).setUserDefaultAccesPilicy(newUser);
            
            return AuthorizationResult.approved();
        }

        final Set<Group> userGroups = userAndGroups.getGroups();
        if (policy.getUsers().contains(user.getIdentifier()) || containsGroup(userGroups, policy)) {
            return AuthorizationResult.approved();
        }
        return AuthorizationResult.denied(request.getExplanationSupplier().get());
    }

}