edg.workload.userinterface.jclient
Class UserCredential

java.lang.Object
  extended byedg.workload.userinterface.jclient.UserCredential

public class UserCredential
extends java.lang.Object

The UserCredential class allows to control the general user security certificate's validity.

This class can manipulate standard proxies as well as edg-VOMS certificates, in order to extract the extension information The main operation are:


Constructor Summary
  UserCredential()
          Empty Constructor try to Load the default proxycertificate
  UserCredential(java.io.File credPath)
          Constructor with File.
protected UserCredential(org.globus.gsi.GlobusCredential proxy)
          Empty Constructor set a proxy
 
Method Summary
 void checkProxy()
          Check if the Proxy Certificate is valid
 boolean containsVO(java.lang.String voName)
          Returns a Boolean value indicating if the Virtual Organisation voName is present in the VOMS proxy extension or not.
static UserCredential createProxy(java.lang.String passPhrase)
          Create the default proxy Create the default proxy certificate with all the default values: 512-key-length bits, 24c hours, not limited
static UserCredential createProxy(java.lang.String passPhrase, java.lang.String userProxy, java.lang.String userCert, java.lang.String userKey, int bits, int hours, boolean limited)
          Create a different proxy than the default one
 void destroyProxy()
          Destroy the proxy file used
 boolean getCredType()
          Return whether the proxy is a full proxy (true) or a limited proxy (false)
static java.lang.String getDefaultCert()
          retrieve the default path for user cert
static java.lang.String getDefaultDir()
          retrieve the default path for cert dir
 java.util.Vector getDefaultGroups()
          Returns a String Vector containing the names of all default Virtual Organisation groups present in the proxy certificate extension if the proxy certificate is a VOMS proxy certificate.
static java.lang.String getDefaultKey()
          retrieve the default path for user key
static java.lang.String getDefaultProxy()
          Retrieve the default path for proxy and check whether the file exists
static java.lang.String getDefaultProxyName()
          Retrieve where default proxy file should be created
 java.lang.String getDefaultVOName()
          Returns the name of the default Virtual Organisation contained in the proxy certificate if the proxy certificate is a VOMS proxy certificate.
 java.util.Vector getGroups(java.lang.String voName)
          Returns a String Vector containing the names of all voName groups present in the proxy certificate extension if the proxy certificate is a VOMS proxy certificate.
 int getStrenght()
          Return the Cred type of the Proxy Certificate
 java.lang.String getSubject()
          Return the Subject of the Proxy Certificate
 int getTimeLeft()
          Return the Strenght of the Proxy Certificate
 java.util.Vector getVONames()
          Returns a Vector containing the names of all Virtual Organisations contained in the proxy certificate extension if the proxy certificate is a VOMS proxy certificate.
 java.lang.String getX500UserSubject()
          Returns the proxy user subject removing all occurencies of "CN=/Proxy".
static java.lang.String getX500UserSubject(java.lang.String proxySubject)
          Returns the proxy user subject removing all occurencies of "CN=/Proxy" from the specified proxySubject String.
 boolean hasVOMSExtension()
          Returns a Boolean value indicating if the proxy certificate has a VOMS extension or not (if the proxy is a VOMS proxy certificate or not).
static void setDefaultProxy(java.lang.String proxyName)
          Set statically the default proxy used for the current session.
 void setEnvCert(java.lang.String certPath)
          Set the specified path to be the default x509 certificate file
 void setEnvDir(java.lang.String dirPath)
          Set the specified path to be the default x509 user cert diectory
 void setEnvKey(java.lang.String keyPath)
          Set the specified path to be the default x509 key file
 void setEnvProxy(java.lang.String proxyPath)
          Set the specified path to be the default x509 proxy file
 void setProxy(java.io.File credPath)
          Set the proxy certificate to a non-default value
 void unsetProxy()
          Unset a previous non-default proxy and look for the default one
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserCredential

protected UserCredential(org.globus.gsi.GlobusCredential proxy)
Empty Constructor set a proxy

Parameters:
proxy - an instance of a proxy certificate

UserCredential

public UserCredential()
               throws java.io.FileNotFoundException,
                      org.globus.gsi.GlobusCredentialException
Empty Constructor try to Load the default proxycertificate

Throws:
java.io.FileNotFoundException - Unable to retrieve find the default proxy certificate
org.globus.gsi.GlobusCredentialException - Unable to parse the default proxy certificate

UserCredential

public UserCredential(java.io.File credPath)
               throws java.io.FileNotFoundException,
                      org.globus.gsi.GlobusCredentialException
Constructor with File. Try to set the specified path as the default proxy

Parameters:
credPath - a File where to load the proxy from
Throws:
java.io.FileNotFoundException - Unable to retrieve find the default proxy certificate
org.globus.gsi.GlobusCredentialException - Unable to parse the default proxy certificate
Method Detail

destroyProxy

public void destroyProxy()
Destroy the proxy file used


createProxy

public static UserCredential createProxy(java.lang.String passPhrase)
                                  throws java.io.FileNotFoundException,
                                         java.io.IOException,
                                         java.security.GeneralSecurityException,
                                         java.io.FileNotFoundException,
                                         org.globus.gsi.GlobusCredentialException
Create the default proxy Create the default proxy certificate with all the default values: 512-key-length bits, 24c hours, not limited

Parameters:
passPhrase - the passphrase needed in oprder to generate the proxy certificate
Throws:
java.io.FileNotFoundException - unable to find one or more default files
java.io.IOException - when Input Output occurred while creating/loading certificates
java.security.GeneralSecurityException - when error occurred while decrypting keys/passphrase
org.globus.gsi.GlobusCredentialException - unable to create the proxy certificate

createProxy

public static UserCredential createProxy(java.lang.String passPhrase,
                                         java.lang.String userProxy,
                                         java.lang.String userCert,
                                         java.lang.String userKey,
                                         int bits,
                                         int hours,
                                         boolean limited)
                                  throws java.io.FileNotFoundException,
                                         java.io.IOException,
                                         java.security.GeneralSecurityException,
                                         org.globus.gsi.GlobusCredentialException
Create a different proxy than the default one

Parameters:
passPhrase - the passphrase needed in oprder to generate the proxy certificate
userProxy - a string representing the file that will be created
userCert - the String which point to the user cert file if different from the default one
userKey - the String which point to the user key file if different from the default one
bits - the key-length bits dimension ( default value is 512 )
hours - the validity length of proxy in hours (default value is 24)
limited - Deterimne whether the proxy is limited or not (default value is false)
Throws:
java.io.FileNotFoundException - unable to find one or more default files
java.io.IOException - when Input Output occurred while creating/loading certificates
java.security.GeneralSecurityException - when error occurred while decrypting keys/passphrase
org.globus.gsi.GlobusCredentialException - unable to create the proxy certificate

getDefaultProxyName

public static java.lang.String getDefaultProxyName()
Retrieve where default proxy file should be created

Returns:
the string representation of the proxy file name

setDefaultProxy

public static void setDefaultProxy(java.lang.String proxyName)
Set statically the default proxy used for the current session.


getDefaultProxy

public static java.lang.String getDefaultProxy()
                                        throws java.io.FileNotFoundException
Retrieve the default path for proxy and check whether the file exists

Returns:
the string representation of the proxy file name
Throws:
java.io.FileNotFoundException - if the file is not present

getDefaultCert

public static java.lang.String getDefaultCert()
                                       throws java.io.FileNotFoundException
retrieve the default path for user cert

Returns:
the string representation of the User cert file name
Throws:
java.io.FileNotFoundException - if the file is not present

getDefaultKey

public static java.lang.String getDefaultKey()
                                      throws java.io.FileNotFoundException
retrieve the default path for user key

Returns:
the string representation of the user key file name
Throws:
java.io.FileNotFoundException - if the file is not present

getDefaultDir

public static java.lang.String getDefaultDir()
                                      throws java.io.FileNotFoundException
retrieve the default path for cert dir

Returns:
the string representation of the user cert dir
Throws:
java.io.FileNotFoundException - if the dir is not present

setEnvProxy

public void setEnvProxy(java.lang.String proxyPath)
Set the specified path to be the default x509 proxy file


setEnvCert

public void setEnvCert(java.lang.String certPath)
Set the specified path to be the default x509 certificate file


setEnvKey

public void setEnvKey(java.lang.String keyPath)
Set the specified path to be the default x509 key file


setEnvDir

public void setEnvDir(java.lang.String dirPath)
Set the specified path to be the default x509 user cert diectory


setProxy

public void setProxy(java.io.File credPath)
              throws org.globus.gsi.GlobusCredentialException
Set the proxy certificate to a non-default value

Throws:
org.globus.gsi.GlobusCredentialException - - Unable to get the specified proxy certificate

unsetProxy

public void unsetProxy()
                throws org.globus.gsi.GlobusCredentialException,
                       java.io.FileNotFoundException
Unset a previous non-default proxy and look for the default one

Throws:
org.globus.gsi.GlobusCredentialException - - Unable to get the default proxy certificate
java.io.FileNotFoundException

checkProxy

public void checkProxy()
                throws org.globus.gsi.GlobusCredentialException
Check if the Proxy Certificate is valid

Throws:
org.globus.gsi.GlobusCredentialException - - Unable to get the proxy certificate

getSubject

public java.lang.String getSubject()
                            throws org.globus.gsi.GlobusCredentialException
Return the Subject of the Proxy Certificate

Throws:
org.globus.gsi.GlobusCredentialException - - Unable to get the proxy certificate

getCredType

public boolean getCredType()
Return whether the proxy is a full proxy (true) or a limited proxy (false)

Throws:
org.globus.gsi.GlobusCredentialException - - Unable to get the proxy certificate

getStrenght

public int getStrenght()
Return the Cred type of the Proxy Certificate

Throws:
org.globus.gsi.GlobusCredentialException - - Unable to get the proxy certificate

getTimeLeft

public int getTimeLeft()
Return the Strenght of the Proxy Certificate

Throws:
org.globus.gsi.GlobusCredentialException - - Unable to get the proxy certificate

getX500UserSubject

public java.lang.String getX500UserSubject()
                                    throws org.globus.gsi.GlobusCredentialException
Returns the proxy user subject removing all occurencies of "CN=/Proxy".

Returns:
proxy user subject.
Throws:
org.globus.gsi.GlobusCredentialException - - Unable to load proxy certificate.

getX500UserSubject

public static java.lang.String getX500UserSubject(java.lang.String proxySubject)
Returns the proxy user subject removing all occurencies of "CN=/Proxy" from the specified proxySubject String.

Returns:
proxy user subject.

getVONames

public java.util.Vector getVONames()
                            throws java.io.FileNotFoundException,
                                   org.globus.gsi.GlobusCredentialException,
                                   java.lang.Exception
Returns a Vector containing the names of all Virtual Organisations contained in the proxy certificate extension if the proxy certificate is a VOMS proxy certificate.

Returns:
a String Vector with all proxy certificate Virtual Organisations, if the proxy is a VOMS proxy, an empty Vector if the proxy is not a VOMS proxy.
Throws:
java.io.FileNotFoundException - - Unable to find proxy certificate file.
org.globus.gsi.GlobusCredentialException - - Unable to load proxy certificate.
java.lang.Exception

getDefaultVOName

public java.lang.String getDefaultVOName()
                                  throws java.io.IOException,
                                         org.globus.gsi.GlobusCredentialException,
                                         java.lang.Exception
Returns the name of the default Virtual Organisation contained in the proxy certificate if the proxy certificate is a VOMS proxy certificate. (the default Virtual Organisation is the first in the VOMS extension).

Returns:
the name of the default proxy certificate Virtual Organisation, if the proxy is a VOMS proxy, an empty String if the proxy is not a VOMS proxy.
Throws:
java.io.IOException - - Unable to find proxy certificate file.
org.globus.gsi.GlobusCredentialException - - Unable to load proxy certificate.
java.lang.Exception

getGroups

public java.util.Vector getGroups(java.lang.String voName)
                           throws java.io.IOException,
                                  org.globus.gsi.GlobusCredentialException,
                                  java.lang.Exception
Returns a String Vector containing the names of all voName groups present in the proxy certificate extension if the proxy certificate is a VOMS proxy certificate.

Parameters:
voName - the name of the Virtual Organisation.
Returns:
a Vector containing all voName groups, if the proxy is a VOMS proxy, an empty Vector if the proxy is not a VOMS proxy or no groups are present.
Throws:
java.io.IOException - - Unable to find proxy certificate file.
org.globus.gsi.GlobusCredentialException - - Unable to load proxy certificate.
java.lang.Exception

getDefaultGroups

public java.util.Vector getDefaultGroups()
                                  throws java.io.IOException,
                                         org.globus.gsi.GlobusCredentialException,
                                         java.lang.Exception
Returns a String Vector containing the names of all default Virtual Organisation groups present in the proxy certificate extension if the proxy certificate is a VOMS proxy certificate.

Returns:
a Vector containing all default Virtual Organisation groups, if the proxy is a VOMS proxy, an empty Vector if the proxy is not a VOMS proxy or no groups are present.
Throws:
java.io.IOException - - Unable to find proxy certificate file.
org.globus.gsi.GlobusCredentialException - - Unable to load proxy certificate.
java.lang.Exception

containsVO

public boolean containsVO(java.lang.String voName)
                   throws java.io.IOException,
                          org.globus.gsi.GlobusCredentialException,
                          java.lang.Exception
Returns a Boolean value indicating if the Virtual Organisation voName is present in the VOMS proxy extension or not.

Parameters:
voName - the name of the Virtual Organisation.
Returns:
true, if the proxy is a VOMS proxy and voName is present, false otherwise.
Throws:
java.io.IOException - - Unable to find proxy certificate file.
org.globus.gsi.GlobusCredentialException - - Unable to load proxy certificate.
java.lang.Exception

hasVOMSExtension

public boolean hasVOMSExtension()
                         throws java.io.IOException,
                                org.globus.gsi.GlobusCredentialException,
                                java.lang.Exception
Returns a Boolean value indicating if the proxy certificate has a VOMS extension or not (if the proxy is a VOMS proxy certificate or not).

Returns:
true, if the proxy has a VOMS extension, false otherwise.
Throws:
java.io.IOException - - Unable to find proxy certificate file.
org.globus.gsi.GlobusCredentialException - - Unable to load proxy certificate.
java.lang.Exception