org.gcube.common.core.security.utils
Class ProxyUtil

java.lang.Object
  extended by org.gcube.common.core.security.utils.ProxyUtil

public class ProxyUtil
extends Object

Author:
Andrea Turli

Constructor Summary
ProxyUtil()
          Constructor
 
Method Summary
static String getCA(org.gridforum.jgss.ExtendedGSSCredential credentials)
          This method return the CA of credentials passed as parameter in the OSG format.
static org.gridforum.jgss.ExtendedGSSCredential getCredentialsFromMyproxy(String myProxyHost, int myProxyPort, String username, String password, int hours)
          This method allows to retrieve credentials from a myproxy repository.
static String getDN(org.gridforum.jgss.ExtendedGSSCredential credentials)
          This method return the DN of credentials passed as parameter in the OSG format.
static String getDNOnlineRepresentation(String rfc2253Format)
           
static int getEndUserCertificateindex(X509Certificate[] certs)
          This methods returns the certificate index belonging to the array having as issuer a certificate not present in the array
static org.gridforum.jgss.ExtendedGSSCredential loadProxyCredentials(byte[] credentials)
          Utility method to parse proxy credentials.
static org.gridforum.jgss.ExtendedGSSCredential loadProxyCredentials(String fileName)
          Utility method to load proxy credentials from a file.
static X509Certificate[] orderChain(X509Certificate[] certs)
          Starting from "endUserCertificate" (the certificate retreived with getRootCertificateindex) this method builds an array containing all descendants certificates.
static org.gridforum.jgss.ExtendedGSSCredential orderCredentials(org.gridforum.jgss.ExtendedGSSCredential credentials)
          Order the certificate chain according to the GSI Requirements
static X509Certificate[] removeCACertificateFromArray(X509Certificate[] certs)
          This methods remove the CA certificate from the certificate chain passed.
static void storeProxyCredentials(String fileName, org.gridforum.jgss.ExtendedGSSCredential credentials)
          Utility method to store proxy credentials to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxyUtil

public ProxyUtil()
Constructor

Method Detail

loadProxyCredentials

public static org.gridforum.jgss.ExtendedGSSCredential loadProxyCredentials(byte[] credentials)
                                                                     throws GSSException
Utility method to parse proxy credentials. This class provides methods to access VOMS extensions contained in a VOMS proxy certificate. It permits to retrieve the roles associated to the certificate subject.

Parameters:
credentials - the byte array containing proxy credentials to load
Returns:
an ExtendedGSSCredential object containing parsed credentials
Throws:
GSSException - If an exception occurs parsing credentials

loadProxyCredentials

public static org.gridforum.jgss.ExtendedGSSCredential loadProxyCredentials(String fileName)
                                                                     throws IOException,
                                                                            GSSException
Utility method to load proxy credentials from a file.

Parameters:
fileName - the absolute or relative path of file containing proxy credentials to load
Returns:
an ExtendedGSSCredential object containing parsed credentials
Throws:
IOException - if an exeption occurs loading credentials from file
GSSException - If an exception occurs parsing credentials

storeProxyCredentials

public static void storeProxyCredentials(String fileName,
                                         org.gridforum.jgss.ExtendedGSSCredential credentials)
                                  throws GSSException,
                                         IOException
Utility method to store proxy credentials to a file.

Parameters:
fileName - the absolute or relative path of file where to store proxy credentials
credentials - Credentials to be stored on file
Throws:
IOException - if an exeption occurs storing credentials to file
GSSException - If an exception occurs extracting credentials

getCredentialsFromMyproxy

public static org.gridforum.jgss.ExtendedGSSCredential getCredentialsFromMyproxy(String myProxyHost,
                                                                                 int myProxyPort,
                                                                                 String username,
                                                                                 String password,
                                                                                 int hours)
                                                                          throws org.globus.myproxy.MyProxyException
This method allows to retrieve credentials from a myproxy repository.

Parameters:
myProxyHost - host of the myproxy repository
myProxyPort - port of the myproxy repository
username - username of the account to use
password - password of the account to use
hours - lifetime of delegated credentials in hours
Returns:
the credentials
Throws:
org.globus.myproxy.MyProxyException - if credentials cannot be retrieved

getDN

public static String getDN(org.gridforum.jgss.ExtendedGSSCredential credentials)
                    throws Exception
This method return the DN of credentials passed as parameter in the OSG format.

Returns:
the DN in the OSG format
Throws:
Exception - if the DN cannot be retrieved

getCA

public static String getCA(org.gridforum.jgss.ExtendedGSSCredential credentials)
                    throws Exception
This method return the CA of credentials passed as parameter in the OSG format.

Returns:
the CA in the OSG format
Throws:
Exception - if the CA cannot be retrieved

getEndUserCertificateindex

public static int getEndUserCertificateindex(X509Certificate[] certs)
This methods returns the certificate index belonging to the array having as issuer a certificate not present in the array

Parameters:
certs - the certificate chain to search

removeCACertificateFromArray

public static X509Certificate[] removeCACertificateFromArray(X509Certificate[] certs)
This methods remove the CA certificate from the certificate chain passed.

Parameters:
certs - the certificate chain to search
Returns:
the certificate chain without the CA certificate

orderChain

public static X509Certificate[] orderChain(X509Certificate[] certs)
                                    throws Exception
Starting from "endUserCertificate" (the certificate retreived with getRootCertificateindex) this method builds an array containing all descendants certificates. This array is ordered in this way: certs[0] = certificato utente (o rootCertificate) certs[1] = certificato utente/proxy/proxy/proxy certs[1] = certificato utente/proxy/proxy certs[1] = certificato utente/proxy

Parameters:
certs - the certificate chain to order
Returns:
the ordered certificate chain
Throws:
Exception

orderCredentials

public static org.gridforum.jgss.ExtendedGSSCredential orderCredentials(org.gridforum.jgss.ExtendedGSSCredential credentials)
                                                                 throws Exception
Order the certificate chain according to the GSI Requirements

Throws:
Exception

getDNOnlineRepresentation

public static String getDNOnlineRepresentation(String rfc2253Format)


Copyright © 2012. All Rights Reserved.