public abstract class Credential extends Object implements Cloneable
Each context has a data object associated with it. The data object is opaque to the Octopus 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.
Modifier and Type | Field and Description |
---|---|
protected HashMap<String,Object> |
dataObjects
The data objects are used to store adaptor-specific information in the
security context.
|
protected HashMap<String,String> |
notes |
protected String |
password
This member variables holds the passphrase of the SecurityContext
|
protected String |
username
the user name to use for this context
|
Modifier | Constructor and Description |
---|---|
protected |
Credential(String username,
String password) |
Modifier and Type | Method and Description |
---|---|
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.
|
protected String username
protected String password
protected HashMap<String,Object> dataObjects
public abstract Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public Object getDataObject(String key)
key
- the key that was used to store the datapublic void putDataObject(String key, Object data)
key
- the key that should be used to store the datadata
- the data object that has to be associated with the contextpublic void removeDataObject(String key)
key
- the key that was used to store the datapublic final void addNote(String key, String value)
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:
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.
key
- the name of the notevalue
- the value of the notepublic final boolean containsNoteKey(String key)
key
.key
- the key to look forpublic final String getNoteValue(String key)
key
.key
- the key to look forpublic boolean isValidFor(String adaptorName, String host, int port)
adaptorName
- the name of the adaptor that wants to use this contexthost
- the destination hostnameport
- the destination portpublic String getUsername()
public void setUsername(String username)
username
- the user name to setpublic String getPassword()
public void setPassword(String password)
password
- the password to set