edu.uiuc.ncsa.MyProxy
Class MyProxyLogon

java.lang.Object
  extended by edu.uiuc.ncsa.MyProxy.MyProxyLogon

public class MyProxyLogon
extends java.lang.Object

The MyProxyLogon class provides an interface for retrieving credentials from a MyProxy server.

First, use setHost, setPort, setUsername, setPassphrase, setCredentialName, setLifetime and requestTrustRoots to configure. Then call connect, logon, getCredentials, then disconnect. Use getCertificates and getPrivateKey to access the retrieved credentials, or writeProxyFile or saveCredentialsToFile to write them to a file. Use writeTrustRoots, getTrustedCAs, getCRLs, getTrustRootData, and getTrustRootFilenames for trust root information.

Version:
1.1
See Also:
MyProxy Project Home Page

Field Summary
static java.lang.String BouncyCastleLicense
           
static java.lang.String version
           
 
Constructor Summary
MyProxyLogon()
          Constructs a MyProxyLogon object.
 
Method Summary
 void connect()
          Connects to the MyProxy server at the desired host and port.
 void disconnect()
          Disconnects from the MyProxy server.
 java.util.Collection getCertificates()
          Gets the certificates returned from the MyProxy server by getCredentials().
 java.lang.String getCredentialName()
          Gets the optional MyProxy credential name.
 void getCredentials()
          Retrieves credentials from the MyProxy server.
 java.security.cert.X509CRL[] getCRLs()
          Gets the CRLs returned by the MyProxy server.
static java.lang.String getExistingTrustRootPath()
          Gets the existing trusted CA certificates directory.
 java.lang.String getHost()
          Gets the hostname of the MyProxy server.
 javax.net.ssl.KeyManagerFactory getKeyManagerFactory()
          Get the key manager factory set by setKeyManagerFactory().
 int getLifetime()
          Gets the requested credential lifetime.
 int getPort()
          Gets the port of the MyProxy server.
 java.security.PrivateKey getPrivateKey()
          Gets the private key generated by getCredentials().
static java.lang.String getProxyLocation()
          Returns the default Globus proxy file location.
 java.security.cert.X509Certificate[] getTrustedCAs()
          Gets the trusted CA certificates returned by the MyProxy server.
 java.lang.String[] getTrustRootData()
          Gets trust root data corresponding to the trust root filenames.
 java.lang.String[] getTrustRootFilenames()
          Gets trust root filenames.
static java.lang.String getTrustRootPath()
          Returns the trusted certificates directory location where writeTrustRoots() will store certificates.
 java.lang.String getUsername()
          Gets the MyProxy username.
 void logon()
          Logs on to the MyProxy server by issuing the MyProxy GET command.
static void main(java.lang.String[] args)
          Provides a simple command-line interface.
 void requestTrustRoots(boolean flag)
          Sets whether to request trust roots (CA certificates, CRLs, signing policy files) from the MyProxy server.
 void saveCredentials(java.io.OutputStream os)
          Writes the retrieved credentials to the specified output stream.
 void saveCredentialsToFile(java.lang.String filename)
          Writes the retrieved credentials to the specified filename.
 void setCredentialName(java.lang.String credname)
          Sets the optional MyProxy credential name.
 void setHost(java.lang.String host)
          Sets the hostname of the MyProxy server.
 void setKeyManagerFactory(javax.net.ssl.KeyManagerFactory keyManagerFactory)
          Set the key manager factory for use in client-side SSLSocket certificate-based authentication to the MyProxy server.
 void setLifetime(int seconds)
          Sets the requested credential lifetime.
 void setPassphrase(java.lang.String passphrase)
          Sets the MyProxy passphrase.
 void setPort(int port)
          Sets the port of the MyProxy server.
 void setUsername(java.lang.String username)
          Sets the MyProxy username.
 void writeProxyFile()
          Writes the retrieved credentials to the Globus proxy file location.
 boolean writeTrustRoots()
          Writes the retrieved trust roots to the Globus trusted certificates directory.
 boolean writeTrustRoots(java.lang.String directory)
          Writes the retrieved trust roots to a trusted certificates directory.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
See Also:
Constant Field Values

BouncyCastleLicense

public static final java.lang.String BouncyCastleLicense
Constructor Detail

MyProxyLogon

public MyProxyLogon()
Constructs a MyProxyLogon object.

Method Detail

getHost

public java.lang.String getHost()
Gets the hostname of the MyProxy server.

Returns:
MyProxy server hostname

setHost

public void setHost(java.lang.String host)
Sets the hostname of the MyProxy server. Defaults to localhost.

Parameters:
host - MyProxy server hostname

getPort

public int getPort()
Gets the port of the MyProxy server.

Returns:
MyProxy server port

setPort

public void setPort(int port)
Sets the port of the MyProxy server. Defaults to 7512.

Parameters:
port - MyProxy server port

getUsername

public java.lang.String getUsername()
Gets the MyProxy username.

Returns:
MyProxy server port

setUsername

public void setUsername(java.lang.String username)
Sets the MyProxy username. Defaults to user.name.

Parameters:
username - MyProxy username

getCredentialName

public java.lang.String getCredentialName()
Gets the optional MyProxy credential name.

Returns:
credential name

setCredentialName

public void setCredentialName(java.lang.String credname)
Sets the optional MyProxy credential name.

Parameters:
credname - credential name

setPassphrase

public void setPassphrase(java.lang.String passphrase)
Sets the MyProxy passphrase.

Parameters:
passphrase - MyProxy passphrase

getLifetime

public int getLifetime()
Gets the requested credential lifetime.

Returns:
Credential lifetime

setLifetime

public void setLifetime(int seconds)
Sets the requested credential lifetime. Defaults to 43200 seconds (12 hours).

Parameters:
seconds - Credential lifetime

getCertificates

public java.util.Collection getCertificates()
Gets the certificates returned from the MyProxy server by getCredentials().

Returns:
Collection of java.security.cert.Certificate objects

getPrivateKey

public java.security.PrivateKey getPrivateKey()
Gets the private key generated by getCredentials().

Returns:
PrivateKey

requestTrustRoots

public void requestTrustRoots(boolean flag)
Sets whether to request trust roots (CA certificates, CRLs, signing policy files) from the MyProxy server. Defaults to false (i.e., not to request trust roots).

Parameters:
flag - If true, request trust roots. If false, don't request trust roots.

getTrustRootFilenames

public java.lang.String[] getTrustRootFilenames()
Gets trust root filenames.

Returns:
trust root filenames

getTrustRootData

public java.lang.String[] getTrustRootData()
Gets trust root data corresponding to the trust root filenames.

Returns:
trust root data

connect

public void connect()
             throws java.io.IOException,
                    java.security.GeneralSecurityException
Connects to the MyProxy server at the desired host and port. Requires host authentication via SSL. The host's certificate subject must match the requested hostname. If CA certificates are found in the standard GSI locations, they will be used to verify the server's certificate. If trust roots are requested and no CA certificates are found, the server's certificate will still be accepted.

Throws:
java.io.IOException
java.security.GeneralSecurityException

getKeyManagerFactory

public javax.net.ssl.KeyManagerFactory getKeyManagerFactory()
Get the key manager factory set by setKeyManagerFactory().

Returns:
KeyManagerFactory

setKeyManagerFactory

public void setKeyManagerFactory(javax.net.ssl.KeyManagerFactory keyManagerFactory)
Set the key manager factory for use in client-side SSLSocket certificate-based authentication to the MyProxy server. Call this before connect().

Parameters:
keyManagerFactory - Key manager factory to use

disconnect

public void disconnect()
                throws java.io.IOException
Disconnects from the MyProxy server.

Throws:
java.io.IOException

logon

public void logon()
           throws java.io.IOException,
                  java.security.GeneralSecurityException
Logs on to the MyProxy server by issuing the MyProxy GET command.

Throws:
java.io.IOException
java.security.GeneralSecurityException

getCredentials

public void getCredentials()
                    throws java.io.IOException,
                           java.security.GeneralSecurityException
Retrieves credentials from the MyProxy server.

Throws:
java.io.IOException
java.security.GeneralSecurityException

writeProxyFile

public void writeProxyFile()
                    throws java.io.IOException,
                           java.security.GeneralSecurityException
Writes the retrieved credentials to the Globus proxy file location.

Throws:
java.io.IOException
java.security.GeneralSecurityException

saveCredentials

public void saveCredentials(java.io.OutputStream os)
                     throws java.io.IOException,
                            java.security.GeneralSecurityException
Writes the retrieved credentials to the specified output stream.

Parameters:
os - OutputStream to write to
Throws:
java.io.IOException
java.security.GeneralSecurityException

saveCredentialsToFile

public void saveCredentialsToFile(java.lang.String filename)
                           throws java.io.IOException,
                                  java.security.GeneralSecurityException
Writes the retrieved credentials to the specified filename.

Throws:
java.io.IOException
java.security.GeneralSecurityException

writeTrustRoots

public boolean writeTrustRoots()
                        throws java.io.IOException
Writes the retrieved trust roots to the Globus trusted certificates directory.

Returns:
true if trust roots are written successfully, false if no trust roots are available to be written
Throws:
java.io.IOException

writeTrustRoots

public boolean writeTrustRoots(java.lang.String directory)
                        throws java.io.IOException
Writes the retrieved trust roots to a trusted certificates directory.

Parameters:
directory - path where the trust roots should be written
Returns:
true if trust roots are written successfully, false if no trust roots are available to be written
Throws:
java.io.IOException

getTrustedCAs

public java.security.cert.X509Certificate[] getTrustedCAs()
                                                   throws java.security.cert.CertificateException
Gets the trusted CA certificates returned by the MyProxy server.

Returns:
trusted CA certificates, or null if none available
Throws:
java.security.cert.CertificateException

getCRLs

public java.security.cert.X509CRL[] getCRLs()
                                     throws java.security.cert.CertificateException
Gets the CRLs returned by the MyProxy server.

Returns:
CRLs or null if none available
Throws:
java.security.cert.CertificateException

getTrustRootPath

public static java.lang.String getTrustRootPath()
Returns the trusted certificates directory location where writeTrustRoots() will store certificates.


getExistingTrustRootPath

public static java.lang.String getExistingTrustRootPath()
Gets the existing trusted CA certificates directory.

Returns:
directory path string or null if none found

getProxyLocation

public static java.lang.String getProxyLocation()
                                         throws java.io.IOException
Returns the default Globus proxy file location.

Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
Provides a simple command-line interface.