android.security.KeyChainException Java Examples
The following examples show how to use
android.security.KeyChainException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtAuthHelper.java From bitmask_android with GNU General Public License v3.0 | 6 votes |
@Nullable @WorkerThread public static byte[] signData(@NonNull Context context, @NonNull String extAuthPackageName, @NonNull String alias, @NonNull byte[] data ) throws KeyChainException, InterruptedException { try (ExternalAuthProviderConnection authProviderConnection = bindToExtAuthProvider(context.getApplicationContext(), extAuthPackageName)) { ExternalCertificateProvider externalAuthProvider = authProviderConnection.getService(); return externalAuthProvider.getSignedData(alias, data); } catch (RemoteException e) { throw new KeyChainException(e); } }
Example #2
Source File: ExtAuthHelper.java From bitmask_android with GNU General Public License v3.0 | 6 votes |
@Nullable @WorkerThread public static X509Certificate[] getCertificateChain(@NonNull Context context, @NonNull String extAuthPackageName, @NonNull String alias) throws KeyChainException { final byte[] certificateBytes; try (ExternalAuthProviderConnection authProviderConnection = bindToExtAuthProvider(context.getApplicationContext(), extAuthPackageName)) { ExternalCertificateProvider externalAuthProvider = authProviderConnection.getService(); certificateBytes = externalAuthProvider.getCertificateChain(alias); if (certificateBytes == null) { return null; } Collection<X509Certificate> chain = toCertificates(certificateBytes); return chain.toArray(new X509Certificate[chain.size()]); } catch (RemoteException | RuntimeException | InterruptedException e) { throw new KeyChainException(e); } }
Example #3
Source File: VpnProfile.java From bitmask_android with GNU General Public License v3.0 | 5 votes |
private X509Certificate[] getKeyStoreCertificates(Context context) throws KeyChainException, InterruptedException { PrivateKey privateKey = KeyChain.getPrivateKey(context, mAlias); mPrivateKey = privateKey; X509Certificate[] caChain = KeyChain.getCertificateChain(context, mAlias); return caChain; }
Example #4
Source File: VpnProfile.java From bitmask_android with GNU General Public License v3.0 | 5 votes |
private byte[] getExtAppSignedData(Context c, byte[] data) { if (TextUtils.isEmpty(mExternalAuthenticator)) return null; try { return ExtAuthHelper.signData(c, mExternalAuthenticator, mAlias, data); } catch (KeyChainException | InterruptedException e) { VpnStatus.logError(R.string.error_extapp_sign, mExternalAuthenticator, e.getClass().toString(), e.getLocalizedMessage()); return null; } }
Example #5
Source File: ExtAuthHelper.java From bitmask_android with GNU General Public License v3.0 | 5 votes |
public static Bundle getCertificateMetaData(@NonNull Context context, @NonNull String extAuthPackageName, String alias) throws KeyChainException { try (ExternalAuthProviderConnection authProviderConnection = bindToExtAuthProvider(context.getApplicationContext(), extAuthPackageName)) { ExternalCertificateProvider externalAuthProvider = authProviderConnection.getService(); return externalAuthProvider.getCertificateMetaData(alias); } catch (RemoteException | RuntimeException | InterruptedException e) { throw new KeyChainException(e); } }
Example #6
Source File: VpnProfile.java From bitmask_android with GNU General Public License v3.0 | 4 votes |
private X509Certificate[] getExtAppCertificates(Context context) throws KeyChainException { if (mExternalAuthenticator == null || mAlias == null) throw new KeyChainException("Alias or external auth provider name not set"); return ExtAuthHelper.getCertificateChain(context, mExternalAuthenticator, mAlias); }