public abstract class AbstractPolicyBasedAuthorizer extends Object implements ManagedAuthorizer
| Modifier and Type | Class and Description |
|---|---|
private static class |
AbstractPolicyBasedAuthorizer.PoliciesUsersAndGroups |
| Modifier and Type | Field and Description |
|---|---|
(package private) static String |
ACTIONS_ATTR |
private static String |
ALLOW_EXTERNAL_DTD |
private static String |
ALLOW_EXTERNAL_GENERAL_ENTITIES |
private static String |
ALLOW_EXTERNAL_PARAM_ENTITIES |
private static String |
DISALLOW_DOCTYPES |
(package private) static String |
GROUP_ELEMENT |
(package private) static String |
GROUP_USER_ELEMENT |
(package private) static String |
IDENTIFIER_ATTR |
(package private) static String |
IDENTITY_ATTR |
private static org.slf4j.Logger |
logger |
(package private) static String |
NAME_ATTR |
(package private) static String |
POLICY_ELEMENT |
(package private) static String |
POLICY_GROUP_ELEMENT |
(package private) static String |
POLICY_USER_ELEMENT |
(package private) static String |
RESOURCE_ATTR |
(package private) static String |
USER_ELEMENT |
(package private) static XMLOutputFactory |
XML_OUTPUT_FACTORY |
| Constructor and Description |
|---|
AbstractPolicyBasedAuthorizer() |
| Modifier and Type | Method and Description |
|---|---|
AccessPolicy |
addAccessPolicy(AccessPolicy accessPolicy)
Adds the given policy ensuring that multiple policies can not be added for the same resource and action.
|
Group |
addGroup(Group group)
Adds a new group.
|
private void |
addPoliciesUsersAndGroups(AbstractPolicyBasedAuthorizer.PoliciesUsersAndGroups policiesUsersAndGroups) |
User |
addUser(User user)
Adds the given user.
|
AuthorizationResult |
authorize(AuthorizationRequest request)
Determines if the specified user/entity is authorized to access the specified resource within the given context.
|
protected abstract void |
backupPoliciesUsersAndGroups() |
void |
checkInheritability(String proposedFingerprint)
Returns whether the proposed fingerprint is inheritable.
|
private boolean |
containsGroup(Set<Group> userGroups,
AccessPolicy policy)
Determines if the policy contains one of the user's groups.
|
abstract AccessPolicy |
deleteAccessPolicy(AccessPolicy policy)
Deletes the given policy.
|
abstract Group |
deleteGroup(Group group)
Deletes the given group.
|
abstract User |
deleteUser(User user)
Deletes the given user.
|
protected abstract AccessPolicy |
doAddAccessPolicy(AccessPolicy accessPolicy)
Adds the given policy.
|
abstract Group |
doAddGroup(Group group)
Adds a new group.
|
abstract User |
doAddUser(User user)
Adds the given user.
|
protected abstract void |
doOnConfigured(AuthorizerConfigurationContext configurationContext)
Allows sub-classes to take action when onConfigured is called.
|
abstract Group |
doUpdateGroup(Group group)
The group represented by the provided instance will be updated based on the provided instance.
|
abstract User |
doUpdateUser(User user)
The user represented by the provided instance will be updated based on the provided instance.
|
void |
forciblyInheritFingerprint(String fingerprint)
Parses the fingerprint and determines whether or not the fingerprint can be inherited in the same manner as
ManagedAuthorizer.inheritFingerprint(String). |
abstract Set<AccessPolicy> |
getAccessPolicies()
Retrieves all access policies.
|
abstract AccessPolicy |
getAccessPolicy(String identifier)
Retrieves the policy with the given identifier.
|
AccessPolicyProvider |
getAccessPolicyProvider()
Returns the AccessPolicy provider for this managed Authorizer.
|
String |
getFingerprint()
Returns a fingerprint representing the authorizations managed by this authorizer.
|
abstract Group |
getGroup(String identifier)
Retrieves a Group by id.
|
abstract Group |
getGroupByName(String name)
Retrieves a group by name.
|
abstract Set<Group> |
getGroups()
Retrieves all groups.
|
private List<AccessPolicy> |
getSortedAccessPolicies() |
private List<Group> |
getSortedGroups() |
private List<User> |
getSortedUsers() |
abstract User |
getUser(String identifier)
Retrieves the user with the given identifier.
|
abstract User |
getUserByIdentity(String identity)
Retrieves the user with the given identity.
|
abstract Set<User> |
getUsers()
Retrieves all users.
|
abstract UsersAndAccessPolicies |
getUsersAndAccessPolicies()
Returns the UserAccessPolicies instance.
|
void |
inheritFingerprint(String fingerprint)
Parses the fingerprint and adds any users, groups, and policies to the current Authorizer.
|
private void |
inheritPoliciesUsersAndGroups(AbstractPolicyBasedAuthorizer.PoliciesUsersAndGroups policiesUsersAndGroups) |
private boolean |
isInheritable(AbstractPolicyBasedAuthorizer.PoliciesUsersAndGroups policiesUsersAndGroups) |
void |
onConfigured(AuthorizerConfigurationContext configurationContext)
Called to configure the Authorizer.
|
private Document |
parseFingerprint(InputStream inputStream) |
private Group |
parseGroup(Element element) |
private AbstractPolicyBasedAuthorizer.PoliciesUsersAndGroups |
parsePoliciesUsersAndGroups(String fingerprint) |
private AccessPolicy |
parsePolicy(Element element) |
private User |
parseUser(Element element) |
protected abstract void |
purgePoliciesUsersAndGroups() |
abstract AccessPolicy |
updateAccessPolicy(AccessPolicy accessPolicy)
The policy represented by the provided instance will be updated based on the provided instance.
|
Group |
updateGroup(Group group)
The group represented by the provided instance will be updated based on the provided instance.
|
User |
updateUser(User user)
The user represented by the provided instance will be updated based on the provided instance.
|
private void |
writeGroup(XMLStreamWriter writer,
Group group) |
private void |
writePolicy(XMLStreamWriter writer,
AccessPolicy policy) |
private void |
writeUser(XMLStreamWriter writer,
User user) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitialize, preDestructionprivate static final org.slf4j.Logger logger
private static final String DISALLOW_DOCTYPES
private static final String ALLOW_EXTERNAL_GENERAL_ENTITIES
private static final String ALLOW_EXTERNAL_PARAM_ENTITIES
private static final String ALLOW_EXTERNAL_DTD
static final XMLOutputFactory XML_OUTPUT_FACTORY
static final String USER_ELEMENT
static final String GROUP_USER_ELEMENT
static final String GROUP_ELEMENT
static final String POLICY_ELEMENT
static final String POLICY_USER_ELEMENT
static final String POLICY_GROUP_ELEMENT
static final String IDENTIFIER_ATTR
static final String IDENTITY_ATTR
static final String NAME_ATTR
static final String RESOURCE_ATTR
static final String ACTIONS_ATTR
public final void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException
AuthorizeronConfigured in interface AuthorizerconfigurationContext - at the time of configurationAuthorizerCreationException - for any issues configuring the providerprotected abstract void doOnConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException
configurationContext - the configuration contextAuthorizerCreationException - if an error occurs during onConfigured processpublic final AuthorizationResult authorize(AuthorizationRequest request) throws AuthorizationAccessException
Authorizerauthorize in interface Authorizerrequest - The authorization requestAuthorizationAccessException - if unable to access the policiesprivate boolean containsGroup(Set<Group> userGroups, AccessPolicy policy)
userGroups - the set of the user's groupspolicy - the policypublic final Group addGroup(Group group) throws AuthorizationAccessException
group - the Group to addAuthorizationAccessException - if there was an unexpected error performing the operationIllegalStateException - if a group with the same name already existspublic abstract Group doAddGroup(Group group) throws AuthorizationAccessException
group - the Group to addAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract Group getGroup(String identifier) throws AuthorizationAccessException
identifier - the identifier of the Group to retrieveAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract Group getGroupByName(String name) throws AuthorizationAccessException
name - the name of the group to retrieveAuthorizationAccessException - if there was an unexpected error performing the operationprotected abstract void purgePoliciesUsersAndGroups()
protected abstract void backupPoliciesUsersAndGroups()
public final Group updateGroup(Group group) throws AuthorizationAccessException
group - an updated group instanceAuthorizationAccessException - if there was an unexpected error performing the operationIllegalStateException - if there is already a group with the same namepublic abstract Group doUpdateGroup(Group group) throws AuthorizationAccessException
group - an updated group instanceAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract Group deleteGroup(Group group) throws AuthorizationAccessException
group - the group to deleteAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract Set<Group> getGroups() throws AuthorizationAccessException
AuthorizationAccessException - if there was an unexpected error performing the operationpublic final User addUser(User user) throws AuthorizationAccessException
user - the user to addAuthorizationAccessException - if there was an unexpected error performing the operationIllegalStateException - if there is already a user with the same identitypublic abstract User doAddUser(User user) throws AuthorizationAccessException
user - the user to addAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract User getUser(String identifier) throws AuthorizationAccessException
identifier - the id of the user to retrieveAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract User getUserByIdentity(String identity) throws AuthorizationAccessException
identity - the identity of the user to retrieveAuthorizationAccessException - if there was an unexpected error performing the operationpublic final User updateUser(User user) throws AuthorizationAccessException
user - an updated user instanceAuthorizationAccessException - if there was an unexpected error performing the operationIllegalStateException - if there is already a user with the same identitypublic abstract User doUpdateUser(User user) throws AuthorizationAccessException
user - an updated user instanceAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract User deleteUser(User user) throws AuthorizationAccessException
user - the user to deleteAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract Set<User> getUsers() throws AuthorizationAccessException
AuthorizationAccessException - if there was an unexpected error performing the operationpublic final AccessPolicy addAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException
accessPolicy - the policy to addAuthorizationAccessException - if there was an unexpected error performing the operationprotected abstract AccessPolicy doAddAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException
accessPolicy - the policy to addAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract AccessPolicy getAccessPolicy(String identifier) throws AuthorizationAccessException
identifier - the id of the policy to retrieveAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract AccessPolicy updateAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException
accessPolicy - an updated policyAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract AccessPolicy deleteAccessPolicy(AccessPolicy policy) throws AuthorizationAccessException
policy - the policy to deleteAuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract Set<AccessPolicy> getAccessPolicies() throws AuthorizationAccessException
AuthorizationAccessException - if there was an unexpected error performing the operationpublic abstract UsersAndAccessPolicies getUsersAndAccessPolicies() throws AuthorizationAccessException
AuthorizationAccessException - if there was an unexpected error performing the operationpublic final void checkInheritability(String proposedFingerprint) throws AuthorizationAccessException, UninheritableAuthorizationsException
checkInheritability in interface ManagedAuthorizerproposedFingerprint - the proposed fingerprintAuthorizationAccessException - if there was an unexpected error performing the operationUninheritableAuthorizationsException - if the proposed fingerprint was uninheritableprivate boolean isInheritable(AbstractPolicyBasedAuthorizer.PoliciesUsersAndGroups policiesUsersAndGroups)
public final void inheritFingerprint(String fingerprint) throws AuthorizationAccessException
inheritFingerprint in interface ManagedAuthorizerfingerprint - the fingerprint that was obtained from calling getFingerprint() on another Authorizer.AuthorizationAccessException - if there was an unexpected error performing the operationprivate void inheritPoliciesUsersAndGroups(AbstractPolicyBasedAuthorizer.PoliciesUsersAndGroups policiesUsersAndGroups)
private void addPoliciesUsersAndGroups(AbstractPolicyBasedAuthorizer.PoliciesUsersAndGroups policiesUsersAndGroups)
public void forciblyInheritFingerprint(String fingerprint) throws AuthorizationAccessException
ManagedAuthorizerManagedAuthorizer.inheritFingerprint(String). If so, will inherit as such.
Otherwise, a backup of the existing policy provider will be made, if possible, and the policies will be replaced with those in the given fingerprint.forciblyInheritFingerprint in interface ManagedAuthorizerfingerprint - the fingerprint to replace the existing policies withAuthorizationAccessException - if unable to perform the operationprivate AbstractPolicyBasedAuthorizer.PoliciesUsersAndGroups parsePoliciesUsersAndGroups(String fingerprint)
private Document parseFingerprint(InputStream inputStream) throws IOException
IOExceptionprivate AccessPolicy parsePolicy(Element element)
public final AccessPolicyProvider getAccessPolicyProvider()
ManagedAuthorizergetAccessPolicyProvider in interface ManagedAuthorizerpublic final String getFingerprint() throws AuthorizationAccessException
getFingerprint in interface ManagedAuthorizerAuthorizationAccessException - if there was an unexpected error performing the operationprivate void writeUser(XMLStreamWriter writer, User user) throws XMLStreamException
XMLStreamExceptionprivate void writeGroup(XMLStreamWriter writer, Group group) throws XMLStreamException
XMLStreamExceptionprivate void writePolicy(XMLStreamWriter writer, AccessPolicy policy) throws XMLStreamException
XMLStreamExceptionprivate List<AccessPolicy> getSortedAccessPolicies()
Copyright © 2023 Apache NiFi Project. All rights reserved.