Exercise 8: Using the Java Generic
Security Services (GSS) API with SPNEGO
Goal of this exercise:
Currently the only security mechansim available with Java GSS is
"Kerberos". The goal of this exercise is to learn how to use other
Java GSS mechanisms, such as SPNEGO, to secure the association.
This feature is available from Java SE 6 onwards.
What is SPNEGO?
Java GSS is a framework that can support multiple security
mechanisms; a way to negotiate a security mechanism underneath
GSS-API is needed. This is available via SPNEGO.
SPNEGO is the Simple and Protected GSS-API Negotiation
Mechanism, standardized at IETF in RFC 4178. It's a
pseudo-security mechanism used to negotiate an underlying security
mechanism. It provides the flexibility for client and server to
securely negotiate a common GSS security mechanism.
Microsoft makes heavy use of SPNEGO. SPNEGO can be used to
inter-operate with Microsoft Server over HTTP, to support
HTTP-based Cross-Platform authentication via the Negotiate
Protocol.
What do I need do to use SPNEGO in Java GSS?
Currently when using Java GSS with Kerberos, we specify the
Kerberos OID to use Kerberos.
Oid krb5Oid = new Oid("1.2.840.113554.1.2.2");
In order to use SPNEGO, you only need to specify the
SPNEGO OID as follows:-
Oid spnegoOid = new Oid("1.3.6.1.5.5.2");
And henceforth use the SPNEGO OID when creating a
GSSCredential, GSSContext, etc.
Run the client application. GssClient takes two
parameters: the service name and the name of the server that the
service is running on. For example, if the service is
host running on the machine
j1hol-001, you would enter the following. When
prompted for the password, enter changeit.
Received message: Hello There! Thu May 06 12:11:15 PDT
2005
Summary:
In this exercise, you learned
how to write a client-server application that uses the Java GSS API
with SPNEGO to negotiate an underlying security mechanism, such as
Kerberos, and communicate securely using Kerberos as the underlying
authentication system.
Note: Microsoft has implemented certain variations of the
SPNEGO protocol, hence to inter-operate with Microsoft, we have
added an MS mode via a new system property
"sun.security.spnego.msinterop". This property is enabled to "true"
by default. To disable it, you need to explicitly set this property
to "false". To enable SPNEGO debugging, you can set the system
property "sun.security.spnego.debug=true".