camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [2/2] camel git commit: CAMEL-11665 - Camel-Nagios: Deprecate EncryptionMethod and use Encryption Enum
Date Tue, 22 Aug 2017 06:19:58 GMT
CAMEL-11665 - Camel-Nagios: Deprecate EncryptionMethod and use Encryption Enum


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/716928ce
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/716928ce
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/716928ce

Branch: refs/heads/master
Commit: 716928ced7c2a40d76ffed2b76d011b2e4e2e379
Parents: 6e5dce3
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Tue Aug 22 08:19:22 2017 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Tue Aug 22 08:19:22 2017 +0200

----------------------------------------------------------------------
 .../src/main/docs/nagios-component.adoc         |  5 ++--
 .../component/nagios/NagiosConfiguration.java   | 29 +++++++++++---------
 .../nagios/NagiosXorEncryptionTest.java         |  2 +-
 .../NagiosComponentConfiguration.java           | 18 ++++++++++++
 4 files changed, 38 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/716928ce/components/camel-nagios/src/main/docs/nagios-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-nagios/src/main/docs/nagios-component.adoc b/components/camel-nagios/src/main/docs/nagios-component.adoc
index 9bc6501..eab5a1a 100644
--- a/components/camel-nagios/src/main/docs/nagios-component.adoc
+++ b/components/camel-nagios/src/main/docs/nagios-component.adoc
@@ -72,7 +72,7 @@ with the following path and query parameters:
 | **port** | *Required* The port number of the host. |  | int
 |=======================================================================
 
-#### Query Parameters (6 parameters):
+#### Query Parameters (7 parameters):
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |=======================================================================
@@ -81,7 +81,8 @@ with the following path and query parameters:
 | **sendSync** (producer) | Whether or not to use synchronous when sending a passive check.
Setting it to false will allow Camel to continue routing the message and the passive check
message will be send asynchronously. | true | boolean
 | **timeout** (producer) | Sending timeout in millis. | 5000 | int
 | **synchronous** (advanced) | Sets whether synchronous processing should be strictly used
or Camel is allowed to use asynchronous processing (if supported). | false | boolean
-| **encryptionMethod** (security) | To specify an encryption method. |  | NagiosEncryptionMethod
+| **encryption** (security) | To specify an encryption method. |  | Encryption
+| **encryptionMethod** (security) | *Deprecated* To specify an encryption method. |  | NagiosEncryptionMethod
 | **password** (security) | Password to be authenticated when sending checks to Nagios. |
 | String
 |=======================================================================
 // endpoint options: END

http://git-wip-us.apache.org/repos/asf/camel/blob/716928ce/components/camel-nagios/src/main/java/org/apache/camel/component/nagios/NagiosConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-nagios/src/main/java/org/apache/camel/component/nagios/NagiosConfiguration.java
b/components/camel-nagios/src/main/java/org/apache/camel/component/nagios/NagiosConfiguration.java
index 69cdcee..f6af113 100644
--- a/components/camel-nagios/src/main/java/org/apache/camel/component/nagios/NagiosConfiguration.java
+++ b/components/camel-nagios/src/main/java/org/apache/camel/component/nagios/NagiosConfiguration.java
@@ -46,8 +46,11 @@ public class NagiosConfiguration implements Cloneable {
     private int timeout = 5000;
     @UriParam(label = "security", secret = true)
     private String password;
+    @Deprecated
     @UriParam(label = "security")
     private NagiosEncryptionMethod encryptionMethod;
+    @UriParam(label = "security")
+    private Encryption encryption = Encryption.NONE;
 
     /**
      * Returns a copy of this configuration
@@ -88,18 +91,7 @@ public class NagiosConfiguration implements Cloneable {
             nagiosSettings.setNagiosHost(getHost());
             nagiosSettings.setPort(getPort());
             nagiosSettings.setPassword(getPassword());
-
-            if (encryptionMethod != null) {
-                if (NagiosEncryptionMethod.No == encryptionMethod) {
-                    nagiosSettings.setEncryption(Encryption.NONE);
-                } else if (NagiosEncryptionMethod.Xor == encryptionMethod) {
-                    nagiosSettings.setEncryption(Encryption.XOR);
-                } else if (NagiosEncryptionMethod.TripleDes == encryptionMethod) {
-                    nagiosSettings.setEncryption(Encryption.TRIPLE_DES);
-                } else {
-                    throw new IllegalArgumentException("Unknown encryption method: " + encryptionMethod);
-                }
-            }
+            nagiosSettings.setEncryption(encryption);
         }
 
         return nagiosSettings;
@@ -175,10 +167,21 @@ public class NagiosConfiguration implements Cloneable {
         this.encryptionMethod = encryptionMethod;
     }
 
+    public Encryption getEncryption() {
+        return encryption;
+    }
+
+    /**
+     * To specify an encryption method.
+     */
+    public void setEncryption(Encryption encryption) {
+        this.encryption = encryption;
+    }
+
     @Override
     public String toString() {
         return "NagiosConfiguration[host=" + host + ":" + port + ", connectionTimeout=" +
connectionTimeout
-                + ", timeout=" + timeout + ", encryptionMethod=" + encryptionMethod + "]";
+                + ", timeout=" + timeout + ", encryptionMethod=" + encryptionMethod + ",
encryption=" + encryption + "]";
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/716928ce/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosXorEncryptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosXorEncryptionTest.java
b/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosXorEncryptionTest.java
index d9e5346..cf4766c 100644
--- a/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosXorEncryptionTest.java
+++ b/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosXorEncryptionTest.java
@@ -72,7 +72,7 @@ public class NagiosXorEncryptionTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                String uri = "nagios:127.0.0.1:25664?password=secret&encryptionMethod=Xor";
+                String uri = "nagios:127.0.0.1:25664?password=secret&encryption=Xor";
 
                 NagiosComponent nagiosComponent = new NagiosComponent();
                 nagiosComponent.setCamelContext(context);

http://git-wip-us.apache.org/repos/asf/camel/blob/716928ce/platforms/spring-boot/components-starter/camel-nagios-starter/src/main/java/org/apache/camel/component/nagios/springboot/NagiosComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-nagios-starter/src/main/java/org/apache/camel/component/nagios/springboot/NagiosComponentConfiguration.java
b/platforms/spring-boot/components-starter/camel-nagios-starter/src/main/java/org/apache/camel/component/nagios/springboot/NagiosComponentConfiguration.java
index cf7611c..e4db515 100644
--- a/platforms/spring-boot/components-starter/camel-nagios-starter/src/main/java/org/apache/camel/component/nagios/springboot/NagiosComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-nagios-starter/src/main/java/org/apache/camel/component/nagios/springboot/NagiosComponentConfiguration.java
@@ -18,9 +18,11 @@ package org.apache.camel.component.nagios.springboot;
 
 import javax.annotation.Generated;
 import com.googlecode.jsendnsca.NagiosSettings;
+import com.googlecode.jsendnsca.encryption.Encryption;
 import org.apache.camel.component.nagios.NagiosEncryptionMethod;
 import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
 import org.springframework.boot.context.properties.NestedConfigurationProperty;
 
 /**
@@ -90,7 +92,12 @@ public class NagiosComponentConfiguration
         /**
          * To specify an encryption method.
          */
+        @Deprecated
         private NagiosEncryptionMethod encryptionMethod;
+        /**
+         * To specify an encryption method.
+         */
+        private Encryption encryption;
 
         public NagiosSettings getNagiosSettings() {
             return nagiosSettings;
@@ -140,12 +147,23 @@ public class NagiosComponentConfiguration
             this.password = password;
         }
 
+        @Deprecated
+        @DeprecatedConfigurationProperty
         public NagiosEncryptionMethod getEncryptionMethod() {
             return encryptionMethod;
         }
 
+        @Deprecated
         public void setEncryptionMethod(NagiosEncryptionMethod encryptionMethod) {
             this.encryptionMethod = encryptionMethod;
         }
+
+        public Encryption getEncryption() {
+            return encryption;
+        }
+
+        public void setEncryption(Encryption encryption) {
+            this.encryption = encryption;
+        }
     }
 }
\ No newline at end of file


Mime
View raw message