Example usage for org.bouncycastle.x509 ExtendedPKIXParameters CHAIN_VALIDITY_MODEL

List of usage examples for org.bouncycastle.x509 ExtendedPKIXParameters CHAIN_VALIDITY_MODEL

Introduction

In this page you can find the example usage for org.bouncycastle.x509 ExtendedPKIXParameters CHAIN_VALIDITY_MODEL.

Prototype

int CHAIN_VALIDITY_MODEL

To view the source code for org.bouncycastle.x509 ExtendedPKIXParameters CHAIN_VALIDITY_MODEL.

Click Source Link

Document

This model uses the following validity model.

Usage

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

protected static int getErrorNotificationId(int i) {
    switch (i) {/*from   w  w  w.j a va2  s. c  o  m*/
    case ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL /*1*/:
    case F2m.PPB /*3*/:
        return 10436;
    default:
        return 39789;
    }
}

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

public static String getErrorString(int i) {
    switch (i) {//from   ww w.j a v  a2 s  .  c  o m
    case ECCurve.COORD_AFFINE /*0*/:
        return "SUCCESS";
    case ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL /*1*/:
        return "SERVICE_MISSING";
    case CipherSpiExt.DECRYPT_MODE /*2*/:
        return "SERVICE_VERSION_UPDATE_REQUIRED";
    case F2m.PPB /*3*/:
        return "SERVICE_DISABLED";
    case ECCurve.COORD_JACOBIAN_MODIFIED /*4*/:
        return "SIGN_IN_REQUIRED";
    case ECCurve.COORD_LAMBDA_AFFINE /*5*/:
        return "INVALID_ACCOUNT";
    case ECCurve.COORD_LAMBDA_PROJECTIVE /*6*/:
        return "RESOLUTION_REQUIRED";
    case ECCurve.COORD_SKEWED /*7*/:
        return "NETWORK_ERROR";
    case X509KeyUsage.keyAgreement /*8*/:
        return "INTERNAL_ERROR";
    case NamedCurve.sect283k1 /*9*/:
        return "SERVICE_INVALID";
    case NamedCurve.sect283r1 /*10*/:
        return "DEVELOPER_ERROR";
    case CertStatus.UNREVOKED /*11*/:
        return "LICENSE_CHECK_FAILED";
    case X509KeyUsage.dataEncipherment /*16*/:
        return "API_UNAVAILABLE";
    default:
        return "UNKNOWN_ERROR_CODE";
    }
}

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

public static boolean isUserRecoverableError(int i) {
    switch (i) {//  w  w  w  .  j  ava  2  s.c  o m
    case ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL /*1*/:
    case CipherSpiExt.DECRYPT_MODE /*2*/:
    case F2m.PPB /*3*/:
    case NamedCurve.sect283k1 /*9*/:
        return true;
    default:
        return false;
    }
}

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

private static Dialog zza(int i, Activity activity, Fragment fragment, int i2,
        OnCancelListener onCancelListener) {
    AlertDialog.Builder builder;//  w ww  .  ja va  2  s .c o m
    Intent zzan;
    OnClickListener com_google_android_gms_common_internal_zzg;
    CharSequence zzf;
    if (zzlu.zzQ(activity) && i == 2) {
        i = 42;
    }
    if (zzme.zzkg()) {
        TypedValue typedValue = new TypedValue();
        activity.getTheme().resolveAttribute(16843529, typedValue, true);
        if ("Theme.Dialog.Alert".equals(activity.getResources().getResourceEntryName(typedValue.resourceId))) {
            builder = new AlertDialog.Builder(activity, 5);
            if (builder == null) {
                builder = new AlertDialog.Builder(activity);
            }
            builder.setMessage(zze(activity, i));
            if (onCancelListener != null) {
                builder.setOnCancelListener(onCancelListener);
            }
            zzan = zzan(i);
            com_google_android_gms_common_internal_zzg = fragment != null ? new zzg(activity, zzan, i2)
                    : new zzg(fragment, zzan, i2);
            zzf = zzf(activity, i);
            if (zzf != null) {
                builder.setPositiveButton(zzf, com_google_android_gms_common_internal_zzg);
            }
            switch (i) {
            case ECCurve.COORD_AFFINE /*0*/:
                return null;
            case ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL /*1*/:
                return builder.setTitle(C0078R.string.common_google_play_services_install_title).create();
            case CipherSpiExt.DECRYPT_MODE /*2*/:
                return builder.setTitle(C0078R.string.common_google_play_services_update_title).create();
            case F2m.PPB /*3*/:
                return builder.setTitle(C0078R.string.common_google_play_services_enable_title).create();
            case ECCurve.COORD_JACOBIAN_MODIFIED /*4*/:
            case ECCurve.COORD_LAMBDA_PROJECTIVE /*6*/:
                return builder.create();
            case ECCurve.COORD_LAMBDA_AFFINE /*5*/:
                Log.e("GooglePlayServicesUtil",
                        "An invalid account was specified when connecting. Please provide a valid account.");
                return builder.setTitle(C0078R.string.common_google_play_services_invalid_account_title)
                        .create();
            case ECCurve.COORD_SKEWED /*7*/:
                Log.e("GooglePlayServicesUtil", "Network error occurred. Please retry request later.");
                return builder.setTitle(C0078R.string.common_google_play_services_network_error_title).create();
            case X509KeyUsage.keyAgreement /*8*/:
                Log.e("GooglePlayServicesUtil",
                        "Internal error occurred. Please see logs for detailed information");
                return builder.create();
            case NamedCurve.sect283k1 /*9*/:
                Log.e("GooglePlayServicesUtil", "Google Play services is invalid. Cannot recover.");
                return builder.setTitle(C0078R.string.common_google_play_services_unsupported_title).create();
            case NamedCurve.sect283r1 /*10*/:
                Log.e("GooglePlayServicesUtil",
                        "Developer error occurred. Please see logs for detailed information");
                return builder.create();
            case CertStatus.UNREVOKED /*11*/:
                Log.e("GooglePlayServicesUtil", "The application is not licensed to the user.");
                return builder.create();
            case X509KeyUsage.dataEncipherment /*16*/:
                Log.e("GooglePlayServicesUtil",
                        "One of the API components you attempted to connect to is not available.");
                return builder.create();
            case NamedCurve.secp160r2 /*17*/:
                Log.e("GooglePlayServicesUtil", "The specified account could not be signed in.");
                return builder.setTitle(C0078R.string.common_google_play_services_sign_in_failed_title)
                        .create();
            case Place.TYPE_GENERAL_CONTRACTOR /*42*/:
                return builder.setTitle(C0078R.string.common_android_wear_update_title).create();
            default:
                Log.e("GooglePlayServicesUtil", "Unexpected error code " + i);
                return builder.create();
            }
        }
    }
    builder = null;
    if (builder == null) {
        builder = new AlertDialog.Builder(activity);
    }
    builder.setMessage(zze(activity, i));
    if (onCancelListener != null) {
        builder.setOnCancelListener(onCancelListener);
    }
    zzan = zzan(i);
    if (fragment != null) {
    }
    zzf = zzf(activity, i);
    if (zzf != null) {
        builder.setPositiveButton(zzf, com_google_android_gms_common_internal_zzg);
    }
    switch (i) {
    case ECCurve.COORD_AFFINE /*0*/:
        return null;
    case ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL /*1*/:
        return builder.setTitle(C0078R.string.common_google_play_services_install_title).create();
    case CipherSpiExt.DECRYPT_MODE /*2*/:
        return builder.setTitle(C0078R.string.common_google_play_services_update_title).create();
    case F2m.PPB /*3*/:
        return builder.setTitle(C0078R.string.common_google_play_services_enable_title).create();
    case ECCurve.COORD_JACOBIAN_MODIFIED /*4*/:
    case ECCurve.COORD_LAMBDA_PROJECTIVE /*6*/:
        return builder.create();
    case ECCurve.COORD_LAMBDA_AFFINE /*5*/:
        Log.e("GooglePlayServicesUtil",
                "An invalid account was specified when connecting. Please provide a valid account.");
        return builder.setTitle(C0078R.string.common_google_play_services_invalid_account_title).create();
    case ECCurve.COORD_SKEWED /*7*/:
        Log.e("GooglePlayServicesUtil", "Network error occurred. Please retry request later.");
        return builder.setTitle(C0078R.string.common_google_play_services_network_error_title).create();
    case X509KeyUsage.keyAgreement /*8*/:
        Log.e("GooglePlayServicesUtil", "Internal error occurred. Please see logs for detailed information");
        return builder.create();
    case NamedCurve.sect283k1 /*9*/:
        Log.e("GooglePlayServicesUtil", "Google Play services is invalid. Cannot recover.");
        return builder.setTitle(C0078R.string.common_google_play_services_unsupported_title).create();
    case NamedCurve.sect283r1 /*10*/:
        Log.e("GooglePlayServicesUtil", "Developer error occurred. Please see logs for detailed information");
        return builder.create();
    case CertStatus.UNREVOKED /*11*/:
        Log.e("GooglePlayServicesUtil", "The application is not licensed to the user.");
        return builder.create();
    case X509KeyUsage.dataEncipherment /*16*/:
        Log.e("GooglePlayServicesUtil",
                "One of the API components you attempted to connect to is not available.");
        return builder.create();
    case NamedCurve.secp160r2 /*17*/:
        Log.e("GooglePlayServicesUtil", "The specified account could not be signed in.");
        return builder.setTitle(C0078R.string.common_google_play_services_sign_in_failed_title).create();
    case Place.TYPE_GENERAL_CONTRACTOR /*42*/:
        return builder.setTitle(C0078R.string.common_android_wear_update_title).create();
    default:
        Log.e("GooglePlayServicesUtil", "Unexpected error code " + i);
        return builder.create();
    }
}

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

public static Intent zzan(int i) {
    switch (i) {/*from  ww w  . java 2s . c om*/
    case ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL /*1*/:
    case CipherSpiExt.DECRYPT_MODE /*2*/:
        return zzo.zzbl(GOOGLE_PLAY_SERVICES_PACKAGE);
    case F2m.PPB /*3*/:
        return zzo.zzbj(GOOGLE_PLAY_SERVICES_PACKAGE);
    case Place.TYPE_GENERAL_CONTRACTOR /*42*/:
        return zzo.zzjl();
    default:
        return null;
    }
}

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

public static String zze(Context context, int i) {
    Resources resources = context.getResources();
    switch (i) {//from  ww w .  ja v a  2 s.c o  m
    case ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL /*1*/:
        return zza(context.getResources())
                ? resources.getString(C0078R.string.common_google_play_services_install_text_tablet)
                : resources.getString(C0078R.string.common_google_play_services_install_text_phone);
    case CipherSpiExt.DECRYPT_MODE /*2*/:
        return resources.getString(C0078R.string.common_google_play_services_update_text);
    case F2m.PPB /*3*/:
        return resources.getString(C0078R.string.common_google_play_services_enable_text);
    case ECCurve.COORD_LAMBDA_AFFINE /*5*/:
        return resources.getString(C0078R.string.common_google_play_services_invalid_account_text);
    case ECCurve.COORD_SKEWED /*7*/:
        return resources.getString(C0078R.string.common_google_play_services_network_error_text);
    case NamedCurve.sect283k1 /*9*/:
        return resources.getString(C0078R.string.common_google_play_services_unsupported_text);
    case X509KeyUsage.dataEncipherment /*16*/:
        return resources.getString(C0078R.string.commono_google_play_services_api_unavailable_text);
    case NamedCurve.secp160r2 /*17*/:
        return resources.getString(C0078R.string.common_google_play_services_sign_in_failed_text);
    case Place.TYPE_GENERAL_CONTRACTOR /*42*/:
        return resources.getString(C0078R.string.common_android_wear_update_text);
    default:
        return resources.getString(C0078R.string.common_google_play_services_unknown_issue);
    }
}

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

public static String zzf(Context context, int i) {
    Resources resources = context.getResources();
    switch (i) {/*from   ww  w  .ja va  2s .com*/
    case ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL /*1*/:
        return resources.getString(C0078R.string.common_google_play_services_install_button);
    case CipherSpiExt.DECRYPT_MODE /*2*/:
    case Place.TYPE_GENERAL_CONTRACTOR /*42*/:
        return resources.getString(C0078R.string.common_google_play_services_update_button);
    case F2m.PPB /*3*/:
        return resources.getString(C0078R.string.common_google_play_services_enable_button);
    default:
        return resources.getString(17039370);
    }
}

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

public static String zzg(Context context, int i) {
    Resources resources = context.getResources();
    switch (i) {//w  ww.ja v a 2  s.c  om
    case ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL /*1*/:
        return resources.getString(C0078R.string.f5x8f024ee1);
    case CipherSpiExt.DECRYPT_MODE /*2*/:
        return resources.getString(C0078R.string.common_google_play_services_notification_needs_update_title);
    case F2m.PPB /*3*/:
        return resources.getString(C0078R.string.common_google_play_services_needs_enabling_title);
    case ECCurve.COORD_LAMBDA_AFFINE /*5*/:
        return resources.getString(C0078R.string.common_google_play_services_invalid_account_text);
    case ECCurve.COORD_SKEWED /*7*/:
        return resources.getString(C0078R.string.common_google_play_services_network_error_text);
    case NamedCurve.sect283k1 /*9*/:
        return resources.getString(C0078R.string.common_google_play_services_unsupported_text);
    case X509KeyUsage.dataEncipherment /*16*/:
        return resources.getString(C0078R.string.commono_google_play_services_api_unavailable_text);
    case NamedCurve.secp160r2 /*17*/:
        return resources.getString(C0078R.string.common_google_play_services_sign_in_failed_text);
    case Place.TYPE_GENERAL_CONTRACTOR /*42*/:
        return resources.getString(C0078R.string.common_android_wear_notification_needs_update_text);
    default:
        return resources.getString(C0078R.string.common_google_play_services_unknown_issue);
    }
}

From source file:eu.emi.security.authn.x509.helpers.pkipath.bc.RFC3280CertPathUtilitiesHelper.java

License:Open Source License

/**
 * Checks a distribution point for revocation information for the
 * certificate <code>cert</code>.
 * /*from www  . j av  a  2s.com*/
 * @param dp The distribution point to consider.
 * @param paramsPKIX PKIX parameters.
 * @param cert Certificate to check if it is revoked.
 * @param validDate The date when the certificate revocation status
 *                should be checked.
 * @param defaultCRLSignCert The issuer certificate of the certificate
 *                <code>cert</code>.
 * @param defaultCRLSignKey The public key of the issuer certificate
 *                <code>defaultCRLSignCert</code>.
 * @param certStatus The current certificate revocation status.
 * @param reasonMask The reasons mask which is already checked.
 * @param certPathCerts The certificates of the certification path.
 * @throws AnnotatedException if the certificate is revoked or the
 *                 status cannot be checked or some error occurs.
 */
private static void checkCRL(DistributionPoint dp, ExtendedPKIXParameters paramsPKIX, X509Certificate cert,
        Date validDate, X509Certificate defaultCRLSignCert, PublicKey defaultCRLSignKey, CertStatus certStatus,
        ReasonsMask reasonMask, List<?> certPathCerts) throws SimpleValidationErrorException {
    Date currentDate = new Date(System.currentTimeMillis());
    if (validDate.getTime() > currentDate.getTime()) {
        throw new IllegalArgumentException("CRL validation time is in future: " + validDate);
    }

    // (a)
    /*
     * We always get timely valid CRLs, so there is no step (a) (1).
     * "locally cached" CRLs are assumed to be in getStore(),
     * additional CRLs must be enabled in the ExtendedPKIXParameters
     * and are in getAdditionalStore()
     */

    Set<?> crls = CertPathValidatorUtilities.getCompleteCRLs2(dp, cert, currentDate, paramsPKIX);
    boolean validCrlFound = false;
    SimpleValidationErrorException lastException = null;
    Iterator<?> crl_iter = crls.iterator();

    while (crl_iter.hasNext() && certStatus.getCertStatus() == CertStatus.UNREVOKED
            && !reasonMask.isAllReasons()) {
        try {
            X509CRL crl = (X509CRL) crl_iter.next();

            // (d)
            ReasonsMask interimReasonsMask = processCRLD2(crl, dp);

            // (e)
            /*
             * The reasons mask is updated at the end, so
             * only valid CRLs can update it. If this CRL
             * does not contain new reasons it must be
             * ignored.
             */
            if (!interimReasonsMask.hasNewReasons(reasonMask)) {
                continue;
            }

            // (f)
            Set<?> keys = processCRLF2(crl, cert, defaultCRLSignCert, defaultCRLSignKey, paramsPKIX,
                    certPathCerts);
            // (g)
            PublicKey key = processCRLG2(crl, keys);

            X509CRL deltaCRL = null;

            if (paramsPKIX.isUseDeltasEnabled()) {
                // get delta CRLs
                Set<?> deltaCRLs = CertPathValidatorUtilities.getDeltaCRLs2(currentDate, paramsPKIX, crl);
                // we only want one valid delta CRL
                // (h)
                deltaCRL = processCRLH2(deltaCRLs, key);
            }

            /*
             * CRL must be be valid at the current time, not
             * the validation time. If a certificate is
             * revoked with reason keyCompromise,
             * cACompromise, it can be used for forgery,
             * also for the past. This reason may not be
             * contained in older CRLs.
             */

            /*
             * in the chain model signatures stay valid also
             * after the certificate has been expired, so
             * they do not have to be in the CRL validity
             * time
             */

            if (paramsPKIX.getValidityModel() != ExtendedPKIXParameters.CHAIN_VALIDITY_MODEL) {
                /*
                 * if a certificate has expired, but was
                 * revoked, it is not more in the CRL,
                 * so it would be regarded as valid if
                 * the first check is not done
                 */
                if (cert.getNotAfter().getTime() < crl.getThisUpdate().getTime()) {
                    throw new SimpleValidationErrorException(ValidationErrorCode.noValidCrlFound);
                }
            }

            processCRLB1_2(dp, cert, crl);

            // (b) (2)
            processCRLB2_2(dp, cert, crl);

            // (c)
            processCRLC2(deltaCRL, crl, paramsPKIX);

            // (i)
            processCRLI(validDate, deltaCRL, cert, certStatus, paramsPKIX);

            // (j)
            processCRLJ(validDate, crl, cert, certStatus);

            // (k)
            if (certStatus.getCertStatus() == CRLReason.removeFromCRL) {
                certStatus.setCertStatus(CertStatus.UNREVOKED);
            }

            // update reasons mask
            reasonMask.addReasons(interimReasonsMask);

            Set<?> criticalExtensions = crl.getCriticalExtensionOIDs();
            if (criticalExtensions != null) {
                criticalExtensions = new HashSet(criticalExtensions);
                criticalExtensions.remove(X509Extensions.IssuingDistributionPoint.getId());
                criticalExtensions.remove(X509Extensions.DeltaCRLIndicator.getId());

                if (!criticalExtensions.isEmpty()) {
                    throw new SimpleValidationErrorException(ValidationErrorCode.crlUnknownCritExt,
                            criticalExtensions.iterator().next());
                }
            }

            if (deltaCRL != null) {
                criticalExtensions = deltaCRL.getCriticalExtensionOIDs();
                if (criticalExtensions != null) {
                    criticalExtensions = new HashSet(criticalExtensions);
                    criticalExtensions.remove(X509Extensions.IssuingDistributionPoint.getId());
                    criticalExtensions.remove(X509Extensions.DeltaCRLIndicator.getId());
                    if (!criticalExtensions.isEmpty()) {
                        throw new SimpleValidationErrorException(ValidationErrorCode.crlUnknownCritExt,
                                criticalExtensions.iterator().next());
                    }
                }
            }

            validCrlFound = true;
        } catch (SimpleValidationErrorException e) {
            lastException = e;
        }
    }
    if (!validCrlFound) {
        throw lastException;
    }
}