public class GssApiCredential extends Object implements Credential
GSS-API is a language independent standard to support various authentication mechanisms. It is defined in RFC 2743. GSS-API has the goal of hiding all the mechanism specific details from the application developer. It defers all mechanism specific actions to a pluggable security service provider.
JGSS is the java bindings for the GSS-API. JGSS is detailed in RFC 2853. Starting with JDK 1.4.1, java supports GSS-API based authentication. In JDK 1.4.1, Kerberos V5 is the only supported authentication mechanism.
In a typical GSS based authentication, client sends an authentication token to the server. The server gets the token and feeds it to a method defined by the GSS-API. By doing so, it invokes the security provider. The security provider validates the input token, and if it finds the token to be valid, it establishes a GSS context. The output of the GSS api method is a reponse token. The server has to send this token back to the client. Sometimes, establishment of a context requires further token exchanges between the client and the server. The number of token exchanges is determined by the underlying authentication mechanism.
Kerberos V5 mechanism requires only one roundtrip exchange of tokens. The client sends the input token. The server feeds it to security provider and generates a response token. Based on the validity of the token the GSS context also gets established. Then the server sends the response token back to the client.
How do IFS protocol server or applications do Kerberos authentication ?
IFS protocol servers and applications that wish to do Kerberos authentication should first get the input token. Creation of input token may be done either by prompting the client for it or by obtaining interactively. Once the input token is available, the protocol server or application will use the LibraryService method getGssApiCredential to get a credential. The code to do so is as show below.
GssApiCredential cred = myService.getGssApiCredential(inputTicket, null);
At this point the service constructs the GssApiCredential, sets up the inputTicket member and calls the validate() method. Calling validate() causes the acceptSecContext() method on the GSSContext to be called. It results in validation of the authentication data and generation of a response token. If the input token was not valid, then the validate() method throws an exception. Protocols/Applications should handle this exception and indicate an authentication failure to the client. If the GssApiCredential object was successfully constructed, then it means that the authentication data has been already validated. This credential object can now be used to create a iFS session.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
m_InputTicket
Input ticket provided by the protocol or application.
|
protected byte[] |
m_OutputTicket
Output ticket to be sent back to the protocol or application.
|
protected String |
m_UserName
Name of the user that is trying to authenticate.
|
Constructor and Description |
---|
GssApiCredential()
Constructs a GssApiCredential.
|
GssApiCredential(byte[] inputTicket)
Constructs a GssApiCredential.
|
Modifier and Type | Method and Description |
---|---|
GSSContext |
getContext()
Returns the GSS context if one exists.
|
byte[] |
getInputTicket()
Returns the input ticket.
|
String |
getName()
Returns the user name.
|
byte[] |
getOutputTicket()
Returns the output ticket.
|
boolean |
isValid()
Returns true if the input ticket has been validated.
|
void |
setInputTicket(byte[] inputTicket)
Sets up the input ticket.
|
void |
setName(String userName)
Sets the user name for this credential.
|
void |
setServerPrincipalName(String serverPrincipalName)
Sets the name of the principal that is acting as
the acceptor of the credentials.
|
void |
validate()
Attempts to validate the inputTicket.
|
protected byte[] m_InputTicket
protected byte[] m_OutputTicket
protected String m_UserName
public GssApiCredential() throws IfsException
IfsException
- if the operation failspublic GssApiCredential(byte[] inputTicket) throws IfsException
inputTicket
- byte array conatining authentication dataIfsException
- if the operation failspublic byte[] getInputTicket() throws IfsException
IfsException
- if the operation failspublic void setInputTicket(byte[] inputTicket) throws IfsException
inputTicket
- byte array containing the authentication dataIfsException
- if the operation failspublic byte[] getOutputTicket() throws IfsException
IfsException
- if the operation failspublic String getName() throws IfsException
getName
in interface Credential
IfsException
- if the operation failspublic void setName(String userName) throws IfsException
setName
in interface Credential
userName
- the name of the userIfsException
- name cannot be setpublic GSSContext getContext() throws IfsException
IfsException
- if the operation failspublic void setServerPrincipalName(String serverPrincipalName) throws IfsException
serverPrincipalName
- name of the accepting principalIfsException
- if the operation failspublic boolean isValid() throws IfsException
IfsException
- if the operation failspublic void validate() throws IfsException
IfsException
- if the operation failsCopyright © 2023. All rights reserved.