org.italiangrid.voms.util
Class CredentialsUtils

java.lang.Object
  extended by org.italiangrid.voms.util.CredentialsUtils

public class CredentialsUtils
extends Object

An utility class for handling credentials

Author:
Daniele Andreotti, Andrea Ceccanti

Nested Class Summary
static class CredentialsUtils.PrivateKeyEncoding
          The encoding used to serialize proxy credentials private key.
 
Field Summary
static CredentialsUtils.PrivateKeyEncoding DEFAULT_ENCONDING
          The default encoding used when no encoding is specified by callers.
 
Constructor Summary
CredentialsUtils()
           
 
Method Summary
static void savePrivateKey(OutputStream os, PrivateKey key, CredentialsUtils.PrivateKeyEncoding encoding)
          Serializes a private key to an output stream according to an encoding.
static void saveProxyCredentials(OutputStream os, eu.emi.security.authn.x509.X509Credential uc)
          Saves user credentials as a plain text PEM data.
static void saveProxyCredentials(OutputStream os, eu.emi.security.authn.x509.X509Credential uc, CredentialsUtils.PrivateKeyEncoding encoding)
          Saves user credentials as a plain text PEM data.
static void saveProxyCredentials(String proxyFileName, eu.emi.security.authn.x509.X509Credential uc)
          Saves proxy credentials to a file.
static void saveProxyCredentials(String proxyFileName, eu.emi.security.authn.x509.X509Credential uc, CredentialsUtils.PrivateKeyEncoding encoding)
          Saves proxy credentials to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ENCONDING

public static final CredentialsUtils.PrivateKeyEncoding DEFAULT_ENCONDING
The default encoding used when no encoding is specified by callers.

Constructor Detail

CredentialsUtils

public CredentialsUtils()
Method Detail

savePrivateKey

public static void savePrivateKey(OutputStream os,
                                  PrivateKey key,
                                  CredentialsUtils.PrivateKeyEncoding encoding)
                           throws IllegalArgumentException,
                                  IOException
Serializes a private key to an output stream according to an encoding.

Parameters:
os -
key -
encoding -
Throws:
IllegalArgumentException
IOException

saveProxyCredentials

public static void saveProxyCredentials(OutputStream os,
                                        eu.emi.security.authn.x509.X509Credential uc,
                                        CredentialsUtils.PrivateKeyEncoding encoding)
                                 throws UnrecoverableKeyException,
                                        KeyStoreException,
                                        IllegalArgumentException,
                                        NoSuchAlgorithmException,
                                        IOException,
                                        NoSuchProviderException,
                                        CertificateException
Saves user credentials as a plain text PEM data.
Writes the user certificate chain first, then the user key.

Parameters:
os -
uc -
encoding -
Throws:
UnrecoverableKeyException
KeyStoreException
IllegalArgumentException
NoSuchAlgorithmException
IOException
NoSuchProviderException
CertificateException

saveProxyCredentials

public static void saveProxyCredentials(OutputStream os,
                                        eu.emi.security.authn.x509.X509Credential uc)
                                 throws UnrecoverableKeyException,
                                        KeyStoreException,
                                        IllegalArgumentException,
                                        NoSuchAlgorithmException,
                                        IOException,
                                        NoSuchProviderException,
                                        CertificateException
Saves user credentials as a plain text PEM data.
Writes the user certificate chain first, then the user key, using the default encoding specified in DEFAULT_ENCONDING = .

Parameters:
os -
uc -
Throws:
UnrecoverableKeyException
KeyStoreException
IllegalArgumentException
NoSuchAlgorithmException
IOException
NoSuchProviderException
CertificateException

saveProxyCredentials

public static void saveProxyCredentials(String proxyFileName,
                                        eu.emi.security.authn.x509.X509Credential uc,
                                        CredentialsUtils.PrivateKeyEncoding encoding)
                                 throws IOException,
                                        UnrecoverableKeyException,
                                        KeyStoreException,
                                        IllegalArgumentException,
                                        NoSuchAlgorithmException,
                                        NoSuchProviderException,
                                        CertificateException
Saves proxy credentials to a file. This method ensures that the stored proxy is saved with the appropriate file permissions.

Parameters:
proxyFileName - the file where the proxy will be saved
uc - the credential to be saved
encoding - the private key encoding
Throws:
IOException
UnrecoverableKeyException
KeyStoreException
IllegalArgumentException
NoSuchAlgorithmException
NoSuchProviderException
CertificateException

saveProxyCredentials

public static void saveProxyCredentials(String proxyFileName,
                                        eu.emi.security.authn.x509.X509Credential uc)
                                 throws UnrecoverableKeyException,
                                        KeyStoreException,
                                        IllegalArgumentException,
                                        NoSuchAlgorithmException,
                                        NoSuchProviderException,
                                        CertificateException,
                                        IOException
Saves proxy credentials to a file. This method ensures that the stored proxy is saved with the appropriate file permissions, using the default encoding specified in DEFAULT_ENCONDING = .

Parameters:
proxyFileName -
uc -
Throws:
UnrecoverableKeyException
KeyStoreException
IllegalArgumentException
NoSuchAlgorithmException
NoSuchProviderException
CertificateException
IOException


Copyright © 2013. All Rights Reserved.