Ver código fonte

change jks address

wwd 3 anos atrás
pai
commit
b85a0f2144

+ 9 - 2
pom.xml

@@ -178,6 +178,12 @@
     <build>
         <plugins>
             <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>3.1.0</version>
+            </plugin>
+
+            <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
                 <configuration>
@@ -196,7 +202,8 @@
         </plugins>
         <resources>
             <resource>
-                <directory>src/main/resources</directory>
+                <directory>src/main/resources/</directory>
+                <filtering>true</filtering>
                 <!-- src/main/resources下的指定资源放行 -->
                 <includes>
                     <include>**/*.properties</include>
@@ -204,7 +211,7 @@
                     <include>**/*.xml</include>
                     <include>**/*.jks</include>
                 </includes>
-                <filtering>false</filtering>
+
             </resource>
         </resources>
     </build>

+ 1 - 1
src/main/java/com/persagy/ztkencryptdecodedata/alibabaiot/AmqpClient.java

@@ -235,8 +235,8 @@ public class AmqpClient implements ApplicationRunner {
         return Base64.encodeBase64String(rawHmac);
     }
 
-    @Override
     @Async
+    @Override
     public void run(ApplicationArguments args) throws Exception {
         List<Connection> connections = new ArrayList<>();
 

+ 15 - 4
src/main/java/com/persagy/ztkencryptdecodedata/kafka/CloudKafkaConsumerFromEdgeTopic.java

@@ -15,10 +15,14 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.core.annotation.Order;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ResourceUtils;
 
 import javax.annotation.PostConstruct;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStream;
 import java.util.Collection;
 import java.util.Properties;
 import java.util.concurrent.BlockingQueue;
@@ -98,13 +102,20 @@ public class CloudKafkaConsumerFromEdgeTopic implements CommandLineRunner {
         props.put("security.protocol", securtyprotocol);
         props.put("ssl.endpoint.identification.algorithm",algorithm);
         // properties.put("ssl.truststore.location", ResourceUtils.getFile(truststorelocaltion).getPath());
-        // properties.put("ssl.truststore.password", keystorepassword);
-        props.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, ResourceUtils.getFile(keystorelocaltion).getPath());
+        // properties.put("ssl.truststore.password", keystorepassword);ResourceUtils.getFile(keystorelocaltion).getPath()  ResourceUtils.getFile(truststorelocaltion).getPath()
+        if ("dev".equals(active)){
+
+        }else{
+            props.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG,  new File(keystorelocaltion).getAbsolutePath());
+            props.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, new File(truststorelocaltion).getAbsolutePath());
+        }
+
         props.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG,keystorepassword);
         props.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG,keypassword);
-        props.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, ResourceUtils.getFile(truststorelocaltion).getPath());
-        props.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG,truststorepassword);
 
+        props.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG,truststorepassword);
+//        props.put("sasl.jaas.config",
+//                "org.apache.kafka.common.security.scram.ScramLoginModule required username='account_name' password='pwd';");
 
         //metadata.max.age.ms 1000
         KafkaConsumer<String, String> consumer =  new KafkaConsumer<>(props);

+ 13 - 3
src/main/java/com/persagy/ztkencryptdecodedata/kafka/EdgeKafkaProducer.java

@@ -15,9 +15,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ResourceUtils;
 
+import java.io.File;
 import java.util.Properties;
 import java.util.concurrent.*;
 
@@ -75,6 +77,8 @@ public class EdgeKafkaProducer  {
     private  int mm=0;
     @SneakyThrows
     public Future ProducerSend(String moudle, Object object) {
+
+       // InputStream input=EdgeKafkaProducer.class.getClassLoader().getResourceAsStream("db.properties");
         properties = new Properties();
         // 连接的 kafka 集群地址
         properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer);
@@ -92,11 +96,17 @@ public class EdgeKafkaProducer  {
         properties.put("security.protocol", securtyprotocol);
         properties.put("ssl.endpoint.identification.algorithm",algorithm);
        // properties.put("ssl.truststore.location", ResourceUtils.getFile(truststorelocaltion).getPath());
-       // properties.put("ssl.truststore.password", keystorepassword);
-        properties.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, ResourceUtils.getFile(keytorelocaltion).getPath());
+       // properties.put("ssl.truststore.password", keystorepassword);ResourceUtils.getFile(keytorelocaltion).getPath()ResourceUtils.getFile(truststorelocaltion).getPath()
+        if ("dev".equals(active)){
+
+        }else{
+            properties.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG,  new File(keytorelocaltion).getAbsolutePath());
+            properties.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, new File(truststorelocaltion).getAbsolutePath());
+        }
+
+
         properties.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG,keystorepassword);
         properties.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG,keypassword);
-        properties.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG,ResourceUtils.getFile(truststorelocaltion).getPath());
         properties.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG,truststorepassword);
 
 

+ 2 - 2
src/main/resources/application-dev.yml

@@ -17,12 +17,12 @@ spring:
       batch-size: 16384
       buffer-memory: 33554432
       acks: all
-      client-id: edge_clent_dev
+      client-id: _clent_
       key-serializer: org.apache.kafka.common.serialization.IntegerSerializer
       value-serializer: org.apache.kafka.common.serialization.StringSerializer
     consumer:
       bootstrap-servers: 192.168.2.128:9092,192.168.2.128:9093,192.168.2.128:9094
-      group-id: cloud_consumer_dev
+      group-id: _consumer_
       auto-offset-reset: earliest
       key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
       value-deserializer: org.apache.kafka.common.serialization.StringDeserializer

+ 4 - 4
src/main/resources/application-uat.yml

@@ -28,10 +28,10 @@ spring:
         endpoint:
           identification:
             algorithm: ""
-        trust-store-location: "classpath:uatclient.truststore.jks"
+        trust-store-location: "uatclient.truststore.jks"
         trust-store-password: test1234
         key-password: test1234
-        key-store-location: "classpath:uatclient.keystore.jks"
+        key-store-location: "uatclient.keystore.jks"
         key-store-password: test1234
 
 
@@ -51,10 +51,10 @@ spring:
         endpoint:
           identification:
             algorithm: ""
-        trust-store-location: "classpath:uatclient.truststore.jks"
+        trust-store-location: "uatclient.truststore.jks"
         trust-store-password: test1234
         key-password: test1234
-        key-store-location: "classpath:uatclient.keystore.jks"
+        key-store-location: "uatclient.keystore.jks"
         key-store-password: test1234
 
 

src/main/resources/uatclient.keystore.jks → uatclient.keystore.jks


src/main/resources/uatclient.truststore.jks → uatclient.truststore.jks