use of org.apache.nifi.components.AllowableValue in project nifi by apache.
the class TestPutS3Object method testSignerOverrideOptions.
@Test
public void testSignerOverrideOptions() {
final AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
final ClientConfiguration config = new ClientConfiguration();
final PutS3Object processor = new PutS3Object();
final TestRunner runner = TestRunners.newTestRunner(processor);
final List<AllowableValue> allowableSignerValues = PutS3Object.SIGNER_OVERRIDE.getAllowableValues();
final String defaultSignerValue = PutS3Object.SIGNER_OVERRIDE.getDefaultValue();
for (AllowableValue allowableSignerValue : allowableSignerValues) {
String signerType = allowableSignerValue.getValue();
if (!signerType.equals(defaultSignerValue)) {
runner.setProperty(PutS3Object.SIGNER_OVERRIDE, signerType);
ProcessContext context = runner.getProcessContext();
try {
AmazonS3Client s3Client = processor.createClient(context, credentialsProvider, config);
} catch (IllegalArgumentException argEx) {
Assert.fail(argEx.getMessage());
}
}
}
}
use of org.apache.nifi.components.AllowableValue in project nifi by apache.
the class ScriptingComponentHelper method createResources.
/**
* This method creates all resources needed for the script processor to function, such as script engines,
* script file reloader threads, etc.
*/
public void createResources() {
descriptors = new ArrayList<>();
// The following is required for JRuby, should be transparent to everything else.
// Note this is not done in a ScriptEngineConfigurator, as it is too early in the lifecycle. The
// setting must be there before the factories/engines are loaded.
System.setProperty("org.jruby.embed.localvariable.behavior", "persistent");
// Create list of available engines
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
List<ScriptEngineFactory> scriptEngineFactories = scriptEngineManager.getEngineFactories();
if (scriptEngineFactories != null) {
scriptEngineFactoryMap = new HashMap<>(scriptEngineFactories.size());
List<AllowableValue> engineList = new LinkedList<>();
for (ScriptEngineFactory factory : scriptEngineFactories) {
engineList.add(new AllowableValue(factory.getLanguageName()));
scriptEngineFactoryMap.put(factory.getLanguageName(), factory);
}
// Sort the list by name so the list always looks the same.
Collections.sort(engineList, (o1, o2) -> {
if (o1 == null) {
return o2 == null ? 0 : 1;
}
if (o2 == null) {
return -1;
}
return o1.getValue().compareTo(o2.getValue());
});
AllowableValue[] engines = engineList.toArray(new AllowableValue[engineList.size()]);
SCRIPT_ENGINE = new PropertyDescriptor.Builder().name("Script Engine").required(true).description("The engine to execute scripts").allowableValues(engines).defaultValue(engines[0].getValue()).required(true).expressionLanguageSupported(false).build();
descriptors.add(SCRIPT_ENGINE);
}
descriptors.add(ScriptingComponentUtils.SCRIPT_FILE);
descriptors.add(ScriptingComponentUtils.SCRIPT_BODY);
descriptors.add(ScriptingComponentUtils.MODULES);
isInitialized.set(true);
}
use of org.apache.nifi.components.AllowableValue in project nifi by apache.
the class EncryptContent method buildWeakCryptoAllowableValues.
private static AllowableValue[] buildWeakCryptoAllowableValues() {
List<AllowableValue> allowableValues = new ArrayList<>();
allowableValues.add(new AllowableValue(WEAK_CRYPTO_ALLOWED_NAME, "Allowed", "Operation will not be blocked and no alerts will be presented " + "when unsafe combinations of encryption algorithms and passwords are provided"));
allowableValues.add(buildDefaultWeakCryptoAllowableValue());
return allowableValues.toArray(new AllowableValue[0]);
}
use of org.apache.nifi.components.AllowableValue in project nifi by apache.
the class RestrictedSSLContextServiceTest method testTLSAlgorithms.
@Test
public void testTLSAlgorithms() {
final Set<String> expected = new HashSet<>();
expected.add("TLS");
expected.add("TLSv1.2");
final AllowableValue[] allowableValues = RestrictedSSLContextService.buildAlgorithmAllowableValues();
assertThat(allowableValues, notNullValue());
assertThat(allowableValues.length, equalTo(expected.size()));
for (final AllowableValue value : allowableValues) {
assertTrue(expected.contains(value.getValue()));
}
}
use of org.apache.nifi.components.AllowableValue in project nifi by apache.
the class RestrictedSSLContextService method buildAlgorithmAllowableValues.
/**
* Build a restricted set of allowable TLS protocol algorithms.
*
* @return the computed set of allowable values
*/
static AllowableValue[] buildAlgorithmAllowableValues() {
final Set<String> supportedProtocols = new HashSet<>();
/*
* Prepopulate protocols with generic instance types commonly used
* see: http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SSLContext
*/
supportedProtocols.add("TLS");
/*
* Add specifically supported TLS versions
*/
supportedProtocols.add("TLSv1.2");
final int numProtocols = supportedProtocols.size();
// Sort for consistent presentation in configuration views
final List<String> supportedProtocolList = new ArrayList<>(supportedProtocols);
Collections.sort(supportedProtocolList);
final List<AllowableValue> protocolAllowableValues = new ArrayList<>();
for (final String protocol : supportedProtocolList) {
protocolAllowableValues.add(new AllowableValue(protocol));
}
return protocolAllowableValues.toArray(new AllowableValue[numProtocols]);
}
Aggregations