Commit c6761375 authored by Quxl's avatar Quxl

x

parent 81198563
...@@ -10,8 +10,6 @@ import org.springframework.context.ApplicationContext; ...@@ -10,8 +10,6 @@ import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.egolm.sso.config.SAPTrustManager;
@EnableScheduling @EnableScheduling
@SpringBootApplication @SpringBootApplication
@EnableTransactionManagement @EnableTransactionManagement
...@@ -20,9 +18,9 @@ public class SapServiceApplication { ...@@ -20,9 +18,9 @@ public class SapServiceApplication {
private static ApplicationContext applicationContext; private static ApplicationContext applicationContext;
public static void main(String[] args) throws KeyManagementException, NoSuchAlgorithmException { public static void main(String[] args) throws KeyManagementException, NoSuchAlgorithmException {
System.setProperty("java.io.tmpdir", "temp");
System.out.println(System.getProperty("java.home")); System.out.println(System.getProperty("java.home"));
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8")); TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
SAPTrustManager.trustAllHttpsCertificates();
applicationContext = SpringApplication.run(SapServiceApplication.class, args); applicationContext = SpringApplication.run(SapServiceApplication.class, args);
} }
......
package com.egolm.sso.config;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SAPTrustManager implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
private final static Log logger = LogFactory.getLog(SAPTrustManager.class);
public static void trustAllHttpsCertificates() throws NoSuchAlgorithmException, KeyManagementException {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, new TrustManager[] {new SAPTrustManager()}, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
logger.warn("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
return true;
}
});
}
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;
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) throws java.security.cert.CertificateException {
return;
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) throws java.security.cert.CertificateException {
return;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment