注册网站会员,wordpress u盘,网络营销方式对比分析,中国建设网官方网站下载e路每次修改JAVA文件都需要重新启动项目#xff0c;加载时间太长#xff0c;eclipse安装jrebel控件,避免重启项目节省时间。
1、Help-Eclipse Marketplace 2、搜索jrebel 3、Help-jrebel-Configuration 配置jrebel 4、激活jrebel 5、在红色框中填入
http://jrebel…每次修改JAVA文件都需要重新启动项目加载时间太长eclipse安装jrebel控件,避免重启项目节省时间。
1、Help-Eclipse Marketplace 2、搜索jrebel 3、Help-jrebel-Configuration 配置jrebel 4、激活jrebel 5、在红色框中填入
http://jrebel.com.cn/69972f4a-2911-46eb-87ed-7bbb086e4f38 邮箱写自己的邮箱如果出现过期的情况把http://jrebel.com.cn/后面的UUID重新生成即可 UUID生成链接
6、选择要更新的项目 7、选择要启用的服务 8、勾选这两个选项 9、重启启动项目
Console提示这个则表示启用自动加载jrebel控件成功。 10、java代码片段
package sharegoo.util;import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.Date;import org.apache.commons.codec.digest.DigestUtils;
import com.landray.kmss.util.DateUtil;
import com.landray.kmss.util.ResourceUtil;
import com.landray.kmss.util.UserUtil;//加密
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Random;/*** 单点登录加密工具类**/
public class SignOnUtil {/*** 单点登录地址* * return*/public static String getUrl() {String id getUser().getFdId();// 获取当前登录人的IDDate date new Date(); // 获取当前时间戳long timestamp2 date.getTime();String str idtimestamp2;String key 123kjflkjlnf; // 秘钥String iv getIV();//加密String encryptTextCBC encrypt(str, key, iv, AES_CBC);//解密String path /iweb?codeencryptTextCBC;return path;}/** 加密模式之 ECB算法/模式/补码方式 */private static final String AES_ECB AES/ECB/PKCS5Padding;/** 加密模式之 CBC算法/模式/补码方式 */private static final String AES_CBC AES/CBC/PKCS5Padding;/** 加密模式之 CFB算法/模式/补码方式 */private static final String AES_CFB AES/CFB/PKCS5Padding;/** AES 中的 IV 必须是 16 字节128位长 */private static final Integer IV_LENGTH 16;/**** h2空校验/h2* param str 需要判断的值*/public static boolean isEmpty(Object str) {return null str || .equals(str);}/**** h2String 转 byte/h2* param str 需要转换的字符串*/public static byte[] getBytes(String str){if (isEmpty(str)) {return null;}try {return str.getBytes(StandardCharsets.UTF_8);} catch (Exception e) {throw new RuntimeException(e);}}/**** h2初始化向量IV它是一个随机生成的字节数组用于增加加密和解密的安全性/h2*/public static String getIV(){String str abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789;Random random new Random();StringBuffer sb new StringBuffer();for(int i 0 ; i IV_LENGTH ; i){int number random.nextInt(str.length());sb.append(str.charAt(number));}return sb.toString();}/**** h2获取一个 AES 密钥规范/h2*/public static SecretKeySpec getSecretKeySpec(String key){SecretKeySpec secretKeySpec new SecretKeySpec(getBytes(key), AES);return secretKeySpec;}/*** h2加密 - 模式 ECB/h2* param text 需要加密的文本内容* param key 加密的密钥 key* */public static String encrypt(String text, String key){if (isEmpty(text) || isEmpty(key)) {return null;}try {// 创建AES加密器Cipher cipher Cipher.getInstance(AES_ECB);SecretKeySpec secretKeySpec getSecretKeySpec(key);cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);// 加密字节数组byte[] encryptedBytes cipher.doFinal(getBytes(text));// 将密文转换为 Base64 编码字符串return Base64.getEncoder().encodeToString(encryptedBytes);} catch (Exception e) {throw new RuntimeException(e);}}/*** h2解密 - 模式 ECB/h2* param text 需要解密的文本内容* param key 解密的密钥 key* */public static String decrypt(String text, String key){if (isEmpty(text) || isEmpty(key)) {return null;}// 将密文转换为16字节的字节数组byte[] textBytes Base64.getDecoder().decode(text);try {// 创建AES加密器Cipher cipher Cipher.getInstance(AES_ECB);SecretKeySpec secretKeySpec getSecretKeySpec(key);cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);// 解密字节数组byte[] decryptedBytes cipher.doFinal(textBytes);// 将明文转换为字符串return new String(decryptedBytes, StandardCharsets.UTF_8);} catch (Exception e) {throw new RuntimeException(e);}}/*** h2加密 - 自定义加密模式/h2* param text 需要加密的文本内容* param key 加密的密钥 key* param iv 初始化向量* param mode 加密模式* */public static String encrypt(String text, String key, String iv, String mode){if (isEmpty(text) || isEmpty(key) || isEmpty(iv)) {return null;}try {// 创建AES加密器Cipher cipher Cipher.getInstance(mode);SecretKeySpec secretKeySpec getSecretKeySpec(key);cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(getBytes(iv)));// 加密字节数组byte[] encryptedBytes cipher.doFinal(getBytes(text));// 将密文转换为 Base64 编码字符串return Base64.getEncoder().encodeToString(encryptedBytes);} catch (Exception e) {throw new RuntimeException(e);}}/*** h2解密 - 自定义加密模式/h2* param text 需要解密的文本内容* param key 解密的密钥 key* param iv 初始化向量* param mode 加密模式* */public static String decrypt(String text, String key, String iv, String mode){if (isEmpty(text) || isEmpty(key) || isEmpty(iv)) {return null;}// 将密文转换为16字节的字节数组byte[] textBytes Base64.getDecoder().decode(text);try {// 创建AES加密器Cipher cipher Cipher.getInstance(mode);SecretKeySpec secretKeySpec getSecretKeySpec(key);cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(getBytes(iv)));// 解密字节数组byte[] decryptedBytes cipher.doFinal(textBytes);// 将明文转换为字符串return new String(decryptedBytes, StandardCharsets.UTF_8);} catch (Exception e) {throw new RuntimeException(e);}}}11、JSP代码片段
% page languagejava pageEncodingUTF-8 contentTypetext/html; charsetUTF-8%
% page importsharegoo.util.SignOnUtil%
% page importjava.net.URLEncoder%
% page importcom.landray.kmss.util.StringUtil%
% page importjava.io.UnsupportedEncodingException%%//String returnUrl request.getParameter(returnUrl);String pathUrl http://www.local.com;String url pathUrlSignOnUtil.getUrl();response.sendRedirect(url);
%