当前位置: 首页 > news >正文

公司做网站流程重庆招聘网站有哪些

公司做网站流程,重庆招聘网站有哪些,织梦网站后台使用说明书,网站由哪些部分组成部分组成部分文章目录 前言一、集成 Jasypt1. pom 依赖2. yml 依赖 3. 加密工具类3. 使用二、常见问题1. application.yml 失效问题2. 配置热更新失败问题 前言 jasypt 官方地址:https://github.com/ulisesbocchio/jasypt-spring-boot Jasypt可以为Springboot加密的信息很多&a…

文章目录

  • 前言
  • 一、集成 Jasypt
    • 1. pom 依赖
    • 2. yml 依赖
  • 3. 加密工具类
  • 3. 使用
  • 二、常见问题
    • 1. application.yml 失效问题
    • 2. 配置热更新失败问题


前言

jasypt 官方地址:https://github.com/ulisesbocchio/jasypt-spring-boot

Jasypt可以为Springboot加密的信息很多,主要有:

  1. System Property 系统变量。
  2. Envirnment Property 环境变量。
  3. Command Line argument 命令行参数。
  4. Application.properties 应用配置文件。
  5. Yaml properties 应用配置文件。
  6. other custom property sources 其它配置文件。

一、集成 Jasypt

1. pom 依赖

<!-- jasypt(yml加密) -->
<dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId><version>3.0.5</version>
</dependency>

2. yml 依赖

jasypt:encryptor:password: encpassword # 加密盐值(自定义)algorithm: PBEWithMD5AndDES # 加密算法(3.0.5以下版本默认PBEWithMD5AndDES,即DES加密算法-32位密文;3.0.5及以上版本默认PBEWITHHMACSHA512ANDAES_256,即AES加密算法-64位密文)iv-generator-classname: org.jasypt.iv.NoIvGenerator # 加密偏移生成器

3. 加密工具类

使用如下工具类,对密码进行加密获取密文。

import lombok.extern.slf4j.Slf4j;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;/*** jasypt(yml加密)工具** @author whiteen* @date 2024-06-20 00:00:00*/
@Slf4j
public class JasyptUtil {/*** DES加密** @param original 待加密内容* @param password 加密盐值* @return 加密密文* @author whiteen* @date 2024-06-20 00:00:00*/public static String encryptByDes(String original, String password) {StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();// 设置盐值config.setPassword(password);config.setAlgorithm("PBEWithMD5AndDES");config.setIvGeneratorClassName("org.jasypt.iv.NoIvGenerator");encryptor.setConfig(config);// 加密return encryptor.encrypt(original);}/*** AES加密** @param original 待加密内容* @param password 加密盐值* @return 加密密文* @author whiteen* @date 2024-06-20 00:00:00*/public static String encryptByAes(String original, String password) {StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();// 设置盐值config.setPassword(password);config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");encryptor.setConfig(config);// 加密return encryptor.encrypt(original);}/*** DES解密** @param original 待解密内容* @param password 加密盐值* @return 加密明文* @author whiteen* @date 2024-06-20 00:00:00*/public static String decryptByDes(String original, String password) {StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();// 设置盐值config.setPassword(password);config.setAlgorithm("PBEWithMD5AndDES");config.setIvGeneratorClassName("org.jasypt.iv.NoIvGenerator");encryptor.setConfig(config);// 解密return encryptor.decrypt(original);}/*** AES解密** @param original 待解密内容* @param password 加密盐值* @return 加密明文* @author whiteen* @date 2024-06-20 00:00:00*/public static String decryptByAes(String original, String password) {StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();// 设置盐值config.setPassword(password);config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");encryptor.setConfig(config);// 解密return encryptor.decrypt(original);}public static void main(String[] args) {// 待加密内容String original = "original";// 加密盐值String password = "encpassword";// DES加密String encryptedDes = encryptByDes(original, password);log.info("DES密⽂: {}", encryptedDes);// DES解密String decryptedDes = decryptByDes(encryptedDes, password);log.info("DES明⽂: {}", decryptedDes);// AES加密String encryptedAes = encryptByAes(original, password);log.info("AES密⽂: {}", encryptedAes);// AES解密String decryptedAes = decryptByAes(encryptedAes, password);log.info("AES明⽂: {}", decryptedAes);}}

3. 使用

password: ENC(${ORACLE_PWD:password})

二、常见问题

1. application.yml 失效问题

如果你的项目存在 boostrap.yml 配置文件,在引入 jasypt-spring-boot-starter 之后,发现 application.yml 与 application-dev.yml 配置没有生效,需要在 boostrap.yml 中设置 jasypt.encryptor.bootstrap 属性为 false,禁用对 boostrap 配置文件的加密支持,就可以解决 application.yml 与 application-dev.yml 配置失效的问题。

说明:
当 jasypt 和 springcloud 一起使用时,bootstrap 的配置会失效。追踪代码发现,spring 在启动 bootstrap 容器后,当把 bootstrap 容器的 environment 合并到子容器时,只同步了 OriginTrackedMapPropertySource 类型 BootstrapApplicationListener,此时所有的 PropertySource 都已经被包装为 EncryptablePropertySourceWrapper,所以会导致 bootstrap 的配置不会合并到子容器。

2. 配置热更新失败问题

在 yml 配置文件中设置环境变量报错。

参考 apollo 跟 jasypt-spring-boot-2.1.0.jar 不兼容问题: https://github.com/apolloconfig/apollo/issues/2162

升级 jasypt-spring-boot-starter 到 3.0.5 及以上版本可以解决配置热更新问题,再新增 algorithm 和 iv-generator-classname 两个配置即可:

<!-- jasypt(yml加密) -->
<dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId><version>3.0.5</version>
</dependency>
jasypt:encryptor:password: encpassword # 加密盐值(自定义)algorithm: PBEWithMD5AndDES # 加密算法(3.0.5以下版本默认PBEWithMD5AndDES,即DES加密算法-32位密文;3.0.5及以上版本默认PBEWITHHMACSHA512ANDAES_256,即AES加密算法-64位密文)iv-generator-classname: org.jasypt.iv.NoIvGenerator # 加密偏移生成器

这样就可以在 yml 配置文件中设置环境变量:

password: ENC(${ORACLE_PWD:BBO5rGF40i+Sg5oG36MT5aEwpdrOe5f2})
http://www.yayakq.cn/news/646076/

相关文章:

  • 网站程序前台怎么创建自己的官网
  • logo商标设计网站电子商务营销
  • 做网站是先做后台还是前端wordpress 多语言 站点
  • 河北建设厅查询网站首页网站底部版权信息模板
  • 网站内容建设评估简洁风格的网站模板免费下载
  • 哪里有网站开发服务网站开发周期安排
  • 东莞网站seo公司高校宣传网站建设
  • 游仙移动网站建设防窜货管理系统开发
  • 网站建设方案的所属行业是云栖建站
  • 网站安装系统怎么安装教程视频apache重定向wordpress
  • 做网站需要什么部门批准高级网站开发技术
  • 山东公司注册网站什么是网络营销包含哪些内容
  • 自助建网站系统源码延庆网站建设优化seo
  • 网站推广的内涵网站建设的软件介绍
  • php做的大型网站怎么样免费给网站做优化
  • 企业网站推广的方法有哪些国家职业技能培训平台
  • 邯郸做网站的公司iis怎么部署网站
  • 舟山建设网站公司seo需要掌握什么技能
  • 自己做的网站标题合肥做网站
  • 做淘客网站大型网站开发框架
  • 做网站 备案网站怎么做筛选功能的代码
  • 中国国防建设网站上海知名网站设计
  • 设计发明的网站wordpress 中文版 编码
  • 网站空间有什么用网络营销公
  • 宁晋网站建设设计优化网站建设
  • 建一个网站需要多少费用wordpress主题包
  • 单位建网站的详细步骤软件定制公司值得去吗
  • 怎么做网站推销产品在线培训平台有哪些
  • 自助建站网站建设设计公司无锡网站推广$做下拉去118cr
  • 地方网站商城怎么做老地方在线观看免费资源大全