Skip to content

Commit

Permalink
Merge branch '3.2.x'
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
ChunMengLu committed Nov 17, 2024
2 parents f61a0bb + 3a8736e commit c27b9bc
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 19 deletions.
20 changes: 20 additions & 0 deletions mica-core/src/main/java/net/dreamlu/mica/core/geo/GeoType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -99,6 +101,7 @@ public GeoPoint toBD09(double lon, double lat) {
}
};

@JsonValue
private final String type;
private final String desc;

Expand Down Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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 {
}
Expand All @@ -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 {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Byte> 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<String, Byte> dataMap = JsonUtil.readMap(inputStream, Byte.class);
YEAR_DATA_MAP.put(year, dataMap);
}
}
List<HolidaysApiProperties.ExtData> extDataList = properties.getExtData();
for (HolidaysApiProperties.ExtData extData : extDataList) {
String dataPath = extData.getDataPath();
Expand Down
35 changes: 35 additions & 0 deletions mica-holidays/src/main/resources/data/2025_data.json
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ public static Pair<SSLContext, X509TrustManager> 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);
Expand All @@ -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);
Expand Down

0 comments on commit c27b9bc

Please sign in to comment.