Search in sources :

Example 11 with User

use of org.apache.nifi.registry.security.authorization.User in project nifi-registry by apache.

the class FileUserGroupProvider method updateUser.

@Override
public synchronized User updateUser(User user) throws AuthorizationAccessException {
    if (user == null) {
        throw new IllegalArgumentException("User cannot be null");
    }
    final UserGroupHolder holder = userGroupHolder.get();
    final Tenants tenants = holder.getTenants();
    final List<org.apache.nifi.registry.security.authorization.file.tenants.generated.User> users = tenants.getUsers().getUser();
    // fine the User that needs to be updated
    org.apache.nifi.registry.security.authorization.file.tenants.generated.User updateUser = null;
    for (org.apache.nifi.registry.security.authorization.file.tenants.generated.User jaxbUser : users) {
        if (user.getIdentifier().equals(jaxbUser.getIdentifier())) {
            updateUser = jaxbUser;
            break;
        }
    }
    // if user wasn't found return null, otherwise update the user and save changes
    if (updateUser == null) {
        return null;
    } else {
        updateUser.setIdentity(user.getIdentity());
        saveAndRefreshHolder(tenants);
        return userGroupHolder.get().getUsersById().get(user.getIdentifier());
    }
}
Also used : User(org.apache.nifi.registry.security.authorization.User) Tenants(org.apache.nifi.registry.security.authorization.file.tenants.generated.Tenants)

Aggregations

User (org.apache.nifi.registry.security.authorization.User)11 Group (org.apache.nifi.registry.security.authorization.Group)9 Tenants (org.apache.nifi.registry.security.authorization.file.tenants.generated.Tenants)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 AuthorizationAccessException (org.apache.nifi.registry.security.authorization.exception.AuthorizationAccessException)3 IOException (java.io.IOException)2 UserAndGroups (org.apache.nifi.registry.security.authorization.UserAndGroups)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 StringWriter (java.io.StringWriter)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 UnrecoverableKeyException (java.security.UnrecoverableKeyException)1 CertificateException (java.security.cert.CertificateException)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1