Package org.italiangrid.voms.util
Class CredentialsUtils
- java.lang.Object
-
- org.italiangrid.voms.util.CredentialsUtils
-
public class CredentialsUtils extends java.lang.ObjectAn utility class for handling credentials- Author:
- Daniele Andreotti, Andrea Ceccanti
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCredentialsUtils.PrivateKeyEncodingThe encoding used to serialize proxy credentials private key.
-
Field Summary
Fields Modifier and Type Field Description static CredentialsUtils.PrivateKeyEncodingDEFAULT_ENCONDINGThe default encoding used when no encoding is specified by callers.
-
Constructor Summary
Constructors Constructor Description CredentialsUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidsavePrivateKey(java.io.OutputStream os, java.security.PrivateKey key, CredentialsUtils.PrivateKeyEncoding encoding)Serializes a private key to an output stream according to an encoding.static voidsaveProxyCredentials(java.io.OutputStream os, eu.emi.security.authn.x509.X509Credential uc)Saves user credentials as a plain text PEM data.static voidsaveProxyCredentials(java.io.OutputStream os, eu.emi.security.authn.x509.X509Credential uc, CredentialsUtils.PrivateKeyEncoding encoding)Saves user credentials as a plain text PEM data.static voidsaveProxyCredentials(java.lang.String proxyFileName, eu.emi.security.authn.x509.X509Credential uc)Saves proxy credentials to a file.static voidsaveProxyCredentials(java.lang.String proxyFileName, eu.emi.security.authn.x509.X509Credential uc, CredentialsUtils.PrivateKeyEncoding encoding)Saves proxy credentials to a file.
-
-
-
Field Detail
-
DEFAULT_ENCONDING
public static final CredentialsUtils.PrivateKeyEncoding DEFAULT_ENCONDING
The default encoding used when no encoding is specified by callers.
-
-
Method Detail
-
savePrivateKey
public static void savePrivateKey(java.io.OutputStream os, java.security.PrivateKey key, CredentialsUtils.PrivateKeyEncoding encoding) throws java.io.IOExceptionSerializes a private key to an output stream according to an encoding.- Parameters:
os- the target output streamkey- the key to be serializedencoding- the encoding- Throws:
java.lang.IllegalArgumentException- for unsupported private key encodingsjava.io.IOException- if write fails for any reason on the output stream
-
saveProxyCredentials
public static void saveProxyCredentials(java.io.OutputStream os, eu.emi.security.authn.x509.X509Credential uc, CredentialsUtils.PrivateKeyEncoding encoding) throws java.io.IOExceptionSaves user credentials as a plain text PEM data.
Writes the user certificate chain first, then the user key.- Parameters:
os- the output streamuc- the user credential that must be serializedencoding- the private key encoding- Throws:
java.io.IOException- in case of errors writing on the output stream
-
saveProxyCredentials
public static void saveProxyCredentials(java.io.OutputStream os, eu.emi.security.authn.x509.X509Credential uc) throws java.io.IOExceptionSaves user credentials as a plain text PEM data.
Writes the user certificate chain first, then the user key, using the default encoding specified inDEFAULT_ENCONDING.- Parameters:
os- the output stream for the saved proxyuc- the user credential- Throws:
java.io.IOException- in case of errors writing to the output stream
-
saveProxyCredentials
public static void saveProxyCredentials(java.lang.String proxyFileName, eu.emi.security.authn.x509.X509Credential uc, CredentialsUtils.PrivateKeyEncoding encoding) throws java.io.IOExceptionSaves 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 saveduc- the credential to be savedencoding- the private key encoding- Throws:
java.io.IOException- in case of errors writing to the proxy file
-
saveProxyCredentials
public static void saveProxyCredentials(java.lang.String proxyFileName, eu.emi.security.authn.x509.X509Credential uc) throws java.io.IOExceptionSaves proxy credentials to a file. This method ensures that the stored proxy is saved with the appropriate file permissions, using the default encoding specified inDEFAULT_ENCONDING.- Parameters:
proxyFileName- the file where the proxy will be saveduc- the credential to be saved- Throws:
java.io.IOException- in case of errors writing the credential to the proxy file
-
-