Search in sources :

Example 6 with PropertyValue

use of org.apache.nifi.registry.util.PropertyValue in project nifi-registry by apache.

the class CompositeConfigurableUserGroupProvider method onConfigured.

@Override
public void onConfigured(AuthorizerConfigurationContext configurationContext) throws SecurityProviderCreationException {
    final PropertyValue configurableUserGroupProviderKey = configurationContext.getProperty(PROP_CONFIGURABLE_USER_GROUP_PROVIDER);
    if (!configurableUserGroupProviderKey.isSet()) {
        throw new SecurityProviderCreationException("The Configurable User Group Provider must be set.");
    }
    final UserGroupProvider userGroupProvider = userGroupProviderLookup.getUserGroupProvider(configurableUserGroupProviderKey.getValue());
    if (userGroupProvider == null) {
        throw new SecurityProviderCreationException(String.format("Unable to locate the Configurable User Group Provider: %s", configurableUserGroupProviderKey));
    }
    if (!(userGroupProvider instanceof ConfigurableUserGroupProvider)) {
        throw new SecurityProviderCreationException(String.format("The Configurable User Group Provider is not configurable: %s", configurableUserGroupProviderKey));
    }
    // Ensure that the ConfigurableUserGroupProvider is not also listed as one of the providers for the CompositeUserGroupProvider
    for (Map.Entry<String, String> entry : configurationContext.getProperties().entrySet()) {
        Matcher matcher = USER_GROUP_PROVIDER_PATTERN.matcher(entry.getKey());
        if (matcher.matches() && !StringUtils.isBlank(entry.getValue())) {
            final String userGroupProviderKey = entry.getValue();
            if (userGroupProviderKey.equals(configurableUserGroupProviderKey.getValue())) {
                throw new SecurityProviderCreationException(String.format("Duplicate provider in Composite Configurable User Group Provider configuration: %s", userGroupProviderKey));
            }
        }
    }
    configurableUserGroupProvider = (ConfigurableUserGroupProvider) userGroupProvider;
    // configure the CompositeUserGroupProvider
    super.onConfigured(configurationContext);
}
Also used : SecurityProviderCreationException(org.apache.nifi.registry.security.exception.SecurityProviderCreationException) Matcher(java.util.regex.Matcher) PropertyValue(org.apache.nifi.registry.util.PropertyValue) Map(java.util.Map)

Aggregations

SecurityProviderCreationException (org.apache.nifi.registry.security.exception.SecurityProviderCreationException)6 PropertyValue (org.apache.nifi.registry.util.PropertyValue)6 Map (java.util.Map)3 Matcher (java.util.regex.Matcher)3 File (java.io.File)2 IOException (java.io.IOException)2 Date (java.util.Date)2 JAXBException (javax.xml.bind.JAXBException)2 SAXException (org.xml.sax.SAXException)2 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 HashMap (java.util.HashMap)1 NamingException (javax.naming.NamingException)1 SSLContext (javax.net.ssl.SSLContext)1 AuthorizationAccessException (org.apache.nifi.registry.security.authorization.exception.AuthorizationAccessException)1 Authorizations (org.apache.nifi.registry.security.authorization.file.generated.Authorizations)1 Tenants (org.apache.nifi.registry.security.authorization.file.tenants.generated.Tenants)1