List of usage examples for java.security UnrecoverableKeyException getMessage
public String getMessage()
From source file:org.alfresco.extension.countersign.signature.RepositoryManagedSignatureProvider.java
/** * Get the Certificate Authority private key * /*w ww . jav a2s . co m*/ * @return */ private PrivateKey getCaKey(KeyStore trustedKs) { PrivateKey caKey = null; String keyAlias = config.getProperty(RepositoryManagedSignatureProviderFactory.TRUSTED_KEY_ALIAS); String keyPassword = config.getProperty(RepositoryManagedSignatureProviderFactory.TRUSTED_KEY_PASSWORD); try { caKey = (PrivateKey) trustedKs.getKey(keyAlias, keyPassword.toCharArray()); } catch (KeyStoreException kse) { throw new AlfrescoRuntimeException(kse.getMessage()); } catch (UnrecoverableKeyException uke) { throw new AlfrescoRuntimeException(uke.getMessage()); } catch (NoSuchAlgorithmException nsae) { throw new AlfrescoRuntimeException(nsae.getMessage()); } return caKey; }
From source file:com.tozny.e3db.android.DefaultKeyAuthenticator.java
@Override public void getPassword(final PasswordHandler handler) { this.activity.runOnUiThread(new Runnable() { @Override/*from w w w .ja v a 2s .c o m*/ public void run() { Context ctx = DefaultKeyAuthenticator.this.activity; final EditText input = new EditText(ctx); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); new AlertDialog.Builder(DefaultKeyAuthenticator.this.activity) .setMessage(ctx.getString(R.string.key_provider_please_enter_pin)) .setPositiveButton(ctx.getString(R.string.key_provider_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { try { handler.handlePassword(input.getText().toString()); } catch (UnrecoverableKeyException e) { wrongPasswordCount[0]++; if (wrongPasswordCount[0] >= 3) { handler.handleError( new RuntimeException("Too many password tries.")); } else { Toast.makeText(DefaultKeyAuthenticator.this.activity, e.getMessage(), Toast.LENGTH_SHORT).show(); getPassword(handler); } } } }) .setNegativeButton(ctx.getString(R.string.key_provider_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { handler.handleCancel(); } }) .setView(input).show(); input.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { if (input.isEnabled() && input.isFocusable()) { input.post(new Runnable() { @Override public void run() { final InputMethodManager imm = (InputMethodManager) DefaultKeyAuthenticator.this.activity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT); } }); } } }); } }); }