use of org.apache.nifi.atlas.security.AtlasAuthN in project nifi by apache.
the class ReportLineageToAtlas method customValidate.
@Override
protected Collection<ValidationResult> customValidate(ValidationContext context) {
final Collection<ValidationResult> results = new ArrayList<>();
final boolean isSSLContextServiceSet = context.getProperty(SSL_CONTEXT_SERVICE).isSet();
final ValidationResult.Builder invalidSSLService = new ValidationResult.Builder().subject(SSL_CONTEXT_SERVICE.getDisplayName()).valid(false);
parseAtlasUrls(context.getProperty(ATLAS_URLS), input -> {
final ValidationResult.Builder builder = new ValidationResult.Builder().subject(ATLAS_URLS.getDisplayName()).input(input);
try {
final URL url = new URL(input);
if ("https".equalsIgnoreCase(url.getProtocol()) && !isSSLContextServiceSet) {
results.add(invalidSSLService.explanation("required by HTTPS Atlas access").build());
} else {
results.add(builder.explanation("Valid URI").valid(true).build());
}
} catch (Exception e) {
results.add(builder.explanation("Contains invalid URI: " + e).valid(false).build());
}
});
final String atlasAuthNMethod = context.getProperty(ATLAS_AUTHN_METHOD).getValue();
final AtlasAuthN atlasAuthN = getAtlasAuthN(atlasAuthNMethod);
results.addAll(atlasAuthN.validate(context));
clusterResolverLoader.forEach(resolver -> results.addAll(resolver.validate(context)));
if (context.getProperty(ATLAS_CONF_CREATE).asBoolean()) {
Stream.of(ATLAS_CONF_DIR, ATLAS_DEFAULT_CLUSTER_NAME, KAFKA_BOOTSTRAP_SERVERS).filter(p -> !context.getProperty(p).isSet()).forEach(p -> results.add(new ValidationResult.Builder().subject(p.getDisplayName()).explanation("required to create Atlas configuration file.").valid(false).build()));
validateKafkaProperties(context, results, isSSLContextServiceSet, invalidSSLService);
}
return results;
}
use of org.apache.nifi.atlas.security.AtlasAuthN in project nifi by apache.
the class ITNiFiAtlasClient method setup.
@Before
public void setup() {
// Add your atlas server ip address into /etc/hosts as atlas.example.com
PropertyContext propertyContext = mock(PropertyContext.class);
when(propertyContext.getProperty(ReportLineageToAtlas.ATLAS_USER)).thenReturn(new MockPropertyValue("admin"));
when(propertyContext.getProperty(ReportLineageToAtlas.ATLAS_PASSWORD)).thenReturn(new MockPropertyValue("admin"));
final AtlasAuthN atlasAuthN = new Basic();
atlasAuthN.configure(propertyContext);
atlasClient = new NiFiAtlasClient(atlasAuthN.createClient(new String[] { "http://atlas.example.com:21000/" }));
}
Aggregations