org.gridlab.gat.security
Class SecurityContext

java.lang.Object
  extended by org.gridlab.gat.security.SecurityContext
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
CertificateSecurityContext, CredentialSecurityContext, MyProxyServerCredentialSecurityContext, PasswordSecurityContext

public abstract class SecurityContext
extends Object
implements Cloneable

A container for security Information.

Each context has a data object associated with it. The data object is opaque to the GAT API and is used and manipulated by adaptors based upon their interpretation of the context. A globus adaptor could store a GSI credential in it, while an SSH adaptor could store the private key in the data object.

Notes restrict the access to the context because it is a bad idea to broadcast passwords / credentials, so it is useful to restrict those to a set of hosts or adaptors.


Method Summary
 void addNote(String key, String value)
          Add notes to this context.
abstract  Object clone()
          Returns a clone of this context.
 boolean containsNoteKey(String key)
          Checks whether there exists a note with the given key.
abstract  boolean equals(Object obj)
           
 Object getDataObject(String key)
          This method is used by adaptors to get adaptor-specific data associated with this context.
 String getNoteValue(String key)
          Gets the value belonging to the note with the give key.
 String getPassword()
          Gets the password.
 String getUsername()
          Returns the user name.
abstract  int hashCode()
           
 boolean isValidFor(String adaptorName, String host, int port)
          This method checks the notes associated with this security context, and sees if the context is usable by a particular adaptor.
 void putDataObject(String key, Object data)
          This method is used by adaptors to get adaptor-specific data associated with this context.
 void removeDataObject(String key)
          This method is used by adaptors to remove adaptor-specific data associated with this context.
 void setPassword(String password)
          Sets the password.
 void setUsername(String username)
          Sets the user name.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equals

public abstract boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public abstract int hashCode()
Overrides:
hashCode in class Object

clone

public abstract Object clone()
                      throws CloneNotSupportedException
Returns a clone of this context.

Overrides:
clone in class Object
Returns:
the clone of this security context
Throws:
CloneNotSupportedException

getDataObject

public Object getDataObject(String key)
This method is used by adaptors to get adaptor-specific data associated with this context.

Parameters:
key - the key that was used to store the data
Returns:
the data object

putDataObject

public void putDataObject(String key,
                          Object data)
This method is used by adaptors to get adaptor-specific data associated with this context.

Parameters:
key - the key that should be used to store the data
data - the data object that has to be associated with the context

removeDataObject

public void removeDataObject(String key)
This method is used by adaptors to remove adaptor-specific data associated with this context.

Parameters:
key - the key that was used to store the data

addNote

public final void addNote(String key,
                          String value)
Add notes to this context. Notes are used to give information to the adaptors. An example is:

addNote("host", "machine1.cs.vu.nl")

to indicate that this context is only valid for the machine above. Notes restrict and precise the usage of the authentication data. So an adaptor can verify in advance the usefulness of the authentication data for the host it want to access (e.g. for job submission).

If no notes are defined, adaptors are allowed to use the context for any machine. If at least one note is defined, access is restricted to the adaptor/machine defined in the note(s)

the set of notes known so far is:

Minimum set of supported key/value pairs
Key Value Example
hosts String "hostname1:port1,hostname2:port2", where the port is optional
adaptors String "adaptorName1,adaptorName2,..."

There may be more notes that are understood by a particular adaptor.

Parameters:
key - the name of the note
value - the value of the note

containsNoteKey

public final boolean containsNoteKey(String key)
Checks whether there exists a note with the given key.

Parameters:
key - the key to look for
Returns:
true if a note exists with the given key

getNoteValue

public final String getNoteValue(String key)
Gets the value belonging to the note with the give key.

Parameters:
key - the key to look for
Returns:
the note attached to this key

isValidFor

public boolean isValidFor(String adaptorName,
                          String host,
                          int port)
This method checks the notes associated with this security context, and sees if the context is usable by a particular adaptor.

Parameters:
adaptorName - the name of the adaptor that wants to use this context
host - the destination hostname
port - the destination port
Returns:
true: the context is valid

getUsername

public String getUsername()
Returns the user name.

Returns:
the user name

setUsername

public void setUsername(String username)
Sets the user name.

Parameters:
username - the user name to set

getPassword

public String getPassword()
Gets the password.

Returns:
the password

setPassword

public void setPassword(String password)
Sets the password.

Parameters:
password - the password to set