diff --git a/README.md b/README.md new file mode 100644 index 0000000..5e22bdf --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +### cdnServer插件说明 + +本项目为cdnServer的插件, 一般开发人员只需要开发好这个项目后, cdnServer主项目进行合并打包即可完成对此项目的整合. + +本项目为springboot3的项目, 使用jdk21进行开发, 前端html模板为freemarker, 数据库orm为自研的jpaHelper. + +jpaHelper的使用说明看这个页面: https://gitee.com/cym1102/jpaHelper 主要特点是不需要手动维护数据库结构, 添加model后自动生成表结构 + +网页框架用的jquery + layui官网说明: https://layui.dev/ + +### 文件说明 + +com.cym.CdnWebUI.java : 主启动类 + +com.cym.controller.page.LoginExampleController.java : 登录接口 +com.cym.controller.page.ExampleController.java : 演示模块接口 + +com.cym.model.* : 数据库映射对象 + +com.cym.ext.* : 主要是一些类的扩展类, 方便返回更多数据给前端 + +com.cym.service.* : 数据访问层 + +com.cym.utils.* : 工具类 \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/CertExportEmailDTO.java b/src/main/java/com/cym/utils/cert/CertExportEmailDTO.java deleted file mode 100644 index 03deb59..0000000 --- a/src/main/java/com/cym/utils/cert/CertExportEmailDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -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 certExportEmailVOS; - private String[] email; - private Map maps; -} diff --git a/src/main/java/com/cym/utils/cert/CertExportEmailVO.java b/src/main/java/com/cym/utils/cert/CertExportEmailVO.java deleted file mode 100644 index 5f51b17..0000000 --- a/src/main/java/com/cym/utils/cert/CertExportEmailVO.java +++ /dev/null @@ -1,337 +0,0 @@ -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 sans; - private String ocspUrl; - private String crlUrl; - private String caUrl; - private String publicKey; - private String openSSL; - private List 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 getSans() { - return sans; - } - public void setSans(List 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 getCertificateChains() { - return certificateChains; - } - public void setCertificateChains(List certificateChains) { - this.certificateChains = certificateChains; - } - - -} diff --git a/src/main/java/com/cym/utils/cert/CertInfoDTO.java b/src/main/java/com/cym/utils/cert/CertInfoDTO.java deleted file mode 100644 index 0c77da8..0000000 --- a/src/main/java/com/cym/utils/cert/CertInfoDTO.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.cym.utils.cert; - -import java.util.List; -import java.util.Map; - -public class CertInfoDTO { - - List> pactMap; - - String webTitle; - String webServer; - String ipAddr; - String icon; - List 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> getPactMap() { - return pactMap; - } - - public void setPactMap(List> 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 getCertExportEmailVOS() { - return certExportEmailVOS; - } - - public void setCertExportEmailVOS(List 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; - } - -} diff --git a/src/main/java/com/cym/utils/cert/CertificateChain.java b/src/main/java/com/cym/utils/cert/CertificateChain.java deleted file mode 100644 index 6d0f517..0000000 --- a/src/main/java/com/cym/utils/cert/CertificateChain.java +++ /dev/null @@ -1,65 +0,0 @@ -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; - } - - -} diff --git a/src/main/java/com/cym/utils/cert/CertificateDetectionUtils.java b/src/main/java/com/cym/utils/cert/CertificateDetectionUtils.java deleted file mode 100644 index 45f4f9e..0000000 --- a/src/main/java/com/cym/utils/cert/CertificateDetectionUtils.java +++ /dev/null @@ -1,839 +0,0 @@ -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> pactMap = Lists.newLinkedList(); - List 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 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 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 certInfo = getCertInfo(cert.toString()); - List sansList = new ArrayList<>(); - if (Objects.nonNull(cert.getSubjectAlternativeNames())) { - Collection> 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 - * @throws - * @author ZhangSan_Plus - * @date 15:40 2022/9/1 - **/ - public static List getCertChain(Certificate[] certificates, String thumbPrint) throws Exception { - List certificateChains = Lists.newArrayList(); - List x509Certificates = Arrays.asList(certificates); - List 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 certificates1 = certificateList.subList(thumb, x509Certificates.size()); - certificates1.forEach(c -> { - CertificateChain certificateChain = certChainDeal(c); - certificateChains.add(certificateChain); - }); - return certificateChains; - } - - public static List getCertChain1(Certificate[] certificates) throws Exception { - List 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 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 - * @throws - * @author ZhangSan_Plus - * @date 10:14 2022/8/31 - **/ - public static Map getCertInfo(String cert) { - Map 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 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 - * @throws - * @author ZhangSan_Plus - * @date 13:40 2022/9/1 - **/ - public static Map getWebInfo(String vls, String web) { - Map 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("")) { - String titleStr = trim.substring(trim.indexOf("<title>"), trim.indexOf("")).replace("", ""); - 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; - } -} diff --git a/src/main/java/com/cym/utils/cert/DateUtils.java b/src/main/java/com/cym/utils/cert/DateUtils.java deleted file mode 100644 index 60815bc..0000000 --- a/src/main/java/com/cym/utils/cert/DateUtils.java +++ /dev/null @@ -1,928 +0,0 @@ -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(); - } - -} diff --git a/src/main/java/com/cym/utils/cert/PunyUtils.java b/src/main/java/com/cym/utils/cert/PunyUtils.java deleted file mode 100644 index a017626..0000000 --- a/src/main/java/com/cym/utils/cert/PunyUtils.java +++ /dev/null @@ -1,194 +0,0 @@ -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"); - } - } - -} diff --git a/src/main/java/com/cym/utils/cert/ssl/AccessDescriptions.java b/src/main/java/com/cym/utils/cert/ssl/AccessDescriptions.java deleted file mode 100644 index 94b40a1..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/AccessDescriptions.java +++ /dev/null @@ -1,21 +0,0 @@ - -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; - } -} diff --git a/src/main/java/com/cym/utils/cert/ssl/AccessLocation.java b/src/main/java/com/cym/utils/cert/ssl/AccessLocation.java deleted file mode 100644 index 4fc42b3..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/AccessLocation.java +++ /dev/null @@ -1,20 +0,0 @@ -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; - } -} diff --git a/src/main/java/com/cym/utils/cert/ssl/AccessMethod.java b/src/main/java/com/cym/utils/cert/ssl/AccessMethod.java deleted file mode 100644 index aaac5a5..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/AccessMethod.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.cym.utils.cert.ssl; -public class AccessMethod -{ -} diff --git a/src/main/java/com/cym/utils/cert/ssl/AlgorithmId.java b/src/main/java/com/cym/utils/cert/ssl/AlgorithmId.java deleted file mode 100644 index 1d4474e..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/AlgorithmId.java +++ /dev/null @@ -1,26 +0,0 @@ -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; - } -} diff --git a/src/main/java/com/cym/utils/cert/ssl/AuthKeyId.java b/src/main/java/com/cym/utils/cert/ssl/AuthKeyId.java deleted file mode 100644 index 8c978dd..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/AuthKeyId.java +++ /dev/null @@ -1,12 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/AuthorityInfoAccessExtension.java b/src/main/java/com/cym/utils/cert/ssl/AuthorityInfoAccessExtension.java deleted file mode 100644 index 4bb0514..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/AuthorityInfoAccessExtension.java +++ /dev/null @@ -1,70 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/AuthorityKeyIdentifierExtension.java b/src/main/java/com/cym/utils/cert/ssl/AuthorityKeyIdentifierExtension.java deleted file mode 100644 index a9184c0..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/AuthorityKeyIdentifierExtension.java +++ /dev/null @@ -1,62 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/BasicConstraintsExtension.java b/src/main/java/com/cym/utils/cert/ssl/BasicConstraintsExtension.java deleted file mode 100644 index 0940e25..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/BasicConstraintsExtension.java +++ /dev/null @@ -1,62 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/CRLDistributionPointsExtension.java b/src/main/java/com/cym/utils/cert/ssl/CRLDistributionPointsExtension.java deleted file mode 100644 index b3da3f6..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/CRLDistributionPointsExtension.java +++ /dev/null @@ -1,62 +0,0 @@ -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; - } -} diff --git a/src/main/java/com/cym/utils/cert/ssl/CertificatePoliciesExtension.java b/src/main/java/com/cym/utils/cert/ssl/CertificatePoliciesExtension.java deleted file mode 100644 index 3e0b739..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/CertificatePoliciesExtension.java +++ /dev/null @@ -1,62 +0,0 @@ -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; - } -} diff --git a/src/main/java/com/cym/utils/cert/ssl/ExtendedKeyUsageExtension.java b/src/main/java/com/cym/utils/cert/ssl/ExtendedKeyUsageExtension.java deleted file mode 100644 index 8ed7911..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/ExtendedKeyUsageExtension.java +++ /dev/null @@ -1,70 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/ExtensionId.java b/src/main/java/com/cym/utils/cert/ssl/ExtensionId.java deleted file mode 100644 index cee5e14..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/ExtensionId.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.cym.utils.cert.ssl; -public class ExtensionId -{ -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/HostObject.java b/src/main/java/com/cym/utils/cert/ssl/HostObject.java deleted file mode 100644 index bc0f3c7..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/HostObject.java +++ /dev/null @@ -1,21 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/IssuerDN.java b/src/main/java/com/cym/utils/cert/ssl/IssuerDN.java deleted file mode 100644 index d345441..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/IssuerDN.java +++ /dev/null @@ -1,100 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/Name.java b/src/main/java/com/cym/utils/cert/ssl/Name.java deleted file mode 100644 index c717e31..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/Name.java +++ /dev/null @@ -1,52 +0,0 @@ -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; - } -} diff --git a/src/main/java/com/cym/utils/cert/ssl/OID.java b/src/main/java/com/cym/utils/cert/ssl/OID.java deleted file mode 100644 index 2ed3b15..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/OID.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.cym.utils.cert.ssl; -public class OID -{ -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/PublicKey.java b/src/main/java/com/cym/utils/cert/ssl/PublicKey.java deleted file mode 100644 index e4c7674..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/PublicKey.java +++ /dev/null @@ -1,21 +0,0 @@ -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; - -} diff --git a/src/main/java/com/cym/utils/cert/ssl/Root.java b/src/main/java/com/cym/utils/cert/ssl/Root.java deleted file mode 100644 index 1a4b932..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/Root.java +++ /dev/null @@ -1,77 +0,0 @@ -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; - - -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/SSLBasicInfo.java b/src/main/java/com/cym/utils/cert/ssl/SSLBasicInfo.java deleted file mode 100644 index 5f4089d..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SSLBasicInfo.java +++ /dev/null @@ -1,72 +0,0 @@ -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; -} diff --git a/src/main/java/com/cym/utils/cert/ssl/SSLDetailsInfo.java b/src/main/java/com/cym/utils/cert/ssl/SSLDetailsInfo.java deleted file mode 100644 index c9671ad..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SSLDetailsInfo.java +++ /dev/null @@ -1,47 +0,0 @@ -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; - -} diff --git a/src/main/java/com/cym/utils/cert/ssl/SSLInfo.java b/src/main/java/com/cym/utils/cert/ssl/SSLInfo.java deleted file mode 100644 index ae5d78f..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SSLInfo.java +++ /dev/null @@ -1,26 +0,0 @@ -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; - -} diff --git a/src/main/java/com/cym/utils/cert/ssl/SSLIssuerInfo.java b/src/main/java/com/cym/utils/cert/ssl/SSLIssuerInfo.java deleted file mode 100644 index d7765f4..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SSLIssuerInfo.java +++ /dev/null @@ -1,22 +0,0 @@ -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; -} diff --git a/src/main/java/com/cym/utils/cert/ssl/SSLSubjectInfo.java b/src/main/java/com/cym/utils/cert/ssl/SSLSubjectInfo.java deleted file mode 100644 index 07faf50..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SSLSubjectInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -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; -} diff --git a/src/main/java/com/cym/utils/cert/ssl/SerialNumberObject.java b/src/main/java/com/cym/utils/cert/ssl/SerialNumberObject.java deleted file mode 100644 index 3f9d675..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SerialNumberObject.java +++ /dev/null @@ -1,12 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/SubjectAlternativeNameExtension.java b/src/main/java/com/cym/utils/cert/ssl/SubjectAlternativeNameExtension.java deleted file mode 100644 index f8bf3fe..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SubjectAlternativeNameExtension.java +++ /dev/null @@ -1,62 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/SubjectDN.java b/src/main/java/com/cym/utils/cert/ssl/SubjectDN.java deleted file mode 100644 index cedaaf2..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SubjectDN.java +++ /dev/null @@ -1,100 +0,0 @@ -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; - } -} diff --git a/src/main/java/com/cym/utils/cert/ssl/SubjectKeyId.java b/src/main/java/com/cym/utils/cert/ssl/SubjectKeyId.java deleted file mode 100644 index 9cc9029..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SubjectKeyId.java +++ /dev/null @@ -1,12 +0,0 @@ -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; - } -} diff --git a/src/main/java/com/cym/utils/cert/ssl/SubjectKeyIdentifierExtension.java b/src/main/java/com/cym/utils/cert/ssl/SubjectKeyIdentifierExtension.java deleted file mode 100644 index 2524f2e..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/SubjectKeyIdentifierExtension.java +++ /dev/null @@ -1,62 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/cym/utils/cert/ssl/XccSSLInfo.java b/src/main/java/com/cym/utils/cert/ssl/XccSSLInfo.java deleted file mode 100644 index 5940341..0000000 --- a/src/main/java/com/cym/utils/cert/ssl/XccSSLInfo.java +++ /dev/null @@ -1,79 +0,0 @@ -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; -}