List of usage examples for org.bouncycastle.jce X509KeyUsage keyAgreement
int keyAgreement
To view the source code for org.bouncycastle.jce X509KeyUsage keyAgreement.
Click Source Link
From source file:com.google.android.gms.common.GooglePlayServicesUtil.java
public static String getErrorString(int i) { switch (i) {//from w w w . j a va 2 s. c om 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
private static Dialog zza(int i, Activity activity, Fragment fragment, int i2, OnCancelListener onCancelListener) { AlertDialog.Builder builder;//from w w w. ja v a 2s . com 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:org.cesecore.keybind.impl.OcspKeyBindingTest.java
License:Open Source License
@Test public void testOcspSigningCertificateValidationNegatives() throws IOException, InvalidAlgorithmParameterException, InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalStateException, NoSuchProviderException, OperatorCreationException, CertificateException { assertFalse(/*w w w . j a v a 2s.c o m*/ "KU!=digitalSignature|nonRepudiation and EKU=id_kp_OCSPSigning should be treated as an invalid OCSP singing certificate.", OcspKeyBinding.isOcspSigningCertificate( getCertificate(X509KeyUsage.keyAgreement + X509KeyUsage.cRLSign, ekuExtensionOnly))); assertFalse( "KU=digitalSignature and EKU!=id_kp_OCSPSigning should be treated as an invalid OCSP singing certificate.", OcspKeyBinding.isOcspSigningCertificate(getCertificate(X509KeyUsage.digitalSignature, null))); assertFalse( "KU=nonRepudiation and EKU!=id_kp_OCSPSigning should be treated as an invalid OCSP singing certificate.", OcspKeyBinding.isOcspSigningCertificate(getCertificate(X509KeyUsage.nonRepudiation, null))); }
From source file:org.cesecore.util.CertTools.java
License:Open Source License
/** * Converts Sun Key usage bits to Bouncy castle key usage kits * //from w w w .j a v a 2s .c om * @param sku key usage bit fields according to java.security.cert.X509Certificate#getKeyUsage, must be a boolean aray of size 9. * @return key usage int according to org.bouncycastle.jce.X509KeyUsage#X509KeyUsage, or -1 if input is null. * @see java.security.cert.X509Certificate#getKeyUsage * @see org.bouncycastle.jce.X509KeyUsage#X509KeyUsage */ public static int sunKeyUsageToBC(boolean[] sku) { if (sku == null) { return -1; } int bcku = 0; if (sku[0]) { bcku = bcku | X509KeyUsage.digitalSignature; } if (sku[1]) { bcku = bcku | X509KeyUsage.nonRepudiation; } if (sku[2]) { bcku = bcku | X509KeyUsage.keyEncipherment; } if (sku[3]) { bcku = bcku | X509KeyUsage.dataEncipherment; } if (sku[4]) { bcku = bcku | X509KeyUsage.keyAgreement; } if (sku[5]) { bcku = bcku | X509KeyUsage.keyCertSign; } if (sku[6]) { bcku = bcku | X509KeyUsage.cRLSign; } if (sku[7]) { bcku = bcku | X509KeyUsage.encipherOnly; } if (sku[8]) { bcku = bcku | X509KeyUsage.decipherOnly; } return bcku; }
From source file:org.xipki.pki.scep.serveremulator.CaEmulator.java
License:Open Source License
public Certificate generateCert(final SubjectPublicKeyInfo pubKeyInfo, final X500Name subjectDn, final Date notBefore) throws Exception { ParamUtil.requireNonNull("pubKeyInfo", pubKeyInfo); ParamUtil.requireNonNull("subjectDn", subjectDn); ParamUtil.requireNonNull("notBefore", notBefore); Date notAfter = new Date(notBefore.getTime() + 730 * DAY_IN_MS); BigInteger tmpSerialNumber = BigInteger.valueOf(serialNumber.getAndAdd(1)); X509v3CertificateBuilder certGenerator = new X509v3CertificateBuilder(caSubject, tmpSerialNumber, notBefore, notAfter, subjectDn, pubKeyInfo); X509KeyUsage ku = new X509KeyUsage(X509KeyUsage.digitalSignature | X509KeyUsage.dataEncipherment | X509KeyUsage.keyAgreement | X509KeyUsage.keyEncipherment); certGenerator.addExtension(Extension.keyUsage, true, ku); BasicConstraints bc = new BasicConstraints(false); certGenerator.addExtension(Extension.basicConstraints, true, bc); String signatureAlgorithm = ScepUtil.getSignatureAlgorithm(caKey, ScepHashAlgoType.SHA256); ContentSigner contentSigner = new JcaContentSignerBuilder(signatureAlgorithm).build(caKey); Certificate asn1Cert = certGenerator.build(contentSigner).toASN1Structure(); serialCertMap.put(tmpSerialNumber, asn1Cert); reqSubjectCertMap.put(subjectDn, asn1Cert); return asn1Cert; }
From source file:org.xipki.pki.scep.util.ScepUtil.java
License:Open Source License
public static X509Certificate generateSelfsignedCert(final X500Name subjectDn, final SubjectPublicKeyInfo pubKeyInfo, final PrivateKey identityKey) throws CertificateException { ParamUtil.requireNonNull("subjectDn", subjectDn); ParamUtil.requireNonNull("pubKeyInfo", pubKeyInfo); ParamUtil.requireNonNull("identityKey", identityKey); Date notBefore = new Date(System.currentTimeMillis() - 5 * MIN_IN_MS); Date notAfter = new Date(notBefore.getTime() + 30 * DAY_IN_MS); X509v3CertificateBuilder certGenerator = new X509v3CertificateBuilder(subjectDn, BigInteger.ONE, notBefore, notAfter, subjectDn, pubKeyInfo); X509KeyUsage ku = new X509KeyUsage(X509KeyUsage.digitalSignature | X509KeyUsage.dataEncipherment | X509KeyUsage.keyAgreement | X509KeyUsage.keyEncipherment); try {/*from w w w. j av a 2 s .c o m*/ certGenerator.addExtension(Extension.keyUsage, true, ku); } catch (CertIOException ex) { throw new CertificateException("could not generate self-signed certificate: " + ex.getMessage(), ex); } String sigAlgorithm = ScepUtil.getSignatureAlgorithm(identityKey, ScepHashAlgoType.SHA1); ContentSigner contentSigner; try { contentSigner = new JcaContentSignerBuilder(sigAlgorithm).build(identityKey); } catch (OperatorCreationException ex) { throw new CertificateException("error while creating signer", ex); } Certificate asn1Cert = certGenerator.build(contentSigner).toASN1Structure(); return toX509Cert(asn1Cert); }