@Test public void testAddUser() throws Exception { writeFile(primaryTenants, EMPTY_TENANTS); userGroupProvider.onConfigured(configurationContext); assertEquals(0, userGroupProvider.getUsers().size()); final User user = new User.Builder() .identifier("user-1") .identity("user-identity-1") .build(); final User addedUser = userGroupProvider.addUser(user); assertNotNull(addedUser); assertEquals(user.getIdentifier(), addedUser.getIdentifier()); assertEquals(user.getIdentity(), addedUser.getIdentity()); final Set<User> users = userGroupProvider.getUsers(); assertEquals(1, users.size()); }
@Override public synchronized User addUser(User user) throws AuthorizationAccessException { if (user == null) { throw new IllegalArgumentException("User cannot be null"); } final org.apache.nifi.authorization.file.tenants.generated.User jaxbUser = createJAXBUser(user); final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); tenants.getUsers().getUser().add(jaxbUser); saveAndRefreshHolder(tenants); return userGroupHolder.get().getUsersById().get(user.getIdentifier()); }
FileUserGroupProvider implements ConfigurableUserGroupProvider { @Override public synchronized User addUser(User user) throws AuthorizationAccessException { if (user == null) { throw new IllegalArgumentException("User cannot be null"); } final org.apache.nifi.authorization.file.tenants.generated.User jaxbUser = createJAXBUser(user); final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); tenants.getUsers().getUser().add(jaxbUser); saveAndRefreshHolder(tenants); return userGroupHolder.get().getUsersById().get(user.getIdentifier()); } }
FileUserGroupProvider implements ConfigurableUserGroupProvider { @Override public synchronized User addUser(User user) throws AuthorizationAccessException { if (user == null) { throw new IllegalArgumentException("User cannot be null"); } final org.apache.nifi.authorization.file.tenants.generated.User jaxbUser = createJAXBUser(user); final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); tenants.getUsers().getUser().add(jaxbUser); saveAndRefreshHolder(tenants); return userGroupHolder.get().getUsersById().get(user.getIdentifier()); }  }
FileUserGroupProvider implements ConfigurableUserGroupProvider { @Override public synchronized User addUser(User user) throws AuthorizationAccessException { if (user == null) { throw new IllegalArgumentException("User cannot be null"); } final org.apache.nifi.authorization.file.tenants.generated.User jaxbUser = createJAXBUser(user); final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); tenants.getUsers().getUser().add(jaxbUser); saveAndRefreshHolder(tenants); return userGroupHolder.get().getUsersById().get(user.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 User addUser(User user) throws AuthorizationAccessException { if (user == null) { throw new IllegalArgumentException("User cannot be null"); } final org.apache.nifi.authorization.file.tenants.generated.User jaxbUser = createJAXBUser(user); final UserGroupHolder holder = userGroupHolder.get(); final Tenants tenants = holder.getTenants(); tenants.getUsers().getUser().add(jaxbUser); saveAndRefreshHolder(tenants); return userGroupHolder.get().getUsersById().get(user.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();  }