本文整理汇总了Java中org.apache.nifi.ssl.SSLContextService类的典型用法代码示例。如果您正苦于以下问题:Java SSLContextService类的具体用法?Java SSLContextService怎么用?Java SSLContextService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SSLContextService类属于org.apache.nifi.ssl包,在下文中一共展示了SSLContextService类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCommsSession
import org.apache.nifi.ssl.SSLContextService; //导入依赖的package包/类
private CommsSession createCommsSession(final ConfigurationContext context) throws IOException {
final String hostname = context.getProperty(HOSTNAME).evaluateAttributeExpressions().getValue();
final int port = context.getProperty(PORT).evaluateAttributeExpressions().asInteger();
final long timeoutMillis = context.getProperty(COMMUNICATIONS_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS);
final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
final CommsSession commsSession;
if (sslContextService == null) {
commsSession = new StandardCommsSession(hostname, port);
} else {
commsSession = new SSLCommsSession(sslContextService.createSSLContext(ClientAuth.REQUIRED), hostname, port);
}
commsSession.setTimeout(timeoutMillis, TimeUnit.MILLISECONDS);
return commsSession;
}
示例2: setConnectionFactoryProperties
import org.apache.nifi.ssl.SSLContextService; //导入依赖的package包/类
/**
* This operation follows standard bean convention by matching property name to its corresponding 'setter' method.
* Once the method was located it is invoked to set the corresponding property to a value provided by during service
* configuration. For example, 'channel' property will correspond to 'setChannel(..) method and 'queueManager'
* property will correspond to setQueueManager(..) method with a single argument.
*
* There are also few adjustments to accommodate well known brokers. For example ActiveMQ ConnectionFactory accepts
* address of the Message Broker in a form of URL while IBMs in the form of host/port pair (more common). So this
* method will use value retrieved from the 'BROKER_URI' static property 'as is' if ConnectionFactory implementation
* is coming from ActiveMQ and for all others (for now) the 'BROKER_URI' value will be split on ':' and the
* resulting pair will be used to execute setHostName(..) and setPort(..) methods on the provided ConnectionFactory.
* This may need to be maintained and adjusted to accommodate other implementation of ConnectionFactory, but only
* for URL/Host/Port issue. All other properties are set as dynamic properties where user essentially provides both
* property name and value, The bean convention is also explained in user manual for this component with links
* pointing to documentation of various ConnectionFactories.
*
* @see #setProperty(String, String) method
*/
private void setConnectionFactoryProperties(ConfigurationContext context) {
for (final Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) {
logger.info("entry = " + entry.toString());
PropertyDescriptor descriptor = entry.getKey();
String propertyName = descriptor.getName();
if (descriptor.isDynamic()) {
this.setProperty(propertyName, entry.getValue());
} else {
if (propertyName.equals(BROKER)) {
if (context.getProperty(CONNECTION_FACTORY_IMPL).evaluateAttributeExpressions().getValue().startsWith("org.apache.activemq")) {
this.setProperty("brokerURL", entry.getValue());
} else if (isSolace(context)) {
// TODO
;
} else {
String[] hostPort = entry.getValue().split(":");
if (hostPort.length == 2) {
this.setProperty("hostName", hostPort[0]);
this.setProperty("port", hostPort[1]);
} else if (hostPort.length != 2) {
this.setProperty("serverUrl", entry.getValue()); // for tibco
} else {
throw new IllegalArgumentException("Failed to parse broker url: " + entry.getValue());
}
}
SSLContextService sc = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
if (sc != null) {
SSLContext ssl = sc.createSSLContext(ClientAuth.NONE);
this.setProperty("sSLSocketFactory", ssl.getSocketFactory());
}
} // ignore 'else', since it's the only non-dynamic property that is relevant to CF configuration
}
}
}
示例3: setConnectionFactoryProperties
import org.apache.nifi.ssl.SSLContextService; //导入依赖的package包/类
/**
* This operation follows standard bean convention by matching property name
* to its corresponding 'setter' method. Once the method was located it is
* invoked to set the corresponding property to a value provided by during
* service configuration. For example, 'channel' property will correspond to
* 'setChannel(..) method and 'queueManager' property will correspond to
* setQueueManager(..) method with a single argument.
*
* There are also few adjustments to accommodate well known brokers. For
* example ActiveMQ ConnectionFactory accepts address of the Message Broker
* in a form of URL while IBMs in the form of host/port pair (more common).
* So this method will use value retrieved from the 'BROKER_URI' static
* property 'as is' if ConnectionFactory implementation is coming from
* ActiveMQ and for all others (for now) the 'BROKER_URI' value will be
* split on ':' and the resulting pair will be used to execute
* setHostName(..) and setPort(..) methods on the provided
* ConnectionFactory. This may need to be maintained and adjusted to
* accommodate other implementation of ConnectionFactory, but only for
* URL/Host/Port issue. All other properties are set as dynamic properties
* where user essentially provides both property name and value, The bean
* convention is also explained in user manual for this component with links
* pointing to documentation of various ConnectionFactories.
*
* @see #setProperty(String, String) method
*/
private void setConnectionFactoryProperties(ConfigurationContext context) {
for (final Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) {
PropertyDescriptor descriptor = entry.getKey();
String propertyName = descriptor.getName();
if (descriptor.isDynamic()) {
this.setProperty(propertyName, entry.getValue());
} else {
if (propertyName.equals(BROKER)) {
String impl = context.getProperty(CONNECTION_FACTORY_IMPL).evaluateAttributeExpressions().getValue();
boolean isSolace = "com.solacesystems.jms.SolConnectionFactoryImpl".equals(impl);
if (impl.startsWith("org.apache.activemq")) {
this.setProperty("brokerURL", entry.getValue());
} else {
String val = entry.getValue();
if(val != null) {
String[] hostPort = val.split(":");
if (hostPort.length == 2) {
this.setProperty(isSolace? "Host" :"hostName", hostPort[0]);
this.setProperty("port", hostPort[1]);
} else if (hostPort.length != 2) {
this.setProperty(isSolace? "Host" : "serverUrl", val); // for tibco
} else {
throw new IllegalArgumentException("Failed to parse broker url: " + entry.getValue());
}
}
}
SSLContextService sc = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
if (sc != null) {
SSLContext ssl = sc.createSSLContext(ClientAuth.NONE);
this.setProperty("sSLSocketFactory", ssl.getSocketFactory());
}
} // ignore 'else', since it's the only non-dynamic property that is relevant to CF configuration
}
}
}
示例4: setConnectionFactoryProperties
import org.apache.nifi.ssl.SSLContextService; //导入依赖的package包/类
/**
* This operation follows standard bean convention by matching property name
* to its corresponding 'setter' method. Once the method was located it is
* invoked to set the corresponding property to a value provided by during
* service configuration. For example, 'channel' property will correspond to
* 'setChannel(..) method and 'queueManager' property will correspond to
* setQueueManager(..) method with a single argument.
*
* There are also few adjustments to accommodate well known brokers. For
* example ActiveMQ ConnectionFactory accepts address of the Message Broker
* in a form of URL while IBMs in the form of host/port pair (more common).
* So this method will use value retrieved from the 'BROKER_URI' static
* property 'as is' if ConnectionFactory implementation is coming from
* ActiveMQ and for all others (for now) the 'BROKER_URI' value will be
* split on ':' and the resulting pair will be used to execute
* setHostName(..) and setPort(..) methods on the provided
* ConnectionFactory. This may need to be maintained and adjusted to
* accommodate other implementation of ConnectionFactory, but only for
* URL/Host/Port issue. All other properties are set as dynamic properties
* where user essentially provides both property name and value, The bean
* convention is also explained in user manual for this component with links
* pointing to documentation of various ConnectionFactories.
*
* @see #setProperty(String, String) method
*/
private void setConnectionFactoryProperties(ConfigurationContext context) {
for (final Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) {
PropertyDescriptor descriptor = entry.getKey();
String propertyName = descriptor.getName();
if (descriptor.isDynamic()) {
this.setProperty(propertyName, entry.getValue());
} else {
if (propertyName.equals(BROKER)) {
if (context.getProperty(CONNECTION_FACTORY_IMPL).evaluateAttributeExpressions().getValue().startsWith("org.apache.activemq")) {
this.setProperty("brokerURL", entry.getValue());
} else {
String[] hostPort = entry.getValue().split(":");
if (hostPort.length == 2) {
this.setProperty("hostName", hostPort[0]);
this.setProperty("port", hostPort[1]);
} else if (hostPort.length != 2) {
this.setProperty("serverUrl", entry.getValue()); // for tibco
} else {
throw new IllegalArgumentException("Failed to parse broker url: " + entry.getValue());
}
}
SSLContextService sc = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
if (sc != null) {
SSLContext ssl = sc.createSSLContext(ClientAuth.NONE);
this.setProperty("sSLSocketFactory", ssl.getSocketFactory());
}
} // ignore 'else', since it's the only non-dynamic property that is relevant to CF configuration
}
}
}