jpl.mipl.mdms.FileService.komodo.util
Class UserAuthenticator

java.lang.Object
  extended by jpl.mipl.mdms.FileService.komodo.util.UserAuthenticator

public class UserAuthenticator
extends Object

Purpose: Utility class that performs user authentication for a filetype or, more generally, a server group. Prior to this class, the only way to verify a user has access was to perform a connection to a filetype. This utility offers to ability to confirm authentication prior to that step.

   Copyright 2005, California Institute of Technology.
   ALL RIGHTS RESERVED.
   U.S. Government Sponsorship acknowledge. 2005.
   
 ============================================================================
 Modification History :
 ----------------------

 Date              Who              What
 ----------------------------------------------------------------------------
 10/12/2005        Nick             Initial Release
 10/19/2005        Nick             Added unknwnCmdOp field to handle older
                                    servers oblivious to  authentication API 
 ============================================================================
 

Version:
$Id: UserAuthenticator.java,v 1.7 2008/06/03 19:30:41 ntt Exp $
Author:
Nicholas Toole (Nicholas.T.Toole@jpl.nasa.gov)

Field Summary
protected  URL _domainFile
           
protected  String _password
           
protected  int _security
           
protected  int _unknownCmdOperation
           
protected  String _username
           
static int UNKNOWN_COMMAND_WILL_FAIL
          Results with errno representing unknown/unrecognized commands will be treated as if the authentication failed.
static int UNKNOWN_COMMAND_WILL_PASS
          Results with errno representing unknown/unrecognized commands will be treated as if the authentication succeeded.
 
Constructor Summary
UserAuthenticator(String domainFile)
          Constructor.
UserAuthenticator(String domainFile, int security)
          Constructor.
UserAuthenticator(URL domainFile)
          Constructor.
UserAuthenticator(URL domainFile, int security)
          Constructor.
 
Method Summary
 boolean authenticate(String user, String pwd, String groupName, String ftName)
          Perform an authentication procedure for a (user,pwd) and a servergroup.
 int getUnknownCommandOperation()
          Return ths current operation option for situation where server returns with 'unknown operation' message.
 void setUnknownCommandOperation(int operationId)
          Sets the operation option for case where server replies with an 'unknown operation' message, which usually denotes a server running an older version of the FEI protocol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_COMMAND_WILL_PASS

public static final int UNKNOWN_COMMAND_WILL_PASS
Results with errno representing unknown/unrecognized commands will be treated as if the authentication succeeded. This is used when communicating with older server that doesn't know about pre-authentication. In which case, the convention was to allow user to proceed and rely on any errors to occur later.

See Also:
Constant Field Values

UNKNOWN_COMMAND_WILL_FAIL

public static final int UNKNOWN_COMMAND_WILL_FAIL
Results with errno representing unknown/unrecognized commands will be treated as if the authentication failed.

See Also:
Constant Field Values

_domainFile

protected URL _domainFile

_security

protected int _security

_username

protected String _username

_password

protected String _password

_unknownCmdOperation

protected int _unknownCmdOperation
Constructor Detail

UserAuthenticator

public UserAuthenticator(String domainFile)
                  throws SessionException
Constructor. Assumes SSL security option and always pass for unknown command replies from servere.

Parameters:
domainFile - Path of FEI domain file
Throws:
SessionException

UserAuthenticator

public UserAuthenticator(String domainFile,
                         int security)
                  throws SessionException
Constructor. Assumes always pass for unknown command replies from server.

Parameters:
domainFile - Path of FEI domain file
security - Security option for connection
Throws:
SessionException

UserAuthenticator

public UserAuthenticator(URL domainFile)
                  throws SessionException
Constructor. Assumes always pass for unknown command replies from server.

Parameters:
domainFile - Path of FEI domain file
security - Security option for connection
Throws:
SessionException

UserAuthenticator

public UserAuthenticator(URL domainFile,
                         int security)
                  throws SessionException
Constructor. Assumes always pass for unknown command replies from server.

Parameters:
domainFile - Path of FEI domain file
security - Security option for connection
Throws:
SessionException
Method Detail

authenticate

public boolean authenticate(String user,
                            String pwd,
                            String groupName,
                            String ftName)
                     throws SessionException
Perform an authentication procedure for a (user,pwd) and a servergroup. If no filetype is included, then method will return true if there exists a filetype the user can access. If filetype was included, then method returns true iff user can access the specific filetype.

Parameters:
user - User name, cannot be null.
pwd - User password, cannot be null.
groupName - Name of server group, cannot be null.
ftName - Name of filetype, can be null.
Throws:
SessionException - if session error occurs during authentication.

setUnknownCommandOperation

public void setUnknownCommandOperation(int operationId)
Sets the operation option for case where server replies with an 'unknown operation' message, which usually denotes a server running an older version of the FEI protocol. Options are UNKNOWN_COMMAND_WILL_FAIL/UNKNOWN_COMMAND_WILL_PASS to automatically restrict/grant access, respectively.

Parameters:
operationId - One of UserAuthentication.UNKNOWN_COMMAND_WILL_{FAIL|PASS}.

getUnknownCommandOperation

public int getUnknownCommandOperation()
Return ths current operation option for situation where server returns with 'unknown operation' message.

Returns:
Operation id.