public abstract class AbstractPolicyBasedAuthorizer extends Object implements Authorizer
| Modifier and Type | Field and Description |
|---|---|
(package private) static String |
ACTIONS_ATTR |
(package private) static DocumentBuilderFactory |
DOCUMENT_BUILDER_FACTORY |
static String |
EMPTY_FINGERPRINT |
(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 |
(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.
|
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.
|
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.
|
abstract Set<AccessPolicy> |
getAccessPolicies()
Retrieves all access policies.
|
abstract AccessPolicy |
getAccessPolicy(String identifier)
Retrieves the policy with the given identifier.
|
String |
getFingerprint()
Returns a fingerprint representing the authorizations managed by this authorizer.
|
abstract Group |
getGroup(String identifier)
Retrieves a Group by id.
|
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.
|
void |
onConfigured(AuthorizerConfigurationContext configurationContext)
Called to configure the Authorizer.
|
private Group |
parseGroup(Element element) |
private AccessPolicy |
parsePolicy(Element element) |
private User |
parseUser(Element element) |
private boolean |
policyExists(AccessPolicy checkAccessPolicy)
Checks if another policy exists with the same resource and action as the given policy.
|
private boolean |
tenantExists(String identifier,
String identity)
Checks if another user exists with the same identity.
|
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, preDestructionstatic final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY
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 static final String EMPTY_FINGERPRINT
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 processprivate boolean policyExists(AccessPolicy checkAccessPolicy)
checkAccessPolicy - an access policy being checkedprivate boolean tenantExists(String identifier, String identity)
identifier - identity of the useridentity - identity of the userpublic 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 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 inheritFingerprint(String fingerprint) throws AuthorizationAccessException
fingerprint - the fingerprint that was obtained from calling getFingerprint() on another Authorizer.AuthorizationAccessExceptionprivate AccessPolicy parsePolicy(Element element)
public final String getFingerprint() throws AuthorizationAccessException
AuthorizationAccessExceptionprivate 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 © 2016 Apache NiFi Project. All rights reserved.