1
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package com.cym;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@EnableAsync
|
||||
@EnableTransactionManagement
|
||||
@SpringBootApplication
|
||||
public class CdnWebUI {
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(CdnWebUI.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.cym.config;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||
|
||||
import freemarker.template.TemplateException;
|
||||
|
||||
@Configuration
|
||||
public class FreeMarkerConfig {
|
||||
|
||||
@Bean
|
||||
public FreeMarkerConfigurer freeMarkerConfigurer() throws IOException, TemplateException {
|
||||
FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
|
||||
freeMarkerConfigurer.setTemplateLoaderPath("classpath:templates/");
|
||||
|
||||
freemarker.template.Configuration configuration = freeMarkerConfigurer.createConfiguration();
|
||||
configuration.setDefaultEncoding("UTF-8");
|
||||
configuration.setSetting("classic_compatible", "true");// 使用经典语法
|
||||
configuration.setSetting("number_format", "0.##");
|
||||
|
||||
freeMarkerConfigurer.setConfiguration(configuration);
|
||||
return freeMarkerConfigurer;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FreeMarkerViewResolver freeMarkerViewResolver() {
|
||||
FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
|
||||
resolver.setPrefix("");
|
||||
resolver.setSuffix(".html");
|
||||
resolver.setContentType("text/html; charset=UTF-8");
|
||||
resolver.setRequestContextAttribute("request"); // 将上下文路径注入request变量
|
||||
resolver.setExposeSessionAttributes(true); // 将session属性展示
|
||||
return resolver;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.cym.config;
|
||||
|
||||
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
|
||||
import jakarta.servlet.MultipartConfigElement;
|
||||
|
||||
@Configuration
|
||||
public class MultipartConfig {
|
||||
|
||||
@Bean
|
||||
public MultipartConfigElement multipartConfigElement() {
|
||||
MultipartConfigFactory factory = new MultipartConfigFactory();
|
||||
|
||||
// 置文件大小限制 ,超出此大小页面会抛出异常信息
|
||||
factory.setMaxFileSize(DataSize.ofGigabytes(5)); // KB,MB
|
||||
// 设置总上传数据总大小
|
||||
factory.setMaxRequestSize(DataSize.ofGigabytes(5));
|
||||
// 设置文件临时文件夹路径
|
||||
factory.setLocation(System.getProperty("java.io.tmpdir"));
|
||||
// 如果文件大于这个值,将以文件的形式存储,如果小/于这个值文件将存储在内存中,默认为0
|
||||
// factory.setMaxRequestSize(0);
|
||||
return factory.createMultipartConfig();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.cym.controller.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.cym.bean.Page;
|
||||
import com.cym.ext.ExampleExt;
|
||||
import com.cym.model.Admin;
|
||||
import com.cym.model.Example;
|
||||
import com.cym.service.ExampleService;
|
||||
import com.cym.utils.BaseController;
|
||||
import com.cym.utils.JsonResult;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/adminPage/example")
|
||||
public class ExampleController extends BaseController {
|
||||
@Autowired
|
||||
ExampleService exampleService;
|
||||
|
||||
@RequestMapping("")
|
||||
public ModelAndView index(ModelAndView modelAndView, Page page) {
|
||||
page = exampleService.search(page);
|
||||
|
||||
List<ExampleExt> exts = new ArrayList<ExampleExt>();
|
||||
for (Example example : (List<Example>) page.getList()) {
|
||||
ExampleExt exampleExt = new ExampleExt();
|
||||
BeanUtil.copyProperties(example, exampleExt);
|
||||
|
||||
exampleExt.setAdmin(jpaHelper.findById(example.getAdminId(), Admin.class));
|
||||
|
||||
exts.add(exampleExt);
|
||||
}
|
||||
page.setList(exts);
|
||||
|
||||
|
||||
modelAndView.addObject("adminList", jpaHelper.findAll(Admin.class));
|
||||
modelAndView.addObject("page", page);
|
||||
modelAndView.setViewName("/example/index");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping("addOver")
|
||||
@ResponseBody
|
||||
public JsonResult addOver(Example example) {
|
||||
|
||||
jpaHelper.insertOrUpdate(example);
|
||||
|
||||
return renderSuccess();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("detail")
|
||||
@ResponseBody
|
||||
public JsonResult detail(String id) {
|
||||
Example example = jpaHelper.findById(id, Example.class);
|
||||
ExampleExt exampleExt = new ExampleExt();
|
||||
BeanUtil.copyProperties(example, exampleExt);
|
||||
|
||||
exampleExt.setAdmin(jpaHelper.findById(example.getAdminId(), Admin.class));
|
||||
|
||||
return renderSuccess(exampleExt);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping("del")
|
||||
@ResponseBody
|
||||
public JsonResult del(String id) {
|
||||
jpaHelper.deleteById(id, Example.class);
|
||||
|
||||
return renderSuccess();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.cym.ext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cym.model.Admin;
|
||||
import com.cym.utils.MenuUtils.Menu;
|
||||
import com.cym.utils.MenuUtils.MenuCategory;
|
||||
|
||||
public class AdminExt extends Admin {
|
||||
|
||||
private static final long serialVersionUID = 1137434496709241566L;
|
||||
|
||||
List<MenuCategory> menuCategoryList;
|
||||
|
||||
List<Menu> menuList;
|
||||
|
||||
List<NameValue> nameValues;
|
||||
|
||||
|
||||
public List<NameValue> getNameValues() {
|
||||
return nameValues;
|
||||
}
|
||||
|
||||
public void setNameValues(List<NameValue> nameValues) {
|
||||
this.nameValues = nameValues;
|
||||
}
|
||||
|
||||
public List<MenuCategory> getMenuCategoryList() {
|
||||
return menuCategoryList;
|
||||
}
|
||||
|
||||
public void setMenuCategoryList(List<MenuCategory> menuCategoryList) {
|
||||
this.menuCategoryList = menuCategoryList;
|
||||
}
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public List<Menu> getMenuList() {
|
||||
return menuList;
|
||||
}
|
||||
|
||||
public void setMenuList(List<Menu> menuList) {
|
||||
this.menuList = menuList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.cym.ext;
|
||||
|
||||
import com.cym.model.Admin;
|
||||
import com.cym.model.Example;
|
||||
|
||||
public class ExampleExt extends Example {
|
||||
|
||||
Admin admin;
|
||||
|
||||
public Admin getAdmin() {
|
||||
return admin;
|
||||
}
|
||||
|
||||
public void setAdmin(Admin admin) {
|
||||
this.admin = admin;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.cym.ext;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class NameValue implements Serializable {
|
||||
private static final long serialVersionUID = 7601908525981573453L;
|
||||
|
||||
String name;
|
||||
String value;
|
||||
|
||||
public NameValue() {
|
||||
|
||||
}
|
||||
|
||||
public NameValue(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.cym.ext;
|
||||
|
||||
import com.cym.model.Level;
|
||||
import com.cym.model.User;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Schema(description = "用户Ext")
|
||||
public class UserExt extends User {
|
||||
private static final long serialVersionUID = 3218155943288312071L;
|
||||
|
||||
@Schema(description = "用户等级")
|
||||
Level level;
|
||||
@Schema(description = "域名数")
|
||||
Long domainCount;
|
||||
@Schema(description = "四层转发数")
|
||||
Long upstreamCount;
|
||||
@Schema(description = "证书数")
|
||||
Long certCount;
|
||||
@Schema(description = "推广url")
|
||||
String parentUrl;
|
||||
|
||||
@Schema(description = "主机数量")
|
||||
Long machineCount;
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public Long getMachineCount() {
|
||||
return machineCount;
|
||||
}
|
||||
|
||||
public void setMachineCount(Long machineCount) {
|
||||
this.machineCount = machineCount;
|
||||
}
|
||||
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Level level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public Long getDomainCount() {
|
||||
return domainCount;
|
||||
}
|
||||
|
||||
public void setDomainCount(Long domainCount) {
|
||||
this.domainCount = domainCount;
|
||||
}
|
||||
|
||||
public Long getUpstreamCount() {
|
||||
return upstreamCount;
|
||||
}
|
||||
|
||||
public void setUpstreamCount(Long upstreamCount) {
|
||||
this.upstreamCount = upstreamCount;
|
||||
}
|
||||
|
||||
public Long getCertCount() {
|
||||
return certCount;
|
||||
}
|
||||
|
||||
public void setCertCount(Long certCount) {
|
||||
this.certCount = certCount;
|
||||
}
|
||||
|
||||
public String getParentUrl() {
|
||||
return parentUrl;
|
||||
}
|
||||
|
||||
public void setParentUrl(String parentUrl) {
|
||||
this.parentUrl = parentUrl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.cym.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.cym.bean.CreateTime;
|
||||
import com.cym.bean.InitValue;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Schema(description = "管理员")
|
||||
@Entity
|
||||
public class Admin implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4917355177911155544L;
|
||||
|
||||
@Id
|
||||
String id;
|
||||
|
||||
@Schema(description = "用户名")
|
||||
@Column(unique = true)
|
||||
String name;
|
||||
|
||||
@Schema(description = "密码")
|
||||
String pass;
|
||||
|
||||
@Schema(description = "电话")
|
||||
String phone;
|
||||
@Schema(description = "邮箱")
|
||||
String email;
|
||||
|
||||
@Schema(description = "自动登录key")
|
||||
String autoKey;
|
||||
|
||||
@CreateTime
|
||||
Long createTime;
|
||||
|
||||
@InitValue("0")
|
||||
@Schema(description = "类型 0:普通管理员 1:超级管理员")
|
||||
Integer type;
|
||||
|
||||
@Schema(description = "tg对话id")
|
||||
String chatId;
|
||||
|
||||
@Schema(description = "api token")
|
||||
String token;
|
||||
|
||||
@Schema(description = "token有效期")
|
||||
Long tokenExpiresTime;
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public Long getTokenExpiresTime() {
|
||||
return tokenExpiresTime;
|
||||
}
|
||||
|
||||
public void setTokenExpiresTime(Long tokenExpiresTime) {
|
||||
this.tokenExpiresTime = tokenExpiresTime;
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public void setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
// public Integer getType() {
|
||||
// return type;
|
||||
// }
|
||||
//
|
||||
// public void setType(Integer type) {
|
||||
// this.type = type;
|
||||
// }
|
||||
|
||||
public String getAutoKey() {
|
||||
return autoKey;
|
||||
}
|
||||
|
||||
public void setAutoKey(String autoKey) {
|
||||
this.autoKey = autoKey;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPass() {
|
||||
return pass;
|
||||
}
|
||||
|
||||
public void setPass(String pass) {
|
||||
this.pass = pass;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.cym.model;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Schema(description = "演示表")
|
||||
@Entity
|
||||
public class Example {
|
||||
@Id
|
||||
String id;
|
||||
|
||||
@Schema(description = "名称")
|
||||
String name;
|
||||
|
||||
@Schema(description = "描述")
|
||||
String descr;
|
||||
@Schema(description = "管理员id")
|
||||
String adminId;
|
||||
|
||||
|
||||
|
||||
public String getAdminId() {
|
||||
return adminId;
|
||||
}
|
||||
|
||||
public void setAdminId(String adminId) {
|
||||
this.adminId = adminId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescr() {
|
||||
return descr;
|
||||
}
|
||||
|
||||
public void setDescr(String descr) {
|
||||
this.descr = descr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.cym.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
import com.cym.bean.CreateTime;
|
||||
import com.cym.bean.InitValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.SchemaProperty;
|
||||
|
||||
@Schema(description ="用户等级")
|
||||
@Entity
|
||||
public class Level implements Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 105453908518958974L;
|
||||
|
||||
@Schema(description ="主键")
|
||||
@Id
|
||||
String id;
|
||||
|
||||
@Schema(description ="名称")
|
||||
String name;
|
||||
|
||||
@Schema(description ="类型 0:折扣 1:扣减金额")
|
||||
@InitValue("0")
|
||||
Integer type;
|
||||
|
||||
@Schema(description ="折扣")
|
||||
Double discount;
|
||||
|
||||
// @InitValue("0")
|
||||
// @Schema(description ="扣减金额(CNY)")
|
||||
// Double subtractionCny;
|
||||
|
||||
@InitValue("0")
|
||||
@Schema(description ="扣减金额(USD)")
|
||||
Double subtractionUsd;
|
||||
|
||||
@CreateTime
|
||||
Long createTime;
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
// public Double getSubtractionCny() {
|
||||
// return subtractionCny;
|
||||
// }
|
||||
//
|
||||
// public void setSubtractionCny(Double subtractionCny) {
|
||||
// this.subtractionCny = subtractionCny;
|
||||
// }
|
||||
|
||||
public Double getSubtractionUsd() {
|
||||
return subtractionUsd;
|
||||
}
|
||||
|
||||
public void setSubtractionUsd(Double subtractionUsd) {
|
||||
this.subtractionUsd = subtractionUsd;
|
||||
}
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Double getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
|
||||
public void setDiscount(Double discount) {
|
||||
this.discount = discount;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,482 @@
|
||||
package com.cym.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
import com.cym.bean.CreateTime;
|
||||
import com.cym.bean.InitValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.SchemaProperty;
|
||||
|
||||
@Schema(description ="用户")
|
||||
@Entity
|
||||
public class User implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3591882129154972699L;
|
||||
|
||||
@Schema(description ="主键")
|
||||
@Id
|
||||
String id;
|
||||
@Schema(description ="用户名")
|
||||
@Column(unique = true)
|
||||
String name;
|
||||
@Schema(description ="用户真实名称")
|
||||
String realname;
|
||||
@Schema(description ="地址")
|
||||
String addr;
|
||||
|
||||
/*-----------OEM信息----------*/
|
||||
@Schema(description ="访问域名")
|
||||
String host;
|
||||
@Schema(description ="公司名")
|
||||
String companyName;
|
||||
@Schema(description ="版权")
|
||||
String copyright;
|
||||
|
||||
@Schema(description ="qq")
|
||||
String qq;
|
||||
@Schema(description ="电话")
|
||||
String phone;
|
||||
@Schema(description ="邮箱")
|
||||
String email;
|
||||
@Schema(description ="密码")
|
||||
String pass;
|
||||
|
||||
@Schema(description ="货币类型 CNY:人民币 USD:美元")
|
||||
@InitValue("CNY")
|
||||
String moneyType;
|
||||
|
||||
@Schema(description ="余额")
|
||||
@Column(columnDefinition = "decimal(20,2)")
|
||||
@InitValue("0")
|
||||
Double money;
|
||||
|
||||
@Schema(description ="分润(美元)")
|
||||
@InitValue("0")
|
||||
Double profitUsd;
|
||||
|
||||
|
||||
@Schema(description ="注册ip")
|
||||
String registIp;
|
||||
|
||||
@Schema(description ="注册时间")
|
||||
Long registTime;
|
||||
|
||||
@Schema(description ="实名认证状态 0:未认证 1:认证中 2:已认证 3:认证失败")
|
||||
@InitValue("0")
|
||||
Integer realNameStatus;
|
||||
|
||||
@Schema(description ="推广人id")
|
||||
String parentUserId;
|
||||
|
||||
@Schema(description ="api key")
|
||||
String apiKey;
|
||||
|
||||
@Schema(description ="api apiSecret")
|
||||
String apiSecret;
|
||||
|
||||
@Schema(description ="api token")
|
||||
String token;
|
||||
|
||||
@Schema(description ="token有效期")
|
||||
Long tokenExpiresTime;
|
||||
|
||||
@Schema(description ="用户等级id")
|
||||
String levelId;
|
||||
|
||||
@Schema(description ="身份证号码")
|
||||
String idCard;
|
||||
|
||||
@Schema(description ="身份证正面")
|
||||
String cardFront;
|
||||
|
||||
@Schema(description ="身份证背面")
|
||||
String cardBack;
|
||||
|
||||
@Schema(description ="手持身份证照片")
|
||||
String cardHand;
|
||||
|
||||
@Schema(description ="自动登录key")
|
||||
String autoKey;
|
||||
|
||||
@Schema(description ="创建时间")
|
||||
@CreateTime
|
||||
Long createTime;
|
||||
|
||||
@Schema(description ="是否从fk同步过来")
|
||||
@InitValue("false")
|
||||
Boolean fromFk;
|
||||
|
||||
@InitValue("0")
|
||||
@Schema(description ="保证金")
|
||||
Double ensureMoney;
|
||||
|
||||
@Schema(description ="保证金时间")
|
||||
Long ensureMoneyTime;
|
||||
|
||||
@InitValue("false")
|
||||
@Schema(description ="是否长期合作伙伴")
|
||||
Boolean longTime;
|
||||
|
||||
@Schema(description ="tg对话id")
|
||||
String chatId;
|
||||
|
||||
@Schema(description ="短信条数")
|
||||
@InitValue("0")
|
||||
Long smsCount;
|
||||
|
||||
@Schema(description ="使用短信通知")
|
||||
@InitValue("false")
|
||||
Boolean smsNotice;
|
||||
|
||||
|
||||
// acme-dns需要的参数
|
||||
String username;
|
||||
String password;
|
||||
String fulldomain;
|
||||
String subdomain;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getFulldomain() {
|
||||
return fulldomain;
|
||||
}
|
||||
|
||||
public void setFulldomain(String fulldomain) {
|
||||
this.fulldomain = fulldomain;
|
||||
}
|
||||
|
||||
public String getSubdomain() {
|
||||
return subdomain;
|
||||
}
|
||||
|
||||
public void setSubdomain(String subdomain) {
|
||||
this.subdomain = subdomain;
|
||||
}
|
||||
|
||||
public Boolean getSmsNotice() {
|
||||
return smsNotice;
|
||||
}
|
||||
|
||||
public void setSmsNotice(Boolean smsNotice) {
|
||||
this.smsNotice = smsNotice;
|
||||
}
|
||||
|
||||
public Long getSmsCount() {
|
||||
return smsCount;
|
||||
}
|
||||
|
||||
public void setSmsCount(Long smsCount) {
|
||||
this.smsCount = smsCount;
|
||||
}
|
||||
|
||||
public Double getProfitUsd() {
|
||||
return profitUsd;
|
||||
}
|
||||
|
||||
public void setProfitUsd(Double profitUsd) {
|
||||
this.profitUsd = profitUsd;
|
||||
}
|
||||
|
||||
public String getChatId() {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
public void setChatId(String chatId) {
|
||||
this.chatId = chatId;
|
||||
}
|
||||
|
||||
public String getCopyright() {
|
||||
return copyright;
|
||||
}
|
||||
|
||||
public void setCopyright(String copyright) {
|
||||
this.copyright = copyright;
|
||||
}
|
||||
|
||||
public Boolean getLongTime() {
|
||||
return longTime;
|
||||
}
|
||||
|
||||
public void setLongTime(Boolean longTime) {
|
||||
this.longTime = longTime;
|
||||
}
|
||||
|
||||
public Double getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(Double money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public Double getEnsureMoney() {
|
||||
return ensureMoney;
|
||||
}
|
||||
|
||||
public void setEnsureMoney(Double ensureMoney) {
|
||||
this.ensureMoney = ensureMoney;
|
||||
}
|
||||
|
||||
public Long getEnsureMoneyTime() {
|
||||
return ensureMoneyTime;
|
||||
}
|
||||
|
||||
public void setEnsureMoneyTime(Long ensureMoneyTime) {
|
||||
this.ensureMoneyTime = ensureMoneyTime;
|
||||
}
|
||||
|
||||
public String getCardHand() {
|
||||
return cardHand;
|
||||
}
|
||||
|
||||
public void setCardHand(String cardHand) {
|
||||
this.cardHand = cardHand;
|
||||
}
|
||||
|
||||
public Boolean getFromFk() {
|
||||
return fromFk;
|
||||
}
|
||||
|
||||
public void setFromFk(Boolean fromFk) {
|
||||
this.fromFk = fromFk;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public Long getRegistTime() {
|
||||
return registTime;
|
||||
}
|
||||
|
||||
public void setRegistTime(Long registTime) {
|
||||
this.registTime = registTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getAutoKey() {
|
||||
return autoKey;
|
||||
}
|
||||
|
||||
public void setAutoKey(String autoKey) {
|
||||
this.autoKey = autoKey;
|
||||
}
|
||||
|
||||
public String getIdCard() {
|
||||
return idCard;
|
||||
}
|
||||
|
||||
public void setIdCard(String idCard) {
|
||||
this.idCard = idCard;
|
||||
}
|
||||
|
||||
public String getCardFront() {
|
||||
return cardFront;
|
||||
}
|
||||
|
||||
public void setCardFront(String cardFront) {
|
||||
this.cardFront = cardFront;
|
||||
}
|
||||
|
||||
public String getCardBack() {
|
||||
return cardBack;
|
||||
}
|
||||
|
||||
public void setCardBack(String cardBack) {
|
||||
this.cardBack = cardBack;
|
||||
}
|
||||
|
||||
// public String getAdminId() {
|
||||
// return adminId;
|
||||
// }
|
||||
//
|
||||
// public void setAdminId(String adminId) {
|
||||
// this.adminId = adminId;
|
||||
// }
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getLevelId() {
|
||||
return levelId;
|
||||
}
|
||||
|
||||
public void setLevelId(String levelId) {
|
||||
this.levelId = levelId;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public String getApiSecret() {
|
||||
return apiSecret;
|
||||
}
|
||||
|
||||
public void setApiSecret(String apiSecret) {
|
||||
this.apiSecret = apiSecret;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public Long getTokenExpiresTime() {
|
||||
return tokenExpiresTime;
|
||||
}
|
||||
|
||||
public void setTokenExpiresTime(Long tokenExpiresTime) {
|
||||
this.tokenExpiresTime = tokenExpiresTime;
|
||||
}
|
||||
|
||||
public String getParentUserId() {
|
||||
return parentUserId;
|
||||
}
|
||||
|
||||
public void setParentUserId(String parentUserId) {
|
||||
this.parentUserId = parentUserId;
|
||||
}
|
||||
|
||||
// public Integer getMoneyType() {
|
||||
// return moneyType;
|
||||
// }
|
||||
//
|
||||
// public void setMoneyType(Integer moneyType) {
|
||||
// this.moneyType = moneyType;
|
||||
// }
|
||||
|
||||
public Integer getRealNameStatus() {
|
||||
return realNameStatus;
|
||||
}
|
||||
|
||||
public void setRealNameStatus(Integer realNameStatus) {
|
||||
this.realNameStatus = realNameStatus;
|
||||
}
|
||||
|
||||
public String getRegistIp() {
|
||||
return registIp;
|
||||
}
|
||||
|
||||
public void setRegistIp(String registIp) {
|
||||
this.registIp = registIp;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPass() {
|
||||
return pass;
|
||||
}
|
||||
|
||||
public void setPass(String pass) {
|
||||
this.pass = pass;
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return realname;
|
||||
}
|
||||
|
||||
public void setRealname(String realname) {
|
||||
this.realname = realname;
|
||||
}
|
||||
|
||||
public String getAddr() {
|
||||
return addr;
|
||||
}
|
||||
|
||||
public void setAddr(String addr) {
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
public String getCompanyName() {
|
||||
return companyName;
|
||||
}
|
||||
|
||||
public void setCompanyName(String companyName) {
|
||||
this.companyName = companyName;
|
||||
}
|
||||
|
||||
public String getQq() {
|
||||
return qq;
|
||||
}
|
||||
|
||||
public void setQq(String qq) {
|
||||
this.qq = qq;
|
||||
}
|
||||
|
||||
public String getMoneyType() {
|
||||
return moneyType;
|
||||
}
|
||||
|
||||
public void setMoneyType(String moneyType) {
|
||||
this.moneyType = moneyType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.cym.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cym.bean.Page;
|
||||
import com.cym.model.Example;
|
||||
import com.cym.utils.JpaHelper;
|
||||
|
||||
@Service
|
||||
public class ExampleService {
|
||||
@Autowired
|
||||
JpaHelper jpaHelper;
|
||||
|
||||
public Page search(Page page) {
|
||||
page = jpaHelper.findPageByQuery(page, Example.class);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.cym.utils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import com.cym.bean.Page;
|
||||
import com.cym.ext.AdminExt;
|
||||
import com.cym.ext.UserExt;
|
||||
import com.cym.model.User;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* Author: D.Yang Email: koyangslash@gmail.com Date: 16/10/9 Time: 下午1:37
|
||||
* Describe: 基础控制器
|
||||
*/
|
||||
@Component
|
||||
public class BaseController {
|
||||
@Autowired
|
||||
public JpaHelper jpaHelper;
|
||||
|
||||
public JsonResult renderError() {
|
||||
JsonResult result = new JsonResult();
|
||||
result.setSuccess(false);
|
||||
result.setStatus("200");
|
||||
result.setTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
;
|
||||
return result;
|
||||
}
|
||||
|
||||
public JsonResult renderError(String msg) {
|
||||
JsonResult result = renderError();
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
public JsonResult renderSuccess() {
|
||||
JsonResult result = new JsonResult();
|
||||
result.setSuccess(true);
|
||||
result.setStatus("200");
|
||||
result.setTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
return result;
|
||||
}
|
||||
|
||||
public JsonResult renderSuccess(Object obj) {
|
||||
JsonResult result = renderSuccess();
|
||||
result.setObj(obj);
|
||||
return result;
|
||||
}
|
||||
|
||||
public AdminExt getAdmin() {
|
||||
HttpSession httpSession = getHttpSession();
|
||||
if (httpSession != null) {
|
||||
AdminExt adminExt = (AdminExt) httpSession.getAttribute("adminLogin");
|
||||
return adminExt;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getAdminId() {
|
||||
AdminExt adminExt = getAdmin();
|
||||
return adminExt != null ? adminExt.getId() : null;
|
||||
}
|
||||
|
||||
public String getLoginIp() {
|
||||
HttpSession httpSession = getHttpSession();
|
||||
if (httpSession != null) {
|
||||
return (String) getHttpSession().getAttribute("loginIp");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
User user = getUser();
|
||||
return user != null ? user.getId() : null;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
UserExt userExt = (UserExt) getHttpSession().getAttribute("userLogin");
|
||||
if (userExt != null) {
|
||||
return jpaHelper.findById(userExt.getId(), User.class);
|
||||
} else {
|
||||
String token = getHttpServletRequest().getHeader("token");
|
||||
if (StrUtil.isNotEmpty(token)) {
|
||||
return jpaHelper.findOneByQuery(new ConditionAndWrapper().eq(User::getToken, token), User.class);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Page buildPage(Integer pageNum, Integer pageSize) {
|
||||
Page page = new Page<>();
|
||||
if (pageNum != null) {
|
||||
page.setPageNum(pageNum);
|
||||
}
|
||||
if (pageSize != null) {
|
||||
page.setPageSize(pageSize);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
public String removeHttp(String str) {
|
||||
if (StrUtil.isNotEmpty(str)) {
|
||||
return str.replace("http://", "").replace("https://", "").replace("/", "");
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public HttpSession getHttpSession() {
|
||||
ServletRequestAttributes requestAttributes = ServletRequestAttributes.class.cast(RequestContextHolder.getRequestAttributes());
|
||||
if (requestAttributes != null) {
|
||||
HttpServletRequest request = requestAttributes.getRequest();
|
||||
HttpSession httpSession = request.getSession();
|
||||
return httpSession;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HttpServletRequest getHttpServletRequest() {
|
||||
ServletRequestAttributes requestAttributes = ServletRequestAttributes.class.cast(RequestContextHolder.getRequestAttributes());
|
||||
HttpServletRequest request = requestAttributes.getRequest();
|
||||
|
||||
return request;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.cym.utils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* Author: D.Yang Email: koyangslash@gmail.com Date: 16/8/31 Time: 下午5:50
|
||||
* Describe: 封装Json返回信息
|
||||
*/
|
||||
@Schema(description = "返回结果")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class JsonResult<T> {
|
||||
@Schema(description = "请求结果")
|
||||
private boolean success;
|
||||
@Schema(description = "请求状态 200:请求成功 401:token无效 500:服务器错误")
|
||||
private String status;
|
||||
@Schema(description = "错误信息")
|
||||
private String msg;
|
||||
@Schema(description = "时间")
|
||||
private String time;
|
||||
@Schema(description = "返回内容")
|
||||
private T obj;
|
||||
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return JSONUtil.toJsonStr(this);
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public T getObj() {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public void setObj(T obj) {
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
package com.cym.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MenuUtils {
|
||||
// List<MenuCategory> menuCategoryList;
|
||||
|
||||
public List<MenuCategory> getAll() {
|
||||
List<MenuCategory> menuCategoryList = new ArrayList<>();
|
||||
// DNS管理
|
||||
MenuCategory menuCategory = new MenuCategory("DNS管理", "other");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/dns?pageSize=50", "DNS管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/hwKey?pageSize=20", "华为key管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/lineGroup?pageSize=20", "线路组"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/lineRoute?pageSize=20", "线路组解析"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
// 服务器管理
|
||||
menuCategory = new MenuCategory("服务器管理", "system");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/node?pageSize=50", "节点管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/nodeStatus?pageSize=50", "节点状态"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/property?pageSize=50", "资产管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/area?pageSize=20", "地域管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/ruleTab?", "缓存规则"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/ip?pageSize=20", "IP管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/task?pageSize=20", "同步任务"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
// 站点管理
|
||||
menuCategory = new MenuCategory("站点管理", "user");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/domainAdmin?pageSize=20", "域名列表"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/upstreamAdmin?pageSize=20", "四层转发"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/certAdmin?pageSize=20", "证书列表"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/dnsApi?pageSize=20", "DNS API"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/transfer?pageSize=20", "中转管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/statsTab?", "数据统计"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/domainRank?", "域名排行"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/refresh?", "刷新缓存"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
// 套餐管理
|
||||
menuCategory = new MenuCategory("套餐管理", "product");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/product?pageSize=20", "套餐管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/orderAdmin?pageSize=20", "售出套餐"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/customOrder?pageSize=20", "自定义套餐"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
// IDC管理
|
||||
menuCategory = new MenuCategory("IDC管理", "product");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/machineOrderAdmin?pageSize=20", "售出主机"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/machine?pageSize=50", "服务器产品"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/machineVps?pageSize=50", "云主机产品"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/machineRoom?pageSize=20", "机房管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/machineProvider?pageSize=20", "供应商管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/icp?pageSize=20", "ICP白名单"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
// 财务管理
|
||||
menuCategory = new MenuCategory("财务管理", "user");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/consumeRecord?pageSize=20", "消费充值记录"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
// 用户管理
|
||||
menuCategory = new MenuCategory("用户管理", "user");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/user?pageSize=20", "用户管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/admin?pageSize=20", "管理员管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/level?pageSize=20", "用户等级管理"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/workOrder?pageSize=20", "工单管理"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
// 系统设置
|
||||
menuCategory = new MenuCategory("系统设置", "system");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/errorPage?", "错误页面"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/quartzJob?pageSize=50", "定时任务"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
// 日志管理
|
||||
menuCategory = new MenuCategory("日志管理", "other");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/dnsOperationLog?pageSize=50", "DNS操作日志"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/operationLog?pageSize=50", "操作日志"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/domainFreeCheck?pageSize=50", "违规监控"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/checkLog?pageSize=50", "监控记录"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/checkLogRank?pageSize=50", "监控排行"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
// 邮件管理
|
||||
menuCategory = new MenuCategory("邮件管理", "other");
|
||||
menuCategory.getMenus().add(new Menu("adminPage/emailSendLog?pageSize=20", "邮件日志"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/emailTemplate?pageSize=20", "邮件模板"));
|
||||
menuCategory.getMenus().add(new Menu("adminPage/telegramSendLog?pageSize=20", "Telegram日志"));
|
||||
menuCategoryList.add(menuCategory);
|
||||
|
||||
return menuCategoryList;
|
||||
}
|
||||
|
||||
public List<MenuCategory> getByUrls(List<String> urls) {
|
||||
List<MenuCategory> menuCategoryUsers = getAll();
|
||||
|
||||
for (MenuCategory menuCategory : menuCategoryUsers) {
|
||||
for (Menu menu : menuCategory.getMenus()) {
|
||||
menu.setShow(false);
|
||||
if (urls.contains(menu.getUrl())) {
|
||||
menu.setShow(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return menuCategoryUsers;
|
||||
}
|
||||
|
||||
public List<Menu> getAllMenu() {
|
||||
List<Menu> menus = new ArrayList<>();
|
||||
for (MenuCategory menuCategory : getAll()) {
|
||||
menus.addAll(menuCategory.getMenus());
|
||||
}
|
||||
|
||||
return menus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单分类
|
||||
*
|
||||
* @author CYM
|
||||
*
|
||||
*/
|
||||
public static class MenuCategory implements Serializable {
|
||||
private static final long serialVersionUID = 3175408543485317759L;
|
||||
|
||||
private String name;
|
||||
|
||||
private String group;
|
||||
|
||||
private List<Menu> menus;
|
||||
|
||||
public MenuCategory(String name, String group) {
|
||||
this.name = name;
|
||||
this.group = group;
|
||||
this.menus = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Menu> getMenus() {
|
||||
return menus;
|
||||
}
|
||||
|
||||
public void setMenus(List<Menu> menus) {
|
||||
this.menus = menus;
|
||||
}
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单
|
||||
*
|
||||
* @author CYM
|
||||
*
|
||||
*/
|
||||
public static class Menu implements Serializable {
|
||||
private static final long serialVersionUID = 6848241258354172694L;
|
||||
|
||||
private String url;
|
||||
private String name;
|
||||
private Boolean show;
|
||||
|
||||
public Menu(String url, String name) {
|
||||
this.url = url;
|
||||
this.name = name;
|
||||
this.show = true;
|
||||
}
|
||||
|
||||
public Boolean getShow() {
|
||||
return show;
|
||||
}
|
||||
|
||||
public void setShow(Boolean show) {
|
||||
this.show = show;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.cym.utils.cert;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author ZhangSan_Plus
|
||||
* @version 1.0
|
||||
* @className SSLEmailDTO
|
||||
* @description
|
||||
* @date 2021/5/20 9:57
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CertExportEmailDTO implements Serializable {
|
||||
private List<CertExportEmailVO> certExportEmailVOS;
|
||||
private String[] email;
|
||||
private Map<String, Integer> maps;
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
package com.cym.utils.cert;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ZhangSan_Plus
|
||||
* @version 1.0
|
||||
* @className CertExportEmailVO
|
||||
* @description
|
||||
* @date 2022/8/29 15:17
|
||||
**/
|
||||
@Data
|
||||
public class CertExportEmailVO {
|
||||
|
||||
/**
|
||||
* 证书响应状态
|
||||
*/
|
||||
private String success;
|
||||
private String ctUrl;
|
||||
private String commonUrl;
|
||||
/**
|
||||
* 信任状态
|
||||
*/
|
||||
private String trustStatus;
|
||||
/**
|
||||
* 通用名称
|
||||
*/
|
||||
private String commonName;
|
||||
/**
|
||||
* 加密算法
|
||||
*/
|
||||
private String encryptionAlgorithm;
|
||||
/**
|
||||
* 签名算法
|
||||
*/
|
||||
private String signatureAlgorithm;
|
||||
/**
|
||||
* 证书透明(CT)
|
||||
*/
|
||||
private String certificateTransparency;
|
||||
/**
|
||||
* 吊销状态
|
||||
*/
|
||||
private String revocationStatus;
|
||||
private String ocspBindState;
|
||||
private String ocspMustBind;
|
||||
private String isSNI;
|
||||
private String weakKey;
|
||||
//主题信息
|
||||
private String subjectCN;
|
||||
private String subjectO;
|
||||
private String subjectOU;
|
||||
private String subjectL;
|
||||
private String subjectST;
|
||||
private String subjectC;
|
||||
//签发者信息
|
||||
private String issueCN;
|
||||
private String issueO;
|
||||
private String issueC;
|
||||
private String issueOU;
|
||||
//证书信息
|
||||
private String serialNumber;
|
||||
private String rootCert;
|
||||
private String algorithm;
|
||||
private String certificateType;
|
||||
private String certificateBrand;
|
||||
private String privateKeyLen;
|
||||
private String SHA1Fingerprint;
|
||||
private String SHA256Fingerprint;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private String validityPeriod;
|
||||
private String extKeyUsage;
|
||||
private List<String> sans;
|
||||
private String ocspUrl;
|
||||
private String crlUrl;
|
||||
private String caUrl;
|
||||
private String publicKey;
|
||||
private String openSSL;
|
||||
private List<CertificateChain> certificateChains;
|
||||
public String getSuccess() {
|
||||
return success;
|
||||
}
|
||||
public void setSuccess(String success) {
|
||||
this.success = success;
|
||||
}
|
||||
public String getCtUrl() {
|
||||
return ctUrl;
|
||||
}
|
||||
public void setCtUrl(String ctUrl) {
|
||||
this.ctUrl = ctUrl;
|
||||
}
|
||||
public String getCommonUrl() {
|
||||
return commonUrl;
|
||||
}
|
||||
public void setCommonUrl(String commonUrl) {
|
||||
this.commonUrl = commonUrl;
|
||||
}
|
||||
public String getTrustStatus() {
|
||||
return trustStatus;
|
||||
}
|
||||
public void setTrustStatus(String trustStatus) {
|
||||
this.trustStatus = trustStatus;
|
||||
}
|
||||
public String getCommonName() {
|
||||
return commonName;
|
||||
}
|
||||
public void setCommonName(String commonName) {
|
||||
this.commonName = commonName;
|
||||
}
|
||||
public String getEncryptionAlgorithm() {
|
||||
return encryptionAlgorithm;
|
||||
}
|
||||
public void setEncryptionAlgorithm(String encryptionAlgorithm) {
|
||||
this.encryptionAlgorithm = encryptionAlgorithm;
|
||||
}
|
||||
public String getSignatureAlgorithm() {
|
||||
return signatureAlgorithm;
|
||||
}
|
||||
public void setSignatureAlgorithm(String signatureAlgorithm) {
|
||||
this.signatureAlgorithm = signatureAlgorithm;
|
||||
}
|
||||
public String getCertificateTransparency() {
|
||||
return certificateTransparency;
|
||||
}
|
||||
public void setCertificateTransparency(String certificateTransparency) {
|
||||
this.certificateTransparency = certificateTransparency;
|
||||
}
|
||||
public String getRevocationStatus() {
|
||||
return revocationStatus;
|
||||
}
|
||||
public void setRevocationStatus(String revocationStatus) {
|
||||
this.revocationStatus = revocationStatus;
|
||||
}
|
||||
public String getOcspBindState() {
|
||||
return ocspBindState;
|
||||
}
|
||||
public void setOcspBindState(String ocspBindState) {
|
||||
this.ocspBindState = ocspBindState;
|
||||
}
|
||||
public String getOcspMustBind() {
|
||||
return ocspMustBind;
|
||||
}
|
||||
public void setOcspMustBind(String ocspMustBind) {
|
||||
this.ocspMustBind = ocspMustBind;
|
||||
}
|
||||
public String getIsSNI() {
|
||||
return isSNI;
|
||||
}
|
||||
public void setIsSNI(String isSNI) {
|
||||
this.isSNI = isSNI;
|
||||
}
|
||||
public String getWeakKey() {
|
||||
return weakKey;
|
||||
}
|
||||
public void setWeakKey(String weakKey) {
|
||||
this.weakKey = weakKey;
|
||||
}
|
||||
public String getSubjectCN() {
|
||||
return subjectCN;
|
||||
}
|
||||
public void setSubjectCN(String subjectCN) {
|
||||
this.subjectCN = subjectCN;
|
||||
}
|
||||
public String getSubjectO() {
|
||||
return subjectO;
|
||||
}
|
||||
public void setSubjectO(String subjectO) {
|
||||
this.subjectO = subjectO;
|
||||
}
|
||||
public String getSubjectOU() {
|
||||
return subjectOU;
|
||||
}
|
||||
public void setSubjectOU(String subjectOU) {
|
||||
this.subjectOU = subjectOU;
|
||||
}
|
||||
public String getSubjectL() {
|
||||
return subjectL;
|
||||
}
|
||||
public void setSubjectL(String subjectL) {
|
||||
this.subjectL = subjectL;
|
||||
}
|
||||
public String getSubjectST() {
|
||||
return subjectST;
|
||||
}
|
||||
public void setSubjectST(String subjectST) {
|
||||
this.subjectST = subjectST;
|
||||
}
|
||||
public String getSubjectC() {
|
||||
return subjectC;
|
||||
}
|
||||
public void setSubjectC(String subjectC) {
|
||||
this.subjectC = subjectC;
|
||||
}
|
||||
public String getIssueCN() {
|
||||
return issueCN;
|
||||
}
|
||||
public void setIssueCN(String issueCN) {
|
||||
this.issueCN = issueCN;
|
||||
}
|
||||
public String getIssueO() {
|
||||
return issueO;
|
||||
}
|
||||
public void setIssueO(String issueO) {
|
||||
this.issueO = issueO;
|
||||
}
|
||||
public String getIssueC() {
|
||||
return issueC;
|
||||
}
|
||||
public void setIssueC(String issueC) {
|
||||
this.issueC = issueC;
|
||||
}
|
||||
public String getIssueOU() {
|
||||
return issueOU;
|
||||
}
|
||||
public void setIssueOU(String issueOU) {
|
||||
this.issueOU = issueOU;
|
||||
}
|
||||
public String getSerialNumber() {
|
||||
return serialNumber;
|
||||
}
|
||||
public void setSerialNumber(String serialNumber) {
|
||||
this.serialNumber = serialNumber;
|
||||
}
|
||||
public String getRootCert() {
|
||||
return rootCert;
|
||||
}
|
||||
public void setRootCert(String rootCert) {
|
||||
this.rootCert = rootCert;
|
||||
}
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
public void setAlgorithm(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
public String getCertificateType() {
|
||||
return certificateType;
|
||||
}
|
||||
public void setCertificateType(String certificateType) {
|
||||
this.certificateType = certificateType;
|
||||
}
|
||||
public String getCertificateBrand() {
|
||||
return certificateBrand;
|
||||
}
|
||||
public void setCertificateBrand(String certificateBrand) {
|
||||
this.certificateBrand = certificateBrand;
|
||||
}
|
||||
public String getPrivateKeyLen() {
|
||||
return privateKeyLen;
|
||||
}
|
||||
public void setPrivateKeyLen(String privateKeyLen) {
|
||||
this.privateKeyLen = privateKeyLen;
|
||||
}
|
||||
public String getSHA1Fingerprint() {
|
||||
return SHA1Fingerprint;
|
||||
}
|
||||
public void setSHA1Fingerprint(String sHA1Fingerprint) {
|
||||
SHA1Fingerprint = sHA1Fingerprint;
|
||||
}
|
||||
public String getSHA256Fingerprint() {
|
||||
return SHA256Fingerprint;
|
||||
}
|
||||
public void setSHA256Fingerprint(String sHA256Fingerprint) {
|
||||
SHA256Fingerprint = sHA256Fingerprint;
|
||||
}
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
public String getValidityPeriod() {
|
||||
return validityPeriod;
|
||||
}
|
||||
public void setValidityPeriod(String validityPeriod) {
|
||||
this.validityPeriod = validityPeriod;
|
||||
}
|
||||
public String getExtKeyUsage() {
|
||||
return extKeyUsage;
|
||||
}
|
||||
public void setExtKeyUsage(String extKeyUsage) {
|
||||
this.extKeyUsage = extKeyUsage;
|
||||
}
|
||||
public List<String> getSans() {
|
||||
return sans;
|
||||
}
|
||||
public void setSans(List<String> sans) {
|
||||
this.sans = sans;
|
||||
}
|
||||
public String getOcspUrl() {
|
||||
return ocspUrl;
|
||||
}
|
||||
public void setOcspUrl(String ocspUrl) {
|
||||
this.ocspUrl = ocspUrl;
|
||||
}
|
||||
public String getCrlUrl() {
|
||||
return crlUrl;
|
||||
}
|
||||
public void setCrlUrl(String crlUrl) {
|
||||
this.crlUrl = crlUrl;
|
||||
}
|
||||
public String getCaUrl() {
|
||||
return caUrl;
|
||||
}
|
||||
public void setCaUrl(String caUrl) {
|
||||
this.caUrl = caUrl;
|
||||
}
|
||||
public String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
public void setPublicKey(String publicKey) {
|
||||
this.publicKey = publicKey;
|
||||
}
|
||||
public String getOpenSSL() {
|
||||
return openSSL;
|
||||
}
|
||||
public void setOpenSSL(String openSSL) {
|
||||
this.openSSL = openSSL;
|
||||
}
|
||||
public List<CertificateChain> getCertificateChains() {
|
||||
return certificateChains;
|
||||
}
|
||||
public void setCertificateChains(List<CertificateChain> certificateChains) {
|
||||
this.certificateChains = certificateChains;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.cym.utils.cert;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CertInfoDTO {
|
||||
|
||||
List<Map<String, String>> pactMap;
|
||||
|
||||
String webTitle;
|
||||
String webServer;
|
||||
String ipAddr;
|
||||
String icon;
|
||||
List<CertExportEmailVO> certExportEmailVOS;
|
||||
String rating;
|
||||
String ats;
|
||||
String pciDss;
|
||||
String detectionTime;
|
||||
|
||||
Boolean pass;
|
||||
|
||||
public Boolean getPass() {
|
||||
return pass;
|
||||
}
|
||||
|
||||
public void setPass(Boolean pass) {
|
||||
this.pass = pass;
|
||||
}
|
||||
|
||||
public List<Map<String, String>> getPactMap() {
|
||||
return pactMap;
|
||||
}
|
||||
|
||||
public void setPactMap(List<Map<String, String>> pactMap) {
|
||||
this.pactMap = pactMap;
|
||||
}
|
||||
|
||||
public String getWebTitle() {
|
||||
return webTitle;
|
||||
}
|
||||
|
||||
public void setWebTitle(String webTitle) {
|
||||
this.webTitle = webTitle;
|
||||
}
|
||||
|
||||
public String getWebServer() {
|
||||
return webServer;
|
||||
}
|
||||
|
||||
public void setWebServer(String webServer) {
|
||||
this.webServer = webServer;
|
||||
}
|
||||
|
||||
public String getIpAddr() {
|
||||
return ipAddr;
|
||||
}
|
||||
|
||||
public void setIpAddr(String ipAddr) {
|
||||
this.ipAddr = ipAddr;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public List<CertExportEmailVO> getCertExportEmailVOS() {
|
||||
return certExportEmailVOS;
|
||||
}
|
||||
|
||||
public void setCertExportEmailVOS(List<CertExportEmailVO> certExportEmailVOS) {
|
||||
this.certExportEmailVOS = certExportEmailVOS;
|
||||
}
|
||||
|
||||
public String getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public void setRating(String rating) {
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
public String getAts() {
|
||||
return ats;
|
||||
}
|
||||
|
||||
public void setAts(String ats) {
|
||||
this.ats = ats;
|
||||
}
|
||||
|
||||
public String getPciDss() {
|
||||
return pciDss;
|
||||
}
|
||||
|
||||
public void setPciDss(String pciDss) {
|
||||
this.pciDss = pciDss;
|
||||
}
|
||||
|
||||
public String getDetectionTime() {
|
||||
return detectionTime;
|
||||
}
|
||||
|
||||
public void setDetectionTime(String detectionTime) {
|
||||
this.detectionTime = detectionTime;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.cym.utils.cert;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ZhangSan_Plus
|
||||
* @version 1.0
|
||||
* @className CertificateChain
|
||||
* @description
|
||||
* @date 2022/9/1 13:59
|
||||
**/
|
||||
@Data
|
||||
public class CertificateChain {
|
||||
private String issuedTo;
|
||||
private String issuer;
|
||||
private String encryptionAlgorithm;
|
||||
private String signAlgorithm;
|
||||
private String certFingerprint;
|
||||
private String publicKeyPINValue;
|
||||
private String validityPeriod;
|
||||
public String getIssuedTo() {
|
||||
return issuedTo;
|
||||
}
|
||||
public void setIssuedTo(String issuedTo) {
|
||||
this.issuedTo = issuedTo;
|
||||
}
|
||||
public String getIssuer() {
|
||||
return issuer;
|
||||
}
|
||||
public void setIssuer(String issuer) {
|
||||
this.issuer = issuer;
|
||||
}
|
||||
public String getEncryptionAlgorithm() {
|
||||
return encryptionAlgorithm;
|
||||
}
|
||||
public void setEncryptionAlgorithm(String encryptionAlgorithm) {
|
||||
this.encryptionAlgorithm = encryptionAlgorithm;
|
||||
}
|
||||
public String getSignAlgorithm() {
|
||||
return signAlgorithm;
|
||||
}
|
||||
public void setSignAlgorithm(String signAlgorithm) {
|
||||
this.signAlgorithm = signAlgorithm;
|
||||
}
|
||||
public String getCertFingerprint() {
|
||||
return certFingerprint;
|
||||
}
|
||||
public void setCertFingerprint(String certFingerprint) {
|
||||
this.certFingerprint = certFingerprint;
|
||||
}
|
||||
public String getPublicKeyPINValue() {
|
||||
return publicKeyPINValue;
|
||||
}
|
||||
public void setPublicKeyPINValue(String publicKeyPINValue) {
|
||||
this.publicKeyPINValue = publicKeyPINValue;
|
||||
}
|
||||
public String getValidityPeriod() {
|
||||
return validityPeriod;
|
||||
}
|
||||
public void setValidityPeriod(String validityPeriod) {
|
||||
this.validityPeriod = validityPeriod;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,839 @@
|
||||
package com.cym.utils.cert;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.ConnectException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.cym.utils.cert.ssl.Root;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
/**
|
||||
* @author ZhangSan_Plus
|
||||
* @version 1.0
|
||||
* @className CertificateDetectionUtils
|
||||
* @description
|
||||
* @date 2022/8/27 16:36
|
||||
**/
|
||||
@Component
|
||||
public class CertificateDetectionUtils {
|
||||
private static final Pattern CN_PATTERN = Pattern.compile("[\u4e00-\u9fa5]");
|
||||
private static final String HTTPS_STR = "https://";
|
||||
private static final String HTTP_STR = "http://";
|
||||
private static final String DOMAIN_NOT_MATCH_STR = "域名不匹配";
|
||||
private static final String DV_SSL_STR = "DV SSL";
|
||||
private static final String OV_SSL_STR = "OV SSL";
|
||||
private static final String EV_SSL_STR = "EV SSL";
|
||||
private static final String SERIALNUMBER_STR = "SERIALNUMBER";
|
||||
private static final String O_STR = "O";
|
||||
private static final String ST_STR = "ST";
|
||||
private static final String OU_STR = "OU";
|
||||
private static final String L_STR = "L";
|
||||
private static final String C_STR = "C";
|
||||
private static final String CN_STR = "CN";
|
||||
private static final String SHA1_AUTH_STR = "SHA-1";
|
||||
private static final String SHA256_AUTH_STR = "SHA-256";
|
||||
private static final String NORMAL_STR = "正常";
|
||||
private static final String YES_STR = "是";
|
||||
private static final String NO_STR = "否";
|
||||
private static final String SUPPORT_STR = "支持";
|
||||
private static final String NO_SUPPORT_STR = "不支持";
|
||||
|
||||
/**
|
||||
* 根据网址获取证书详细信息(包含当前网址受信任,不受信任的证书)
|
||||
*
|
||||
* @param hpUrl
|
||||
* @return com.cym.utils.cert.CertInfoDTO
|
||||
* @throws Exception
|
||||
* @author ZhangSan_Plus
|
||||
* @date 19:35 2022/9/5
|
||||
**/
|
||||
public static CertInfoDTO getCert(String hpUrl) throws Exception {
|
||||
hpUrl = hpUrl.contains(HTTP_STR) || hpUrl.contains(HTTPS_STR) ? hpUrl.replaceAll(HTTP_STR, "").replaceAll(HTTPS_STR, "").trim() : hpUrl.trim();
|
||||
hpUrl = CNRulesMate(hpUrl) ? chineseDomainNameDecoding(hpUrl) : hpUrl;
|
||||
long start = System.currentTimeMillis();
|
||||
CertInfoDTO certInfoDTO = new CertInfoDTO();
|
||||
List<Map<String, String>> pactMap = Lists.newLinkedList();
|
||||
List<CertExportEmailVO> certExportEmailVOS = Lists.newArrayList();
|
||||
// 获取受信任证书
|
||||
CertExportEmailVO certExportEmailVO = defaultDetection(hpUrl.toLowerCase());
|
||||
// 获取不受信任的证书
|
||||
// CertExportEmailVO certExportEmailVO1 = trustDetection(hpUrl.toLowerCase());
|
||||
if (StringUtils.isNotBlank(certExportEmailVO.getIssueC())) {
|
||||
pactMap.add(certCompatible(certExportEmailVO.getSuccess()));
|
||||
certExportEmailVOS.add(certExportEmailVO);
|
||||
}
|
||||
// if (StringUtils.isNotBlank(certExportEmailVO1.getCertificateType())
|
||||
// && !(StringUtils.isNotBlank(certExportEmailVO.getCommonName()) ? certExportEmailVO.getCommonUrl() : "").equals(certExportEmailVO1.getCommonUrl())) {
|
||||
// pactMap.add(certCompatible(certExportEmailVO1.getSuccess()));
|
||||
// certExportEmailVOS.add(certExportEmailVO1);
|
||||
// }
|
||||
certInfoDTO.setPactMap(pactMap);
|
||||
// 获取当前网址的title,icon,ip等信息
|
||||
Map<String, String> webInfo = getWebInfo(StringUtils.isNotBlank(certExportEmailVO.getCommonName()) ? HTTPS_STR : HTTP_STR, hpUrl);
|
||||
certInfoDTO.setWebTitle(webInfo.get("title"));
|
||||
certInfoDTO.setWebServer("-");
|
||||
certInfoDTO.setIpAddr(webInfo.get("ip"));
|
||||
certInfoDTO.setIcon(webInfo.get("favicon"));
|
||||
certInfoDTO.setCertExportEmailVOS(certExportEmailVOS);
|
||||
if (certExportEmailVOS.size() != 0) {
|
||||
String rating = getRating(certExportEmailVOS.get(0));
|
||||
String status = rating.equals("B") || rating.equals("T") ? "不合规" : "合规";
|
||||
certInfoDTO.setRating(rating);
|
||||
certInfoDTO.setAts(status);
|
||||
certInfoDTO.setPciDss(status);
|
||||
certInfoDTO.setPass(true);
|
||||
} else {
|
||||
certInfoDTO.setPass(false);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
certInfoDTO.setDetectionTime(DateUtils.formatDate(new Date(), DateUtils.DATE_DEFAULT) + " ( 耗时:" + (end - start) / 1000 + "秒 )");
|
||||
return certInfoDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取HTTPS请求连接
|
||||
*
|
||||
* @param url
|
||||
* @return javax.net.ssl.HttpsURLConnection
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 14:31 2022/9/2
|
||||
**/
|
||||
public static HttpsURLConnection getConn(URL url) {
|
||||
HttpsURLConnection conn = null;
|
||||
try {
|
||||
conn = (HttpsURLConnection) url.openConnection();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn.addRequestProperty("Accept", "*/*");
|
||||
conn.addRequestProperty("Accept-Encoding", "gzip,deflate,sdch");
|
||||
conn.addRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
|
||||
conn.addRequestProperty("Cache-Control", "max-age=0");
|
||||
conn.addRequestProperty("Connection", "keep-alive");
|
||||
conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
conn.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36");
|
||||
conn.setDoOutput(true);
|
||||
conn.setUseCaches(false);
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.setReadTimeout(10000);
|
||||
return conn;
|
||||
}
|
||||
|
||||
/***
|
||||
* 默认证书匹配(只匹配SSL证书安全的证书信息) --若证书抛出没有证书的错误会进行信任全部证书进行检测
|
||||
* --会将所有证书进行匹配包括已经过期或者证书和主域名不匹配的都会进行处理
|
||||
*
|
||||
*
|
||||
* -SSL证书会进行两次匹配规则如下 若两次证书查询的结果相同则代表该网站仅有一个RSA,若两次查询结果不相同会将证书分为 RSA1 RSA2
|
||||
*
|
||||
* @author ZhangSan_Plus
|
||||
* @date 10:04 2022/8/31
|
||||
* @param hpUrl
|
||||
* @return com.cym.utils.cert.CertExportEmailVO
|
||||
* @throws
|
||||
**/
|
||||
public static CertExportEmailVO defaultDetection(String hpUrl) throws Exception {
|
||||
URL url = new URL(HTTPS_STR + hpUrl);
|
||||
// 发起HTTPS请求
|
||||
trustAllHttpsCertificates(1);
|
||||
HttpsURLConnection conn = getConn(url);
|
||||
CertExportEmailVO certExportEmailVO = new CertExportEmailVO();
|
||||
try {
|
||||
conn.connect();
|
||||
if (Objects.nonNull(conn.getServerCertificates())) {
|
||||
Certificate[] serverCertificates = conn.getServerCertificates();
|
||||
X509Certificate certs = (X509Certificate) serverCertificates[0];
|
||||
certExportEmailVO = deal(certs, certExportEmailVO);
|
||||
String parentCert = (serverCertificates.length > 1) ? NO_STR : YES_STR;
|
||||
certExportEmailVO.setRootCert(parentCert);
|
||||
certExportEmailVO.setOcspBindState(parentCert.equals(YES_STR) ? SUPPORT_STR : NO_SUPPORT_STR);
|
||||
certExportEmailVO.setOcspMustBind(parentCert.equals(YES_STR) ? YES_STR : NO_STR);
|
||||
certExportEmailVO.setIsSNI(parentCert.equals(YES_STR) ? YES_STR : NO_STR);
|
||||
certExportEmailVO.setWeakKey(parentCert.equals(YES_STR) ? NO_STR : YES_STR);
|
||||
List<CertificateChain> certChain = getCertChain(serverCertificates, getThumbPrint(certs, SHA1_AUTH_STR).toUpperCase());
|
||||
certExportEmailVO.setCertificateChains(certChain);
|
||||
conn.disconnect();
|
||||
if (!certExportEmailVO.getCommonName().contains(hpUrl.substring(hpUrl.indexOf(".") + 1))) {
|
||||
if (!certExportEmailVO.getSans().contains(hpUrl.replaceAll("www\\.", ""))) {
|
||||
certExportEmailVO.setCommonUrl(certExportEmailVO.getCommonName());
|
||||
certExportEmailVO.setCommonName(certExportEmailVO.getCommonName() + " (不匹配)");
|
||||
certExportEmailVO.setSuccess(DOMAIN_NOT_MATCH_STR);
|
||||
certExportEmailVO.setTrustStatus(DOMAIN_NOT_MATCH_STR);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
conn.disconnect();
|
||||
}
|
||||
return certExportEmailVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 中文正则表达式
|
||||
*
|
||||
* @param countName 域名
|
||||
* @return boolean
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 10:11 2022/8/31
|
||||
**/
|
||||
public static boolean CNRulesMate(String countName) {
|
||||
Matcher m = CN_PATTERN.matcher(countName);
|
||||
if (m.find()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对包含中文的域名进行中文域名解析
|
||||
*
|
||||
* @param doMain
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 10:11 2022/8/31
|
||||
**/
|
||||
public static String chineseDomainNameDecoding(String doMain) throws Exception {
|
||||
String[] doMainPunyList = doMain.split("\\.");
|
||||
String doMainPunyCode = "";
|
||||
// 中文域名的解析
|
||||
for (int i = 0; i < doMainPunyList.length; i++) {
|
||||
if (i == doMainPunyList.length - 1) {
|
||||
if (CNRulesMate(doMainPunyList[i])) {
|
||||
doMainPunyCode += "xn--" + PunyUtils.encode(doMainPunyList[i]);
|
||||
} else {
|
||||
doMainPunyCode += doMainPunyList[i];
|
||||
}
|
||||
} else {
|
||||
if (CNRulesMate(doMainPunyList[i])) {
|
||||
doMainPunyCode += "xn--" + PunyUtils.encode(doMainPunyList[i]) + ".";
|
||||
} else {
|
||||
doMainPunyCode += doMainPunyList[i] + ".";
|
||||
}
|
||||
}
|
||||
}
|
||||
return doMainPunyCode;
|
||||
}
|
||||
|
||||
static class Verifier implements HostnameVerifier {
|
||||
|
||||
@Override
|
||||
public boolean verify(String arg0, SSLSession arg1) {
|
||||
return true; // mark everything as verified
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 信任所有证书实现类
|
||||
*/
|
||||
static class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isServerTrusted(java.security.cert.X509Certificate[] certs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isClientTrusted(java.security.cert.X509Certificate[] certs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 信任网站所有SSL证书
|
||||
*
|
||||
* @param status
|
||||
* @return void
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 10:11 2022/8/31
|
||||
**/
|
||||
private static void trustAllHttpsCertificates(Integer status) throws Exception {
|
||||
javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
|
||||
javax.net.ssl.TrustManager tm = new miTM();
|
||||
trustAllCerts[0] = tm;
|
||||
// 实例化SSL协议
|
||||
javax.net.ssl.SSLContext sc = (status == 1) ? javax.net.ssl.SSLContext.getInstance("TLSv1.2") : javax.net.ssl.SSLContext.getInstance("SSL");
|
||||
|
||||
// 实例化SSl协议 信任所有证书
|
||||
sc.init(null, trustAllCerts, null);
|
||||
javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* 证书后续处理具体规则匹配
|
||||
*
|
||||
* @param cert
|
||||
* @param xccSSLInfo
|
||||
* @return com.cym.utils.cert.CertExportEmailVO
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 19:40 2022/9/5
|
||||
**/
|
||||
public static CertExportEmailVO deal(X509Certificate cert, CertExportEmailVO xccSSLInfo) throws Exception {
|
||||
Map<String, String> certInfo = getCertInfo(cert.toString());
|
||||
List<String> sansList = new ArrayList<>();
|
||||
if (Objects.nonNull(cert.getSubjectAlternativeNames())) {
|
||||
Collection<List<?>> subjectAlternativeNames = cert.getSubjectAlternativeNames();
|
||||
subjectAlternativeNames.forEach(c -> sansList.add(c.get(1).toString()));
|
||||
}
|
||||
// Root root = JSON.parseObject(JSON.toJSONString(cert), Root.class);
|
||||
// xccSSLInfo.setCommonUrl(root.getSubjectDN().getCommonName());
|
||||
xccSSLInfo.setCommonUrl(cert.getSubjectX500Principal().getName());
|
||||
// xccSSLInfo.setCommonName(root.getSubjectDN().getCommonName());
|
||||
xccSSLInfo.setCommonName(cert.getSubjectX500Principal().getName());
|
||||
xccSSLInfo.setSignatureAlgorithm(cert.getSigAlgName());
|
||||
xccSSLInfo.setEncryptionAlgorithm(cert.toString().contains("SHA256withECDSA") ? "ECDSA 256 bits" : "RSA 2048 bits");
|
||||
xccSSLInfo.setCertificateTransparency("是 (Google: (来自证书,有效); Apple: (来自证书,有效))Firefox: (来自证书,有效))");
|
||||
xccSSLInfo.setRevocationStatus(NORMAL_STR);
|
||||
/**
|
||||
* 主题信息
|
||||
*/
|
||||
xccSSLInfo.setSubjectCN(sslSp(cert.getSubjectDN().toString(), CN_STR));
|
||||
xccSSLInfo.setSubjectO(sslSp(cert.getSubjectDN().toString(), O_STR));
|
||||
xccSSLInfo.setSubjectST(sslSp(cert.getSubjectDN().toString(), ST_STR));
|
||||
xccSSLInfo.setSubjectOU(sslSp(cert.getSubjectDN().toString(), OU_STR));
|
||||
xccSSLInfo.setSubjectL(sslSp(cert.getSubjectDN().toString(), L_STR));
|
||||
xccSSLInfo.setSubjectC(sslSp(cert.getSubjectDN().toString(), C_STR));
|
||||
|
||||
/**
|
||||
* 签发者信息
|
||||
*/
|
||||
xccSSLInfo.setIssueCN(sslSp(cert.getIssuerDN().toString(), CN_STR));
|
||||
xccSSLInfo.setIssueO(sslSp(cert.getIssuerDN().toString(), O_STR));
|
||||
xccSSLInfo.setIssueOU(sslSp(cert.getIssuerDN().toString(), OU_STR));
|
||||
xccSSLInfo.setIssueC(sslSp(cert.getIssuerDN().toString(), C_STR));
|
||||
|
||||
/**
|
||||
* 证书信息
|
||||
*/
|
||||
xccSSLInfo.setSerialNumber(certInfo.get("serialNumber"));
|
||||
xccSSLInfo.setAlgorithm(cert.getSigAlgName());
|
||||
xccSSLInfo.setCertificateType(getSSLType(cert));
|
||||
xccSSLInfo.setCertificateBrand(sslSp(cert.getIssuerDN().toString(), CN_STR).split(" ")[0]);
|
||||
xccSSLInfo.setPrivateKeyLen("2048 Bits");
|
||||
xccSSLInfo.setSHA1Fingerprint(getThumbPrint(cert, SHA1_AUTH_STR).toUpperCase());
|
||||
xccSSLInfo.setSHA256Fingerprint(getThumbPrint(cert, SHA256_AUTH_STR).toUpperCase());
|
||||
xccSSLInfo.setStartTime(DateUtils.formatDate(cert.getNotBefore(), DateUtils.DATETIME_DEFAULT));
|
||||
xccSSLInfo.setEndTime(DateUtils.formatDate(cert.getNotAfter(), DateUtils.DATETIME_DEFAULT));
|
||||
xccSSLInfo.setSuccess(DateUtils.daysBetween(new Date(), cert.getNotAfter()) > 0 && StringUtils.isBlank(xccSSLInfo.getSuccess()) ? NORMAL_STR : "已过期");
|
||||
xccSSLInfo.setTrustStatus(DateUtils.daysBetween(new Date(), cert.getNotAfter()) > 0 && StringUtils.isBlank(xccSSLInfo.getTrustStatus()) ? "可信" : "已过期");
|
||||
xccSSLInfo.setValidityPeriod(DateUtils.daysBetween(new Date(), cert.getNotAfter()) + "天");
|
||||
xccSSLInfo.setExtKeyUsage("extKeyUsage:Server authentication,Client authentication");
|
||||
xccSSLInfo.setSans(sansList);
|
||||
// xccSSLInfo.setOcspUrl((Objects.nonNull(root.getAuthorityInfoAccessExtension())) ? root.getAuthorityInfoAccessExtension().getAccessDescriptions().get(0).getAccessLocation().getName().getName() : "");
|
||||
// xccSSLInfo.setCaUrl((Objects.nonNull(root.getAuthorityInfoAccessExtension())) ? root.getAuthorityInfoAccessExtension().getAccessDescriptions().get(0).getAccessLocation().getName().getName() : "");
|
||||
xccSSLInfo.setCrlUrl(certInfo.get("crlUrl"));
|
||||
xccSSLInfo.setPublicKey(cert.getPublicKey().getFormat());
|
||||
xccSSLInfo.setOpenSSL("OpenSSL:" + "\n" + "Certificate:" + "\n" + cert);
|
||||
return xccSSLInfo;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取证书链
|
||||
*
|
||||
* @param certificates
|
||||
* @return java.util.List<com.cym.utils.cert.CertificateChain>
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 15:40 2022/9/1
|
||||
**/
|
||||
public static List<CertificateChain> getCertChain(Certificate[] certificates, String thumbPrint) throws Exception {
|
||||
List<CertificateChain> certificateChains = Lists.newArrayList();
|
||||
List<Certificate> x509Certificates = Arrays.asList(certificates);
|
||||
List<X509Certificate> certificateList = Lists.newLinkedList();
|
||||
int thumb = 0;
|
||||
for (int i = 0; i < x509Certificates.size(); i++) {
|
||||
X509Certificate cert = (X509Certificate) certificates[i];
|
||||
certificateList.add(cert);
|
||||
if (thumbPrint.equals(getThumbPrint(cert, SHA1_AUTH_STR).toUpperCase())) {
|
||||
thumb = i;
|
||||
}
|
||||
}
|
||||
List<X509Certificate> certificates1 = certificateList.subList(thumb, x509Certificates.size());
|
||||
certificates1.forEach(c -> {
|
||||
CertificateChain certificateChain = certChainDeal(c);
|
||||
certificateChains.add(certificateChain);
|
||||
});
|
||||
return certificateChains;
|
||||
}
|
||||
|
||||
public static List<CertificateChain> getCertChain1(Certificate[] certificates) throws Exception {
|
||||
List<CertificateChain> certificateChains = Lists.newArrayList();
|
||||
for (int i = 0; i < certificates.length; i++) {
|
||||
X509Certificate cert = (X509Certificate) certificates[i];
|
||||
CertificateChain certificateChain = certChainDeal(cert);
|
||||
certificateChains.add(certificateChain);
|
||||
}
|
||||
return certificateChains;
|
||||
}
|
||||
|
||||
public static CertificateChain certChainDeal(X509Certificate cert) {
|
||||
CertificateChain certificateChain = new CertificateChain();
|
||||
certificateChain.setValidityPeriod(DateUtils.formatDate(cert.getNotBefore(), DateUtils.DATETIME_YYYY_MM_DD_HH_MM_SS).concat("~")
|
||||
.concat(DateUtils.formatDate(cert.getNotAfter(), DateUtils.DATETIME_YYYY_MM_DD_HH_MM_SS)).concat("(剩余 " + DateUtils.daysBetween(new Date(), cert.getNotAfter()) + "天)"));
|
||||
try {
|
||||
certificateChain.setCertFingerprint(getThumbPrint(cert, SHA1_AUTH_STR).toUpperCase());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
certificateChain.setEncryptionAlgorithm(cert.toString().contains("SHA256withECDSA") ? "ECDSA 256 bits" : "RSA 2048 bits");
|
||||
certificateChain.setSignAlgorithm(cert.getSigAlgName());
|
||||
certificateChain.setIssuedTo(sslSp(cert.getSubjectDN().toString(), CN_STR));
|
||||
certificateChain.setIssuer(sslSp(cert.getIssuerDN().toString(), CN_STR));
|
||||
return certificateChain;
|
||||
}
|
||||
|
||||
/**
|
||||
* 信任所有证书
|
||||
*
|
||||
* @param hpUrl
|
||||
* @return com.cym.utils.cert.CertExportEmailVO
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 14:32 2022/9/2
|
||||
**/
|
||||
public static CertExportEmailVO trustDetection(String hpUrl) throws Exception {
|
||||
CertExportEmailVO xccSSLInfo = new CertExportEmailVO();
|
||||
URL url = new URL(HTTPS_STR + hpUrl);
|
||||
// 发起HTTPS请求
|
||||
trustAllHttpsCertificates(2);
|
||||
HttpsURLConnection conn = getConn(url);
|
||||
conn.setHostnameVerifier(new Verifier());
|
||||
try {
|
||||
conn.connect();
|
||||
Certificate[] serverCertificates = conn.getServerCertificates();
|
||||
X509Certificate certs = (X509Certificate) serverCertificates[0];
|
||||
xccSSLInfo = deal(certs, xccSSLInfo);
|
||||
List<CertificateChain> certChain = getCertChain(serverCertificates, getThumbPrint(certs, SHA1_AUTH_STR).toUpperCase());
|
||||
xccSSLInfo.setCertificateChains(certChain);
|
||||
String parentCert = (serverCertificates.length > 1) ? NO_STR : YES_STR;
|
||||
xccSSLInfo.setOcspBindState(parentCert.equals(YES_STR) ? SUPPORT_STR : NO_SUPPORT_STR);
|
||||
xccSSLInfo.setOcspMustBind(parentCert.equals(YES_STR) ? YES_STR : NO_STR);
|
||||
xccSSLInfo.setIsSNI(parentCert.equals(YES_STR) ? YES_STR : NO_STR);
|
||||
xccSSLInfo.setWeakKey(parentCert.equals(YES_STR) ? NO_STR : YES_STR);
|
||||
conn.disconnect();
|
||||
if (!xccSSLInfo.getCommonName().contains(hpUrl.substring(hpUrl.indexOf(".") + 1))) {
|
||||
if (xccSSLInfo.getSans().size() == 0 || !xccSSLInfo.getSans().contains(hpUrl)) {
|
||||
xccSSLInfo.setCommonName(xccSSLInfo.getCommonName() + " (不匹配)");
|
||||
xccSSLInfo.setSuccess(DOMAIN_NOT_MATCH_STR);
|
||||
xccSSLInfo.setTrustStatus("域名不匹配 (主流浏览器访问不受影响,影响少数不支持SNI的旧浏览器)");
|
||||
}
|
||||
}
|
||||
} catch (ConnectException e) {
|
||||
return xccSSLInfo;
|
||||
} catch (Exception cer) {
|
||||
return xccSSLInfo;
|
||||
} finally {
|
||||
conn.disconnect();
|
||||
}
|
||||
return xccSSLInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 证书类型规则匹配 -- DV 证书信息中仅包含COMMON_NAME 信息 -- OV 证书信息中包含企业的一些基本信息 -- EV
|
||||
* 证书中包含企业的工商注册号 SERIALNUMBER
|
||||
*
|
||||
* @param cert X.509证书链
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 10:12 2022/8/31
|
||||
**/
|
||||
public static String getSSLType(X509Certificate cert) {
|
||||
if (StringUtils.isBlank(sslSp(cert.getSubjectDN().toString(), O_STR)) && StringUtils.isBlank(sslSp(cert.getSubjectDN().toString(), ST_STR))) {
|
||||
return DV_SSL_STR;
|
||||
}
|
||||
if (StringUtils.isBlank(sslSp(cert.getSubjectDN().toString(), SERIALNUMBER_STR))) {
|
||||
return OV_SSL_STR;
|
||||
} else {
|
||||
return EV_SSL_STR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取证书序列号及CRURL(证书列表吊销信息) domain:https://sina.com.cn eg:
|
||||
* http://crl3.digicert.com/GeoTrustCNRSACAG1.crl,http://crl4.digicert.com/GeoTrustCNRSACAG1.crl
|
||||
*
|
||||
* @param cert
|
||||
* @return java.util.Map<java.lang.String, java.lang.String>
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 10:14 2022/8/31
|
||||
**/
|
||||
public static Map<String, String> getCertInfo(String cert) {
|
||||
Map<String, String> certMap = Maps.newHashMap();
|
||||
if (cert.contains("SerialNumber: [") && cert.contains("]\n" + "\n" + "Certificate")) {
|
||||
try {
|
||||
String serialNumber = cert.substring(cert.indexOf("SerialNumber: ["), cert.indexOf("]\n" + "\n" + "Certificate")).replace(" ", "").replace("SerialNumber:[", "").replace("]", "")
|
||||
.toUpperCase();
|
||||
certMap.put("serialNumber", serialNumber);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else {
|
||||
String serialNumber = cert.substring(cert.indexOf("SerialNumber: ["), cert.indexOf("]\n" + " Algorithm: [")).replaceAll(" ", "").replaceAll("SerialNumber:\\[", "").replaceAll("]", "")
|
||||
.toUpperCase();
|
||||
certMap.put("serialNumber", serialNumber);
|
||||
}
|
||||
if (cert.contains("[URIName:")) {
|
||||
String crlUrl = cert.substring(cert.indexOf("[URIName:"), cert.indexOf("[6]")).replaceAll("\\[URIName:", "").replaceAll("]", "").replaceAll("DistributionPoint:", "").replaceAll("\n", "")
|
||||
.replaceAll(" ", "");
|
||||
certMap.put("crlUrl", crlUrl);
|
||||
}
|
||||
return certMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据规则匹配颁发者和使用者的信息
|
||||
*
|
||||
* @param str
|
||||
* @param key
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 10:17 2022/8/31
|
||||
**/
|
||||
public static String sslSp(String str, String key) {
|
||||
if (str.contains(".,")) {
|
||||
str = str.replace(".,", "&");
|
||||
}
|
||||
Map<String, String> maps = Maps.newHashMap();
|
||||
String[] split = str.split(",");
|
||||
for (String s : split) {
|
||||
if (s.contains("=")) {
|
||||
String[] split1 = s.split("=");
|
||||
if (split1.length == 2) {
|
||||
maps.put(split1[0].trim(), split1[1].replace("\"", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
return maps.containsKey(key) ? maps.get(key) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cert
|
||||
* @param algorithm 算法(支持SHA-1 和 SHA-256)
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 10:17 2022/8/31
|
||||
**/
|
||||
private static String getThumbPrint(X509Certificate cert, String algorithm) throws Exception {
|
||||
MessageDigest md = MessageDigest.getInstance(algorithm);
|
||||
byte[] der = cert.getEncoded();
|
||||
md.update(der);
|
||||
byte[] digest = md.digest();
|
||||
return bytesToHexString(digest);
|
||||
}
|
||||
|
||||
/**
|
||||
* byte[]转String
|
||||
*
|
||||
* @param src
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 10:21 2022/8/31
|
||||
**/
|
||||
private static String bytesToHexString(byte[] src) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
int v = src[i] & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取网站信息
|
||||
*
|
||||
* @param web
|
||||
* @return java.util.Map<java.lang.String, java.lang.String>
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 13:40 2022/9/1
|
||||
**/
|
||||
public static Map<String, String> getWebInfo(String vls, String web) {
|
||||
Map<String, String> webMap = Maps.newHashMap();
|
||||
try {
|
||||
trustAllHttpsCertificates(2);
|
||||
URL url = new URL(vls + web);
|
||||
String ipAddress = InetAddress.getByName(web).getHostAddress();
|
||||
URLConnection URLconnection = url.openConnection();
|
||||
HttpURLConnection httpConnection = (HttpURLConnection) URLconnection;
|
||||
int responseCode = httpConnection.getResponseCode();
|
||||
webMap.put("ip", StringUtils.isBlank(ipAddress) ? "-" : ipAddress);
|
||||
webMap.put("favicon", findIco(vls + web));
|
||||
if (!getResponseStatus().contains(responseCode)) {
|
||||
InputStream in = httpConnection.getInputStream();
|
||||
InputStreamReader isr = new InputStreamReader(in);
|
||||
BufferedReader bufferedReader = new BufferedReader(isr);
|
||||
String str;
|
||||
while ((str = bufferedReader.readLine()) != null) {
|
||||
String trim = str.trim();
|
||||
if (trim.contains("<title>")) {
|
||||
String titleStr = trim.substring(trim.indexOf("<title>"), trim.indexOf("</title>")).replace("<title>", "");
|
||||
webMap.put("title", responseCode == 301 ? "redirect to https://" + web : titleStr);
|
||||
}
|
||||
}
|
||||
bufferedReader.close();
|
||||
} else {
|
||||
webMap.put("title", "redirect to https://" + web);
|
||||
webMap.put("ip", "-");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return webMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取网站favicon
|
||||
*
|
||||
* @param navUrl
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 13:36 2022/9/1
|
||||
**/
|
||||
private static String findIco(String navUrl) {
|
||||
String body = HttpUtil.get(navUrl);
|
||||
String str = body.split("/favicon.ico")[0];
|
||||
int http = str.indexOf(HTTPS_STR, str.length() - 100);
|
||||
if (http == -1) {
|
||||
http = str.indexOf(HTTPS_STR, str.length() - 100);
|
||||
}
|
||||
if (http == -1) {
|
||||
// 说明没有指定 走拼接逻辑
|
||||
int i = navUrl.indexOf("/", 8);
|
||||
if (i > 0) {
|
||||
navUrl = navUrl.substring(0, i);
|
||||
}
|
||||
} else {
|
||||
navUrl = str.substring(http);
|
||||
}
|
||||
return navUrl + "/favicon.ico";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取证书兼容性测试
|
||||
*
|
||||
* @param success
|
||||
* @return java.util.Map<java.lang.String, java.lang.String>
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:20 2022/9/1
|
||||
**/
|
||||
public static Map<String, String> certCompatible(String success) {
|
||||
Map<String, String> maps = Maps.newLinkedHashMap();
|
||||
String status = success.equals(NORMAL_STR) ? YES_STR : NO_STR;
|
||||
if (success.equals("网址无法访问") || success.equals("没有证书")) {
|
||||
return maps;
|
||||
} else {
|
||||
maps.put("Android 2.3 (Gingerbread)", status);
|
||||
maps.put("Android 4.0 (Ice Cream Sandwich)", status);
|
||||
maps.put("Android 4.1 (Jelly Bean)", status);
|
||||
maps.put("Android 4.2 (Jelly Bean)", status);
|
||||
maps.put("Android 4.3 (Jelly Bean)", status);
|
||||
maps.put("Android 4.4 (KitKat)", status);
|
||||
maps.put("Android 5.0 (Lollipop)", status);
|
||||
maps.put("Android 5.1 (Lollipop)", status);
|
||||
maps.put("Android 6.0 (Marshmallow)", status);
|
||||
maps.put("Android 7.0 (Android Nougat)", status);
|
||||
maps.put("Android 7.1 (Android Nougat)", status);
|
||||
maps.put("Android 8.0 (Android Oreo)", status);
|
||||
maps.put("Android 9.0 (Android Pie)", status);
|
||||
maps.put("Android 10.0 (Android Q)", status);
|
||||
maps.put("Android 11.0 (Android R)", status);
|
||||
maps.put("iOS 5-6", status);
|
||||
maps.put("iOS 7", status);
|
||||
maps.put("iOS 8", status);
|
||||
maps.put("iOS 9", status);
|
||||
maps.put("iOS 10", status);
|
||||
maps.put("iOS 11", status);
|
||||
maps.put("iOS 12", status);
|
||||
maps.put("iOS 13", status);
|
||||
maps.put("iOS 14", status);
|
||||
maps.put("OS X 10.9 (Mavericks)", status);
|
||||
maps.put("OS X 10.10 (Yosemite)", status);
|
||||
maps.put("OS X 10.11 (Eicapitan)", status);
|
||||
maps.put("OS X 10.12 (Sierra)", status);
|
||||
maps.put("OS X 10.13 (High Sierra)", status);
|
||||
maps.put("OS X 10.14 (Mojave)", status);
|
||||
maps.put("java 7u181", status);
|
||||
maps.put("java 8u161", status);
|
||||
maps.put("java_8u181", status);
|
||||
maps.put("java_8u202", status);
|
||||
maps.put("java 9", status);
|
||||
maps.put("java 10", status);
|
||||
maps.put("java 11", status);
|
||||
maps.put("java 12", status);
|
||||
maps.put("java 13", status);
|
||||
maps.put("java 17", status);
|
||||
maps.put("Firefox 3.0", status);
|
||||
maps.put("Firefox 3.5", status);
|
||||
maps.put("Firefox 3.6", status);
|
||||
maps.put("Firefox 6.0", status);
|
||||
maps.put("Firefox 16", status);
|
||||
maps.put("Firefox 23", status);
|
||||
maps.put("Firefox 32", status);
|
||||
maps.put("Firefox 42", status);
|
||||
maps.put("Firefox 50", status);
|
||||
maps.put("Firefox 51", status);
|
||||
maps.put("Firefox 54", status);
|
||||
maps.put("Firefox 58", status);
|
||||
maps.put("Firefox 63", status);
|
||||
maps.put("Firefox 65", status);
|
||||
maps.put("Windows XP", status);
|
||||
maps.put("Windows 7", status);
|
||||
maps.put("Windows 8", status);
|
||||
maps.put("Windows 10", status);
|
||||
maps.put("Windows 11", status);
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
public static String getRating(CertExportEmailVO certExportEmailVO) {
|
||||
if (certExportEmailVO.getSuccess().equals(NORMAL_STR) && certExportEmailVO.getCertificateType().equals(EV_SSL_STR)) {
|
||||
return "A+";
|
||||
}
|
||||
if (certExportEmailVO.getSuccess().equals(NORMAL_STR) && certExportEmailVO.getCertificateType().equals(OV_SSL_STR)) {
|
||||
return "A";
|
||||
}
|
||||
if (certExportEmailVO.getSuccess().equals(NORMAL_STR) && certExportEmailVO.getCertificateType().equals(DV_SSL_STR)) {
|
||||
return "A-";
|
||||
}
|
||||
if (certExportEmailVO.getSuccess().equals(DOMAIN_NOT_MATCH_STR)) {
|
||||
return "T";
|
||||
}
|
||||
return "B";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取证书响应错误状态码
|
||||
*
|
||||
* @param
|
||||
* @return java.util.List<java.lang.Integer>
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 11:26 2022/9/2
|
||||
**/
|
||||
public static List<Integer> getResponseStatus() {
|
||||
String code = "[\n" + " 404,\n" + " 400,\n" + " 500,\n" + " 502,\n" + " 503,\n" + " 504,\n" + " 505,\n" + " 506,\n" + " 507,\n" + " 508,\n" + " 509,\n" + " 511,\n" + " 512,\n"
|
||||
+ " 513,\n" + " 521,\n" + " 530,\n" + " 600,\n" + " 651\n" + "]";
|
||||
List<Integer> codeList = JSON.parseObject(code, List.class);
|
||||
return codeList;
|
||||
}
|
||||
|
||||
public CertExportEmailVO getCertChain(String fingerprint, String hpUrl) throws Exception {
|
||||
hpUrl = hpUrl.contains(HTTP_STR) || hpUrl.contains(HTTPS_STR) ? hpUrl.replaceAll(HTTP_STR, "").replaceAll(HTTPS_STR, "").trim() : hpUrl.trim();
|
||||
hpUrl = CNRulesMate(hpUrl) ? chineseDomainNameDecoding(hpUrl) : hpUrl;
|
||||
CertExportEmailVO certExportEmailVO1 = distrustCert(fingerprint, hpUrl);
|
||||
CertExportEmailVO certExportEmailVO = noDistrustCert(fingerprint, hpUrl);
|
||||
return StringUtils.isNotBlank(certExportEmailVO1.getSerialNumber()) ? certExportEmailVO1 : certExportEmailVO;
|
||||
}
|
||||
|
||||
public static CertExportEmailVO distrustCert(String fingerprint, String hpUrl) throws Exception {
|
||||
URL url = new URL(HTTPS_STR + hpUrl);
|
||||
// 发起HTTPS请求
|
||||
trustAllHttpsCertificates(1);
|
||||
HttpsURLConnection conn = getConn(url);
|
||||
CertExportEmailVO certExportEmailVO = new CertExportEmailVO();
|
||||
try {
|
||||
conn.connect();
|
||||
Certificate[] serverCertificates = conn.getServerCertificates();
|
||||
for (int i = 0; i < serverCertificates.length; i++) {
|
||||
X509Certificate certs = (X509Certificate) serverCertificates[i];
|
||||
if (getThumbPrint(certs, SHA1_AUTH_STR).toUpperCase().equals(fingerprint)) {
|
||||
certExportEmailVO = deal(certs, certExportEmailVO);
|
||||
certExportEmailVO.setCertificateChains(getCertChain(serverCertificates, getThumbPrint(certs, SHA1_AUTH_STR).toUpperCase()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} finally {
|
||||
conn.disconnect();
|
||||
}
|
||||
return certExportEmailVO;
|
||||
}
|
||||
|
||||
public static CertExportEmailVO noDistrustCert(String fingerprint, String hpUrl) throws Exception {
|
||||
CertExportEmailVO certExportEmailVO = new CertExportEmailVO();
|
||||
URL url = new URL(HTTPS_STR + hpUrl);
|
||||
trustAllHttpsCertificates(2);
|
||||
HttpsURLConnection conn = getConn(url);
|
||||
conn.setHostnameVerifier(new Verifier());
|
||||
try {
|
||||
conn.connect();
|
||||
Certificate[] serverCertificates = conn.getServerCertificates();
|
||||
for (int i = 0; i < serverCertificates.length; i++) {
|
||||
X509Certificate certs = (X509Certificate) serverCertificates[i];
|
||||
if (getThumbPrint(certs, SHA1_AUTH_STR).toUpperCase().equals(fingerprint)) {
|
||||
certExportEmailVO = deal(certs, certExportEmailVO);
|
||||
certExportEmailVO.setCertificateChains(getCertChain(serverCertificates, getThumbPrint(certs, SHA1_AUTH_STR).toUpperCase()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} finally {
|
||||
conn.disconnect();
|
||||
}
|
||||
return certExportEmailVO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,928 @@
|
||||
package com.cym.utils.cert;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* @ClassName DateUtils
|
||||
* @Description 日期工具类
|
||||
* @Author ZhangSan_Plus
|
||||
* @Date 2020/5/11 9:53
|
||||
* @Version 1.0
|
||||
**/
|
||||
public class DateUtils {
|
||||
public final static int FORMAT_DEFAULT = 0;
|
||||
|
||||
/**
|
||||
* 日时字符串格式:长格式(如:年份用4位表示)
|
||||
*/
|
||||
public final static int FORMAT_LONG = 1;
|
||||
|
||||
/**
|
||||
* 日时字符串格式:短格式(如:年份用2位表示)
|
||||
*/
|
||||
public final static int FORMAT_SHORT = 2;
|
||||
|
||||
/**
|
||||
* 默认日期字符串格式 "yyyy-MM-dd"
|
||||
*/
|
||||
public final static String DATE_DEFAULT = "yyyy-MM-dd";
|
||||
/**
|
||||
* 日期字符串格式 "yyyy"
|
||||
*/
|
||||
private final static String DATE_YYYY = "yyyy";
|
||||
/**
|
||||
* 日期字符串格式 "mm"
|
||||
*/
|
||||
private final static String DATE_MM = "mm";
|
||||
/**
|
||||
* 日期字符串格式 "dd"
|
||||
*/
|
||||
private final static String DATE_DD = "dd";
|
||||
/**
|
||||
* 日期字符串格式 "yyyyMM"
|
||||
*/
|
||||
public final static String DATE_YYYYMM = "yyyyMM";
|
||||
|
||||
/**
|
||||
* 日期字符串格式 "yyyyMMdd"
|
||||
*/
|
||||
public final static String DATE_YYYYMMDD = "yyyyMMdd";
|
||||
|
||||
/**
|
||||
* 日期字符串格式 "yyyy-MM"
|
||||
*/
|
||||
public final static String DATE_YYYY_MM = "yyyy-MM";
|
||||
|
||||
/**
|
||||
* 日期字符串格式 "yyyy-MM-dd"
|
||||
*/
|
||||
public final static String DATE_YYYY_MM_DD = "yyyy-MM-dd";
|
||||
|
||||
/**
|
||||
* 默认日时字符串格式 "yyyy-MM-dd HH:mm:ss"
|
||||
*/
|
||||
public final static String DATETIME_DEFAULT = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 日时字符串格式 "yyyy-MM-dd HH:mm"
|
||||
*/
|
||||
public final static String DATETIME_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
|
||||
|
||||
/**
|
||||
* 日时字符串格式 "yyyy-MM-dd HH:mm:ss"
|
||||
*/
|
||||
public final static String DATETIME_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 日时字符串格式 "yyyy-MM-dd HH:mm:ss.SSS"
|
||||
*/
|
||||
public final static String DATETIME_YYYY_MM_DD_HH_MM_SS_SSS = "yyyy-MM-dd HH:mm:ss.SSS";
|
||||
|
||||
/**
|
||||
* 默认时间字符串格式 "HH:mm:ss"
|
||||
*/
|
||||
public final static String TIME_DEFAULT = "HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 默认时间字符串格式 "HH:mm"
|
||||
*/
|
||||
public final static String TIME_HH_MM = "HH:mm";
|
||||
|
||||
/**
|
||||
* 默认时间字符串格式 "HH:mm:ss"
|
||||
*/
|
||||
public final static String TIME_HH_MM_SS = "HH:mm:ss";
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
public static final long YEAR_NUMBER = 365;
|
||||
/**
|
||||
* 分
|
||||
*/
|
||||
public static final long MINUTE_TTL = 60 * 1000L;
|
||||
/**
|
||||
* 时
|
||||
*/
|
||||
public static final long HOURS_TTL = 60 * 60 * 1000L;
|
||||
/**
|
||||
* 半天
|
||||
*/
|
||||
public static final long HALF_DAY_TTL = 12 * 60 * 60 * 1000L;
|
||||
/**
|
||||
* 天
|
||||
*/
|
||||
public static final long DAY_TTL = 24 * 60 * 60L * 1000L;
|
||||
/**
|
||||
* 月
|
||||
*/
|
||||
public static final long MONTH_TTL = 30 * 24 * 60 * 60 * 1000L;
|
||||
public static final String DAY_BEFORE_STR = "天前";
|
||||
public static final String HOUR_BEFORE_STR = "小时前";
|
||||
public static final String MINUTE_BEFORE_STR = "分钟前";
|
||||
public static final String SECONDS_BEFORE_STR = "秒前";
|
||||
public static final String TIME_OPERATION_SRT = "TIME_OPERATION";
|
||||
public static final String TIME_STRAP_STR = "TIME_STRAP";
|
||||
|
||||
public static Integer getMonth(Integer month) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(new Date());
|
||||
c.add(Calendar.MONTH, month);
|
||||
return c.get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串转换成日期
|
||||
*
|
||||
* @param str
|
||||
* @return java.util.Date
|
||||
* @author ZhangSan_Plus
|
||||
* @description //
|
||||
* @date 18:46 2022/2/28
|
||||
**/
|
||||
public static Date getDateToStr(String str) {
|
||||
SimpleDateFormat format = new SimpleDateFormat(DATE_YYYY_MM_DD);
|
||||
Date r = null;
|
||||
try {
|
||||
r = format.parse(str);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间计算
|
||||
*
|
||||
* @param day
|
||||
* @return
|
||||
*/
|
||||
public static String countData(String day) {
|
||||
SimpleDateFormat format = new SimpleDateFormat(DATE_YYYY_MM_DD);
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.YEAR, -Integer.parseInt(day));
|
||||
Date start = c.getTime();
|
||||
String startDay = format.format(start);
|
||||
return startDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期前一天日期
|
||||
*
|
||||
* @param specifiedDay
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:04 2021/4/30
|
||||
**/
|
||||
public static String getSpecifiedDayBefore(String specifiedDay) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date date = null;
|
||||
try {
|
||||
date = new SimpleDateFormat(DATE_YYYY_MM_DD).parse(specifiedDay);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
c.setTime(date);
|
||||
int day = c.get(Calendar.DATE);
|
||||
c.set(Calendar.DATE, day - 1);
|
||||
|
||||
String dayBefore = new SimpleDateFormat(DATE_YYYY_MM_DD).format(c.getTime());
|
||||
return dayBefore;
|
||||
}
|
||||
|
||||
public static String ToSevenDate(String specifiedDay) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date date = null;
|
||||
try {
|
||||
date = new SimpleDateFormat(DATE_YYYY_MM_DD).parse(specifiedDay);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
c.setTime(date);
|
||||
int day = c.get(Calendar.DATE);
|
||||
c.set(Calendar.DATE, day - 7);
|
||||
|
||||
String dayBefore = new SimpleDateFormat(DATE_YYYY_MM_DD).format(c.getTime());
|
||||
return dayBefore;
|
||||
}
|
||||
|
||||
public static String ToThirtyDate(String specifiedDay) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date date = null;
|
||||
try {
|
||||
date = new SimpleDateFormat(DATE_YYYY_MM_DD).parse(specifiedDay);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
c.setTime(date);
|
||||
int day = c.get(Calendar.DATE);
|
||||
c.set(Calendar.DATE, day - 30);
|
||||
|
||||
String dayBefore = new SimpleDateFormat(DATE_YYYY_MM_DD).format(c.getTime());
|
||||
return dayBefore;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期后一天的数据
|
||||
*
|
||||
* @param
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:35 2021/4/30
|
||||
**/
|
||||
public static String getSpecifiedDayAfter(String specifiedDay) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date date = null;
|
||||
try {
|
||||
date = new SimpleDateFormat(DATE_YYYY_MM_DD).parse(specifiedDay);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
c.setTime(date);
|
||||
int day = c.get(Calendar.DATE);
|
||||
c.set(Calendar.DATE, day + 1);
|
||||
|
||||
String dayAfter = new SimpleDateFormat(DATE_YYYY_MM_DD).format(c.getTime());
|
||||
return dayAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the difference between two time
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return int(两个时间相差的天数)
|
||||
* @throws
|
||||
* @Author ZhangSan_Plus
|
||||
*/
|
||||
public static int daysBetween(Date startDate, Date endDate) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(startDate);
|
||||
long sTime = calendar.getTimeInMillis();
|
||||
calendar.setTime(endDate);
|
||||
long endTime = calendar.getTimeInMillis();
|
||||
long between_days = (endTime - sTime) / DAY_TTL;
|
||||
return Integer.parseInt(String.valueOf(between_days));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算时间差距年月,并计算信用分
|
||||
*
|
||||
* @param fromDate
|
||||
* @param toDate
|
||||
* @return java.util.Map<java.lang.String, java.lang.Object>
|
||||
* @author ZhangSan_Plus
|
||||
* @description //
|
||||
* @date 9:34 2021/12/17
|
||||
**/
|
||||
public static Map<String, Object> dayCompare(Date fromDate, Date toDate, Integer type) {
|
||||
Map<String, Object> maps = Maps.newHashMap();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(fromDate);
|
||||
int startY = calendar.get(Calendar.YEAR);
|
||||
int startM = calendar.get(Calendar.MONTH);
|
||||
Calendar calendar1 = Calendar.getInstance();
|
||||
calendar1.setTime(toDate);
|
||||
int endY = calendar1.get(Calendar.YEAR);
|
||||
int endM = calendar1.get(Calendar.MONTH);
|
||||
int mos = (endY - startY) * 12 + (endM - startM);
|
||||
int lyear = mos / 12;
|
||||
int lmonth = mos % 12;
|
||||
maps.put("year", lyear);
|
||||
maps.put("month", lmonth);
|
||||
if (type == 1) {
|
||||
if (lyear != 0) {
|
||||
if (lmonth == 0) {
|
||||
maps.put("cred", lyear + "年");
|
||||
maps.put("sources", (lyear * 12 * 10 + lmonth * 10));
|
||||
} else {
|
||||
maps.put("cred", lyear + "年" + lmonth + "个月");
|
||||
maps.put("sources", (lyear * 12 * 10 + lmonth * 10));
|
||||
}
|
||||
} else {
|
||||
if (lmonth == 0) {
|
||||
lmonth = lmonth + 1;
|
||||
}
|
||||
maps.put("cred", lmonth + "个月");
|
||||
maps.put("sources", (lmonth * 10));
|
||||
}
|
||||
} else {
|
||||
maps.put("cred", lyear + 1 + "年");
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间戳差值计算
|
||||
*
|
||||
* @param
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author liyangshuai
|
||||
* @date 15:40 2021/6/9
|
||||
**/
|
||||
public static String getDistanceTime(long time1, long time2) {
|
||||
long diff;
|
||||
if (time1 < time2) {
|
||||
diff = time2 - time1;
|
||||
} else {
|
||||
diff = time1 - time2;
|
||||
}
|
||||
long day = diff / (DAY_TTL);
|
||||
long hour = (diff / (60 * 60 * 1000) - day * 24);
|
||||
long min = ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60);
|
||||
long sec = (diff / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
|
||||
if (day != 0) {
|
||||
if (day > 10) {
|
||||
return sdf.format(new Date(time2));
|
||||
}
|
||||
return day + "天前";
|
||||
}
|
||||
if (hour != 0) {
|
||||
return hour + HOUR_BEFORE_STR;
|
||||
}
|
||||
if (min != 0) {
|
||||
return min + MINUTE_BEFORE_STR;
|
||||
}
|
||||
if (sec != 0) {
|
||||
return sec + SECONDS_BEFORE_STR;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat(DATE_YYYY_MM_DD);
|
||||
private static SimpleDateFormat HMSSdf = new SimpleDateFormat(DATETIME_YYYY_MM_DD_HH_MM_SS);
|
||||
|
||||
public static Map<String, Object> getDateUnixStr(String dateStr) throws ParseException {
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
long diff;
|
||||
long time1 = System.currentTimeMillis();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(HMSSdf.parse(dateStr));
|
||||
calendar.add(Calendar.DAY_OF_MONTH, 0);
|
||||
long time2 = calendar.getTime().getTime();
|
||||
map.put(TIME_STRAP_STR, time2);
|
||||
if (time1 < time2) {
|
||||
diff = time2 - time1;
|
||||
} else {
|
||||
diff = time1 - time2;
|
||||
}
|
||||
long day = diff / (DAY_TTL);
|
||||
long hour = (diff / (60 * 60 * 1000) - day * 24);
|
||||
long min = ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60);
|
||||
long sec = (diff / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
|
||||
if (day != 0) {
|
||||
map.put(TIME_OPERATION_SRT, String.valueOf(sdf.format(new Date(time2))));
|
||||
return map;
|
||||
}
|
||||
if (hour != 0) {
|
||||
map.put(TIME_OPERATION_SRT, hour + HOUR_BEFORE_STR);
|
||||
return map;
|
||||
}
|
||||
if (min != 0) {
|
||||
map.put(TIME_OPERATION_SRT, min + MINUTE_BEFORE_STR);
|
||||
return map;
|
||||
}
|
||||
if (sec != 0) {
|
||||
map.put(TIME_OPERATION_SRT, sec + SECONDS_BEFORE_STR);
|
||||
return map;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current system time
|
||||
*
|
||||
* @param
|
||||
* @return java.util.Date
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:36 2021/4/30
|
||||
**/
|
||||
public static Date getNewDate() {
|
||||
SimpleDateFormat df = new SimpleDateFormat(DATETIME_YYYY_MM_DD_HH_MM_SS);
|
||||
Date newDate = null;
|
||||
try {
|
||||
newDate = df.parse(df.format(new Date()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return newDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date string format by default(yyyy-MM-dd) pattern can "yyyy-MM-dd"
|
||||
* "HH:mm:ss" "E"
|
||||
*
|
||||
* @param date
|
||||
* @param pattern
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:37 2021/4/30
|
||||
**/
|
||||
public static String formatDate(Date date, Object... pattern) {
|
||||
String formatDate = null;
|
||||
if (pattern != null && pattern.length > 0) {
|
||||
formatDate = DateFormatUtils.format(date, pattern[0].toString());
|
||||
} else {
|
||||
formatDate = DateFormatUtils.format(date, DATE_YYYY_MM_DD);
|
||||
}
|
||||
return formatDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据指定的时间催获取时间
|
||||
*
|
||||
* @param dateUnix
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 11:00 2021/7/5
|
||||
**/
|
||||
public static String getDateByDateUnix(Long dateUnix) {
|
||||
return sdf.format(new Date(dateUnix * 1000));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期 指定天数的字符串值
|
||||
*
|
||||
* @param date
|
||||
* @param days
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 14:39 2021/5/6
|
||||
**/
|
||||
public static String getDisposeDate(Date date, Integer days) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, days);
|
||||
return DateFormatUtils.format(calendar.getTime(), DATE_YYYY_MM_DD);
|
||||
}
|
||||
|
||||
public static Date getDisposeToDate(Date date, Integer days) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, days);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static Date getDisposeToYear(Date date, Integer year) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.YEAR, year);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定时间的时间戳
|
||||
* <p>
|
||||
* (int) (System.currentTimeMillis() / 1000) https://tool.lu/timestamp/
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @param
|
||||
* @return long
|
||||
* @throws
|
||||
* @author liyangshuai
|
||||
* @date 15:28 2021/6/9
|
||||
**/
|
||||
public static long getUnixNum(Date date, Integer days) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, days);
|
||||
long time = calendar.getTime().getTime() / 1000;
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the current year str format(yyyy)
|
||||
*
|
||||
* @param
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:49 2021/4/30
|
||||
**/
|
||||
public static String getYear() {
|
||||
return formatDate(new Date(), DATE_YYYY);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the current month format(MM)
|
||||
*
|
||||
* @param
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:52 2021/4/30
|
||||
**/
|
||||
public static String getMonth() {
|
||||
return formatDate(new Date(), DATE_MM);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the current day format(dd)
|
||||
*
|
||||
* @param
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:52 2021/4/30
|
||||
**/
|
||||
public static String getDay() {
|
||||
return formatDate(new Date(), DATE_DD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间的字符串形式(例如;"201806291135")
|
||||
*
|
||||
* @return 年月日时分
|
||||
*/
|
||||
public static String getDateToString() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
return getYear() + getMonth() + getDay() + c.get(Calendar.HOUR_OF_DAY) + c.get(Calendar.MINUTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of years in the past
|
||||
*
|
||||
* @param date
|
||||
* @return java.lang.Long
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:37 2021/4/30
|
||||
**/
|
||||
public static Long pastYear(Date date) {
|
||||
return date == null ? null : pastDays(date) / YEAR_NUMBER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of days in the past
|
||||
*
|
||||
* @param date
|
||||
* @return long
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:38 2021/4/30
|
||||
**/
|
||||
public static long pastDays(Date date) {
|
||||
long t = System.currentTimeMillis() - date.getTime();
|
||||
return t / DAY_TTL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取过去的小时
|
||||
*
|
||||
* @param date
|
||||
* @return long
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:38 2021/4/30
|
||||
**/
|
||||
public static long pastHour(Date date) {
|
||||
long t = System.currentTimeMillis() - date.getTime();
|
||||
return t / HOURS_TTL;
|
||||
}
|
||||
|
||||
/**
|
||||
* return To date the number of days in the past
|
||||
*
|
||||
* @param date
|
||||
* @return long
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:39 2021/4/30
|
||||
**/
|
||||
public static long pastMinutes(Date date) {
|
||||
long t = System.currentTimeMillis() - date.getTime();
|
||||
return t / MINUTE_TTL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of days between two dates
|
||||
*
|
||||
* @param before
|
||||
* @param after
|
||||
* @return double
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 17:39 2021/4/30
|
||||
**/
|
||||
public static double getDistanceOfTwoDate(Date before, Date after) {
|
||||
long beforeTime = before.getTime();
|
||||
long afterTime = after.getTime();
|
||||
return (afterTime - beforeTime) / DAY_TTL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过身份证号码获取出生日期、性别、年齡
|
||||
*
|
||||
* @param certificateNo
|
||||
* @return 返回的出生日期格式:1990-01-01 性别格式:2-女,1-男
|
||||
*/
|
||||
public static Map<String, String> getBirAgeSex(String certificateNo) {
|
||||
String birthday = "";
|
||||
String age = "";
|
||||
String sexCode = "";
|
||||
int year = Calendar.getInstance().get(Calendar.YEAR);
|
||||
char[] number = certificateNo.toCharArray();
|
||||
boolean flag = true;
|
||||
if (number.length == 15) {
|
||||
for (int x = 0; x < number.length; x++) {
|
||||
if (!flag) {
|
||||
return new HashMap<>(10);
|
||||
}
|
||||
flag = Character.isDigit(number[x]);
|
||||
}
|
||||
} else if (number.length == 18) {
|
||||
for (int x = 0; x < number.length - 1; x++) {
|
||||
if (!flag) {
|
||||
return new HashMap<>(10);
|
||||
}
|
||||
flag = Character.isDigit(number[x]);
|
||||
|
||||
}
|
||||
}
|
||||
if (flag && certificateNo.length() == 15) {
|
||||
birthday = "19" + certificateNo.substring(6, 8) + "-" + certificateNo.substring(8, 10) + "-" + certificateNo.substring(10, 12);
|
||||
sexCode = Integer.parseInt(certificateNo.substring(certificateNo.length() - 3, certificateNo.length())) % 2 == 0 ? "2" : "1";
|
||||
age = (year - Integer.parseInt("19" + certificateNo.substring(6, 8))) + "";
|
||||
} else {
|
||||
birthday = certificateNo.substring(6, 10) + "-" + certificateNo.substring(10, 12) + "-" + certificateNo.substring(12, 14);
|
||||
sexCode = Integer.parseInt(certificateNo.substring(certificateNo.length() - 4, certificateNo.length() - 1)) % 2 == 0 ? "2" : "1";
|
||||
age = (year - Integer.parseInt(certificateNo.substring(6, 10))) + "";
|
||||
}
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("birthday", birthday);
|
||||
map.put("age", age);
|
||||
map.put("sexCode", sexCode);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份证的号码算出当前身份证持有者的年龄 18位身份证
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @author ZhangSan_Plus
|
||||
*/
|
||||
public static int getCarAge(String birthday) {
|
||||
// 得到年份
|
||||
String year = birthday.substring(0, 4);
|
||||
// 得到月份
|
||||
String yue = birthday.substring(4, 6);
|
||||
// 得到当前的系统时间
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat(DATE_YYYY_MM_DD);
|
||||
// 当前年份
|
||||
String fYear = format.format(date).substring(0, 4);
|
||||
// 月份
|
||||
String fYue = format.format(date).substring(5, 7);
|
||||
int age = 0;
|
||||
// 当前月份大于用户出身的月份表示已过生
|
||||
if (Integer.parseInt(yue) <= Integer.parseInt(fYue)) {
|
||||
age = Integer.parseInt(fYear) - Integer.parseInt(year) + 1;
|
||||
} else {// 当前用户还没过生
|
||||
age = Integer.parseInt(fYear) - Integer.parseInt(year);
|
||||
}
|
||||
return age;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份证获取性别
|
||||
*/
|
||||
public static String getCarSex(String CardCode) {
|
||||
String sex;
|
||||
if (Integer.parseInt(CardCode.substring(16).substring(0, 1)) % 2 == 0) {
|
||||
// 判断性别
|
||||
sex = "2";
|
||||
} else {
|
||||
sex = "1";
|
||||
}
|
||||
return sex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传入的日历型日期,计算出执行的时间值(精确版)
|
||||
*
|
||||
* @param beginTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
public static String countExecTimeToString_exact(Calendar beginTime, Calendar endTime) {// 计算两个日期类型之间的差值(单位:毫秒)
|
||||
Long timeDispersion = endTime.getTimeInMillis() - beginTime.getTimeInMillis();
|
||||
String tmpMsg = "耗时: ";
|
||||
// 记录时间的数值(几小时、几分、几秒)
|
||||
int timeNum = 0;
|
||||
// 判断是否足够一小时
|
||||
if (timeDispersion >= (HOURS_TTL)) { // 若足够则计算有几小时
|
||||
timeNum = (int) (timeDispersion / HOURS_TTL);
|
||||
tmpMsg += timeNum + "时";
|
||||
timeDispersion = timeDispersion - (timeNum * HOURS_TTL);
|
||||
}
|
||||
// 判断是否足够一分钟
|
||||
if (timeDispersion >= (MINUTE_TTL)) {// 若足够则计算有几分钟
|
||||
timeNum = (int) (timeDispersion / MINUTE_TTL);
|
||||
tmpMsg += timeNum + "分";
|
||||
timeDispersion = timeDispersion - (timeNum * MINUTE_TTL);
|
||||
}
|
||||
// 判断是否足够一秒
|
||||
if (timeDispersion >= 1000) {
|
||||
timeNum = (int) (timeDispersion / 1000);
|
||||
tmpMsg += timeNum + "秒";
|
||||
timeDispersion = timeDispersion - timeNum * 1000;
|
||||
}
|
||||
tmpMsg += timeDispersion + "毫秒";
|
||||
return tmpMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接返回毫秒数
|
||||
*
|
||||
* @param beginTime
|
||||
* @param endTime
|
||||
* @return java.lang.Long
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 14:43 2021/5/6
|
||||
**/
|
||||
public static Long countMsDataTime(Calendar beginTime, Calendar endTime) {
|
||||
return (endTime.getTimeInMillis() - beginTime.getTimeInMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传入的long类型日期,计算出执行的时间值(精确版)
|
||||
*
|
||||
* @param beginTime
|
||||
* @param endTime
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 14:44 2021/5/6
|
||||
**/
|
||||
public static String countMsDataTimeToString(Long beginTime, Long endTime) {
|
||||
Long timeDispersion = endTime - beginTime;
|
||||
String tmpMsg = "耗时: ";
|
||||
int timeNum = 0;
|
||||
if (timeDispersion >= (HOURS_TTL)) {
|
||||
timeNum = (int) (timeDispersion / (HOURS_TTL));
|
||||
tmpMsg += timeNum + "时";
|
||||
timeDispersion = timeDispersion - (timeNum * HOURS_TTL);
|
||||
}
|
||||
if (timeDispersion >= (MINUTE_TTL)) {
|
||||
timeNum = (int) (timeDispersion / (MINUTE_TTL));
|
||||
tmpMsg += timeNum + "分";
|
||||
timeDispersion = timeDispersion - (timeNum * MINUTE_TTL);
|
||||
}
|
||||
if (timeDispersion >= 1000) {
|
||||
timeNum = (int) (timeDispersion / 1000);
|
||||
tmpMsg += timeNum + "秒";
|
||||
timeDispersion = timeDispersion - timeNum * 1000;
|
||||
}
|
||||
tmpMsg += timeDispersion + "毫秒";
|
||||
return tmpMsg;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定年度全部月份集合
|
||||
*
|
||||
* @param year
|
||||
* @return java.util.List<java.lang.String>
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 14:45 2021/5/6
|
||||
**/
|
||||
public static List<String> getYearMonthByYear(String year) {
|
||||
List<String> monthList = new ArrayList<>();
|
||||
for (int i = 1; i <= 12; i++) {
|
||||
monthList.add(year + "-" + (i < 10 ? "0" : "") + i);
|
||||
}
|
||||
return monthList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下个月
|
||||
*
|
||||
* @param dateStr
|
||||
* @param format
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 14:45 2021/5/6
|
||||
**/
|
||||
public static String getPreMonth(String dateStr, String format) {
|
||||
String preMonth = "";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
Date date;
|
||||
try {
|
||||
date = sdf.parse(dateStr);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.MONTH, 1);
|
||||
sdf.format(calendar.getTime());
|
||||
|
||||
} catch (ParseException e) {
|
||||
// Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return preMonth;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下个月str
|
||||
*
|
||||
* @param dateStr
|
||||
* @param format
|
||||
* @return java.lang.String
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 14:46 2021/5/6
|
||||
**/
|
||||
public static String getPreMonthFormat(String dateStr, String format) {
|
||||
String preMonth = "";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
Date date;
|
||||
try {
|
||||
date = sdf.parse(dateStr);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.MONTH, 1);
|
||||
preMonth = sdf.format(calendar.getTime());
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return preMonth;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期比较
|
||||
*
|
||||
* @param
|
||||
* @return boolean
|
||||
* @throws
|
||||
* @author ZhangSan_Plus
|
||||
* @date 14:47 2021/5/6
|
||||
**/
|
||||
public static boolean dateSize(String aDate, String bDate, SimpleDateFormat format) {
|
||||
boolean str = false;
|
||||
try {
|
||||
if (StringUtils.isBlank(aDate) && StringUtils.isBlank(bDate)) {
|
||||
Date date1 = format.parse(aDate);
|
||||
Date date2 = format.parse(bDate);
|
||||
str = date1.after(date2);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
// Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static Map<Integer, Long> timestamp() {
|
||||
Map<Integer, Long> timeMap = Maps.newHashMap();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
int[] yearArr = new int[] { 1, 1, 1, 2, 5, 1 };
|
||||
int[] arr = new int[] { 1, 2, 3, 5, 10, 11 };
|
||||
for (int i = 0; i < yearArr.length; i++) {
|
||||
calendar.add(Calendar.YEAR, -yearArr[i]);
|
||||
timeMap.put(arr[i], calendar.getTimeInMillis());
|
||||
}
|
||||
return timeMap;
|
||||
}
|
||||
|
||||
public static Date getDateToOne() {
|
||||
Date date = new Date();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.MONTH, 1);
|
||||
/**
|
||||
* 1. getActualMinimum(Calendar.DAY_OF_MONTH)是拿到当月最小天数作为第一天
|
||||
*
|
||||
* 2. calendar.set(Calendar.DAY_OF_MONTH, 1)也能获取当月第一天
|
||||
*/
|
||||
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
|
||||
System.out.println(calendar.getTime());
|
||||
String s = DateUtils.formatDate(calendar.getTime(), DateUtils.DATE_YYYY_MM_DD);
|
||||
System.out.println(s);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.cym.utils.cert;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author czh
|
||||
* @data 2020/10/20 10:47
|
||||
*/
|
||||
public class PunyUtils {
|
||||
static int TMIN = 1;
|
||||
static int TMAX = 26;
|
||||
static int BASE = 36;
|
||||
static int INITIAL_N = 128;
|
||||
static int INITIAL_BIAS = 72;
|
||||
static int DAMP = 700;
|
||||
static int SKEW = 38;
|
||||
static char DELIMITER = '-';
|
||||
|
||||
|
||||
public static String encode(String input) throws Exception {
|
||||
int n = INITIAL_N;
|
||||
int delta = 0;
|
||||
int bias = INITIAL_BIAS;
|
||||
StringBuilder output = new StringBuilder();
|
||||
// Copy all basic code points to the output
|
||||
int b = 0;
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char c = input.charAt(i);
|
||||
if (isBasic(c)) {
|
||||
output.append(c);
|
||||
b++;
|
||||
}
|
||||
}
|
||||
// Append delimiter
|
||||
if (b > 0) {
|
||||
output.append(DELIMITER);
|
||||
}
|
||||
int h = b;
|
||||
while (h < input.length()) {
|
||||
int m = Integer.MAX_VALUE;
|
||||
// Find the minimum code point >= n
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
int c = input.charAt(i);
|
||||
if (c >= n && c < m) {
|
||||
m = c;
|
||||
}
|
||||
}
|
||||
if (m - n > (Integer.MAX_VALUE - delta) / (h + 1)) {
|
||||
throw new Exception("OVERFLOW");
|
||||
}
|
||||
delta = delta + (m - n) * (h + 1);
|
||||
n = m;
|
||||
for (int j = 0; j < input.length(); j++) {
|
||||
int c = input.charAt(j);
|
||||
if (c < n) {
|
||||
delta++;
|
||||
if (0 == delta) {
|
||||
throw new Exception("OVERFLOW");
|
||||
}
|
||||
}
|
||||
if (c == n) {
|
||||
int q = delta;
|
||||
for (int k = BASE;; k += BASE) {
|
||||
int t;
|
||||
if (k <= bias) {
|
||||
t = TMIN;
|
||||
} else if (k >= bias + TMAX) {
|
||||
t = TMAX;
|
||||
} else {
|
||||
t = k - bias;
|
||||
}
|
||||
if (q < t) {
|
||||
break;
|
||||
}
|
||||
output.append((char) digit2codepoint(t + (q - t) % (BASE - t)));
|
||||
q = (q - t) / (BASE - t);
|
||||
}
|
||||
output.append((char) digit2codepoint(q));
|
||||
bias = adapt(delta, h + 1, h == b);
|
||||
delta = 0;
|
||||
h++;
|
||||
}
|
||||
}
|
||||
delta++;
|
||||
n++;
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
/**
|
||||
* Decode a punycoded string.
|
||||
*
|
||||
* @param input
|
||||
* Punycode string
|
||||
*
|
||||
* @return Unicode string.
|
||||
*/
|
||||
public static String decode(String input) throws Exception {
|
||||
int n = INITIAL_N;
|
||||
int i = 0;
|
||||
int bias = INITIAL_BIAS;
|
||||
StringBuilder output = new StringBuilder();
|
||||
int d = input.lastIndexOf(DELIMITER);
|
||||
if (d > 0) {
|
||||
for (int j = 0; j < d; j++) {
|
||||
char c = input.charAt(j);
|
||||
if (!isBasic(c)) {
|
||||
throw new Exception("BAD_INPUT");
|
||||
}
|
||||
output.append(c);
|
||||
}
|
||||
d++;
|
||||
} else {
|
||||
d = 0;
|
||||
}
|
||||
while (d < input.length()) {
|
||||
int oldi = i;
|
||||
int w = 1;
|
||||
for (int k = BASE;; k += BASE) {
|
||||
if (d == input.length()) {
|
||||
throw new Exception("BAD_INPUT");
|
||||
}
|
||||
int c = input.charAt(d++);
|
||||
int digit = codepoint2digit(c);
|
||||
if (digit > (Integer.MAX_VALUE - i) / w) {
|
||||
throw new Exception("OVERFLOW");
|
||||
}
|
||||
i = i + digit * w;
|
||||
int t;
|
||||
if (k <= bias) {
|
||||
t = TMIN;
|
||||
} else if (k >= bias + TMAX) {
|
||||
t = TMAX;
|
||||
} else {
|
||||
t = k - bias;
|
||||
}
|
||||
if (digit < t) {
|
||||
break;
|
||||
}
|
||||
w = w * (BASE - t);
|
||||
}
|
||||
bias = adapt(i - oldi, output.length() + 1, oldi == 0);
|
||||
if (i / (output.length() + 1) > Integer.MAX_VALUE - n) {
|
||||
throw new Exception("OVERFLOW");
|
||||
}
|
||||
n = n + i / (output.length() + 1);
|
||||
i = i % (output.length() + 1);
|
||||
output.insert(i, (char) n);
|
||||
i++;
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
public static int adapt(int delta, int numpoints, boolean first) {
|
||||
if (first) {
|
||||
delta = delta / DAMP;
|
||||
} else {
|
||||
delta = delta / 2;
|
||||
}
|
||||
delta = delta + (delta / numpoints);
|
||||
int k = 0;
|
||||
while (delta > ((BASE - TMIN) * TMAX) / 2) {
|
||||
delta = delta / (BASE - TMIN);
|
||||
k = k + BASE;
|
||||
}
|
||||
return k + ((BASE - TMIN + 1) * delta) / (delta + SKEW);
|
||||
}
|
||||
|
||||
public static boolean isBasic(char c) {
|
||||
return c < 0x80;
|
||||
}
|
||||
public static int digit2codepoint(int d) throws Exception {
|
||||
if (d < 26) {
|
||||
// 0..25 : 'a'..'z'
|
||||
return d + 'a';
|
||||
} else if (d < 36) {
|
||||
// 26..35 : '0'..'9';
|
||||
return d - 26 + '0';
|
||||
} else {
|
||||
throw new Exception("BAD_INPUT");
|
||||
}
|
||||
}
|
||||
public static int codepoint2digit(int c) throws Exception {
|
||||
if (c - '0' < 10) {
|
||||
// '0'..'9' : 26..35
|
||||
return c - '0' + 26;
|
||||
} else if (c - 'a' < 26) {
|
||||
// 'a'..'z' : 0..25
|
||||
return c - 'a';
|
||||
} else {
|
||||
throw new Exception("BAD_INPUT");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class AccessDescriptions
|
||||
{
|
||||
private AccessLocation accessLocation;
|
||||
|
||||
private AccessMethod accessMethod;
|
||||
|
||||
public void setAccessLocation(AccessLocation accessLocation){
|
||||
this.accessLocation = accessLocation;
|
||||
}
|
||||
public AccessLocation getAccessLocation(){
|
||||
return this.accessLocation;
|
||||
}
|
||||
public void setAccessMethod(AccessMethod accessMethod){
|
||||
this.accessMethod = accessMethod;
|
||||
}
|
||||
public AccessMethod getAccessMethod(){
|
||||
return this.accessMethod;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class AccessLocation
|
||||
{
|
||||
private Name name;
|
||||
|
||||
private int type;
|
||||
|
||||
public void setName(Name name){
|
||||
this.name = name;
|
||||
}
|
||||
public Name getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setType(int type){
|
||||
this.type = type;
|
||||
}
|
||||
public int getType(){
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class AccessMethod
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AlgorithmId {
|
||||
private String name;
|
||||
|
||||
private OID oID;
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setOID(OID oID) {
|
||||
this.oID = oID;
|
||||
}
|
||||
|
||||
public OID getOID() {
|
||||
return this.oID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class AuthKeyId
|
||||
{
|
||||
private String identifier;
|
||||
|
||||
public void setIdentifier(String identifier){
|
||||
this.identifier = identifier;
|
||||
}
|
||||
public String getIdentifier(){
|
||||
return this.identifier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
import java.util.List;
|
||||
|
||||
public class AuthorityInfoAccessExtension
|
||||
{
|
||||
private List<AccessDescriptions> accessDescriptions;
|
||||
|
||||
private boolean critical;
|
||||
|
||||
private List<String> elements;
|
||||
|
||||
private ExtensionId extensionId;
|
||||
|
||||
private String extensionValue;
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
public void setAccessDescriptions(List<AccessDescriptions> accessDescriptions){
|
||||
this.accessDescriptions = accessDescriptions;
|
||||
}
|
||||
public List<AccessDescriptions> getAccessDescriptions(){
|
||||
return this.accessDescriptions;
|
||||
}
|
||||
public void setCritical(boolean critical){
|
||||
this.critical = critical;
|
||||
}
|
||||
public boolean getCritical(){
|
||||
return this.critical;
|
||||
}
|
||||
public void setElements(List<String> elements){
|
||||
this.elements = elements;
|
||||
}
|
||||
public List<String> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
public void setExtensionId(ExtensionId extensionId){
|
||||
this.extensionId = extensionId;
|
||||
}
|
||||
public ExtensionId getExtensionId(){
|
||||
return this.extensionId;
|
||||
}
|
||||
public void setExtensionValue(String extensionValue){
|
||||
this.extensionValue = extensionValue;
|
||||
}
|
||||
public String getExtensionValue(){
|
||||
return this.extensionValue;
|
||||
}
|
||||
public void setId(String id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getId(){
|
||||
return this.id;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setValue(String value){
|
||||
this.value = value;
|
||||
}
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
import java.util.List;
|
||||
|
||||
public class AuthorityKeyIdentifierExtension
|
||||
{
|
||||
private boolean critical;
|
||||
|
||||
private List<String> elements;
|
||||
|
||||
private ExtensionId extensionId;
|
||||
|
||||
private String extensionValue;
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
public void setCritical(boolean critical){
|
||||
this.critical = critical;
|
||||
}
|
||||
public boolean getCritical(){
|
||||
return this.critical;
|
||||
}
|
||||
public void setElements(List<String> elements){
|
||||
this.elements = elements;
|
||||
}
|
||||
public List<String> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
public void setExtensionId(ExtensionId extensionId){
|
||||
this.extensionId = extensionId;
|
||||
}
|
||||
public ExtensionId getExtensionId(){
|
||||
return this.extensionId;
|
||||
}
|
||||
public void setExtensionValue(String extensionValue){
|
||||
this.extensionValue = extensionValue;
|
||||
}
|
||||
public String getExtensionValue(){
|
||||
return this.extensionValue;
|
||||
}
|
||||
public void setId(String id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getId(){
|
||||
return this.id;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setValue(String value){
|
||||
this.value = value;
|
||||
}
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
import java.util.List;
|
||||
|
||||
public class BasicConstraintsExtension
|
||||
{
|
||||
private boolean critical;
|
||||
|
||||
private List<String> elements;
|
||||
|
||||
private ExtensionId extensionId;
|
||||
|
||||
private String extensionValue;
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
public void setCritical(boolean critical){
|
||||
this.critical = critical;
|
||||
}
|
||||
public boolean getCritical(){
|
||||
return this.critical;
|
||||
}
|
||||
public void setElements(List<String> elements){
|
||||
this.elements = elements;
|
||||
}
|
||||
public List<String> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
public void setExtensionId(ExtensionId extensionId){
|
||||
this.extensionId = extensionId;
|
||||
}
|
||||
public ExtensionId getExtensionId(){
|
||||
return this.extensionId;
|
||||
}
|
||||
public void setExtensionValue(String extensionValue){
|
||||
this.extensionValue = extensionValue;
|
||||
}
|
||||
public String getExtensionValue(){
|
||||
return this.extensionValue;
|
||||
}
|
||||
public void setId(String id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getId(){
|
||||
return this.id;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setValue(String value){
|
||||
this.value = value;
|
||||
}
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
import java.util.List;
|
||||
|
||||
public class CRLDistributionPointsExtension
|
||||
{
|
||||
private boolean critical;
|
||||
|
||||
private List<String> elements;
|
||||
|
||||
private ExtensionId extensionId;
|
||||
|
||||
private String extensionValue;
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
public void setCritical(boolean critical){
|
||||
this.critical = critical;
|
||||
}
|
||||
public boolean getCritical(){
|
||||
return this.critical;
|
||||
}
|
||||
public void setElements(List<String> elements){
|
||||
this.elements = elements;
|
||||
}
|
||||
public List<String> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
public void setExtensionId(ExtensionId extensionId){
|
||||
this.extensionId = extensionId;
|
||||
}
|
||||
public ExtensionId getExtensionId(){
|
||||
return this.extensionId;
|
||||
}
|
||||
public void setExtensionValue(String extensionValue){
|
||||
this.extensionValue = extensionValue;
|
||||
}
|
||||
public String getExtensionValue(){
|
||||
return this.extensionValue;
|
||||
}
|
||||
public void setId(String id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getId(){
|
||||
return this.id;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setValue(String value){
|
||||
this.value = value;
|
||||
}
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
import java.util.List;
|
||||
|
||||
public class CertificatePoliciesExtension
|
||||
{
|
||||
private boolean critical;
|
||||
|
||||
private List<String> elements;
|
||||
|
||||
private ExtensionId extensionId;
|
||||
|
||||
private String extensionValue;
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
public void setCritical(boolean critical){
|
||||
this.critical = critical;
|
||||
}
|
||||
public boolean getCritical(){
|
||||
return this.critical;
|
||||
}
|
||||
public void setElements(List<String> elements){
|
||||
this.elements = elements;
|
||||
}
|
||||
public List<String> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
public void setExtensionId(ExtensionId extensionId){
|
||||
this.extensionId = extensionId;
|
||||
}
|
||||
public ExtensionId getExtensionId(){
|
||||
return this.extensionId;
|
||||
}
|
||||
public void setExtensionValue(String extensionValue){
|
||||
this.extensionValue = extensionValue;
|
||||
}
|
||||
public String getExtensionValue(){
|
||||
return this.extensionValue;
|
||||
}
|
||||
public void setId(String id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getId(){
|
||||
return this.id;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setValue(String value){
|
||||
this.value = value;
|
||||
}
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
import java.util.List;
|
||||
|
||||
public class ExtendedKeyUsageExtension
|
||||
{
|
||||
private boolean critical;
|
||||
|
||||
private List<String> elements;
|
||||
|
||||
private List<String> extendedKeyUsage;
|
||||
|
||||
private ExtensionId extensionId;
|
||||
|
||||
private String extensionValue;
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
public void setCritical(boolean critical){
|
||||
this.critical = critical;
|
||||
}
|
||||
public boolean getCritical(){
|
||||
return this.critical;
|
||||
}
|
||||
public void setElements(List<String> elements){
|
||||
this.elements = elements;
|
||||
}
|
||||
public List<String> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
public void setExtendedKeyUsage(List<String> extendedKeyUsage){
|
||||
this.extendedKeyUsage = extendedKeyUsage;
|
||||
}
|
||||
public List<String> getExtendedKeyUsage(){
|
||||
return this.extendedKeyUsage;
|
||||
}
|
||||
public void setExtensionId(ExtensionId extensionId){
|
||||
this.extensionId = extensionId;
|
||||
}
|
||||
public ExtensionId getExtensionId(){
|
||||
return this.extensionId;
|
||||
}
|
||||
public void setExtensionValue(String extensionValue){
|
||||
this.extensionValue = extensionValue;
|
||||
}
|
||||
public String getExtensionValue(){
|
||||
return this.extensionValue;
|
||||
}
|
||||
public void setId(String id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getId(){
|
||||
return this.id;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setValue(String value){
|
||||
this.value = value;
|
||||
}
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class ExtensionId
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
public class HostObject
|
||||
{
|
||||
private String name;
|
||||
|
||||
private int type;
|
||||
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setType(int type){
|
||||
this.type = type;
|
||||
}
|
||||
public int getType(){
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class IssuerDN
|
||||
{
|
||||
private String commonName;
|
||||
|
||||
private String country;
|
||||
|
||||
private boolean empty;
|
||||
|
||||
private String encoded;
|
||||
|
||||
private String encodedInternal;
|
||||
|
||||
private String name;
|
||||
|
||||
private String organization;
|
||||
|
||||
private String organizationalUnit;
|
||||
|
||||
private String rFC1779Name;
|
||||
|
||||
private String rFC2253CanonicalName;
|
||||
|
||||
private String rFC2253Name;
|
||||
|
||||
private int type;
|
||||
|
||||
public void setCommonName(String commonName){
|
||||
this.commonName = commonName;
|
||||
}
|
||||
public String getCommonName(){
|
||||
return this.commonName;
|
||||
}
|
||||
public void setCountry(String country){
|
||||
this.country = country;
|
||||
}
|
||||
public String getCountry(){
|
||||
return this.country;
|
||||
}
|
||||
public void setEmpty(boolean empty){
|
||||
this.empty = empty;
|
||||
}
|
||||
public boolean getEmpty(){
|
||||
return this.empty;
|
||||
}
|
||||
public void setEncoded(String encoded){
|
||||
this.encoded = encoded;
|
||||
}
|
||||
public String getEncoded(){
|
||||
return this.encoded;
|
||||
}
|
||||
public void setEncodedInternal(String encodedInternal){
|
||||
this.encodedInternal = encodedInternal;
|
||||
}
|
||||
public String getEncodedInternal(){
|
||||
return this.encodedInternal;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setOrganization(String organization){
|
||||
this.organization = organization;
|
||||
}
|
||||
public String getOrganization(){
|
||||
return this.organization;
|
||||
}
|
||||
public void setOrganizationalUnit(String organizationalUnit){
|
||||
this.organizationalUnit = organizationalUnit;
|
||||
}
|
||||
public String getOrganizationalUnit(){
|
||||
return this.organizationalUnit;
|
||||
}
|
||||
public void setRFC1779Name(String rFC1779Name){
|
||||
this.rFC1779Name = rFC1779Name;
|
||||
}
|
||||
public String getRFC1779Name(){
|
||||
return this.rFC1779Name;
|
||||
}
|
||||
public void setRFC2253CanonicalName(String rFC2253CanonicalName){
|
||||
this.rFC2253CanonicalName = rFC2253CanonicalName;
|
||||
}
|
||||
public String getRFC2253CanonicalName(){
|
||||
return this.rFC2253CanonicalName;
|
||||
}
|
||||
public void setRFC2253Name(String rFC2253Name){
|
||||
this.rFC2253Name = rFC2253Name;
|
||||
}
|
||||
public String getRFC2253Name(){
|
||||
return this.rFC2253Name;
|
||||
}
|
||||
public void setType(int type){
|
||||
this.type = type;
|
||||
}
|
||||
public int getType(){
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class Name
|
||||
{
|
||||
private String host;
|
||||
|
||||
private HostObject hostObject;
|
||||
|
||||
private String name;
|
||||
|
||||
private String scheme;
|
||||
|
||||
private int type;
|
||||
|
||||
private String uRI;
|
||||
|
||||
public void setHost(String host){
|
||||
this.host = host;
|
||||
}
|
||||
public String getHost(){
|
||||
return this.host;
|
||||
}
|
||||
public void setHostObject(HostObject hostObject){
|
||||
this.hostObject = hostObject;
|
||||
}
|
||||
public HostObject getHostObject(){
|
||||
return this.hostObject;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setScheme(String scheme){
|
||||
this.scheme = scheme;
|
||||
}
|
||||
public String getScheme(){
|
||||
return this.scheme;
|
||||
}
|
||||
public void setType(int type){
|
||||
this.type = type;
|
||||
}
|
||||
public int getType(){
|
||||
return this.type;
|
||||
}
|
||||
public void setURI(String uRI){
|
||||
this.uRI = uRI;
|
||||
}
|
||||
public String getURI(){
|
||||
return this.uRI;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class OID
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PublicKey {
|
||||
private String algorithm;
|
||||
|
||||
private AlgorithmId algorithmId;
|
||||
|
||||
private String encoded;
|
||||
|
||||
private String encodedInternal;
|
||||
|
||||
private String format;
|
||||
|
||||
private String modulus;
|
||||
|
||||
private int publicExponent;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Root {
|
||||
private AuthKeyId authKeyId;
|
||||
|
||||
private AuthorityInfoAccessExtension authorityInfoAccessExtension;
|
||||
|
||||
private AuthorityKeyIdentifierExtension authorityKeyIdentifierExtension;
|
||||
|
||||
private int basicConstraints;
|
||||
|
||||
private BasicConstraintsExtension basicConstraintsExtension;
|
||||
|
||||
private CRLDistributionPointsExtension cRLDistributionPointsExtension;
|
||||
|
||||
private CertificatePoliciesExtension certificatePoliciesExtension;
|
||||
|
||||
private List<String> criticalExtensionOIDs;
|
||||
|
||||
private List<String> elements;
|
||||
|
||||
private String encoded;
|
||||
|
||||
private String encodedInternal;
|
||||
|
||||
private List<String> extendedKeyUsage;
|
||||
|
||||
private ExtendedKeyUsageExtension extendedKeyUsageExtension;
|
||||
|
||||
private IssuerDN issuerDN;
|
||||
|
||||
private List<Boolean> keyUsage;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<String> nonCriticalExtensionOIDs;
|
||||
|
||||
private Date notAfter;
|
||||
|
||||
private Date notBefore;
|
||||
|
||||
private PublicKey publicKey;
|
||||
|
||||
private double serialNumber;
|
||||
|
||||
private SerialNumberObject serialNumberObject;
|
||||
|
||||
private String sigAlgName;
|
||||
|
||||
private String sigAlgOID;
|
||||
|
||||
private String signature;
|
||||
|
||||
private SubjectAlternativeNameExtension subjectAlternativeNameExtension;
|
||||
|
||||
private List<List<String>> subjectAlternativeNames;
|
||||
|
||||
private SubjectDN subjectDN;
|
||||
|
||||
private SubjectKeyId subjectKeyId;
|
||||
|
||||
private SubjectKeyIdentifierExtension subjectKeyIdentifierExtension;
|
||||
|
||||
private String tBSCertificate;
|
||||
|
||||
private String type;
|
||||
|
||||
private int version;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author czh
|
||||
* @data 2020/10/10 9:26
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Table(name = "tb_ssl_basic_info")
|
||||
public class SSLBasicInfo {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
private String domain;
|
||||
|
||||
//序列号
|
||||
private String serialNum;
|
||||
//版本
|
||||
private String version;
|
||||
//加密算法
|
||||
private String encryptionAlgorithm;
|
||||
//签名算法
|
||||
private String signatureAlgorithm;
|
||||
|
||||
//证书类型
|
||||
private String certificateType;
|
||||
//证书品牌
|
||||
private String certificateBrand;
|
||||
//sha256指纹
|
||||
private String sha256Fingerprint;
|
||||
//签发时间
|
||||
private Date issueDate;
|
||||
//到期时间
|
||||
private Date deadlineDate;
|
||||
|
||||
|
||||
|
||||
private String themeAll;
|
||||
|
||||
private String themeCn;
|
||||
private String themeO;
|
||||
private String themeOu;
|
||||
private String themeL;
|
||||
private String themeSt;
|
||||
private String themeC;
|
||||
|
||||
|
||||
private String issueAll;
|
||||
|
||||
private String issueCn;
|
||||
private String issueO;
|
||||
private String issueC;
|
||||
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author czh
|
||||
* @data 2020/8/11 11:44
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SSLDetailsInfo {
|
||||
|
||||
//序列号
|
||||
private String serialNum;
|
||||
//版本
|
||||
private String version;
|
||||
//加密算法
|
||||
private String encryptionAlgorithm;
|
||||
//签名算法
|
||||
private String signatureAlgorithm;
|
||||
|
||||
//证书类型
|
||||
private String certificateType;
|
||||
//证书品牌
|
||||
private String certificateBrand;
|
||||
//sha256指纹
|
||||
private String sha256Fingerprint;
|
||||
//签发时间
|
||||
private Date issueDate;
|
||||
//到期时间
|
||||
private Date deadlineDate;
|
||||
//有效期
|
||||
private String validPeriod;
|
||||
//sans
|
||||
private List<String> sansList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author czh
|
||||
* @data 2020/8/11 11:44
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SSLInfo {
|
||||
private SSLSubjectInfo sslSubjectInfo;
|
||||
private SSLIssuerInfo sslIssuerInfo;
|
||||
private SSLDetailsInfo sslDetailsInfo;
|
||||
private String subDN;
|
||||
private String issDN;
|
||||
private String webUrl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author czh
|
||||
* @data 2020/8/11 11:44
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SSLIssuerInfo {
|
||||
private String cn;
|
||||
private String o;
|
||||
private String c;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author czh
|
||||
* @data 2020/8/11 11:44
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SSLSubjectInfo {
|
||||
private String cn;
|
||||
private String o;
|
||||
private String ou;
|
||||
private String l;
|
||||
private String st;
|
||||
private String c;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class SerialNumberObject
|
||||
{
|
||||
private double number;
|
||||
|
||||
public void setNumber(double number){
|
||||
this.number = number;
|
||||
}
|
||||
public double getNumber(){
|
||||
return this.number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
import java.util.List;
|
||||
|
||||
public class SubjectAlternativeNameExtension
|
||||
{
|
||||
private boolean critical;
|
||||
|
||||
private List<String> elements;
|
||||
|
||||
private ExtensionId extensionId;
|
||||
|
||||
private String extensionValue;
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
public void setCritical(boolean critical){
|
||||
this.critical = critical;
|
||||
}
|
||||
public boolean getCritical(){
|
||||
return this.critical;
|
||||
}
|
||||
public void setElements(List<String> elements){
|
||||
this.elements = elements;
|
||||
}
|
||||
public List<String> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
public void setExtensionId(ExtensionId extensionId){
|
||||
this.extensionId = extensionId;
|
||||
}
|
||||
public ExtensionId getExtensionId(){
|
||||
return this.extensionId;
|
||||
}
|
||||
public void setExtensionValue(String extensionValue){
|
||||
this.extensionValue = extensionValue;
|
||||
}
|
||||
public String getExtensionValue(){
|
||||
return this.extensionValue;
|
||||
}
|
||||
public void setId(String id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getId(){
|
||||
return this.id;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setValue(String value){
|
||||
this.value = value;
|
||||
}
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class SubjectDN
|
||||
{
|
||||
private String commonName;
|
||||
|
||||
private String country;
|
||||
|
||||
private boolean empty;
|
||||
|
||||
private String encoded;
|
||||
|
||||
private String encodedInternal;
|
||||
|
||||
private String name;
|
||||
|
||||
private String organization;
|
||||
|
||||
private String rFC1779Name;
|
||||
|
||||
private String rFC2253CanonicalName;
|
||||
|
||||
private String rFC2253Name;
|
||||
|
||||
private String state;
|
||||
|
||||
private int type;
|
||||
|
||||
public void setCommonName(String commonName){
|
||||
this.commonName = commonName;
|
||||
}
|
||||
public String getCommonName(){
|
||||
return this.commonName;
|
||||
}
|
||||
public void setCountry(String country){
|
||||
this.country = country;
|
||||
}
|
||||
public String getCountry(){
|
||||
return this.country;
|
||||
}
|
||||
public void setEmpty(boolean empty){
|
||||
this.empty = empty;
|
||||
}
|
||||
public boolean getEmpty(){
|
||||
return this.empty;
|
||||
}
|
||||
public void setEncoded(String encoded){
|
||||
this.encoded = encoded;
|
||||
}
|
||||
public String getEncoded(){
|
||||
return this.encoded;
|
||||
}
|
||||
public void setEncodedInternal(String encodedInternal){
|
||||
this.encodedInternal = encodedInternal;
|
||||
}
|
||||
public String getEncodedInternal(){
|
||||
return this.encodedInternal;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setOrganization(String organization){
|
||||
this.organization = organization;
|
||||
}
|
||||
public String getOrganization(){
|
||||
return this.organization;
|
||||
}
|
||||
public void setRFC1779Name(String rFC1779Name){
|
||||
this.rFC1779Name = rFC1779Name;
|
||||
}
|
||||
public String getRFC1779Name(){
|
||||
return this.rFC1779Name;
|
||||
}
|
||||
public void setRFC2253CanonicalName(String rFC2253CanonicalName){
|
||||
this.rFC2253CanonicalName = rFC2253CanonicalName;
|
||||
}
|
||||
public String getRFC2253CanonicalName(){
|
||||
return this.rFC2253CanonicalName;
|
||||
}
|
||||
public void setRFC2253Name(String rFC2253Name){
|
||||
this.rFC2253Name = rFC2253Name;
|
||||
}
|
||||
public String getRFC2253Name(){
|
||||
return this.rFC2253Name;
|
||||
}
|
||||
public void setState(String state){
|
||||
this.state = state;
|
||||
}
|
||||
public String getState(){
|
||||
return this.state;
|
||||
}
|
||||
public void setType(int type){
|
||||
this.type = type;
|
||||
}
|
||||
public int getType(){
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
public class SubjectKeyId
|
||||
{
|
||||
private String identifier;
|
||||
|
||||
public void setIdentifier(String identifier){
|
||||
this.identifier = identifier;
|
||||
}
|
||||
public String getIdentifier(){
|
||||
return this.identifier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
import java.util.List;
|
||||
|
||||
public class SubjectKeyIdentifierExtension
|
||||
{
|
||||
private boolean critical;
|
||||
|
||||
private List<String> elements;
|
||||
|
||||
private ExtensionId extensionId;
|
||||
|
||||
private String extensionValue;
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
public void setCritical(boolean critical){
|
||||
this.critical = critical;
|
||||
}
|
||||
public boolean getCritical(){
|
||||
return this.critical;
|
||||
}
|
||||
public void setElements(List<String> elements){
|
||||
this.elements = elements;
|
||||
}
|
||||
public List<String> getElements(){
|
||||
return this.elements;
|
||||
}
|
||||
public void setExtensionId(ExtensionId extensionId){
|
||||
this.extensionId = extensionId;
|
||||
}
|
||||
public ExtensionId getExtensionId(){
|
||||
return this.extensionId;
|
||||
}
|
||||
public void setExtensionValue(String extensionValue){
|
||||
this.extensionValue = extensionValue;
|
||||
}
|
||||
public String getExtensionValue(){
|
||||
return this.extensionValue;
|
||||
}
|
||||
public void setId(String id){
|
||||
this.id = id;
|
||||
}
|
||||
public String getId(){
|
||||
return this.id;
|
||||
}
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
public void setValue(String value){
|
||||
this.value = value;
|
||||
}
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.cym.utils.cert.ssl;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ZhangSan_Plus
|
||||
* @version 1.0
|
||||
* @className XccSSLInfo
|
||||
* @description
|
||||
* @date 2022/8/27 16:17
|
||||
**/
|
||||
@Data
|
||||
public class XccSSLInfo {
|
||||
private String success;
|
||||
private String detectUrl;
|
||||
/**
|
||||
* 信任状态
|
||||
*/
|
||||
private String trustStatus;
|
||||
/**
|
||||
* 通用名称
|
||||
*/
|
||||
private String commonName;
|
||||
/**
|
||||
* 颁发者
|
||||
*/
|
||||
private String issuer;
|
||||
/**
|
||||
* 加密算法
|
||||
*/
|
||||
private String encryptionAlgorithm;
|
||||
/**
|
||||
* 签名算法
|
||||
*/
|
||||
private String signatureAlgorithm;
|
||||
/**
|
||||
* 证书透明(CT)
|
||||
*/
|
||||
private String certificateTransparency;
|
||||
/**
|
||||
* 吊销状态
|
||||
*/
|
||||
private String revocationStatus;
|
||||
|
||||
|
||||
//主题信息
|
||||
private String subjectCN;
|
||||
private String subjectO;
|
||||
private String subjectOU;
|
||||
private String subjectL;
|
||||
private String subjectST;
|
||||
private String subjectC;
|
||||
//签发者信息
|
||||
private String issueCN;
|
||||
private String issueO;
|
||||
private String issueC;
|
||||
private String issueOU;
|
||||
//证书信息
|
||||
private String serialNumber;
|
||||
private String rootCert;
|
||||
private String algorithm;
|
||||
private String certificateType;
|
||||
private String certificateBrand;
|
||||
private String privateKeyLen;
|
||||
private String SHA1Fingerprint;
|
||||
private String SHA256Fingerprint;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private String validityPeriod;
|
||||
private String extKeyUsage;
|
||||
private List<List<String>> sans;
|
||||
private String ocspUrl;
|
||||
private String crlUrl;
|
||||
private String caUrl;
|
||||
private String publicKey;
|
||||
private String openSSL;
|
||||
}
|
||||
Reference in New Issue
Block a user