|
Java AFS API v1.4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openafs.jafs.Key
An abstract representation of an AFS key. It holds information about
the key, such as what its version is.
Constructing an instance of a Key
does not mean an actual
AFS key is created on a server -- usually a Key
object is a representation of an already existing AFS key. If,
however, the Key
is constructed with the version number of a
key that does not exist on the server represented by the provided
Server
, a new key with that version number can be
created on that server by calling the create(String)
methods If
such a key does already exist when this method is called,
an exception will be thrown.
The following is a simple example of how to construct and use a
Key
object. It obtains the list of Key
s from
a specified server, and prints the string representation of each key.
import org.openafs.jafs.Cell; import org.openafs.jafs.AFSException; import org.openafs.jafs.Key; import org.openafs.jafs.Server; ... public class ... { ... private Cell cell; private Server server; ... public static void main(String[] args) throws Exception { String username = arg[0]; String password = arg[1]; String cellName = arg[2]; String serverName = arg[3]; token = new Token(username, password, cellName); cell = new Cell(token); server = new Server(serverName, cell); System.out.println("Keys in Server " + server.getName() + ":"); Key[] keys = server.getKeys(); for (int i = 0; i < keys.length; i++) { System.out.println(" -> " + keys[i] ); } } ... }
Constructor Summary | |
Key(int version,
Server server)
Constructs a new Key object instance given the version of
the AFS key and the AFS server, represented by server ,
to which it belongs. |
|
Key(int version,
Server server,
boolean preloadAllMembers)
Constructs a new Key object instance given the version of
the AFS key and the AFS server, represented by server ,
to which it belongs. |
Method Summary | |
int |
compareTo(Key key)
Compares two Key objects respective to their key version and does not factor any other attribute. |
int |
compareTo(Object obj)
Comparable interface method. |
void |
create(String keyString)
Creates a key with this Key's version number at the server,
using the specified String for the key. |
void |
delete()
Removes the key with this Key's version number from
the server. |
boolean |
equals(Key otherKey)
Tests whether two Key objects are equal, based on their
encryption key, version, and associated Server. |
long |
getCheckSum()
Returns the check sum of this key. |
String |
getEncryptionKey()
Returns the encrypted key as a string in octal form. |
GregorianCalendar |
getLastModDate()
Returns the last modification date of this key. |
Server |
getServer()
Returns the server this key is associated with. |
int |
getVersion()
Returns the version of this key in primitive form. |
void |
refresh()
Refreshes the properties of this Key object instance with values from the AFS key it represents. |
String |
toString()
Returns the name of this Key |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Key(int version, Server server) throws AFSException
Key
object instance given the version of
the AFS key and the AFS server, represented by server
,
to which it belongs. This does not actually
create a new AFS key, it just represents one.
If version
is not an actual AFS key, exceptions
will be thrown during subsequent method invocations on this
object, unless the create(String)
method is explicitly called to create it.
version
- the version of the key to representserver
- the server to which the key belongs.
AFSException
- If an error occurs in the native codepublic Key(int version, Server server, boolean preloadAllMembers) throws AFSException
Key
object instance given the version of
the AFS key and the AFS server, represented by server
,
to which it belongs. This does not actually
create a new AFS key, it just represents one.
If version
is not an actual AFS key, exceptions
will be thrown during subsequent method invocations on this
object, unless the create(String)
method is explicitly called to create it. Note that if the key does not
exist and preloadAllMembers
is true, an exception will
be thrown.
This constructor is ideal for point-in-time representation and
transient applications. It ensures all data member values are set and
available without calling back to the filesystem at the first request
for them. Use the refresh()
method to address any coherency
concerns.
version
- the version of the key to representserver
- the server to which the key belongs.preloadAllMembers
- true will ensure all object members are set
upon construction; otherwise members will be
set upon access, which is the default behavior.
AFSException
- If an error occurs in the native coderefresh()
Method Detail |
public void refresh() throws AFSException
Since in most environments administrative changes can be administered from an AFS command-line program or an alternate GUI application, this method provides a means to refresh the Java object representation and thereby ascertain any possible modifications that may have been made from such alternate administrative programs. Using this method before an associated instance accessor will ensure the highest level of representative accuracy, accommodating changes made external to the Java application space. If administrative changes to the underlying AFS system are only allowed via this API, then the use of this method is unnecessary.
AFSException
- If an error occurs in the native codepublic void create(String keyString) throws AFSException
Key's
version number at the server,
using the specified String
for the key.
keyString
- the string to use for the encryption key
AFSException
- If an error occurs in the native codepublic void delete() throws AFSException
Key's
version number from
the server.
AFSException
- If an error occurs in the native codepublic int getVersion()
public Server getServer()
public String getEncryptionKey() throws AFSException
AFSException
- If an error occurs in the native codepublic long getCheckSum() throws AFSException
AFSException
- If an error occurs in the native codepublic GregorianCalendar getLastModDate() throws AFSException
AFSException
- If an error occurs in the native codepublic int compareTo(Key key)
key
- The Key object to be compared to this Key instance
public int compareTo(Object obj)
compareTo
in interface Comparable
compareTo(Key)
public boolean equals(Key otherKey)
Key
objects are equal, based on their
encryption key, version, and associated Server.
otherKey
- the Key to test
public String toString()
Key
toString
in class Object
Key
|
Java AFS API (jafs) for OpenAFS | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |