public boolean hasCsr() { return !StringUtils.isEmpty(csr); } }
static String getIdentifier(final String seed) { if (StringUtils.isBlank(seed)) { return null; } return UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).toString(); }
/** * Returns the whitelisted proxy context paths as a comma-delimited string. The paths have been normalized to the form {@code /some/context/path}. * <p> * Note: Calling {@code NiFiProperties.getProperty(NiFiProperties.WEB_PROXY_CONTEXT_PATH)} will not normalize the paths. * * @return the path(s) */ public String getWhitelistedContextPaths() { return StringUtils.join(getWhitelistedContextPathsAsList(), ","); }
/** * Gets the configured Knox Audiences. * * @return Knox audiences */ public Set<String> getKnoxAudiences() { final String rawAudiences = getProperty(SECURITY_USER_KNOX_AUDIENCES); if (StringUtils.isBlank(rawAudiences)) { return null; } else { final String[] audienceTokens = rawAudiences.split(","); return Stream.of(audienceTokens).map(String::trim).filter(aud -> !StringUtils.isEmpty(aud)).collect(Collectors.toSet()); } }
/** * Returns the network interface list to use for HTTPS. This method returns a mapping of * network interface property names to network interface names. * * @return the property name and network interface name of all HTTPS network interfaces */ public Map<String, String> getHttpsNetworkInterfaces() { final Map<String, String> networkInterfaces = new HashMap<>(); // go through each property for (String propertyName : getPropertyKeys()) { // determine if the property is a network interface name if (StringUtils.startsWith(propertyName, WEB_HTTPS_NETWORK_INTERFACE_PREFIX)) { // get the network interface property key final String key = StringUtils.substringAfter(propertyName, WEB_HTTPS_NETWORK_INTERFACE_PREFIX); networkInterfaces.put(key, getProperty(propertyName)); } } return networkInterfaces; }
public List<Path> getNarLibraryDirectories() { List<Path> narLibraryPaths = new ArrayList<>(); // go through each property for (String propertyName : getPropertyKeys()) { // determine if the property is a nar library path if (StringUtils.startsWith(propertyName, NAR_LIBRARY_DIRECTORY_PREFIX) || NAR_LIBRARY_DIRECTORY.equals(propertyName) || NAR_LIBRARY_AUTOLOAD_DIRECTORY.equals(propertyName)) { // attempt to resolve the path specified String narLib = getProperty(propertyName); if (!StringUtils.isBlank(narLib)) { narLibraryPaths.add(Paths.get(narLib)); } } } if (narLibraryPaths.isEmpty()) { narLibraryPaths.add(Paths.get(DEFAULT_NAR_LIBRARY_DIR)); } return narLibraryPaths; }
final String name = StringUtils.substringAfter(jarEntry.getName(), "docs/"); final String path = coordinate.getGroup() + "/" + coordinate.getId() + "/" + coordinate.getVersion() + "/" + name;
@Override protected PutFlowFile createPut(final ProcessSession session, final ProcessContext context, final FlowFile flowFile) { final String tableName = context.getProperty(TABLE_NAME).evaluateAttributeExpressions(flowFile).getValue(); final String row = context.getProperty(ROW_ID).evaluateAttributeExpressions(flowFile).getValue(); final String columnFamily = context.getProperty(COLUMN_FAMILY).evaluateAttributeExpressions(flowFile).getValue(); final String columnQualifier = context.getProperty(COLUMN_QUALIFIER).evaluateAttributeExpressions(flowFile).getValue(); final String timestampValue = context.getProperty(TIMESTAMP).evaluateAttributeExpressions(flowFile).getValue(); final String visibilityStringToUse = pickVisibilityString(columnFamily, columnQualifier, flowFile, context); final Long timestamp; if (!StringUtils.isBlank(timestampValue)) { try { timestamp = Long.valueOf(timestampValue); } catch (Exception e) { getLogger().error("Invalid timestamp value: " + timestampValue, e); return null; } } else { timestamp = null; } final byte[] buffer = new byte[(int) flowFile.getSize()]; session.read(flowFile, in -> StreamUtils.fillBuffer(in, buffer)); PutColumn column = StringUtils.isEmpty(visibilityStringToUse) ? new PutColumn(columnFamily.getBytes(StandardCharsets.UTF_8), columnQualifier.getBytes(StandardCharsets.UTF_8), buffer, timestamp) : new PutColumn(columnFamily.getBytes(StandardCharsets.UTF_8), columnQualifier.getBytes(StandardCharsets.UTF_8), buffer, timestamp, visibilityStringToUse); final Collection<PutColumn> columns = Collections.singletonList(column); byte[] rowKeyBytes = getRow(row,context.getProperty(ROW_ID_ENCODING_STRATEGY).getValue()); return new PutFlowFile(tableName,rowKeyBytes , columns, flowFile); }
/** * Returns the network interface list to use for HTTP. This method returns a mapping of * network interface property names to network interface names. * * @return the property name and network interface name of all HTTP network interfaces */ public Map<String, String> getHttpNetworkInterfaces() { final Map<String, String> networkInterfaces = new HashMap<>(); // go through each property for (String propertyName : getPropertyKeys()) { // determine if the property is a network interface name if (StringUtils.startsWith(propertyName, WEB_HTTP_NETWORK_INTERFACE_PREFIX)) { // get the network interface property key final String key = StringUtils.substringAfter(propertyName, WEB_HTTP_NETWORK_INTERFACE_PREFIX); networkInterfaces.put(key, getProperty(propertyName)); } } return networkInterfaces; }
private String orDefault(String value, String defaultValue) { return isEmpty(value) ? defaultValue : value; }
public File getClusterNodeFirewallFile() { final String firewallFile = getProperty(CLUSTER_FIREWALL_FILE); if (StringUtils.isBlank(firewallFile)) { return null; } else { return new File(firewallFile); } }
/** * Returns the whitelisted proxy hostnames (and IP addresses) as a comma-delimited string. * The hosts have been normalized to the form {@code somehost.com}, {@code somehost.com:port}, or {@code 127.0.0.1}. * <p> * Note: Calling {@code NiFiProperties.getProperty(NiFiProperties.WEB_PROXY_HOST)} will not normalize the hosts. * * @return the hostname(s) */ public String getWhitelistedHosts() { return StringUtils.join(getWhitelistedHostsAsList(), ","); }
/** * Returns the provenance repository paths. This method returns a mapping of * file repository name to file repository paths. It simply returns the * values configured. No directories will be created as a result of this * operation. * * @return the name and paths of all provenance repository locations */ public Map<String, Path> getProvenanceRepositoryPaths() { final Map<String, Path> provenanceRepositoryPaths = new HashMap<>(); // go through each property for (String propertyName : getPropertyKeys()) { // determine if the property is a file repository path if (StringUtils.startsWith(propertyName, PROVENANCE_REPO_DIRECTORY_PREFIX)) { // get the repository key final String key = StringUtils.substringAfter(propertyName, PROVENANCE_REPO_DIRECTORY_PREFIX); // attempt to resolve the path specified provenanceRepositoryPaths.put(key, Paths.get(getProperty(propertyName))); } } return provenanceRepositoryPaths; }
public boolean hasCertificate() { return !StringUtils.isEmpty(pemEncodedCertificate); }
/** * Returns true if the Kerberos service principal and keytab location * properties are populated. * * @return true if Kerberos service support is enabled */ public boolean isKerberosSpnegoSupportEnabled() { return !StringUtils.isBlank(getKerberosSpnegoPrincipal()) && !StringUtils.isBlank(getKerberosSpnegoKeytabLocation()); }
private String generateMetricsMessage() { StringBuilder sb = new StringBuilder("Counted "); List<String> metrics = new ArrayList<>(); if (countLines) { metrics.add(lineCount + " lines"); } if (countLinesNonEmpty) { metrics.add(lineNonEmptyCount + " non-empty lines"); } if (countWords) { metrics.add(wordCount + " words"); } if (countCharacters) { metrics.add(characterCount + " characters"); } sb.append(StringUtils.join(metrics, ", ")); return sb.toString(); }
/** * Returns the content repository paths. This method returns a mapping of * file repository name to file repository paths. It simply returns the * values configured. No directories will be created as a result of this * operation. * * @return file repositories paths * @throws InvalidPathException If any of the configured paths are invalid */ public Map<String, Path> getContentRepositoryPaths() { final Map<String, Path> contentRepositoryPaths = new HashMap<>(); // go through each property for (String propertyName : getPropertyKeys()) { // determine if the property is a file repository path if (StringUtils.startsWith(propertyName, REPOSITORY_CONTENT_PREFIX)) { // get the repository key final String key = StringUtils.substringAfter(propertyName, REPOSITORY_CONTENT_PREFIX); // attempt to resolve the path specified contentRepositoryPaths.put(key, Paths.get(getProperty(propertyName))); } } return contentRepositoryPaths; }
public void initDefaults() { if (days == 0) { days = DEFAULT_DAYS; } if (keySize == 0) { keySize = DEFAULT_KEY_SIZE; } if (StringUtils.isEmpty(keyPairAlgorithm)) { keyPairAlgorithm = DEFAULT_KEY_PAIR_ALGORITHM; } if (StringUtils.isEmpty(signingAlgorithm)) { signingAlgorithm = DEFAULT_SIGNING_ALGORITHM; } if (port == 0) { port = DEFAULT_PORT; } if (StringUtils.isEmpty(keyStoreType)) { keyStoreType = DEFAULT_KEY_STORE_TYPE; } if (StringUtils.isEmpty(caHostname)) { caHostname = DEFAULT_HOSTNAME; } if (StringUtils.isEmpty(dn)) { dn = calcDefaultDn(caHostname); } }
/** * Returns the whitelisted proxy hostnames (and IP addresses) as a List. The hosts have been normalized to the form {@code somehost.com}, {@code somehost.com:port}, or {@code 127.0.0.1}. * * @return the hostname(s) */ public List<String> getWhitelistedHostsAsList() { String rawProperty = getProperty(WEB_PROXY_HOST, ""); List<String> hosts = Arrays.asList(rawProperty.split(",")); return hosts.stream() .map(this::normalizeHost).filter(host -> !StringUtils.isBlank(host)).collect(Collectors.toList()); }
private static boolean checkControllerServiceEligibility(Class extensionType) { final Class originalExtensionType = extensionType; final ClassLoader originalExtensionClassLoader = extensionType.getClassLoader(); // if the extension does not require instance classloading, its eligible final boolean requiresInstanceClassLoading = extensionType.isAnnotationPresent(RequiresInstanceClassLoading.class); final Set<Class> cobundledApis = new HashSet<>(); while (extensionType != null) { for (final Class i : extensionType.getInterfaces()) { if (originalExtensionClassLoader.equals(i.getClassLoader())) { cobundledApis.add(i); } } extensionType = extensionType.getSuperclass(); } if (!cobundledApis.isEmpty()) { logger.warn(String.format("Controller Service %s is bundled with its supporting APIs %s. The service APIs should not be bundled with the implementations.", originalExtensionType.getName(), StringUtils.join(cobundledApis.stream().map(cls -> cls.getName()).collect(Collectors.toSet()), ", "))); } // the service is eligible when it does not require instance classloading or when the supporting APIs are bundled in a parent NAR return requiresInstanceClassLoading == false || cobundledApis.isEmpty(); }