use of org.apache.nifi.components.AllowableValue in project nifi by apache.
the class HtmlDocumentationWriter method writeValidValues.
/**
* Interrogates a PropertyDescriptor to get a list of AllowableValues, if
* there are none, nothing is written to the stream.
*
* @param xmlStreamWriter the stream writer to use
* @param property the property to describe
* @throws XMLStreamException thrown if there was a problem writing to the
* XML Stream
*/
protected void writeValidValues(XMLStreamWriter xmlStreamWriter, PropertyDescriptor property) throws XMLStreamException {
if (property.getAllowableValues() != null && property.getAllowableValues().size() > 0) {
xmlStreamWriter.writeStartElement("ul");
for (AllowableValue value : property.getAllowableValues()) {
xmlStreamWriter.writeStartElement("li");
xmlStreamWriter.writeCharacters(value.getDisplayName());
if (value.getDescription() != null) {
writeValidValueDescription(xmlStreamWriter, value.getDescription());
}
xmlStreamWriter.writeEndElement();
}
xmlStreamWriter.writeEndElement();
} else if (property.getControllerServiceDefinition() != null) {
Class<? extends ControllerService> controllerServiceClass = property.getControllerServiceDefinition();
writeSimpleElement(xmlStreamWriter, "strong", "Controller Service API: ");
xmlStreamWriter.writeEmptyElement("br");
xmlStreamWriter.writeCharacters(controllerServiceClass.getSimpleName());
final List<Class<? extends ControllerService>> implementationList = lookupControllerServiceImpls(controllerServiceClass);
// Convert it into an array before proceeding
Class<? extends ControllerService>[] implementations = implementationList.stream().toArray(Class[]::new);
xmlStreamWriter.writeEmptyElement("br");
if (implementations.length > 0) {
final String title = implementations.length > 1 ? "Implementations: " : "Implementation: ";
writeSimpleElement(xmlStreamWriter, "strong", title);
iterateAndLinkComponents(xmlStreamWriter, implementations, null, "<br>", controllerServiceClass.getSimpleName());
} else {
xmlStreamWriter.writeCharacters("No implementations found.");
}
}
}
use of org.apache.nifi.components.AllowableValue in project nifi by apache.
the class EncryptContent method buildEncryptionMethodAllowableValues.
private static AllowableValue[] buildEncryptionMethodAllowableValues() {
final EncryptionMethod[] encryptionMethods = EncryptionMethod.values();
List<AllowableValue> allowableValues = new ArrayList<>(encryptionMethods.length);
for (EncryptionMethod em : encryptionMethods) {
allowableValues.add(new AllowableValue(em.name(), em.name(), em.toString()));
}
return allowableValues.toArray(new AllowableValue[0]);
}
use of org.apache.nifi.components.AllowableValue in project nifi by apache.
the class EncryptContent method buildKeyDerivationFunctionAllowableValues.
private static AllowableValue[] buildKeyDerivationFunctionAllowableValues() {
final KeyDerivationFunction[] keyDerivationFunctions = KeyDerivationFunction.values();
List<AllowableValue> allowableValues = new ArrayList<>(keyDerivationFunctions.length);
for (KeyDerivationFunction kdf : keyDerivationFunctions) {
allowableValues.add(new AllowableValue(kdf.name(), kdf.getName(), kdf.getDescription()));
}
return allowableValues.toArray(new AllowableValue[0]);
}
use of org.apache.nifi.components.AllowableValue in project nifi by apache.
the class SSLContextServiceTest method testSSLAlgorithms.
@Test
public void testSSLAlgorithms() throws NoSuchAlgorithmException {
final AllowableValue[] allowableValues = SSLContextService.buildAlgorithmAllowableValues();
// we expect TLS, SSL, and all available configured JVM protocols
final Set<String> expected = new HashSet<>();
expected.add("SSL");
expected.add("TLS");
final String[] supportedProtocols = SSLContext.getDefault().createSSLEngine().getSupportedProtocols();
expected.addAll(Arrays.asList(supportedProtocols));
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 SSLContextService method buildAlgorithmAllowableValues.
/**
* Build a set of allowable TLS/SSL protocol algorithms based on JVM configuration.
*
* @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");
supportedProtocols.add("SSL");
// Determine those provided by the JVM on the system
try {
supportedProtocols.addAll(Arrays.asList(SSLContext.getDefault().createSSLEngine().getSupportedProtocols()));
} catch (NoSuchAlgorithmException e) {
// ignored as default is used
}
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