Search in sources :

Example 1 with UninheritableAuthorizationsException

use of org.apache.nifi.registry.security.authorization.exception.UninheritableAuthorizationsException in project nifi-registry by apache.

the class AbstractPolicyBasedAuthorizer method checkInheritability.

/**
 * Returns whether the proposed fingerprint is inheritable.
 *
 * @param proposedFingerprint the proposed fingerprint
 * @throws AuthorizationAccessException if there was an unexpected error performing the operation
 * @throws UninheritableAuthorizationsException if the proposed fingerprint was uninheritable
 */
@Override
public final void checkInheritability(String proposedFingerprint) throws AuthorizationAccessException, UninheritableAuthorizationsException {
    try {
        // ensure we understand the proposed fingerprint
        parsePoliciesUsersAndGroups(proposedFingerprint);
    } catch (final AuthorizationAccessException e) {
        throw new UninheritableAuthorizationsException("Unable to parse proposed fingerprint: " + e);
    }
    final List<User> users = getSortedUsers();
    final List<Group> groups = getSortedGroups();
    final List<AccessPolicy> accessPolicies = getSortedAccessPolicies();
    // ensure we're in a state to inherit
    if (!users.isEmpty() || !groups.isEmpty() || !accessPolicies.isEmpty()) {
        throw new UninheritableAuthorizationsException("Proposed fingerprint is not inheritable because the current Authorizations is not empty..");
    }
}
Also used : UninheritableAuthorizationsException(org.apache.nifi.registry.security.authorization.exception.UninheritableAuthorizationsException) AuthorizationAccessException(org.apache.nifi.registry.security.authorization.exception.AuthorizationAccessException)

Aggregations

AuthorizationAccessException (org.apache.nifi.registry.security.authorization.exception.AuthorizationAccessException)1 UninheritableAuthorizationsException (org.apache.nifi.registry.security.authorization.exception.UninheritableAuthorizationsException)1