public class MyProxyLogon extends Object
- setHost
- setPort
- setUsername
- setPassphrase
- setCredentialName
- setLifetime
- requestTrustRoots
to configure. Then call
- logon
- getCredentials
- 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.Modifier and Type | Class and Description |
---|---|
protected static class |
MyProxyLogon.State |
Modifier and Type | Field and Description |
---|---|
protected Collection<X509Certificate> |
certificateChain |
protected String |
credname |
int |
DEFAULT_KEY_SIZE |
protected String |
host |
protected static String |
keyAlg |
protected KeyPair |
keypair |
protected int |
keySize |
protected int |
lifetime |
protected int |
MIN_PASS_PHRASE_LEN |
protected String |
passphrase |
protected static String |
pkcs10Provider |
protected static String |
pkcs10SigAlgName |
protected int |
port |
protected boolean |
requestTrustRoots |
protected SSLSocket |
socket |
protected BufferedInputStream |
socketIn |
protected BufferedOutputStream |
socketOut |
protected MyProxyLogon.State |
state |
protected String[] |
trustrootData |
protected String[] |
trustrootFilenames |
protected String |
username |
Constructor and Description |
---|
MyProxyLogon()
Constructs a MyProxyLogon object.
|
MyProxyLogon(MyLoggingFacade myLoggingFacade) |
MyProxyLogon(MyLoggingFacade myLoggingFacade,
String serverDN) |
Modifier and Type | Method and Description |
---|---|
void |
connect()
Connects to the MyProxy server at the desired host and port.
|
void |
disconnect()
Disconnects from the MyProxy server.
|
X509Certificate |
getCertificate() |
Collection<X509Certificate> |
getCertificates()
Gets the certificates returned from the MyProxy server by
getCredentials().
|
String |
getCredentialName()
Gets the optional MyProxy credential name.
|
void |
getCredentials()
Retrieves credentials from the MyProxy server.
|
void |
getCredentials(byte[] derEncodedCertRequest) |
X509CRL[] |
getCRLs()
Gets the CRLs returned by the MyProxy server.
|
static String |
getExistingTrustRootPath()
Gets the existing trusted CA certificates directory.
|
String |
getHost()
Gets the hostname of the MyProxy server.
|
KeyManagerFactory |
getKeyManagerFactory()
Get the key manager factory set by setKeyManagerFactory().
|
int |
getKeySize()
Gets the key size.
|
int |
getLifetime()
Gets the requested credential lifetime.
|
MyLoggingFacade |
getMlf() |
int |
getPort()
Gets the port of the MyProxy server.
|
PrivateKey |
getPrivateKey()
Gets the private key generated by getCredentials().
|
static String |
getProxyLocation()
Returns the default Globus proxy file location.
|
String |
getServerDN()
This will be used against the server's DN by the trust manager when checking the certificate.
|
long |
getSocketTimeout()
Set the socket timeout (in milliseconds) for this connection.
|
X509Certificate[] |
getTrustedCAs()
Gets the trusted CA certificates returned by the MyProxy server.
|
String[] |
getTrustRootData()
Gets trust root data corresponding to the trust root filenames.
|
String[] |
getTrustRootFilenames()
Gets trust root filenames.
|
static String |
getTrustRootPath()
Returns the trusted certificates directory location where
writeTrustRoots() will store certificates.
|
String |
getUsername()
Gets the MyProxy username.
|
protected void |
handleException(Throwable t,
String msg) |
protected String |
hostLookup()
This is the *real* host.
|
boolean |
isConnected() |
boolean |
isDone() |
boolean |
isLoggedOn() |
boolean |
isReady() |
void |
logon()
Logs on to the MyProxy server by issuing the MyProxy GET command.
|
static void |
main(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(OutputStream os)
Writes the retrieved credentials to the specified output stream.
|
void |
saveCredentialsToFile(String filename)
Writes the retrieved credentials to the specified filename.
|
void |
setCredentialName(String credname)
Sets the optional MyProxy credential name.
|
void |
setHost(String host)
Sets the hostname of the MyProxy server.
|
void |
setKeyManagerFactory(KeyManagerFactory keyManagerFactory)
Set the key manager factory for use in client-side SSLSocket
certificate-based authentication to the MyProxy server.
|
void |
setKeySize(int keySize)
Sets the key size.
|
void |
setLifetime(int seconds)
Sets the requested credential lifetime.
|
void |
setPassphrase(String passphrase)
Sets the MyProxy passphrase.
|
void |
setPort(int port)
Sets the port of the MyProxy server.
|
void |
setServerDN(String serverDN) |
void |
setSocketTimeout(long socketTimeout) |
void |
setUsername(String username)
Sets the MyProxy username.
|
String |
toString() |
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(String directory)
Writes the retrieved trust roots to a trusted certificates directory.
|
public final int DEFAULT_KEY_SIZE
protected int keySize
protected final int MIN_PASS_PHRASE_LEN
protected static final String keyAlg
protected static final String pkcs10SigAlgName
protected static final String pkcs10Provider
protected MyProxyLogon.State state
protected String host
protected String username
protected String credname
protected String passphrase
protected int port
protected int lifetime
protected boolean requestTrustRoots
protected SSLSocket socket
protected BufferedInputStream socketIn
protected BufferedOutputStream socketOut
protected KeyPair keypair
protected Collection<X509Certificate> certificateChain
protected String[] trustrootFilenames
protected String[] trustrootData
public MyProxyLogon(MyLoggingFacade myLoggingFacade)
public MyProxyLogon(MyLoggingFacade myLoggingFacade, String serverDN)
public MyProxyLogon()
MyLoggingFacade
object.public MyLoggingFacade getMlf()
public long getSocketTimeout()
public void setSocketTimeout(long socketTimeout)
public String getHost()
protected String hostLookup() throws UnknownHostException
UnknownHostException
public void setHost(String host)
host
- MyProxy server hostnamepublic int getPort()
public void setPort(int port)
port
- MyProxy server portpublic int getKeySize()
public void setKeySize(int keySize)
keySize
- public String getUsername()
public void setUsername(String username)
username
- MyProxy usernamepublic String getCredentialName()
public void setCredentialName(String credname)
credname
- credential namepublic void setPassphrase(String passphrase)
passphrase
- MyProxy passphrasepublic int getLifetime()
public void setLifetime(int seconds)
seconds
- Credential lifetimepublic Collection<X509Certificate> getCertificates()
public PrivateKey getPrivateKey()
public void requestTrustRoots(boolean flag)
flag
- If true, request trust roots. If false, don't request trust
roots.public String[] getTrustRootFilenames()
public String[] getTrustRootData()
public String getServerDN()
public void setServerDN(String serverDN)
public void connect() throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
protected void handleException(Throwable t, String msg) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public KeyManagerFactory getKeyManagerFactory()
public void setKeyManagerFactory(KeyManagerFactory keyManagerFactory)
keyManagerFactory
- Key manager factory to usepublic void disconnect() throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public void logon() throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public void getCredentials(byte[] derEncodedCertRequest) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public void getCredentials() throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public void writeProxyFile() throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public void saveCredentials(OutputStream os) throws IOException, GeneralSecurityException
os
- OutputStream to write toIOException
GeneralSecurityException
public X509Certificate getCertificate()
public void saveCredentialsToFile(String filename) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public boolean writeTrustRoots() throws IOException
IOException
public boolean writeTrustRoots(String directory) throws IOException
directory
- path where the trust roots should be writtenIOException
public X509Certificate[] getTrustedCAs() throws CertificateException
CertificateException
public X509CRL[] getCRLs() throws CertificateException
CertificateException
public static String getTrustRootPath()
public static String getExistingTrustRootPath()
public static String getProxyLocation() throws IOException
IOException
public static void main(String[] args)
public boolean isReady()
public boolean isConnected()
public boolean isLoggedOn()
public boolean isDone()
Copyright © 2019. All Rights Reserved.