{"id":351338,"date":"2024-05-20T12:28:00","date_gmt":"2024-05-20T12:28:00","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=351338"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=351338","title":{"rendered":"<span>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u0430 Controller Service \u0432 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 NiFi<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u041f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u0430<\/h3>\n<p>\u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0441\u0430\u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 <a href=\"https:\/\/nifi.apache.org\/\" rel=\"noopener noreferrer nofollow\">Apache NiFi<\/a> \u0443 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435\u00a0\u0441\u043b\u0443\u0436\u0431\u044b \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 (\u0442\u0438\u043f\u0430 <code>StandardRestrictedSSLContextService<\/code>), \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0441 \u0442\u0438\u043f\u043e\u043c\u00a0<code>SSLContextService<\/code>, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432 NiFi \u0441\u043b\u0443\u0436\u0431\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u0431\u0440\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043e\u0442\u0442\u0443\u0434\u0430. \u0418\u0437\u0443\u0447\u0438\u043b \u043c\u0430\u0442\u0447\u0430\u0441\u0442\u044c, \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e. \u0414\u043e\u0431\u0430\u0432\u0438\u043b \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u0437\u0430\u043a\u0438\u043d\u0443\u043b \u0435\u0433\u043e \u043d\u0430 flow. \u041d\u043e&#8230; \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u043c\u043e\u0438\u00a0<code>StandardRestrictedSSLContextService<\/code>. \u041f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0442\u0430\u043b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043e\u0442 \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u0433\u043e <a href=\"https:\/\/pierrevillard.com\/\" rel=\"noopener noreferrer nofollow\">Pierre Villard<\/a>, \u043d\u043e \u043d\u0438\u043a\u0430\u043a. \u041f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 <a href=\"https:\/\/github.com\/peetkes\/nifi-http-processor\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u0445\u043e\u0436\u0435\u0433\u043e \u043a\u0435\u0439\u0441\u0430 \u043d\u0430 Github<\/a>.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u043e\u043d\u0430 \u0432\u044b\u0437\u0432\u0430\u043b\u0430 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u043e\u0434\u0441\u0443\u043d\u0443\u0442\u044c \u0441\u0432\u043e\u044e \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443 \u0432 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 (\u0447\u0442\u043e \u0442\u043e\u0436\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439).<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440<\/h3>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u043b\u0443\u0436\u0431\u044b, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c.<\/p>\n<pre><code class=\"java\">public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder()     .name(\"SSL Context Service\")     .description(\"SSL Context Service provides trusted certificates and client certificates for TLS communication.\")     .required(false)     .identifiesControllerService(SSLContextService.class)     .build();<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043c\u0435\u0442\u043e\u0434\u0430\u00a0<code>@OnTrigger<\/code>\u00a0\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">SSLContextService sslService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);<\/code><\/pre>\n<p><strong>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u0441\u0430\u043c\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u044d\u0442\u043e\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0440\u0430\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0441\u0435 \u0438 \u0437\u0430\u0442\u0435\u0432\u0430\u043b\u043e\u0441\u044c. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439!<\/strong>  <\/p>\n<p>1) \u0412\u00a0<code>pom.xml<\/code>\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0432\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:  <\/p>\n<pre><code class=\"xml\">&lt;dependency>     &lt;groupId>org.apache.nifi&lt;\/groupId>     &lt;artifactId>nifi-ssl-context-service-api&lt;\/artifactId>     &lt;version>${nifi.version}&lt;\/version> &lt;\/dependency>   &lt;dependency>     &lt;groupId>org.apache.nifi&lt;\/groupId>     &lt;artifactId>nifi-standard-services-api-nar&lt;\/artifactId>     &lt;version>${nifi.version}&lt;\/version>     &lt;type>nar&lt;\/type> &lt;\/dependency><\/code><\/pre>\n<p>2) \u0412\u00a0<code>pom.xml<\/code>\u00a0nar-\u043c\u043e\u0434\u0443\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0434\u043d\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:  <\/p>\n<pre><code class=\"xml\">&lt;dependency>     &lt;groupId>org.apache.nifi&lt;\/groupId>     &lt;artifactId>nifi-standard-services-api-nar&lt;\/artifactId>     &lt;version>${nifi.version}&lt;\/version>     &lt;type>nar&lt;\/type> &lt;\/dependency><\/code><\/pre>\n<p><code>nifi-ssl-context-service-api<\/code>\u00a0&#8212; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u00a0<code>SSLContextService.class<\/code> \u0432 \u043a\u043e\u0434\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430<\/p>\n<p><code>nifi-standard-services-api-nar<\/code>\u00a0&#8212; \u044d\u0442\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u043e\u0431\u043e\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u043b\u0443\u0436\u0431\u044b NiFi<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u043e\u0442 \u0438 \u0432\u0435\u0441\u044c \u0444\u043e\u043a\u0443\u0441.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0434\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 \u043f\u043e \u0442\u0438\u043f\u0443 \u043e\u0442 <code>SSLContextService<\/code>, \u0442\u043e \u043f\u043e\u043c\u043e\u0447\u044c \u0432 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437 <a href=\"https:\/\/github.com\/apache\/nifi\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 NiFi<\/a>.<\/p>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0436\u0431\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432<\/h3>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u044d\u0442\u043e Controller Service, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043a\u0443\u044e \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443 \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0410 \u043f\u043e\u0442\u043e\u043c \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432.<\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>DummySSLContextService.class\u00a0&#8212; \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430 \u0434\u043b\u044f \u0441\u043b\u0443\u0436\u0431\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">import javax.net.ssl.SSLContext; import javax.net.ssl.X509TrustManager; import lombok.Builder; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.security.util.TlsConfiguration; import org.apache.nifi.ssl.SSLContextService;  @Builder public class DummySSLContextService extends AbstractControllerService implements SSLContextService {     private final String keyStoreFile;     private final String keyStorePassword;     private final String keyStoreType;     private final String trustStoreFile;     private final String trustStorePassword;     private final String trustStoreType;      @Override     public TlsConfiguration createTlsConfiguration() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public SSLContext createContext() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public SSLContext createSSLContext(org.apache.nifi.security.util.ClientAuth clientAuth) throws ProcessException {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public SSLContext createSSLContext(ClientAuth clientAuth) throws ProcessException {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public X509TrustManager createTrustManager() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public String getTrustStoreFile() {         return trustStoreFile;     }      @Override     public String getTrustStoreType() {         return trustStoreType;     }      @Override     public String getTrustStorePassword() {         return trustStorePassword;     }      @Override     public boolean isTrustStoreConfigured() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public String getKeyStoreFile() {         return keyStoreFile;     }      @Override     public String getKeyStoreType() {         return keyStoreType;     }      @Override     public String getKeyStorePassword() {         return keyStorePassword;     }      @Override     public String getKeyPassword() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public boolean isKeyStoreConfigured() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public String getSslAlgorithm() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public void onPropertyModified(PropertyDescriptor propertyDescriptor, String s, String s1) {         \/\/ \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>TestData.class &#8212; \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u043b\u0443\u0436\u0431\u044b-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">import java.nio.file.Path;  import org.apache.nifi.ssl.SSLContextService;  public class TestData {     static final String CLIENT_CERT_FILE_NAME = Path.of(\"src\/test\/resources\/client-identity.jks\").toAbsolutePath().toString();     static final String CLIENT_TRUST_FILE_NAME = Path.of(\"src\/test\/resources\/truststore.jks\").toAbsolutePath().toString();     public static final String KEYSTORE_COMMON_PASSWORD = \"changeit\";     public static final String KEYSTORE_COMMON_TYPE = \"JKS\";      public static final SSLContextService TEST_SSL_CONTEXT_SERVICE = DummySSLContextService.builder()             .keyStoreFile(CLIENT_CERT_FILE_NAME)             .keyStorePassword(KEYSTORE_COMMON_PASSWORD)             .keyStoreType(KEYSTORE_COMMON_TYPE)             .trustStoreFile(CLIENT_TRUST_FILE_NAME)             .trustStorePassword(KEYSTORE_COMMON_PASSWORD)             .trustStoreType(KEYSTORE_COMMON_TYPE)             .build(); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0435\u0441\u0442\u00a0(\u0442\u0443\u0442\u00a0<code>SSL_CONTEXT_SERVICE<\/code>\u00a0\u044d\u0442\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430):<\/p>\n<pre><code class=\"java\">    @Test     void should_run_with_service_property() throws InitializationException {         final TestRunner testRunner = TestRunners.newTestRunner(MyProcessor.class);          \/\/ \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430         testRunner.setProperty(SOME_PROPERTY_NAME, SOME_PROPERTY_VALUE);                \/\/ \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f Controller Service         \/\/ \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0438 \u0448\u0430\u0433\u0430         testRunner.addControllerService(\"TestSSLContextService\", TEST_SSL_CONTEXT_SERVICE);         testRunner.setProperty(SSL_CONTEXT_SERVICE, \"TestSSLContextService\");         testRunner.enableControllerService(TEST_SSL_CONTEXT_SERVICE);          \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e flow-\u0444\u0430\u0439\u043b\u0430         Map&lt;String, String> attributes = new HashMap&lt;>();         attributes.put(SOME_ATTR_NAME, SOME_ATTR_VALUE);          \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0438 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 flow-\u0444\u0430\u0439\u043b         \/\/ \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u044e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u043f\u043e\u0442\u043e\u043a         testRunner.enqueue(\"Flowfile content\", attributes);          \/\/ When         testRunner.run();          \/\/ Then         List&lt;MockFlowFile> originalFlowFiles = testRunner.getFlowFilesForRelationship(REL_SUCCESS);         List&lt;MockFlowFile> failureFlowFiles = testRunner.getFlowFilesForRelationship(REL_FAILURE);          assertThat(originalFlowFiles.size()).isEqualTo(1);         assertThat(failureFlowFiles.size()).isZero();          Map&lt;String, String> actualAttributes = originalFlowFiles.get(0).getAttributes();         assertThat(actualAttributes)                 .isNotNull()                 .containsEntry(SOME_ATTR_NAME, SOME_ATTR_VALUE);     }<\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430. \u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u0430 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f))<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/752690\/\"> https:\/\/habr.com\/ru\/articles\/752690\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u041f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u0430<\/h3>\n<p>\u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0441\u0430\u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 <a href=\"https:\/\/nifi.apache.org\/\" rel=\"noopener noreferrer nofollow\">Apache NiFi<\/a> \u0443 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435\u00a0\u0441\u043b\u0443\u0436\u0431\u044b \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 (\u0442\u0438\u043f\u0430 <code>StandardRestrictedSSLContextService<\/code>), \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0441 \u0442\u0438\u043f\u043e\u043c\u00a0<code>SSLContextService<\/code>, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432 NiFi \u0441\u043b\u0443\u0436\u0431\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u0431\u0440\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043e\u0442\u0442\u0443\u0434\u0430. \u0418\u0437\u0443\u0447\u0438\u043b \u043c\u0430\u0442\u0447\u0430\u0441\u0442\u044c, \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e. \u0414\u043e\u0431\u0430\u0432\u0438\u043b \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u0437\u0430\u043a\u0438\u043d\u0443\u043b \u0435\u0433\u043e \u043d\u0430 flow. \u041d\u043e&#8230; \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u043c\u043e\u0438\u00a0<code>StandardRestrictedSSLContextService<\/code>. \u041f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0442\u0430\u043b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043e\u0442 \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u0433\u043e <a href=\"https:\/\/pierrevillard.com\/\" rel=\"noopener noreferrer nofollow\">Pierre Villard<\/a>, \u043d\u043e \u043d\u0438\u043a\u0430\u043a. \u041f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 <a href=\"https:\/\/github.com\/peetkes\/nifi-http-processor\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u0445\u043e\u0436\u0435\u0433\u043e \u043a\u0435\u0439\u0441\u0430 \u043d\u0430 Github<\/a>.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u043e\u043d\u0430 \u0432\u044b\u0437\u0432\u0430\u043b\u0430 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u043e\u0434\u0441\u0443\u043d\u0443\u0442\u044c \u0441\u0432\u043e\u044e \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443 \u0432 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 (\u0447\u0442\u043e \u0442\u043e\u0436\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439).<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440<\/h3>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u043b\u0443\u0436\u0431\u044b, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c.<\/p>\n<pre><code class=\"java\">public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder()     .name(\"SSL Context Service\")     .description(\"SSL Context Service provides trusted certificates and client certificates for TLS communication.\")     .required(false)     .identifiesControllerService(SSLContextService.class)     .build();<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043c\u0435\u0442\u043e\u0434\u0430\u00a0<code>@OnTrigger<\/code>\u00a0\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">SSLContextService sslService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);<\/code><\/pre>\n<p><strong>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u0441\u0430\u043c\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u044d\u0442\u043e\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0440\u0430\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0441\u0435 \u0438 \u0437\u0430\u0442\u0435\u0432\u0430\u043b\u043e\u0441\u044c. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439!<\/strong>  <\/p>\n<p>1) \u0412\u00a0<code>pom.xml<\/code>\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0432\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:  <\/p>\n<pre><code class=\"xml\">&lt;dependency>     &lt;groupId>org.apache.nifi&lt;\/groupId>     &lt;artifactId>nifi-ssl-context-service-api&lt;\/artifactId>     &lt;version>${nifi.version}&lt;\/version> &lt;\/dependency>   &lt;dependency>     &lt;groupId>org.apache.nifi&lt;\/groupId>     &lt;artifactId>nifi-standard-services-api-nar&lt;\/artifactId>     &lt;version>${nifi.version}&lt;\/version>     &lt;type>nar&lt;\/type> &lt;\/dependency><\/code><\/pre>\n<p>2) \u0412\u00a0<code>pom.xml<\/code>\u00a0nar-\u043c\u043e\u0434\u0443\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0434\u043d\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:  <\/p>\n<pre><code class=\"xml\">&lt;dependency>     &lt;groupId>org.apache.nifi&lt;\/groupId>     &lt;artifactId>nifi-standard-services-api-nar&lt;\/artifactId>     &lt;version>${nifi.version}&lt;\/version>     &lt;type>nar&lt;\/type> &lt;\/dependency><\/code><\/pre>\n<p><code>nifi-ssl-context-service-api<\/code>\u00a0&#8212; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u00a0<code>SSLContextService.class<\/code> \u0432 \u043a\u043e\u0434\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430<\/p>\n<p><code>nifi-standard-services-api-nar<\/code>\u00a0&#8212; \u044d\u0442\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u043e\u0431\u043e\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u043b\u0443\u0436\u0431\u044b NiFi<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u043e\u0442 \u0438 \u0432\u0435\u0441\u044c \u0444\u043e\u043a\u0443\u0441.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0434\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 \u043f\u043e \u0442\u0438\u043f\u0443 \u043e\u0442 <code>SSLContextService<\/code>, \u0442\u043e \u043f\u043e\u043c\u043e\u0447\u044c \u0432 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437 <a href=\"https:\/\/github.com\/apache\/nifi\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 NiFi<\/a>.<\/p>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0436\u0431\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432<\/h3>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u044d\u0442\u043e Controller Service, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043a\u0443\u044e \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443 \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0410 \u043f\u043e\u0442\u043e\u043c \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432.<\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>DummySSLContextService.class\u00a0&#8212; \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430 \u0434\u043b\u044f \u0441\u043b\u0443\u0436\u0431\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">import javax.net.ssl.SSLContext; import javax.net.ssl.X509TrustManager; import lombok.Builder; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.security.util.TlsConfiguration; import org.apache.nifi.ssl.SSLContextService;  @Builder public class DummySSLContextService extends AbstractControllerService implements SSLContextService {     private final String keyStoreFile;     private final String keyStorePassword;     private final String keyStoreType;     private final String trustStoreFile;     private final String trustStorePassword;     private final String trustStoreType;      @Override     public TlsConfiguration createTlsConfiguration() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public SSLContext createContext() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public SSLContext createSSLContext(org.apache.nifi.security.util.ClientAuth clientAuth) throws ProcessException {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public SSLContext createSSLContext(ClientAuth clientAuth) throws ProcessException {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public X509TrustManager createTrustManager() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public String getTrustStoreFile() {         return trustStoreFile;     }      @Override     public String getTrustStoreType() {         return trustStoreType;     }      @Override     public String getTrustStorePassword() {         return trustStorePassword;     }      @Override     public boolean isTrustStoreConfigured() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public String getKeyStoreFile() {         return keyStoreFile;     }      @Override     public String getKeyStoreType() {         return keyStoreType;     }      @Override     public String getKeyStorePassword() {         return keyStorePassword;     }      @Override     public String getKeyPassword() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public boolean isKeyStoreConfigured() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public String getSslAlgorithm() {         throw new RuntimeException(\"Method not implemented\");     }      @Override     public void onPropertyModified(PropertyDescriptor propertyDescriptor, String s, String s1) {         \/\/ \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>TestData.class &#8212; \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u043b\u0443\u0436\u0431\u044b-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">import java.nio.file.Path;  import org.apache.nifi.ssl.SSLContextService;  public class TestData {     static final String CLIENT_CERT_FILE_NAME = Path.of(\"src\/test\/resources\/client-identity.jks\").toAbsolutePath().toString();     static final String CLIENT_TRUST_FILE_NAME = Path.of(\"src\/test\/resources\/truststore.jks\").toAbsolutePath().toString();     public static final String KEYSTORE_COMMON_PASSWORD = \"changeit\";     public static final String KEYSTORE_COMMON_TYPE = \"JKS\";      public static final SSLContextService TEST_SSL_CONTEXT_SERVICE = DummySSLContextService.builder()             .keyStoreFile(CLIENT_CERT_FILE_NAME)             .keyStorePassword(KEYSTORE_COMMON_PASSWORD)             .keyStoreType(KEYSTORE_COMMON_TYPE)             .trustStoreFile(CLIENT_TRUST_FILE_NAME)             .trustStorePassword(KEYSTORE_COMMON_PASSWORD)             .trustStoreType(KEYSTORE_COMMON_TYPE)             .build(); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0435\u0441\u0442\u00a0(\u0442\u0443\u0442\u00a0<code>SSL_CONTEXT_SERVICE<\/code>\u00a0\u044d\u0442\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430):<\/p>\n<pre><code class=\"java\">    @Test     void should_run_with_service_property() throws InitializationException {         final TestRunner testRunner = TestRunners.newTestRunner(MyProcessor.class);          \/\/ \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430         testRunner.setProperty(SOME_PROPERTY_NAME, SOME_PROPERTY_VALUE);                \/\/ \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f Controller Service         \/\/ \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0438 \u0448\u0430\u0433\u0430         testRunner.addControllerService(\"TestSSLContextService\", TEST_SSL_CONTEXT_SERVICE);         testRunner.setProperty(SSL_CONTEXT_SERVICE, \"TestSSLContextService\");         testRunner.enableControllerService(TEST_SSL_CONTEXT_SERVICE);          \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e flow-\u0444\u0430\u0439\u043b\u0430         Map&lt;String, String> attributes = new HashMap&lt;>();         attributes.put(SOME_ATTR_NAME, SOME_ATTR_VALUE);          \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0438 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 flow-\u0444\u0430\u0439\u043b         \/\/ \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u044e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u043f\u043e\u0442\u043e\u043a         testRunner.enqueue(\"Flowfile content\", attributes);          \/\/ When         testRunner.run();          \/\/ Then         List&lt;MockFlowFile> originalFlowFiles = testRunner.getFlowFilesForRelationship(REL_SUCCESS);         List&lt;MockFlowFile> failureFlowFiles = testRunner.getFlowFilesForRelationship(REL_FAILURE);          assertThat(originalFlowFiles.size()).isEqualTo(1);         assertThat(failureFlowFiles.size()).isZero();          Map&lt;String, String> actualAttributes = originalFlowFiles.get(0).getAttributes();         assertThat(actualAttributes)                 .isNotNull()                 .containsEntry(SOME_ATTR_NAME, SOME_ATTR_VALUE);     }<\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430. \u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u0430 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f))<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/752690\/\"> https:\/\/habr.com\/ru\/articles\/752690\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-351338","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/351338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=351338"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/351338\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=351338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=351338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=351338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}