使用Kerberos身份validation从Java应用程序访问SharePoint网站

我试图从Java应用程序访问SharePoint网站。 SharePoint服务器更喜欢Kerberos身份validation。 能否请您提供仅实施Kerberos身份validation的示例?

因此,为了帮助您扩大搜索范围,有一点关于此处使用的Kerberos身份validation的SharePoint特定内容。 事实上,SharePoint并没有真正拥有自己的身份validation机制(至少假设我们在这里谈论WSS 3 / MOSS)。 它只依赖于底层的ASP.NET / IIS身份validationfunction。

Sooo,如果你使用现代JDK运行Java,你可能会有一个轻松的时间。 请参阅有关HTTP身份validation机制的文档 。 那里有一些很好的代码片段。 其中一个我将在这里复制以供参考。 真的,请查看链接。

import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.PasswordAuthentication; import java.net.URL; public class RunHttpSpnego { static final String kuser = "username"; // your account name static final String kpass = "password"; // your password for the account static class MyAuthenticator extends Authenticator { public PasswordAuthentication getPasswordAuthentication() { // I haven't checked getRequestingScheme() here, since for NTLM // and Negotiate, the usrname and password are all the same. System.err.println("Feeding username and password for " + getRequestingScheme()); return (new PasswordAuthentication(kuser, kpass.toCharArray())); } } public static void main(String[] args) throws Exception { Authenticator.setDefault(new MyAuthenticator()); URL url = new URL(args[0]); InputStream ins = url.openConnection().getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(ins)); String str; while((str = reader.readLine()) != null) System.out.println(str); } } 

以下是开源SPNEGO HTTP Servlet Filter库 的Java文档中的示例 。

该库有一个客户端,可以连接到已启用集成Windows身份validation的Web服务器。

该项目还提供了有关如何为Kerberos / SPNEGO身份validation设置环境的示例。

  public static void main(final String[] args) throws Exception { System.setProperty("java.security.krb5.conf", "krb5.conf"); System.setProperty("sun.security.krb5.debug", "true"); System.setProperty("java.security.auth.login.config", "login.conf"); SpnegoHttpURLConnection spnego = null; try { spnego = new SpnegoHttpURLConnection("spnego-client", "dfelix", "myp@s5"); spnego.connect(new URL("http://medusa:8080/index.jsp")); System.out.println(spnego.getResponseCode()); } finally { if (null != spnego) { spnego.disconnect(); } } } 

对于Kerberos设置,我知道有3个人在他们之间知道所有关于Curb的信息:Spence Harbar,Bob Fox和Tom Wisnowski。

Spence还在使用Kerberos向导进行设置,以设置Curb和导出设置脚本。

在这里查看他的博客: http : //www.harbar.net/

Tom Wiznowski发了一份白皮书。 HTTP://my/sites/tomwis/Shared%20Documents/Configuring%20Kerberos%20for%20SharePoint.docx

Joel Olson在这里得到了一篇好文章: http : //www.sharepointjoel.com/Lists/Posts/Post.aspx? ID = 2

但是,如果说上述内容,SharePoint仅建议在公司使用时使用Curb。 您不应仅仅因为SharePoint而在公司网络上安装Kerberos。 Kerberos设置很复杂,即使它通常被认为比NTLM更快,但只有当您达到网站上同步用户的某个限制时才会这样。 对于低流量站点,Kerberos通过网络发送的巨大令牌实际上比NTLM慢。

当然有一些function只适用于Kerberos(rss feed,excel服务中的多维数据集,由于双跃点在自定义代码中对Web服务调用进行身份validation)但是当我说NTLM将很好地运行你的时候相信我MOSS也。

如果说上述内容,请指定您试图从Java应用程序中实现哪种集成?

您是否只是尝试调用SharePoint的Web服务层?

安德斯拉斯克