List of usage examples for android.security KeyChain EXTRA_CERTIFICATE
String EXTRA_CERTIFICATE
To view the source code for android.security KeyChain EXTRA_CERTIFICATE.
Click Source Link
From source file:eu.operando.proxy.OperandoProxyStatus.java
private void installCert() throws RootCertificateException, GeneralSecurityException, OperatorCreationException, IOException { new AsyncTask<Void, Void, Certificate>() { Exception error;/*from w ww .ja va 2s . co m*/ ProgressDialog dialog; @Override protected void onPreExecute() { dialog = ProgressDialog.show(MainProxyActivity.this, null, "Generating SSL certificate..."); dialog.setCancelable(false); } @Override protected Certificate doInBackground(Void... params) { try { Certificate cert = BouncyCastleSslEngineSource .initializeKeyStoreStatic(mainContext.getAuthority()); return cert; } catch (Exception e) { error = e; return null; } } @Override protected void onPostExecute(Certificate certificate) { dialog.dismiss(); if (certificate != null) { Intent intent = KeyChain.createInstallIntent(); try { intent.putExtra(KeyChain.EXTRA_CERTIFICATE, certificate.getEncoded()); } catch (CertificateEncodingException e) { e.printStackTrace(); } intent.putExtra(KeyChain.EXTRA_NAME, mainContext.getAuthority().commonName()); startActivityForResult(intent, 1); } else { Toast.makeText(MainProxyActivity.this, "Failed to load certificates, exiting: " + error.getMessage(), Toast.LENGTH_LONG) .show(); finish(); } } }.execute(); }
From source file:nl.nikhef.eduroam.WiFiEduroam.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) // Step 1 for android 4.0 - 4.2 private void installCertificates() { // Install the CA certificate updateStatus("Inputting CA certificate."); Intent intent = KeyChain.createInstallIntent(); intent.putExtra(KeyChain.EXTRA_NAME, ca_name); intent.putExtra(KeyChain.EXTRA_CERTIFICATE, Base64.decode(ca.replaceAll("-----(BEGIN|END) CERTIFICATE-----", ""))); startActivityForResult(intent, 1);/*from w w w . java 2 s .c o m*/ }
From source file:com.foundstone.certinstaller.CertInstallerActivity.java
/** * Install the X509Certificate using the KeyChain intent and specifying a * certificate. The return code is used here to know when type of cert was * installed.//www .java 2s. co m * * @param cert * @param code * @throws Exception */ private void installCert(X509Certificate cert, Integer code) throws Exception { byte[] keystore = cert.getEncoded(); Intent installIntent = KeyChain.createInstallIntent(); installIntent.putExtra(KeyChain.EXTRA_CERTIFICATE, keystore); startActivityForResult(installIntent, code); }
From source file:eu.operando.operandoapp.OperandoProxyStatus.java
private void installCert() throws RootCertificateException, GeneralSecurityException, OperatorCreationException, IOException { new AsyncTask<Void, Void, Certificate>() { Exception error;/*w w w .j a v a 2 s . c o m*/ ProgressDialog dialog; @Override protected void onPreExecute() { dialog = ProgressDialog.show(MainActivity.this, null, "Generating SSL certificate..."); dialog.setCancelable(false); } @Override protected Certificate doInBackground(Void... params) { try { Certificate cert = BouncyCastleSslEngineSource .initializeKeyStoreStatic(mainContext.getAuthority()); return cert; } catch (Exception e) { error = e; return null; } } @Override protected void onPostExecute(Certificate certificate) { dialog.dismiss(); if (certificate != null) { Intent intent = KeyChain.createInstallIntent(); try { intent.putExtra(KeyChain.EXTRA_CERTIFICATE, certificate.getEncoded()); } catch (CertificateEncodingException e) { e.printStackTrace(); } intent.putExtra(KeyChain.EXTRA_NAME, mainContext.getAuthority().commonName()); startActivityForResult(intent, 1); } else { Toast.makeText(MainActivity.this, "Failed to load certificates, exiting: " + error.getMessage(), Toast.LENGTH_LONG).show(); finish(); } } }.execute(); }
From source file:nu.yona.app.ui.YonaActivity.java
private void showInstallAlert(final byte[] keystore) { if (userPreferences.getString(PreferenceConstant.PROFILE_UUID, null) != null) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.certificate_installation)); builder.setMessage(getString(R.string.certfiicate_installtion_detail)); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override/* w w w .j a v a2s .c o m*/ public void onClick(DialogInterface dialog, int which) { isToDisplayLogin = false; Intent installIntent = KeyChain.createInstallIntent(); installIntent.putExtra(KeyChain.EXTRA_CERTIFICATE, keystore); installIntent.putExtra(KeyChain.EXTRA_NAME, getString(R.string.appname)); startActivityForResult(installIntent, INSTALL_CERTIFICATE); } }); builder.setCancelable(false); builder.create().show(); } else { checkVPN(); } }