org.tranche.users
Class UserZipFile

java.lang.Object
  extended by org.tranche.commons.Debuggable
      extended by org.tranche.users.User
          extended by org.tranche.users.UserZipFile
All Implemented Interfaces:
java.lang.Comparable

public class UserZipFile
extends User

A helper class for packaging a user's certificate and private key and anything else in a standard ZIP file.

Author:
Jayson Falkner - jfalkner@umich.edu, James "Augie" Hill - augman85@gmail.com

Field Summary
static java.lang.String PRIVATE_KEY_NAME
          Name of the private key file.
static java.lang.String PUBLIC_CERTIFICATE_NAME
          Name of the public certificate file.
static int VERSION_LATEST
           
static int VERSION_ONE
           
 
Fields inherited from class org.tranche.users.User
ALL_PRIVILEGES, CAN_DELETE_DATA, CAN_DELETE_META_DATA, CAN_GET_CONFIGURATION, CAN_SET_CONFIGURATION, CAN_SET_DATA, CAN_SET_META_DATA, NO_PRIVILEGES
 
Constructor Summary
UserZipFile(java.io.File file)
           
UserZipFile(User user, java.security.PrivateKey key)
           
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares two UserZipFiles.
 java.security.cert.X509Certificate getCertificate()
          Gets the certificate.
 java.lang.String getEmail()
           
 java.io.File getFile()
          Gets the file.
 int getFlags()
          Gets the flags.
 java.lang.String getPassphrase()
          Gets the passphrase used to decrypt the encrypted file.
 java.security.PrivateKey getPrivateKey()
          Gets the private key.
 java.lang.String getUserNameFromCert()
          Gets the user name of the user from the certificate.
 int hashCode()
           
 boolean isExpired()
          Returns true only if certificate is expired.
 boolean isNotYetValid()
          Return true only if certificate not yet valid.
 boolean isValid()
          Returns true if certificate is valid (not expired or and is valid.)
 void saveTo(java.io.File file)
          Saves the user zip file to the given file.
 void setCertificate(java.security.cert.X509Certificate certificate)
          Sets the certificate.
 void setEmail(java.lang.String email)
           
 void setPassphrase(java.lang.String passphrase)
          Sets the passphrase used to decrypt the encrypted file.
 void setPrivateKey(java.security.PrivateKey privateKey)
          Sets the private key.
 
Methods inherited from class org.tranche.users.User
canDeleteData, canDeleteMetaData, canGetConfiguration, canSetConfiguration, canSetData, canSetMetaData, compareTo, equals, isVersionOne, setFlags
 
Methods inherited from class org.tranche.commons.Debuggable
debugErr, debugErr, debugOut, isDebug, setDebug
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_ONE

public static final int VERSION_ONE
See Also:
Constant Field Values

VERSION_LATEST

public static final int VERSION_LATEST
See Also:
Constant Field Values

PUBLIC_CERTIFICATE_NAME

public static final java.lang.String PUBLIC_CERTIFICATE_NAME

Name of the public certificate file.

See Also:
Constant Field Values

PRIVATE_KEY_NAME

public static final java.lang.String PRIVATE_KEY_NAME

Name of the private key file.

See Also:
Constant Field Values
Constructor Detail

UserZipFile

public UserZipFile(User user,
                   java.security.PrivateKey key)
Parameters:
user -
key -

UserZipFile

public UserZipFile(java.io.File file)
Parameters:
file -
Method Detail

saveTo

public void saveTo(java.io.File file)

Saves the user zip file to the given file.

Parameters:
file -

getFile

public java.io.File getFile()

Gets the file.

Returns:

getPassphrase

public java.lang.String getPassphrase()

Gets the passphrase used to decrypt the encrypted file.

Returns:

setPassphrase

public void setPassphrase(java.lang.String passphrase)

Sets the passphrase used to decrypt the encrypted file.

Parameters:
passphrase -

getEmail

public java.lang.String getEmail()
Returns:

setEmail

public void setEmail(java.lang.String email)
Parameters:
email -

getPrivateKey

public java.security.PrivateKey getPrivateKey()

Gets the private key.

Returns:

setPrivateKey

public void setPrivateKey(java.security.PrivateKey privateKey)

Sets the private key.

Parameters:
privateKey -

getFlags

public int getFlags()

Gets the flags.

Overrides:
getFlags in class User
Returns:

getCertificate

public java.security.cert.X509Certificate getCertificate()

Gets the certificate.

Overrides:
getCertificate in class User
Returns:

setCertificate

public void setCertificate(java.security.cert.X509Certificate certificate)

Sets the certificate.

Overrides:
setCertificate in class User
Parameters:
certificate -

isNotYetValid

public boolean isNotYetValid()

Return true only if certificate not yet valid.

Returns:

isExpired

public boolean isExpired()

Returns true only if certificate is expired.

Returns:

isValid

public boolean isValid()

Returns true if certificate is valid (not expired or and is valid.)

Returns:

getUserNameFromCert

public java.lang.String getUserNameFromCert()

Gets the user name of the user from the certificate.

Returns:
User name, if found, or null.

equals

public boolean equals(java.lang.Object o)

Compares two UserZipFiles.

Overrides:
equals in class java.lang.Object
Parameters:
o -
Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:


This code is free for use both commercially and non-commercially as stated in the project's license