diff --git a/mica-core/src/main/java/net/dreamlu/mica/core/geo/GeoType.java b/mica-core/src/main/java/net/dreamlu/mica/core/geo/GeoType.java index 915114f77..3e3bed4fd 100644 --- a/mica-core/src/main/java/net/dreamlu/mica/core/geo/GeoType.java +++ b/mica-core/src/main/java/net/dreamlu/mica/core/geo/GeoType.java @@ -16,6 +16,8 @@ package net.dreamlu.mica.core.geo; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -99,6 +101,7 @@ public GeoPoint toBD09(double lon, double lat) { } }; + @JsonValue private final String type; private final String desc; @@ -129,4 +132,21 @@ public GeoPoint toBD09(double lon, double lat) { */ public abstract GeoPoint toBD09(double lon, double lat); + + /** + * 获取坐标系 + * + * @param type type 坐标系类型 + * @return GeoType + */ + @JsonCreator + public static GeoType getGeoType(String type) { + for (GeoType geoType : values()) { + if (geoType.type.equalsIgnoreCase(type)) { + return geoType; + } + } + throw new IllegalArgumentException("未知的坐标系类型" + type); + } + } diff --git a/mica-core/src/main/java/net/dreamlu/mica/core/ssl/DisableValidationTrustManager.java b/mica-core/src/main/java/net/dreamlu/mica/core/ssl/DisableValidationTrustManager.java index 98163ba89..8968dee92 100644 --- a/mica-core/src/main/java/net/dreamlu/mica/core/ssl/DisableValidationTrustManager.java +++ b/mica-core/src/main/java/net/dreamlu/mica/core/ssl/DisableValidationTrustManager.java @@ -16,8 +16,10 @@ package net.dreamlu.mica.core.ssl; +import javax.net.ssl.SSLEngine; import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; +import javax.net.ssl.X509ExtendedTrustManager; +import java.net.Socket; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -26,12 +28,8 @@ * * @author L.cm */ -public enum DisableValidationTrustManager implements X509TrustManager { - - /** - * 实例 - */ - INSTANCE; +public class DisableValidationTrustManager extends X509ExtendedTrustManager { + public static final DisableValidationTrustManager INSTANCE = new DisableValidationTrustManager(); /** * 获取 TrustManagers @@ -42,6 +40,11 @@ public TrustManager[] getTrustManagers() { return new TrustManager[]{this}; } + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + @Override public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { } @@ -51,8 +54,22 @@ public void checkServerTrusted(X509Certificate[] x509Certificates, String s) thr } @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; + public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { + } + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { + + } + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { + + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { + + } } diff --git a/mica-holidays/src/main/java/net/dreamlu/mica/holidays/impl/HolidaysApiImpl.java b/mica-holidays/src/main/java/net/dreamlu/mica/holidays/impl/HolidaysApiImpl.java index bb8dd39db..7f332e77a 100644 --- a/mica-holidays/src/main/java/net/dreamlu/mica/holidays/impl/HolidaysApiImpl.java +++ b/mica-holidays/src/main/java/net/dreamlu/mica/holidays/impl/HolidaysApiImpl.java @@ -71,14 +71,14 @@ public DaysType getDaysType(LocalDate localDate) { @Override public void afterPropertiesSet() throws Exception { - int[] years = new int[]{2019, 2020, 2021, 2022, 2023, 2024}; - for (int year : years) { - Resource resource = resourceLoader.getResource("classpath:data/" + year + "_data.json"); - try (InputStream inputStream = resource.getInputStream()) { - Map dataMap = JsonUtil.readMap(inputStream, Byte.class); - YEAR_DATA_MAP.put(year, dataMap); - } - } + int[] years = new int[]{2019, 2020, 2021, 2022, 2023, 2024, 2025}; + for (int year : years) { + Resource resource = resourceLoader.getResource("classpath:data/" + year + "_data.json"); + try (InputStream inputStream = resource.getInputStream()) { + Map dataMap = JsonUtil.readMap(inputStream, Byte.class); + YEAR_DATA_MAP.put(year, dataMap); + } + } List extDataList = properties.getExtData(); for (HolidaysApiProperties.ExtData extData : extDataList) { String dataPath = extData.getDataPath(); diff --git a/mica-holidays/src/main/resources/data/2025_data.json b/mica-holidays/src/main/resources/data/2025_data.json new file mode 100644 index 000000000..a78eca4e6 --- /dev/null +++ b/mica-holidays/src/main/resources/data/2025_data.json @@ -0,0 +1,35 @@ +{ + "1001": 2, + "1002": 2, + "1003": 2, + "1004": 1, + "1005": 1, + "1006": 2, + "1007": 1, + "1008": 1, + "1011": 0, + "0101": 2, + "0128": 2, + "0129": 2, + "0130": 2, + "0131": 2, + "0201": 1, + "0202": 1, + "0203": 1, + "0204": 1, + "0404": 2, + "0405": 1, + "0406": 1, + "0501": 2, + "0502": 2, + "0503": 1, + "0504": 1, + "0505": 1, + "0531": 2, + "0601": 1, + "0602": 1, + "0126": 0, + "0208": 0, + "0427": 0, + "0928": 0 +} diff --git a/mica-holidays/src/test/java/net/dreamlu/mica/holidays/test/HolidaysApiTest.java b/mica-holidays/src/test/java/net/dreamlu/mica/holidays/test/HolidaysApiTest.java index bc35906c1..dcfc5ab2c 100644 --- a/mica-holidays/src/test/java/net/dreamlu/mica/holidays/test/HolidaysApiTest.java +++ b/mica-holidays/src/test/java/net/dreamlu/mica/holidays/test/HolidaysApiTest.java @@ -30,6 +30,7 @@ void test() { Assertions.assertEquals(DaysType.HOLIDAYS, daysType); Assertions.assertFalse(holidaysApi.isWeekdays(LocalDate.of(2023, 9, 29))); Assertions.assertTrue(holidaysApi.isWeekdays(LocalDate.of(2023, 10, 7))); + Assertions.assertFalse(holidaysApi.isWeekdays(LocalDate.of(2025, 10, 8))); } } diff --git a/mica-http/src/main/java/net/dreamlu/mica/http/HttpRequest.java b/mica-http/src/main/java/net/dreamlu/mica/http/HttpRequest.java index 704a49b8f..7b4e894d4 100644 --- a/mica-http/src/main/java/net/dreamlu/mica/http/HttpRequest.java +++ b/mica-http/src/main/java/net/dreamlu/mica/http/HttpRequest.java @@ -712,7 +712,7 @@ public static Pair getSslContext(InputStream keySt KeyManager[] kms = null; TrustManager[] tms = null; if (keyStoreInputStream != null) { - KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509"); + KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore keyStore = KeyStore.getInstance("JKS"); char[] keyPassChars = keyPass == null ? null : keyPass.toCharArray(); keyStore.load(keyStoreInputStream, keyPassChars); @@ -737,7 +737,7 @@ private static TrustManager[] getTrustManagers(InputStream trustInputStream, cha if (trustInputStream == null) { return new TrustManager[]{DisableValidationTrustManager.INSTANCE}; } else { - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509"); + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); KeyStore keyStore = KeyStore.getInstance("JKS"); keyStore.load(trustInputStream, trustPassword); trustManagerFactory.init(keyStore);