Access a SharePoint website from a Kerberos authenticated Java application

I am trying to access a SharePoint website from a Java application. The SharePoint server prefers Kerberos authentication. Could you give an example for Kerberos authentication only?

+5
source share
3 answers

Therefore, to help you expand your search for answers a bit, there’s nothing specific in SharePoint for Kerberos authentication. In fact, SharePoint doesn't really have its own authentication mechanisms (at least assuming we're talking about WSS 3 / MOSS here). It simply relies on the core authentication capabilities of ASP.NET/IIS.

So, if you are using Java using the modern JDK, you probably need a simple time. See the docs for HTTP authentication mechanisms . There are some nice code snippets out there. I will reproduce one of them for reference here. Actually check the link.

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); } } 
+7
source

Here's an example from the open source Java documentation SPNEGO HTTP Servlet Filter Library .

There is a client in the library that can connect to a web server with Windows authentication enabled.

The project also has examples of how to configure the Kerberos / SPNEGO authentication environment.

  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(); } } } 
+5
source

To configure Kerberos, I know 3 people who between them know everything you need to know about Curb: Spence Harbar, Bob Fox and Tom Wisnowski.

Spence is also brewed using the Kerberos wizard to configure Curb installation and export scripts.

Check out his blog here: http://www.harbar.net/

Tom Wiznowski sent a white paper. http: //my/sites/tomwis/Shared%20Documents/Configuring%20Kerberos%20for%20SharePoint.docx

Joel Olson got a good article here: http://www.sharepointjoel.com/Lists/Posts/Post.aspx?ID=2

But when said above, SharePoint only recommends Curb when the company is already using it. Do not install Kerberos on your company network just because of SharePoint. Kerberos is difficult to configure, and although it is usually considered faster than NTLM, this is true only when you reach a certain limit of concurrent users on your site. For a low-traffic site, the huge tokens that Kerberos sends over the network actually slow down NTLM.

Of course, there is some functionality that will work only with Kerberos (rss channel, cubes in excel services, authentication of web service calls in user code due to double transitions), but trust me when I say that NTLM will do very Good job from starting your MOSS.

When said above, could you please indicate what kind of integration you are trying to achieve from your Java application?

Are you just trying to invoke SharePoint web service layers?

NTN Anders Rusk

0
source

Source: https://habr.com/ru/post/916466/


All Articles