Search in sources :

Example 1 with Users

use of org.apache.nifi.registry.security.authorization.file.tenants.generated.Users in project nifi-registry by apache.

the class FileUserGroupProvider method load.

/**
 * Loads the authorizations file and populates the AuthorizationsHolder, only called during start-up.
 *
 * @throws JAXBException            Unable to reload the authorized users file
 * @throws IllegalStateException    Unable to sync file with restore
 * @throws SAXException             Unable to unmarshall tenants
 */
private synchronized void load() throws JAXBException, IllegalStateException, SAXException {
    final Tenants tenants = unmarshallTenants();
    if (tenants.getUsers() == null) {
        tenants.setUsers(new Users());
    }
    if (tenants.getGroups() == null) {
        tenants.setGroups(new Groups());
    }
    final UserGroupHolder userGroupHolder = new UserGroupHolder(tenants);
    final boolean emptyTenants = userGroupHolder.getAllUsers().isEmpty() && userGroupHolder.getAllGroups().isEmpty();
    if (emptyTenants) {
        populateInitialUsers(tenants);
        // save any changes that were made and repopulate the holder
        saveAndRefreshHolder(tenants);
    } else {
        this.userGroupHolder.set(userGroupHolder);
    }
}
Also used : Groups(org.apache.nifi.registry.security.authorization.file.tenants.generated.Groups) UserAndGroups(org.apache.nifi.registry.security.authorization.UserAndGroups) Tenants(org.apache.nifi.registry.security.authorization.file.tenants.generated.Tenants) Users(org.apache.nifi.registry.security.authorization.file.tenants.generated.Users)

Aggregations

UserAndGroups (org.apache.nifi.registry.security.authorization.UserAndGroups)1 Groups (org.apache.nifi.registry.security.authorization.file.tenants.generated.Groups)1 Tenants (org.apache.nifi.registry.security.authorization.file.tenants.generated.Tenants)1 Users (org.apache.nifi.registry.security.authorization.file.tenants.generated.Users)1