我不确定如何将其转换为groovy语法。
已经检查了这个differences with java页面。
谢谢!
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) { }
public void checkServerTrusted(X509Certificate[] certs, String authType) { }
}
};
答案 0 :(得分:2)
以下内容应该有效:
import java.security.cert.*
import javax.net.ssl.*
TrustManager[] trustAllCerts = [
[ getAcceptedIssuers: { -> null },
checkClientTrusted: { X509Certificate[] certs, String authType -> },
checkServerTrusted: { X509Certificate[] certs, String authType -> } ] as X509TrustManager
]
答案 1 :(得分:0)
{}
中的始终是一个块/闭包。您必须使用[ new X509TrustManager() { ... } ]
。如果在此结束时遇到问题,请在最后添加... as TrustManager[]
。