@Test public void testAddGroup() throws Exception { writeFile(primaryTenants, EMPTY_TENANTS); userGroupProvider.onConfigured(configurationContext); assertEquals(0, userGroupProvider.getGroups().size()); final Group group = new Group.Builder() .identifier("group-id-1") .name("group-name-1") .build(); final Group addedGroup = userGroupProvider.addGroup(group); assertNotNull(addedGroup); assertEquals(group.getIdentifier(), addedGroup.getIdentifier()); assertEquals(group.getName(), addedGroup.getName()); assertEquals(0, addedGroup.getUsers().size()); final Set<Group> groups = userGroupProvider.getGroups(); assertEquals(1, groups.size()); }
@Override public synchronized Group addGroup(Group group) throws AuthorizationAccessException { if (group == null) { throw new IllegalArgumentException("Group cannot be null"); } final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); final org.apache.nifi.authorization.file.tenants.generated.Group jaxbGroup = new org.apache.nifi.authorization.file.tenants.generated.Group(); jaxbGroup.setIdentifier(group.getIdentifier()); jaxbGroup.setName(group.getName()); for (String groupUser : group.getUsers()) { org.apache.nifi.authorization.file.tenants.generated.Group.User jaxbGroupUser = new org.apache.nifi.authorization.file.tenants.generated.Group.User(); jaxbGroupUser.setIdentifier(groupUser); jaxbGroup.getUser().add(jaxbGroupUser); } tenants.getGroups().getGroup().add(jaxbGroup); saveAndRefreshHolder(tenants); return userGroupHolder.get().getGroupsById().get(group.getIdentifier()); }
FileUserGroupProvider implements ConfigurableUserGroupProvider { @Override public synchronized Group addGroup(Group group) throws AuthorizationAccessException { if (group == null) { throw new IllegalArgumentException("Group cannot be null"); } final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); final org.apache.nifi.authorization.file.tenants.generated.Group jaxbGroup = new org.apache.nifi.authorization.file.tenants.generated.Group(); jaxbGroup.setIdentifier(group.getIdentifier()); jaxbGroup.setName(group.getName()); for (String groupUser : group.getUsers()) { org.apache.nifi.authorization.file.tenants.generated.Group.User jaxbGroupUser = new org.apache.nifi.authorization.file.tenants.generated.Group.User(); jaxbGroupUser.setIdentifier(groupUser); jaxbGroup.getUser().add(jaxbGroupUser); } tenants.getGroups().getGroup().add(jaxbGroup); saveAndRefreshHolder(tenants); return userGroupHolder.get().getGroupsById().get(group.getIdentifier()); } }
FileUserGroupProvider implements ConfigurableUserGroupProvider { @Override public synchronized Group addGroup(Group group) throws AuthorizationAccessException { if (group == null) { throw new IllegalArgumentException("Group cannot be null"); } final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); final org.apache.nifi.authorization.file.tenants.generated.Group jaxbGroup = new org.apache.nifi.authorization.file.tenants.generated.Group(); jaxbGroup.setIdentifier(group.getIdentifier()); jaxbGroup.setName(group.getName()); for (String groupUser : group.getUsers()) { org.apache.nifi.authorization.file.tenants.generated.Group.User jaxbGroupUser = new org.apache.nifi.authorization.file.tenants.generated.Group.User(); jaxbGroupUser.setIdentifier(groupUser); jaxbGroup.getUser().add(jaxbGroupUser); } tenants.getGroups().getGroup().add(jaxbGroup); saveAndRefreshHolder(tenants); return userGroupHolder.get().getGroupsById().get(group.getIdentifier()); }  }
FileUserGroupProvider implements ConfigurableUserGroupProvider { @Override public synchronized Group addGroup(Group group) throws AuthorizationAccessException { if (group == null) { throw new IllegalArgumentException("Group cannot be null"); } final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); final org.apache.nifi.authorization.file.tenants.generated.Group jaxbGroup = new org.apache.nifi.authorization.file.tenants.generated.Group(); jaxbGroup.setIdentifier(group.getIdentifier()); jaxbGroup.setName(group.getName()); for (String groupUser : group.getUsers()) { org.apache.nifi.authorization.file.tenants.generated.Group.User jaxbGroupUser = new org.apache.nifi.authorization.file.tenants.generated.Group.User(); jaxbGroupUser.setIdentifier(groupUser); jaxbGroup.getUser().add(jaxbGroupUser); } tenants.getGroups().getGroup().add(jaxbGroup); saveAndRefreshHolder(tenants); return userGroupHolder.get().getGroupsById().get(group.getIdentifier()); }  @Override void initialize(UserGroupProviderInitializationContext initializationContext); @Override void onConfigured(AuthorizerConfigurationContext configurationContext); @Override Set<User> getUsers(); @Override synchronized User addUser(User user); @Override User getUser(String identifier); @Override synchronized User updateUser(User user); @Override User getUserByIdentity(String identity); @Override synchronized User deleteUser(User user); @Override Set<Group> getGroups(); @Override synchronized Group addGroup(Group group); @Override Group getGroup(String identifier); @Override UserAndGroups getUserAndGroups(final String identity); @Override synchronized Group updateGroup(Group group); @Override synchronized Group deleteGroup(Group group); @AuthorizerContext void setNiFiProperties(NiFiProperties properties); @Override synchronized void inheritFingerprint(String fingerprint); @Override void checkInheritability(String proposedFingerprint); @Override String getFingerprint(); @Override void preDestruction(); }
FileUserGroupProvider implements ConfigurableUserGroupProvider { @Override public synchronized Group addGroup(Group group) throws AuthorizationAccessException { if (group == null) { throw new IllegalArgumentException("Group cannot be null"); } final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); final org.apache.nifi.authorization.file.tenants.generated.Group jaxbGroup = new org.apache.nifi.authorization.file.tenants.generated.Group(); jaxbGroup.setIdentifier(group.getIdentifier()); jaxbGroup.setName(group.getName()); for (String groupUser : group.getUsers()) { org.apache.nifi.authorization.file.tenants.generated.Group.User jaxbGroupUser = new org.apache.nifi.authorization.file.tenants.generated.Group.User(); jaxbGroupUser.setIdentifier(groupUser); jaxbGroup.getUser().add(jaxbGroupUser); } tenants.getGroups().getGroup().add(jaxbGroup); saveAndRefreshHolder(tenants); return userGroupHolder.get().getGroupsById().get(group.getIdentifier()); }  @Override void initialize(UserGroupProviderInitializationContext initializationContext); @Override void onConfigured(AuthorizerConfigurationContext configurationContext); @Override Set<User> getUsers(); @Override synchronized User addUser(User user); @Override User getUser(String identifier); @Override synchronized User updateUser(User user); @Override User getUserByIdentity(String identity); @Override synchronized User deleteUser(User user); @Override Set<Group> getGroups(); @Override synchronized Group addGroup(Group group); @Override Group getGroup(String identifier); @Override UserAndGroups getUserAndGroups(final String identity); @Override synchronized Group updateGroup(Group group); @Override synchronized Group deleteGroup(Group group); @AuthorizerContext void setNiFiProperties(NiFiProperties properties); @Override synchronized void inheritFingerprint(String fingerprint); @Override void checkInheritability(String proposedFingerprint); @Override String getFingerprint(); @Override void preDestruction();  }