public static GSIConstants.CertificateType decideProxyType(
            X509Certificate issuerCert, GSIConstants.DelegationType delegType)
            throws CertificateException {
        GSIConstants.CertificateType proxyType = GSIConstants.CertificateType.UNDEFINED;
        if (delegType == GSIConstants.DelegationType.LIMITED) {
            GSIConstants.CertificateType type = BouncyCastleUtil.getCertificateType(issuerCert);
            if (ProxyCertificateUtil.isGsi4Proxy(type)) {
                proxyType = GSIConstants.CertificateType.GSI_4_LIMITED_PROXY;
            } else if (ProxyCertificateUtil.isGsi3Proxy(type)) {
                proxyType = GSIConstants.CertificateType.GSI_3_LIMITED_PROXY;
            } else if (ProxyCertificateUtil.isGsi2Proxy(type)) {
                proxyType = GSIConstants.CertificateType.GSI_2_LIMITED_PROXY;
            } else {
                // default to RFC compliant proxy
                if (VersionUtil.isGsi2Enabled()) {
                    proxyType = GSIConstants.CertificateType.GSI_2_LIMITED_PROXY;
                } else {
                    proxyType = VersionUtil.isGsi3Enabled() ?
                          GSIConstants.CertificateType.GSI_3_LIMITED_PROXY
                        : GSIConstants.CertificateType.GSI_4_LIMITED_PROXY;
                }
            }
        } else if (delegType == GSIConstants.DelegationType.FULL) {
            GSIConstants.CertificateType type = BouncyCastleUtil.getCertificateType(issuerCert);
            if (ProxyCertificateUtil.isGsi4Proxy(type)) {
                proxyType = GSIConstants.CertificateType.GSI_4_IMPERSONATION_PROXY;
            } else if (ProxyCertificateUtil.isGsi3Proxy(type)) {
                proxyType = GSIConstants.CertificateType.GSI_3_IMPERSONATION_PROXY;
            } else if (ProxyCertificateUtil.isGsi2Proxy(type)) {
                proxyType = GSIConstants.CertificateType.GSI_2_PROXY;
            } else {
                // Default to RFC complaint proxy
                if (VersionUtil.isGsi2Enabled()) {
                    proxyType = GSIConstants.CertificateType.GSI_2_PROXY;
                } else {
                    proxyType = (VersionUtil.isGsi3Enabled()) ?
                          GSIConstants.CertificateType.GSI_3_IMPERSONATION_PROXY
                        : GSIConstants.CertificateType.GSI_4_IMPERSONATION_PROXY;
                }
            }
        }
        return proxyType;
    }
public static GSIConstants . CertificateType decideProxyType ( X509Certificate issuerCert , GSIConstants . DelegationType delegType ) throws CertificateException { GSIConstants . CertificateType proxyType = GSIConstants . CertificateType . UNDEFINED ; if ( delegType == GSIConstants . DelegationType . LIMITED ) { GSIConstants . CertificateType type = BouncyCastleUtil . getCertificateType ( issuerCert ) ; if ( ProxyCertificateUtil . isGsi4Proxy ( type ) ) { proxyType = GSIConstants . CertificateType . GSI_4_LIMITED_PROXY ; } else if ( ProxyCertificateUtil . isGsi3Proxy ( type ) ) { proxyType = GSIConstants . CertificateType . GSI_3_LIMITED_PROXY ; } else if ( ProxyCertificateUtil . isGsi2Proxy ( type ) ) { proxyType = GSIConstants . CertificateType . GSI_2_LIMITED_PROXY ; } else { if ( VersionUtil . isGsi2Enabled ( ) ) { proxyType = GSIConstants . CertificateType . GSI_2_LIMITED_PROXY ; } else { proxyType = VersionUtil . isGsi3Enabled ( ) ? GSIConstants . CertificateType . GSI_3_LIMITED_PROXY : GSIConstants . CertificateType . GSI_4_LIMITED_PROXY ; } } } else if ( delegType == GSIConstants . DelegationType . FULL ) { GSIConstants . CertificateType type = BouncyCastleUtil . getCertificateType ( issuerCert ) ; if ( ProxyCertificateUtil . isGsi4Proxy ( type ) ) { proxyType = GSIConstants . CertificateType . GSI_4_IMPERSONATION_PROXY ; } else if ( ProxyCertificateUtil . isGsi3Proxy ( type ) ) { proxyType = GSIConstants . CertificateType . GSI_3_IMPERSONATION_PROXY ; } else if ( ProxyCertificateUtil . isGsi2Proxy ( type ) ) { proxyType = GSIConstants . CertificateType . GSI_2_PROXY ; } else { if ( VersionUtil . isGsi2Enabled ( ) ) { proxyType = GSIConstants . CertificateType . GSI_2_PROXY ; } else { proxyType = ( VersionUtil . isGsi3Enabled ( ) ) ? GSIConstants . CertificateType . GSI_3_IMPERSONATION_PROXY : GSIConstants . CertificateType . GSI_4_IMPERSONATION_PROXY ; } } } return proxyType ; }
Given a delegation mode and an issuing certificate, decides an
appropriate certificate type to use for proxies
@param issuerCert the issuing certificate of a prospective proxy
@param delegType the desired delegation mode
@return the appropriate certificate type for proxies or
GSIConstants.CertificateType.UNDEFINED when
GSIConstants.DelegationType.NONE was specified
@throws CertificateException when failing to get the certificate type
of the issuing certificate