简体   繁体   English

使用Axis2通过Java使用HTTPS登录到SharePoint

[英]Using Axis2 to login to SharePoint via Java using HTTPS

I'm trying to access a SharePoint server using Java (and Axis2 as the mechanism for creating classes from the WSDL). 我正在尝试使用Java(和Axis2作为从WSDL创建类的机制)访问SharePoint服务器。 I can login and do some operation if the site is hosted through HTTP but through HTTPS it's failing. 如果该站点是通过HTTP托管的,那么我可以登录并进行一些操作,但是通过HTTPS失败了。 Does anyone have any experience doing this or know of a good resource for getting help with this? 有没有人有这样做的经验,或者知道有很好的资源来获得帮助?

Thanks. 谢谢。

The safe bet is that your connection to a secure site is failing because your connection isn't accepting the SSL cert being provided. 可以肯定的是,由于您的连接不接受所提供的SSL证书,因此您与安全站点的连接失败。 To test this, run the following code before connecting: 要对此进行测试,请在连接之前运行以下代码:

public static void trustAllSSL() {

  TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {} public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {} public X509Certificate[] getAcceptedIssuers() { return null; } } }; HostnameVerifier hostVerify = new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }; try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(hostVerify); } catch (Exception e) { e.printStackTrace(); } } 

If you can then connect using Axis2 after running the above code, then that's the reason. 如果您可以在运行上述代码后使用Axis2连接,那就是原因。 You can then either continue to use the above code, or go and get the actual cert from the site (use IE or Firefox to access the site, then get the cert from it's cache) and add it to your keystore for Java. 然后,您可以继续使用上述代码,也可以从网站上获取实际证书(使用IE或Firefox访问该网站,然后从其缓存中获取证书)并将其添加到Java的密钥库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM