NIFI-1952 Create REST endpoints for user/group/policy management
created REST Resources for users, groups, and access policies
added Authorizables for users, groups, and access policies
added methods to DtoFactory and EntityFactory to create objects for users, 
groups, and access policies
extracted anonymous AuthorizableLookup impl in StandardNiFiServiceFacade.java 
to a protected class to make the lookup call mockable in tests
added methods to manage users/groups/access policies to 
StandardNiFiServiceFacade
added StandardNiFiServiceFacadeSpec to unit-test management of 
users/groups/access policies
added implementations for UserDAO, GroupDAO, AccessPolicyDAO.
added spring config for user/group/policy resources and daos
Updated user/group/policy creation via REST resources, no longer requires the 
use of the revision manager
updated StandardNiFiServiceFacadeSpec based on user/group/policy creation 
changes
condensed user/group/policy DAOs to a single DAO 
(StandardPolicyBasedAuthorizerDAO)
fixed spring config of user/group/policy REST resources
Updated to return ComponentEntity objects instead of just their IDs
mid-progress on updating tests
updated code and tests to return component entities from REST endpoints for 
users, groups, policies
This closes #526


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/f47be77b
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/f47be77b
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/f47be77b

Branch: refs/heads/master
Commit: f47be77b6a8b45b878777a45ba776d67e4d9504f
Parents: 32facae
Author: Jeff Storck <[email protected]>
Authored: Thu Jun 2 16:33:05 2016 -0400
Committer: Matt Gilman <[email protected]>
Committed: Wed Jun 22 10:12:41 2016 -0400

----------------------------------------------------------------------
 .../org/apache/nifi/authorization/Group.java    |   2 +-
 .../authorization/AuthorizerFactoryBean.java    | 190 +++-
 .../nifi/web/api/dto/AccessPolicyDTO.java       |  43 +-
 .../org/apache/nifi/web/api/dto/UserDTO.java    | 164 +---
 .../apache/nifi/web/api/dto/UserGroupDTO.java   |  65 +-
 .../nifi/web/api/entity/AccessPolicyEntity.java |  44 +
 .../apache/nifi/web/api/entity/UserEntity.java  |  15 +-
 .../nifi/web/api/entity/UserGroupEntity.java    |  12 +-
 .../resource/AccessPoliciesAuthorizable.java    |  32 +
 .../resource/AccessPolicyAuthorizable.java      |  53 ++
 .../authorization/resource/ResourceFactory.java |  90 ++
 .../resource/UserGroupsAuthorizable.java        |  31 +
 .../resource/UsersAuthorizable.java             |  33 +
 .../org/apache/nifi/web/AuthorizableLookup.java |  28 +
 .../org/apache/nifi/web/NiFiServiceFacade.java  | 110 +++
 .../nifi/web/StandardAuthorizableLookup.java    | 242 +++++
 .../nifi/web/StandardNiFiServiceFacade.java     | 372 +++++---
 .../nifi/web/api/AccessPolicyResource.java      | 440 +++++++++
 .../apache/nifi/web/api/UserGroupsResource.java | 385 ++++++++
 .../org/apache/nifi/web/api/UsersResource.java  | 385 ++++++++
 .../org/apache/nifi/web/api/dto/DtoFactory.java |  60 ++
 .../apache/nifi/web/api/dto/EntityFactory.java  |  45 +
 .../apache/nifi/web/dao/AccessPolicyDAO.java    |  63 ++
 .../java/org/apache/nifi/web/dao/UserDAO.java   |  62 ++
 .../org/apache/nifi/web/dao/UserGroupDAO.java   |  62 ++
 .../impl/StandardPolicyBasedAuthorizerDAO.java  | 255 ++++++
 .../src/main/resources/nifi-web-api-context.xml |  44 +
 .../web/StandardNiFiServiceFacadeSpec.groovy    | 896 +++++++++++++++++++
 .../accesscontrol/AdminAccessControlTest.java   |   3 +-
 29 files changed, 3879 insertions(+), 347 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-api/src/main/java/org/apache/nifi/authorization/Group.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/Group.java 
b/nifi-api/src/main/java/org/apache/nifi/authorization/Group.java
index bb5c1e9..c208dba 100644
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/Group.java
+++ b/nifi-api/src/main/java/org/apache/nifi/authorization/Group.java
@@ -24,7 +24,7 @@ import java.util.Set;
 /**
  * A group that users can belong to.
  */
-public class Group {
+public class Group { // TODO rename to UserGroup
 
     private final String identifier;
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
index d061fe1..e00af72 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/src/main/java/org/apache/nifi/authorization/AuthorizerFactoryBean.java
@@ -47,6 +47,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * Factory bean for loading the configured authorizer.
@@ -287,35 +288,180 @@ public class AuthorizerFactoryBean implements 
FactoryBean, DisposableBean, Autho
      * @return authorizer
      */
     public Authorizer withNarLoader(final Authorizer baseAuthorizer) {
-        return new Authorizer() {
-            @Override
-            public AuthorizationResult authorize(final AuthorizationRequest 
request) throws AuthorizationAccessException {
-                try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
-                    return baseAuthorizer.authorize(request);
+        if (baseAuthorizer instanceof AbstractPolicyBasedAuthorizer) {
+            AbstractPolicyBasedAuthorizer policyBasedAuthorizer = 
(AbstractPolicyBasedAuthorizer) baseAuthorizer;
+            return new AbstractPolicyBasedAuthorizer() {
+                @Override
+                public Group addGroup(Group group) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.addGroup(group);
+                    }
                 }
-            }
 
-            @Override
-            public void initialize(AuthorizerInitializationContext 
initializationContext) throws AuthorizerCreationException {
-                try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
-                    baseAuthorizer.initialize(initializationContext);
+                @Override
+                public Group getGroup(String identifier) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.getGroup(identifier);
+                    }
                 }
-            }
 
-            @Override
-            public void onConfigured(AuthorizerConfigurationContext 
configurationContext) throws AuthorizerCreationException {
-                try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
-                    baseAuthorizer.onConfigured(configurationContext);
+                @Override
+                public Group updateGroup(Group group) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.updateGroup(group);
+                    }
                 }
-            }
 
-            @Override
-            public void preDestruction() throws AuthorizerDestructionException 
{
-                try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
-                    baseAuthorizer.preDestruction();
+                @Override
+                public Group deleteGroup(Group group) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.deleteGroup(group);
+                    }
                 }
-            }
-        };
+
+                @Override
+                public Set<Group> getGroups() throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.getGroups();
+                    }
+                }
+
+                @Override
+                public User addUser(User user) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.addUser(user);
+                    }
+                }
+
+                @Override
+                public User getUser(String identifier) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.getUser(identifier);
+                    }
+                }
+
+                @Override
+                public User getUserByIdentity(String identity) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return 
policyBasedAuthorizer.getUserByIdentity(identity);
+                    }
+                }
+
+                @Override
+                public User updateUser(User user) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.updateUser(user);
+                    }
+                }
+
+                @Override
+                public User deleteUser(User user) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.deleteUser(user);
+                    }
+                }
+
+                @Override
+                public Set<User> getUsers() throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.getUsers();
+                    }
+                }
+
+                @Override
+                public AccessPolicy addAccessPolicy(AccessPolicy accessPolicy) 
throws AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return 
policyBasedAuthorizer.addAccessPolicy(accessPolicy);
+                    }
+                }
+
+                @Override
+                public AccessPolicy getAccessPolicy(String identifier) throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return 
policyBasedAuthorizer.getAccessPolicy(identifier);
+                    }
+                }
+
+                @Override
+                public AccessPolicy updateAccessPolicy(AccessPolicy 
accessPolicy) throws AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return 
policyBasedAuthorizer.updateAccessPolicy(accessPolicy);
+                    }
+                }
+
+                @Override
+                public AccessPolicy deleteAccessPolicy(AccessPolicy 
accessPolicy) throws AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return 
policyBasedAuthorizer.deleteAccessPolicy(accessPolicy);
+                    }
+                }
+
+                @Override
+                public Set<AccessPolicy> getAccessPolicies() throws 
AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return policyBasedAuthorizer.getAccessPolicies();
+                    }
+                }
+
+                @Override
+                public UsersAndAccessPolicies getUsersAndAccessPolicies() 
throws AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return 
policyBasedAuthorizer.getUsersAndAccessPolicies();
+                    }
+                }
+
+                @Override
+                public void initialize(AuthorizerInitializationContext 
initializationContext) throws AuthorizerCreationException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        
policyBasedAuthorizer.initialize(initializationContext);
+                    }
+                }
+
+                @Override
+                public void onConfigured(AuthorizerConfigurationContext 
configurationContext) throws AuthorizerCreationException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        
policyBasedAuthorizer.onConfigured(configurationContext);
+                    }
+                }
+
+                @Override
+                public void preDestruction() throws 
AuthorizerDestructionException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        baseAuthorizer.preDestruction();
+                    }
+                }
+            };
+        } else {
+            return new Authorizer() {
+                @Override
+                public AuthorizationResult authorize(final 
AuthorizationRequest request) throws AuthorizationAccessException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        return baseAuthorizer.authorize(request);
+                    }
+                }
+
+                @Override
+                public void initialize(AuthorizerInitializationContext 
initializationContext) throws AuthorizerCreationException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        baseAuthorizer.initialize(initializationContext);
+                    }
+                }
+
+                @Override
+                public void onConfigured(AuthorizerConfigurationContext 
configurationContext) throws AuthorizerCreationException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        baseAuthorizer.onConfigured(configurationContext);
+                    }
+                }
+
+                @Override
+                public void preDestruction() throws 
AuthorizerDestructionException {
+                    try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
+                        baseAuthorizer.preDestruction();
+                    }
+                }
+            };
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AccessPolicyDTO.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AccessPolicyDTO.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AccessPolicyDTO.java
index 1564362..cd72863 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AccessPolicyDTO.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AccessPolicyDTO.java
@@ -17,15 +17,21 @@
 package org.apache.nifi.web.api.dto;
 
 import com.wordnik.swagger.annotations.ApiModelProperty;
+import org.apache.nifi.web.api.entity.UserEntity;
+import org.apache.nifi.web.api.entity.UserGroupEntity;
 
 import javax.xml.bind.annotation.XmlType;
+import java.util.Set;
 
 /**
  * Details for the access configuration.
  */
 @XmlType(name = "accessPolicy")
-public class AccessPolicyDTO {
+public class AccessPolicyDTO  extends ComponentDTO {
 
+    private String resource;
+    private Set<UserEntity> users;
+    private Set<UserGroupEntity> userGroups;
     private Boolean canRead;
     private Boolean canWrite;
 
@@ -59,4 +65,39 @@ public class AccessPolicyDTO {
         this.canWrite = canWrite;
     }
 
+    /**
+     * @return The resource ID for this access policy.
+     */
+    @ApiModelProperty(value="The resource ID for this access policy.")
+    public String getResource() {
+        return resource;
+    }
+
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+
+    /**
+     * @return The set of user IDs associated with this access policy.
+     */
+    @ApiModelProperty(value = "The set of user IDs associated with this access 
policy.")
+    public Set<UserEntity> getUsers() {
+        return users;
+    }
+
+    public void setUsers(Set<UserEntity> users) {
+        this.users = users;
+    }
+
+    /**
+     * @return The set of user group IDs associated with this access policy.
+     */
+    @ApiModelProperty(value = "The set of user group IDs associated with this 
access policy.")
+    public Set<UserGroupEntity> getUserGroups() {
+        return userGroups;
+    }
+
+    public void setUserGroups(Set<UserGroupEntity> userGroups) {
+        this.userGroups = userGroups;
+    }
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserDTO.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserDTO.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserDTO.java
index 3344306..04d60aa 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserDTO.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserDTO.java
@@ -17,171 +17,43 @@
 package org.apache.nifi.web.api.dto;
 
 import com.wordnik.swagger.annotations.ApiModelProperty;
-import java.util.Date;
-import java.util.Set;
+import org.apache.nifi.web.api.entity.UserGroupEntity;
+
 import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.apache.nifi.web.api.dto.util.DateTimeAdapter;
+import java.util.Set;
 
 /**
  * A user of this NiFi.
  */
 @XmlType(name = "user")
-public class UserDTO {
-
-    private String id;
-    private String dn;
-    private String userName;
-    private String userGroup;
-    private String justification;
-    private Date creation;
-    private String status;
-
-    private Date lastVerified;
-    private Date lastAccessed;
-    private Set<String> authorities;
-
-    /**
-     * @return user id
-     */
-    @ApiModelProperty(
-            value = "The id of the user."
-    )
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    /**
-     * @return users authorities
-     */
-    @ApiModelProperty(
-            value = "The users authorities."
-    )
-    public Set<String> getAuthorities() {
-        return authorities;
-    }
-
-    public void setAuthorities(Set<String> authorities) {
-        this.authorities = authorities;
-    }
-
-    /**
-     * @return creation time for this users account
-     */
-    @XmlJavaTypeAdapter(DateTimeAdapter.class)
-    @ApiModelProperty(
-            value = "The timestamp when the user was created."
-    )
-    public Date getCreation() {
-        return creation;
-    }
+public class UserDTO extends ComponentDTO {
 
-    public void setCreation(Date creation) {
-        this.creation = creation;
-    }
+    private String identity;
+    private Set<UserGroupEntity> groups;
 
     /**
-     * @return users DN
+     * @return users identity
      */
     @ApiModelProperty(
-            value = "The dn of the user."
+            value = "The identity of the user."
     )
-    public String getDn() {
-        return dn;
+    public String getIdentity() {
+        return identity;
     }
 
-    public void setDn(String dn) {
-        this.dn = dn;
+    public void setIdentity(String identity) {
+        this.identity = identity;
     }
 
     /**
-     * @return users name. If the name could not be extracted from the DN, 
this value will be the entire DN
+     * @return groups to which the user belongs
      */
-    @ApiModelProperty(
-            value = "The username. If it could not be extracted from the DN, 
this value will be the entire DN."
-    )
-    public String getUserName() {
-        return userName;
-    }
-
-    public void setUserName(String userName) {
-        this.userName = userName;
+    @ApiModelProperty(value = "The groups to which the user belongs.")
+    public Set<UserGroupEntity> getGroups() {
+        return groups;
     }
 
-    /**
-     * @return user group
-     */
-    @ApiModelProperty(
-            value = "The group this user belongs to."
-    )
-    public String getUserGroup() {
-        return userGroup;
+    public void setGroups(Set<UserGroupEntity> groups) {
+        this.groups = groups;
     }
-
-    public void setUserGroup(String userGroup) {
-        this.userGroup = userGroup;
-    }
-
-    /**
-     * @return users account justification
-     */
-    @ApiModelProperty(
-            value = "The justification for the user account."
-    )
-    public String getJustification() {
-        return justification;
-    }
-
-    public void setJustification(String justification) {
-        this.justification = justification;
-    }
-
-    /**
-     * @return time that the user last accessed the system
-     */
-    @XmlJavaTypeAdapter(DateTimeAdapter.class)
-    @ApiModelProperty(
-            value = "The timestamp the user last accessed the system."
-    )
-    public Date getLastAccessed() {
-        return lastAccessed;
-    }
-
-    public void setLastAccessed(Date lastAccessed) {
-        this.lastAccessed = lastAccessed;
-    }
-
-    /**
-     * @return time that the users credentials were last verified
-     */
-    @XmlJavaTypeAdapter(DateTimeAdapter.class)
-    @ApiModelProperty(
-            value = "The timestamp the user authorities were verified."
-    )
-    public Date getLastVerified() {
-        return lastVerified;
-    }
-
-    public void setLastVerified(Date lastVerified) {
-        this.lastVerified = lastVerified;
-    }
-
-    /**
-     * @return status of the users account
-     */
-    @ApiModelProperty(
-            value = "The user status."
-    )
-    public String getStatus() {
-        return status;
-    }
-
-    public void setStatus(String status) {
-        this.status = status;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserGroupDTO.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserGroupDTO.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserGroupDTO.java
index 8f6a3a1..bd06368 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserGroupDTO.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/UserGroupDTO.java
@@ -17,73 +17,44 @@
 package org.apache.nifi.web.api.dto;
 
 import com.wordnik.swagger.annotations.ApiModelProperty;
-import java.util.Set;
+import org.apache.nifi.web.api.entity.UserEntity;
+
 import javax.xml.bind.annotation.XmlType;
+import java.util.Set;
 
 /**
  * A user group in this NiFi.
  */
 @XmlType(name = "userGroup")
-public class UserGroupDTO {
+public class UserGroupDTO extends ComponentDTO {
 
-    private String group;
-    private Set<String> userIds;
-    private Set<String> authorities;
-    private String status;
-
-    /**
-     * @return user group
-     */
-    @ApiModelProperty(
-            value = "The user group."
-    )
-    public String getGroup() {
-        return group;
-    }
-
-    public void setGroup(String group) {
-        this.group = group;
-    }
+    private String name;
+    private Set<UserEntity> users;
 
     /**
      * @return users in this group
      */
     @ApiModelProperty(
-            value = "The users that belong to the group."
+            value = "The users that belong to the user group."
     )
-    public Set<String> getUserIds() {
-        return userIds;
+    public Set<UserEntity> getUsers() {
+        return users;
     }
 
-    public void setUserIds(Set<String> userIds) {
-        this.userIds = userIds;
+    public void setUsers(Set<UserEntity> users) {
+        this.users = users;
     }
 
     /**
-     * @return status of the users account
+     *
+     * @return name of the user group
      */
-    @ApiModelProperty(
-            value = "The status of the users accounts."
-    )
-    public String getStatus() {
-        return status;
-    }
-
-    public void setStatus(String status) {
-        this.status = status;
-    }
-
-    /**
-     * @return users authorities
-     */
-    @ApiModelProperty(
-            value = "The authorities of the users."
-    )
-    public Set<String> getAuthorities() {
-        return authorities;
+    @ApiModelProperty(value = "The name of the user group.")
+    public String getName() {
+        return name;
     }
 
-    public void setAuthorities(Set<String> authorities) {
-        this.authorities = authorities;
+    public void setName(String name) {
+        this.name = name;
     }
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AccessPolicyEntity.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AccessPolicyEntity.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AccessPolicyEntity.java
new file mode 100644
index 0000000..82a977f
--- /dev/null
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/AccessPolicyEntity.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.web.api.entity;
+
+import org.apache.nifi.web.api.dto.AccessPolicyDTO;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * A serialized representation of this class can be placed in the entity body 
of a request or response to or from the API. This particular entity holds a 
reference to an {@link AccessPolicyDTO}.
+ */
+@XmlRootElement(name = "accessPolicyEntity")
+public class AccessPolicyEntity extends ComponentEntity {
+
+    private AccessPolicyDTO component;
+
+    /**
+     * The {@link AccessPolicyDTO} that is being serialized.
+     *
+     * @return The {@link AccessPolicyDTO} object
+     */
+    public AccessPolicyDTO getComponent() {
+        return component;
+    }
+
+    public void setComponent(AccessPolicyDTO component) {
+        this.component = component;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserEntity.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserEntity.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserEntity.java
index 71554dd..983cdfb 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserEntity.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserEntity.java
@@ -16,28 +16,29 @@
  */
 package org.apache.nifi.web.api.entity;
 
-import javax.xml.bind.annotation.XmlRootElement;
 import org.apache.nifi.web.api.dto.UserDTO;
 
+import javax.xml.bind.annotation.XmlRootElement;
+
 /**
  * A serialized representation of this class can be placed in the entity body 
of a request or response to or from the API. This particular entity holds a 
reference to a UserDTO.
  */
 @XmlRootElement(name = "userEntity")
-public class UserEntity extends Entity {
+public class UserEntity extends ComponentEntity {
 
-    private UserDTO user;
+    private UserDTO component;
 
     /**
      * The UserDTO that is being serialized.
      *
      * @return The UserDTO object
      */
-    public UserDTO getUser() {
-        return user;
+    public UserDTO getComponent() {
+        return component;
     }
 
-    public void setUser(UserDTO user) {
-        this.user = user;
+    public void setComponent(UserDTO component) {
+        this.component = component;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserGroupEntity.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserGroupEntity.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserGroupEntity.java
index 35a88d5..ea8238a 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserGroupEntity.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UserGroupEntity.java
@@ -23,21 +23,21 @@ import org.apache.nifi.web.api.dto.UserGroupDTO;
  * A serialized representation of this class can be placed in the entity body 
of a request or response to or from the API. This particular entity holds a 
reference to a UserGroupDTO.
  */
 @XmlRootElement(name = "userGroupEntity")
-public class UserGroupEntity extends Entity {
+public class UserGroupEntity extends ComponentEntity {
 
-    private UserGroupDTO userGroup;
+    private UserGroupDTO component;
 
     /**
      * The UserGroupDTO that is being serialized.
      *
      * @return The UserGroupDTO object
      */
-    public UserGroupDTO getUserGroup() {
-        return userGroup;
+    public UserGroupDTO getComponent() {
+        return component;
     }
 
-    public void setUserGroup(UserGroupDTO userGroup) {
-        this.userGroup = userGroup;
+    public void setComponent(UserGroupDTO component) {
+        this.component = component;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/AccessPoliciesAuthorizable.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/AccessPoliciesAuthorizable.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/AccessPoliciesAuthorizable.java
new file mode 100644
index 0000000..ad4ba29
--- /dev/null
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/AccessPoliciesAuthorizable.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.authorization.resource;
+
+import org.apache.nifi.authorization.Resource;
+
+public class AccessPoliciesAuthorizable implements Authorizable {
+
+    @Override
+    public Authorizable getParentAuthorizable() {
+        return null;
+    }
+
+    @Override
+    public Resource getResource() {
+        return ResourceFactory.getPoliciesResource();
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/AccessPolicyAuthorizable.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/AccessPolicyAuthorizable.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/AccessPolicyAuthorizable.java
new file mode 100644
index 0000000..5d5eab7
--- /dev/null
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/AccessPolicyAuthorizable.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.authorization.resource;
+
+import org.apache.nifi.authorization.AccessPolicy;
+import org.apache.nifi.authorization.Resource;
+
+public class AccessPolicyAuthorizable implements Authorizable {
+
+    private final AccessPolicy policy;
+
+    public AccessPolicyAuthorizable(AccessPolicy policy) {
+        this.policy = policy;
+    }
+
+    @Override
+    public Authorizable getParentAuthorizable() {
+        return new Authorizable() {
+            @Override
+            public Authorizable getParentAuthorizable() {
+                return null;
+            }
+
+            @Override
+            public Resource getResource() {
+                return ResourceFactory.getPoliciesResource();
+            }
+        };
+    }
+
+    @Override
+    public Resource getResource() {
+        return ResourceFactory.getPolicyResource(policy.getIdentifier());
+    }
+
+    public AccessPolicy getPolicy() {
+        return policy;
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java
index 1e9b8c2..92d8e33 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java
@@ -16,7 +16,10 @@
  */
 package org.apache.nifi.authorization.resource;
 
+import org.apache.nifi.authorization.AccessPolicy;
+import org.apache.nifi.authorization.Group;
 import org.apache.nifi.authorization.Resource;
+import org.apache.nifi.authorization.User;
 
 import java.util.Objects;
 
@@ -286,6 +289,45 @@ public final class ResourceFactory {
         }
     };
 
+    private final static Resource POLICIES_RESOURCE = new Resource() {
+
+        @Override
+        public String getIdentifier() {
+            return "/policies";
+        }
+
+        @Override
+        public String getName() {
+            return "Access Policies";
+        }
+    };
+
+    private final static Resource USERS_RESOURCE = new Resource() {
+
+        @Override
+        public String getIdentifier() {
+            return "/users";
+        }
+
+        @Override
+        public String getName() {
+            return "Users";
+        }
+    };
+
+    private final static Resource USERGROUPS_RESOURCE = new Resource() {
+
+        @Override
+        public String getIdentifier() {
+            return "/user-groups";
+        }
+
+        @Override
+        public String getName() {
+            return "User Groups";
+        }
+    };
+
     /**
      * Gets the Resource for accessing Connections.
      *
@@ -487,6 +529,54 @@ public final class ResourceFactory {
     }
 
     /**
+     * Gets the {@link Resource} for accessing {@link AccessPolicy}s.
+     * @return The policies resource
+     */
+    public static Resource getPoliciesResource() {
+        return POLICIES_RESOURCE;
+    }
+
+    /**
+     * Gets a Resource for accessing an {@link AccessPolicy} configuration.
+     *
+     * @param identifier    The identifier of the component being accessed
+     * @return              The resource
+     */
+    public static Resource getPolicyResource(final String identifier) {
+        Objects.requireNonNull(identifier, "The component identifier must be 
specified.");
+
+        return new Resource() {
+            @Override
+            public String getIdentifier() {
+                return String.format("%s/%s", 
POLICIES_RESOURCE.getIdentifier(), identifier);
+            }
+
+            @Override
+            public String getName() {
+                return identifier;
+            }
+        };
+    }
+
+    /**
+     * Gets a Resource for accessing {@link User} configurations.
+     *
+     * @return              The resource
+     */
+    public static Resource getUsersResource() {
+        return USERS_RESOURCE;
+    }
+
+    /**
+     * Gets a Resource for accessing {@link Group}s configuration.
+     *
+     * @return              The resource
+     */
+    public static Resource getUserGroupsResource() {
+        return USERGROUPS_RESOURCE;
+    }
+
+    /**
      * Gets a Resource for accessing a component configuration.
      *
      * @param resourceType  The type of resource being accessed

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/UserGroupsAuthorizable.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/UserGroupsAuthorizable.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/UserGroupsAuthorizable.java
new file mode 100644
index 0000000..938371c
--- /dev/null
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/UserGroupsAuthorizable.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.authorization.resource;
+
+import org.apache.nifi.authorization.Resource;
+
+public class UserGroupsAuthorizable implements Authorizable {
+    @Override
+    public Authorizable getParentAuthorizable() {
+        return null;
+    }
+
+    @Override
+    public Resource getResource() {
+        return ResourceFactory.getUserGroupsResource();
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/UsersAuthorizable.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/UsersAuthorizable.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/UsersAuthorizable.java
new file mode 100644
index 0000000..2b255d4
--- /dev/null
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/UsersAuthorizable.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.authorization.resource;
+
+import org.apache.nifi.authorization.Resource;
+
+public class UsersAuthorizable implements Authorizable {
+
+    @Override
+    public Authorizable getParentAuthorizable() {
+        return null;
+    }
+
+    @Override
+    public Resource getResource() {
+        return ResourceFactory.getUsersResource();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java
index d6db1f0..e032718 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java
@@ -16,6 +16,9 @@
  */
 package org.apache.nifi.web;
 
+import org.apache.nifi.authorization.AccessPolicy;
+import org.apache.nifi.authorization.Group;
+import org.apache.nifi.authorization.User;
 import org.apache.nifi.authorization.resource.Authorizable;
 import org.apache.nifi.controller.Snippet;
 
@@ -151,4 +154,29 @@ public interface AuthorizableLookup {
      * @return snippet of authorizable's
      */
     Snippet getSnippet(String id);
+
+    /**
+     * Get the {@link Authorizable} that represents the resource of {@link 
User}s.
+     * @return authorizable
+     */
+    Authorizable getUsersAuthorizable();
+
+    /**
+     * Get the {@link Authorizable} that represents the resource of {@link 
Group}s.
+     * @return authorizable
+     */
+    Authorizable getUserGroupsAuthorizable();
+
+    /**
+     * Get the {@link Authorizable} the represents the parent resource of 
{@link AccessPolicy} resources.
+     * @return authorizable
+     */
+    Authorizable getAccessPoliciesAuthorizable();
+
+    /**
+     * Get the {@link Authorizable} the represents the {@link AccessPolicy} 
with the given ID.
+     * @param id access policy ID
+     * @return authorizable
+     */
+    Authorizable getAccessPolicyAuthorizable(String id);
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
index cd27e0d..f9a91cf 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
@@ -21,6 +21,7 @@ import org.apache.nifi.controller.ScheduledState;
 import org.apache.nifi.controller.repository.claim.ContentDirection;
 import org.apache.nifi.controller.service.ControllerServiceState;
 import org.apache.nifi.groups.ProcessGroup;
+import org.apache.nifi.web.api.dto.AccessPolicyDTO;
 import org.apache.nifi.web.api.dto.BulletinBoardDTO;
 import org.apache.nifi.web.api.dto.BulletinQueryDTO;
 import org.apache.nifi.web.api.dto.ClusterDTO;
@@ -50,6 +51,8 @@ import org.apache.nifi.web.api.dto.ResourceDTO;
 import org.apache.nifi.web.api.dto.SnippetDTO;
 import org.apache.nifi.web.api.dto.SystemDiagnosticsDTO;
 import org.apache.nifi.web.api.dto.TemplateDTO;
+import org.apache.nifi.web.api.dto.UserDTO;
+import org.apache.nifi.web.api.dto.UserGroupDTO;
 import org.apache.nifi.web.api.dto.action.ActionDTO;
 import org.apache.nifi.web.api.dto.action.HistoryDTO;
 import org.apache.nifi.web.api.dto.action.HistoryQueryDTO;
@@ -65,6 +68,7 @@ import 
org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO;
 import org.apache.nifi.web.api.dto.status.ProcessorStatusDTO;
 import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO;
 import org.apache.nifi.web.api.dto.status.StatusHistoryDTO;
+import org.apache.nifi.web.api.entity.AccessPolicyEntity;
 import org.apache.nifi.web.api.entity.ConnectionEntity;
 import org.apache.nifi.web.api.entity.ControllerConfigurationEntity;
 import org.apache.nifi.web.api.entity.ControllerServiceEntity;
@@ -81,6 +85,8 @@ import 
org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity;
 import org.apache.nifi.web.api.entity.ReportingTaskEntity;
 import org.apache.nifi.web.api.entity.ScheduleComponentsEntity;
 import org.apache.nifi.web.api.entity.SnippetEntity;
+import org.apache.nifi.web.api.entity.UserEntity;
+import org.apache.nifi.web.api.entity.UserGroupEntity;
 
 import java.util.Date;
 import java.util.List;
@@ -1180,6 +1186,110 @@ public interface NiFiServiceFacade {
     LabelEntity deleteLabel(Revision revision, String labelId);
 
     // ----------------------------------------
+    // User methods
+    // ----------------------------------------
+    /**
+     * Creates a user.
+     * @param revision The starting revision
+     * @param userDTO The user DTO
+     * @return The user transfer object
+     */
+    UserEntity createUser(Revision revision, UserDTO userDTO);
+
+    /**
+     * Gets the user with the specified ID.
+     * @param userId The user ID
+     * @param prune If true, the users in the groups to which this user 
belongs will not be returned
+     * @return The user transfer object
+     */
+    UserEntity getUser(String userId, boolean prune);
+
+    /**
+     * Updates the specified user.
+     * @param revision Revision to compare with current base revision
+     * @param userDTO The user DTO
+     * @return The user transfer object
+     */
+    UpdateResult<UserEntity> updateUser(Revision revision, UserDTO userDTO);
+
+    /**
+     * Deletes the specified user.
+     * @param revision Revision to compare with current base revision
+     * @param userId The user ID
+     * @return The user transfer object of the deleted user
+     */
+    UserEntity deleteUser(Revision revision, String userId);
+
+    // ----------------------------------------
+    // Group methods
+    // ----------------------------------------
+    /**
+     * Creates a user group.
+     * @param revision The starting revision
+     * @param userGroupDTO The user group DTO
+     * @return The user group transfer object
+     */
+    UserGroupEntity createUserGroup(Revision revision, UserGroupDTO 
userGroupDTO);
+
+    /**
+     * Gets the user group with the specified ID.
+     * @param userGroupId The user group ID
+     * @param prune If true, the user groups of the users in this user group 
will not be returned
+     * @return The user group transfer object
+     */
+    UserGroupEntity getUserGroup(String userGroupId, boolean prune);
+
+    /**
+     * Updates the specified user group.
+     * @param revision Revision to compare with current base revision
+     * @param userGroupDTO The user group DTO
+     * @return The user group transfer object
+     */
+    UpdateResult<UserGroupEntity> updateUserGroup(Revision revision, 
UserGroupDTO userGroupDTO);
+
+    /**
+     * Deletes the specified user group.
+     * @param revision Revision to compare with current base revision
+     * @param userGroupId The user group ID
+     * @return The user group transfer object of the deleted user group
+     */
+    UserGroupEntity deleteUserGroup(Revision revision, String userGroupId);
+
+    // ----------------------------------------
+    // AccessPolicy methods
+    // ----------------------------------------
+    /**
+     * Creates an access policy.
+     * @param revision The starting revision
+     * @param accessPolicyDTO The access policy DTO
+     * @return The access policy transfer object
+     */
+    AccessPolicyEntity createAccessPolicy(Revision revision, AccessPolicyDTO 
accessPolicyDTO);
+
+    /**
+     * Gets the access policy with the specified ID.
+     * @param accessPolicyId access policy ID
+     * @return The access policy transfer object
+     */
+    AccessPolicyEntity getAccessPolicy(String accessPolicyId);
+
+    /**
+     * Updates the specified access policy.
+     * @param revision Revision to compare with current base revision
+     * @param accessPolicyDTO The access policy DTO
+     * @return The access policy transfer object
+     */
+    UpdateResult<AccessPolicyEntity> updateAccessPolicy(Revision revision, 
AccessPolicyDTO accessPolicyDTO);
+
+    /**
+     * Deletes the specified access policy.
+     * @param revision Revision to compare with current base revision
+     * @param accessPolicyId The access policy ID
+     * @return The access policy transfer object of the deleted access policy
+     */
+    AccessPolicyEntity deleteAccessPolicy(Revision revision, String 
accessPolicyId);
+
+    // ----------------------------------------
     // Controller Services methods
     // ----------------------------------------
     /**

http://git-wip-us.apache.org/repos/asf/nifi/blob/f47be77b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardAuthorizableLookup.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardAuthorizableLookup.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardAuthorizableLookup.java
new file mode 100644
index 0000000..aef2798
--- /dev/null
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardAuthorizableLookup.java
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.web;
+
+import org.apache.nifi.authorization.resource.AccessPoliciesAuthorizable;
+import org.apache.nifi.authorization.resource.AccessPolicyAuthorizable;
+import org.apache.nifi.authorization.resource.Authorizable;
+import org.apache.nifi.authorization.resource.UserGroupsAuthorizable;
+import org.apache.nifi.authorization.resource.UsersAuthorizable;
+import org.apache.nifi.controller.ConfiguredComponent;
+import org.apache.nifi.controller.Snippet;
+import org.apache.nifi.controller.service.ControllerServiceNode;
+import org.apache.nifi.controller.service.ControllerServiceReference;
+import org.apache.nifi.groups.ProcessGroup;
+import org.apache.nifi.groups.RemoteProcessGroup;
+import org.apache.nifi.web.controller.ControllerFacade;
+import org.apache.nifi.web.dao.AccessPolicyDAO;
+import org.apache.nifi.web.dao.ConnectionDAO;
+import org.apache.nifi.web.dao.ControllerServiceDAO;
+import org.apache.nifi.web.dao.FunnelDAO;
+import org.apache.nifi.web.dao.LabelDAO;
+import org.apache.nifi.web.dao.PortDAO;
+import org.apache.nifi.web.dao.ProcessGroupDAO;
+import org.apache.nifi.web.dao.ProcessorDAO;
+import org.apache.nifi.web.dao.RemoteProcessGroupDAO;
+import org.apache.nifi.web.dao.ReportingTaskDAO;
+import org.apache.nifi.web.dao.SnippetDAO;
+import org.apache.nifi.web.dao.TemplateDAO;
+
+
+class StandardAuthorizableLookup implements AuthorizableLookup {
+
+    private static final UsersAuthorizable USERS_AUTHORIZABLE = new 
UsersAuthorizable();
+    private static final UserGroupsAuthorizable USER_GROUPS_AUTHORIZABLE = new 
UserGroupsAuthorizable();
+    private static final Authorizable ACCESS_POLICIES_AUTHORIZABLE = new 
AccessPoliciesAuthorizable();
+
+    // nifi core components
+    private ControllerFacade controllerFacade;
+
+    // data access objects
+    private ProcessorDAO processorDAO;
+    private ProcessGroupDAO processGroupDAO;
+    private RemoteProcessGroupDAO remoteProcessGroupDAO;
+    private LabelDAO labelDAO;
+    private FunnelDAO funnelDAO;
+    private SnippetDAO snippetDAO;
+    private PortDAO inputPortDAO;
+    private PortDAO outputPortDAO;
+    private ConnectionDAO connectionDAO;
+    private ControllerServiceDAO controllerServiceDAO;
+    private ReportingTaskDAO reportingTaskDAO;
+    private TemplateDAO templateDAO;
+    private AccessPolicyDAO accessPolicyDAO;
+
+    @Override
+    public Authorizable getProcessor(final String id) {
+        return processorDAO.getProcessor(id);
+    }
+
+    @Override
+    public Authorizable getInputPort(final String id) {
+        return inputPortDAO.getPort(id);
+    }
+
+    @Override
+    public Authorizable getOutputPort(final String id) {
+        return outputPortDAO.getPort(id);
+    }
+
+    @Override
+    public Authorizable getConnection(final String id) {
+        return connectionDAO.getConnection(id);
+    }
+
+    @Override
+    public Authorizable getProcessGroup(final String id) {
+        return processGroupDAO.getProcessGroup(id);
+    }
+
+    @Override
+    public Authorizable getRemoteProcessGroup(final String id) {
+        return remoteProcessGroupDAO.getRemoteProcessGroup(id);
+    }
+
+    @Override
+    public Authorizable getRemoteProcessGroupInputPort(final String 
remoteProcessGroupId, final String id) {
+        final RemoteProcessGroup remoteProcessGroup = 
remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupId);
+        return remoteProcessGroup.getInputPort(id);
+    }
+
+    @Override
+    public Authorizable getRemoteProcessGroupOutputPort(final String 
remoteProcessGroupId, final String id) {
+        final RemoteProcessGroup remoteProcessGroup = 
remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupId);
+        return remoteProcessGroup.getOutputPort(id);
+    }
+
+    @Override
+    public Authorizable getLabel(final String id) {
+        return labelDAO.getLabel(id);
+    }
+
+    @Override
+    public Authorizable getFunnel(final String id) {
+        return funnelDAO.getFunnel(id);
+    }
+
+    @Override
+    public Authorizable getControllerService(final String id) {
+        return controllerServiceDAO.getControllerService(id);
+    }
+
+    @Override
+    public Authorizable getControllerServiceReferencingComponent(String 
controllerSeriveId, String id) {
+        final ControllerServiceNode controllerService = 
controllerServiceDAO.getControllerService(controllerSeriveId);
+        final ControllerServiceReference referencingComponents = 
controllerService.getReferences();
+
+        ConfiguredComponent reference = null;
+        for (final ConfiguredComponent component : 
referencingComponents.getReferencingComponents()) {
+            if (component.getIdentifier().equals(id)) {
+                reference = component;
+                break;
+            }
+        }
+
+        if (reference == null) {
+            throw new ResourceNotFoundException("Unable to find referencing 
component with id " + id);
+        }
+
+        return reference;
+    }
+
+    @Override
+    public Authorizable getReportingTask(final String id) {
+        return reportingTaskDAO.getReportingTask(id);
+    }
+
+    @Override
+    public Snippet getSnippet(final String id) {
+        return snippetDAO.getSnippet(id);
+    }
+
+    @Override
+    public Authorizable getUsersAuthorizable() {
+        return USERS_AUTHORIZABLE;
+    }
+
+    @Override
+    public Authorizable getUserGroupsAuthorizable() {
+        return USER_GROUPS_AUTHORIZABLE;
+    }
+
+    @Override
+    public Authorizable getAccessPoliciesAuthorizable() {
+        return ACCESS_POLICIES_AUTHORIZABLE;
+    }
+
+    @Override
+    public Authorizable getAccessPolicyAuthorizable(String id) {
+        return new 
AccessPolicyAuthorizable(accessPolicyDAO.getAccessPolicy(id));
+    }
+
+    @Override
+    public Authorizable getTemplate(final String id) {
+        return templateDAO.getTemplate(id);
+    }
+
+    @Override
+    public Authorizable getConnectable(String id) {
+        final ProcessGroup group = 
processGroupDAO.getProcessGroup(controllerFacade.getRootGroupId());
+        return group.findConnectable(id);
+    }
+
+    public void setProcessorDAO(ProcessorDAO processorDAO) {
+        this.processorDAO = processorDAO;
+    }
+
+    public void setProcessGroupDAO(ProcessGroupDAO processGroupDAO) {
+        this.processGroupDAO = processGroupDAO;
+    }
+
+    public void setRemoteProcessGroupDAO(RemoteProcessGroupDAO 
remoteProcessGroupDAO) {
+        this.remoteProcessGroupDAO = remoteProcessGroupDAO;
+    }
+
+    public void setLabelDAO(LabelDAO labelDAO) {
+        this.labelDAO = labelDAO;
+    }
+
+    public void setFunnelDAO(FunnelDAO funnelDAO) {
+        this.funnelDAO = funnelDAO;
+    }
+
+    public void setSnippetDAO(SnippetDAO snippetDAO) {
+        this.snippetDAO = snippetDAO;
+    }
+
+    public void setInputPortDAO(PortDAO inputPortDAO) {
+        this.inputPortDAO = inputPortDAO;
+    }
+
+    public void setOutputPortDAO(PortDAO outputPortDAO) {
+        this.outputPortDAO = outputPortDAO;
+    }
+
+    public void setConnectionDAO(ConnectionDAO connectionDAO) {
+        this.connectionDAO = connectionDAO;
+    }
+
+    public void setControllerServiceDAO(ControllerServiceDAO 
controllerServiceDAO) {
+        this.controllerServiceDAO = controllerServiceDAO;
+    }
+
+    public void setReportingTaskDAO(ReportingTaskDAO reportingTaskDAO) {
+        this.reportingTaskDAO = reportingTaskDAO;
+    }
+
+    public void setTemplateDAO(TemplateDAO templateDAO) {
+        this.templateDAO = templateDAO;
+    }
+
+    public void setAccessPolicyDAO(AccessPolicyDAO accessPolicyDAO) {
+        this.accessPolicyDAO = accessPolicyDAO;
+    }
+
+    public void setControllerFacade(ControllerFacade controllerFacade) {
+        this.controllerFacade = controllerFacade;
+    }
+}

Reply via email to