Commit c96490f5 authored by xieshaojun's avatar xieshaojun

更新代码

parent f4066961
...@@ -149,6 +149,14 @@ ...@@ -149,6 +149,14 @@
<artifactId>spring-boot-starter-aop</artifactId> <artifactId>spring-boot-starter-aop</artifactId>
</dependency> </dependency>
<!--jasypt加密-->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
package vc.thinker.web;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author : xieshaojun
* @date : 2023/1/5 15:32
*/
@Api
@Slf4j
@RequestMapping("/password")
@RestController
@RequiredArgsConstructor
public class PasswordController {
@Autowired
StringEncryptor encryptor;
@GetMapping("/jia-mi/{password}")
public String encryptorPassword(@PathVariable("password")String password){
return encryptor.encrypt(password);
}
}
...@@ -21,17 +21,23 @@ mqtt: ...@@ -21,17 +21,23 @@ mqtt:
run: ${ MQTT_RUN:true} run: ${ MQTT_RUN:true}
connection: connection:
thinker: thinker:
# broker: ${ MQTT_CONNECTION_BROKER:tcp://120.79.30.193:1883} broker: ${ MQTT_CONNECTION_BROKER:tcp://39.108.185.243:1883}
# clientId: ${ MQTT_CONNECTION_CLIENTID:protocol-proxy-service} clientId: ${ MQTT_CONNECTION_CLIENTID:protocol-proxy-service}
# username: ${ MQTT_CONNECTION_USERNAME:thinker} username: ${ MQTT_CONNECTION_USERNAME:terminal-test1}
password: ${ MQTT_CONNECTION_PASSWORD:123456}
cleanSession: ${ MQTT_CONNECTION_CLEANSESSION:false}
# broker: ${ MQTT_CONNECTION_BROKER:tcp://119.23.65.157:1883}
# clientId: ${ MQTT_CONNECTION_CLIENTID:fox_device_service}
# username: ${ MQTT_CONNECTION_USERNAME:terminal-test1}
# password: ${ MQTT_CONNECTION_PASSWORD:123456} # password: ${ MQTT_CONNECTION_PASSWORD:123456}
## password: ${ MQTT_CONNECTION_PASSWORD:ENC(yZlySGQpCLKNefyzsu5iA3aQ2te7ZKZJuHZoFYZ2gKDe2/u6M2K/x+HEdqYRPO5e)}
# cleanSession: ${ MQTT_CONNECTION_CLEANSESSION:false} # cleanSession: ${ MQTT_CONNECTION_CLEANSESSION:false}
jasypt:
encryptor:
# 加密使用的盐
password: jaspyt_password
broker: ${ MQTT_CONNECTION_BROKER:tcp://119.23.65.157:1883}
clientId: ${ MQTT_CONNECTION_CLIENTID:fox_device_service}
username: ${ MQTT_CONNECTION_USERNAME:thinker}
password: ${ MQTT_CONNECTION_PASSWORD:123456}
cleanSession: ${ MQTT_CONNECTION_CLEANSESSION:false}
# 设备信息 # 设备信息
device: device:
code: zykt-test1 code: zykt-test1
......
...@@ -12,7 +12,7 @@ import vc.thinker.ProtocolProxyApplication; ...@@ -12,7 +12,7 @@ import vc.thinker.ProtocolProxyApplication;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ProtocolProxyApplication.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ProtocolProxyApplication.class)
public class IParameterModelEventServiceTest { public class IServiceTest {
@Autowired @Autowired
private StringEncryptor stringEncryptor; private StringEncryptor stringEncryptor;
......
import org.jasypt.encryption.StringEncryptor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import vc.thinker.ProtocolProxyApplication;
/**
* @author : xieshaojun
* @date : 2023/1/5 15:16
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ProtocolProxyApplication.class)
public class JasyptTest {
@Autowired
private StringEncryptor stringEncryptor;
@Test
public void test() {
//加密
System.out.println(stringEncryptor.encrypt("tcp://120.79.30.193:1883"));
System.out.println(stringEncryptor.encrypt("thinker"));
System.out.println(stringEncryptor.encrypt("123456"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment