edu.isi.pegasus.planner.refiner

## Class Authenticate

- java.lang.Object
- - edu.isi.pegasus.planner.refiner.Authenticate

    public class Authenticate
    extends java.lang.Object

It takes in a authenticate request and authenticates against the resource on the basis of the type of the resource against which authentication is required.

Version:
  $Revision$
Author:
  Karan Vahi

### Nested Class Summary

Nested Classes
`(package private) class` `Authenticate.HostPort` A convenience inner class that stores the host and the port associated with a server.

### Field Summary

Fields
`static int` `GRID_FTP_STANDARD_PORT` The standard port at which Grid FTP runs.
`private AuthenticateRequest` `mAuthRequest` The object containing the authenticate request.
`private org.ietf.jgss.GSSCredential` `mCredential` The credential to be used while authentication to jobmanager.
`private LogManager` `mLogger` The handle to the LogManager object.
`private PoolInfoProvider` `mPoolHandle` The handle to the Pool Info Provider.
`private PegasusProperties` `mProps` The handle to the PegasusProperties object.
`private int` `mTimeout` The timeout value that is to be used in milliseconds
`static int` `TIMEOUT_VALUE` The timeout in seconds.

### Constructor Summary

Constructors
Constructor and Description
`Authenticate(PegasusProperties properties, PoolInfoProvider poolHandle)` The overloaded constructor.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `authenticate(AuthenticateRequest ar)` Authenticates against a resource referred to in the authenticate request object.
`boolean` `authenticateJobManager(java.lang.String contact)` It authenticates against the jobmanager specifyied.
`private java.lang.String` `combine(java.lang.String host, int port)` A small helper method that returns the standard host and port combination to be used for logging purposes.
`private Authenticate.HostPort` `getHostPort(java.lang.String urlPrefix)` Determines the hostname from the urlPrefix string in the pool file.
`boolean` `gridFTPAlive(java.lang.String host, int port)` It checks with a grid ftp server running at a particular host and port, to see if it is up or not.
`static void` `main(java.lang.String[] args)`
`private boolean` `parseGridFTPResponse(java.lang.String response, char type)` The parses the grid ftp server response and returns if the response was valid or not.
`boolean` `removeResource(AuthenticateRequest ar)` It tries to remove a resource from the soft state of the pool.
`void` `setCredential(org.ietf.jgss.GSSCredential credential)` Sets the credential that has to be used for authentication.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### GRID_FTP_STANDARD_PORT

    public static final int GRID_FTP_STANDARD_PORT

The standard port at which Grid FTP runs.

See Also:
  Constant Field Values

#### TIMEOUT_VALUE

    public static final int TIMEOUT_VALUE

The timeout in seconds. All sockets opened timeout after this period.

See Also:
  Constant Field Values

#### mTimeout

    private int mTimeout

The timeout value that is to be used in milliseconds

#### mAuthRequest

    private AuthenticateRequest mAuthRequest

The object containing the authenticate request.

#### mPoolHandle

    private PoolInfoProvider mPoolHandle

The handle to the Pool Info Provider.

#### mLogger

    private LogManager mLogger

The handle to the LogManager object.

#### mProps

    private PegasusProperties mProps

The handle to the PegasusProperties object.

#### mCredential

    private org.ietf.jgss.GSSCredential mCredential

The credential to be used while authentication to jobmanager.

### Constructor Detail

#### Authenticate

    public Authenticate(PegasusProperties properties,
                        PoolInfoProvider poolHandle)

The overloaded constructor.

Parameters:
  `properties` - the `PegasusProperties` to be used.

### Method Detail

#### setCredential

    public void setCredential(org.ietf.jgss.GSSCredential credential)

Sets the credential that has to be used for authentication.

Parameters:
  `credential` - the credential to be set.

#### authenticate

    public boolean authenticate(AuthenticateRequest ar)

Authenticates against a resource referred to in the authenticate request object.

#### removeResource

    public boolean removeResource(AuthenticateRequest ar)

It tries to remove a resource from the soft state of the pool. This is possible only if the underlying pool interface implementation is soft state.

Parameters:
  `ar` - the AuthenticateRequest containing the resource info
Returns:
  boolean true removal was successful. false unable to remove.

#### authenticateJobManager

    public boolean authenticateJobManager(java.lang.String contact)

It authenticates against the jobmanager specifyied.

Parameters:
  `contact` - the jobmanager contact.

#### gridFTPAlive

    public boolean gridFTPAlive(java.lang.String host,
                                int port)

It checks with a grid ftp server running at a particular host and port, to see if it is up or not. This is done by opening a socket to the specified host at the specified port. If the socket timesout (which could be due to excessive load on the server or server being hung) false is returned.

Parameters:
  `host` - the host at which the gridftp server is running .
  `port` - the port at which server is running on the host.
Returns:
  true the gridftp server is alive and kicking. false - the submit host is not connected to the network. - the server is not running. - we were able to connect but timeout. - version is not compatible.

#### parseGridFTPResponse

    private boolean parseGridFTPResponse(java.lang.String response,
                                         char type)

The parses the grid ftp server response and returns if the response was valid or not.

Parameters:
  `response` - the response got from the grid ftp server.
  `type` - c response when first connected to server. q response when sent the quit command.
Returns:
  boolean true if the response was valid false invalid response.

#### combine

    private java.lang.String combine(java.lang.String host,
                                     int port)

A small helper method that returns the standard host and port combination to be used for logging purposes.

Parameters:
  `host` - the host.
  `port` - the port.
Returns:
  combined string.

#### getHostPort

    private Authenticate.HostPort getHostPort(java.lang.String urlPrefix)

Determines the hostname from the urlPrefix string in the pool file.

Parameters:
  `urlPrefix` - the protocol, hostname and port combination.
Returns:
  the host name.

#### main

    public static void main(java.lang.String[] args)