List of usage examples for java.security UnrecoverableKeyException UnrecoverableKeyException
public UnrecoverableKeyException(String msg)
From source file:mitm.common.security.keystore.hibernate.SerializableKeyEntry.java
/** * Deserialize the serialized SerializableKeyEntry object. * // ww w . ja v a2 s . c om * @param serialized the serialized SerializableKeyEntry * @return a deserialized object * @throws UnrecoverableKeyException */ public static SerializableKeyEntry deserialize(byte[] serialized) throws UnrecoverableKeyException { Object o = SerializationUtils.deserialize(serialized); if (!(o instanceof SerializableKeyEntry)) { throw new UnrecoverableKeyException("The serialized is not the correct type."); } return (SerializableKeyEntry) o; }
From source file:org.globus.security.stores.PEMKeyStore.java
/** * Get the key referenced by the specified alias. * /* w w w . ja v a 2 s .c o m*/ * @param s * The key's alias. * @param chars * The key's password. * @return The key reference by the alias or null. * @throws NoSuchAlgorithmException * If the key is encoded with an invalid algorithm. * @throws UnrecoverableKeyException * If the key can not be retrieved. */ @Override public Key engineGetKey(String s, char[] chars) throws NoSuchAlgorithmException, UnrecoverableKeyException { CredentialWrapper credential = getKeyEntry(s); Key key = null; if (credential != null) { try { String password = null; if (chars != null) { password = new String(chars); } key = credential.getCredential().getPrivateKey(password); } catch (ResourceStoreException e) { throw new UnrecoverableKeyException(e.getMessage()); } catch (CredentialException e) { throw new UnrecoverableKeyException(e.getMessage()); } } return key; }
From source file:mitm.common.security.keystore.jce.KeyStoreHibernate.java
@Override public Key engineGetKey(final String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException { KeyStoreEntryHibernate entry;// www .j av a2 s .c o m try { entry = databaseExecutor.executeTransaction(new DatabaseAction<KeyStoreEntryHibernate>() { @Override public KeyStoreEntryHibernate doAction(Session session) { return getEntryByAliasAction(alias, session); } }, ACTION_RETRIES /* retry on a ConstraintViolationException */); if (entry == null) { return null; } byte[] serialized = entry.getEncodedKey(); SerializableKeyEntry serializableKeyEntry = SerializableKeyEntry.deserialize(serialized); Key key; if (password != null) { key = serializableKeyEntry.getKey(password, encryptor); } else { key = serializableKeyEntry.getKey(); } return key; } catch (DatabaseException e) { logger.error("Database exception.", e); throw new UnrecoverableKeyException(e.getMessage()); } catch (InvalidKeyException e) { logger.error("InvalidKeyException.", e); throw new UnrecoverableKeyException(e.getMessage()); } catch (KeyStoreException e) { logger.error("KeyStoreException.", e); throw new UnrecoverableKeyException(e.getMessage()); } catch (InvalidKeySpecException e) { logger.error("InvalidKeySpecException.", e); throw new UnrecoverableKeyException(e.getMessage()); } catch (NoSuchProviderException e) { logger.error("NoSuchProviderException.", e); throw new UnrecoverableKeyException(e.getMessage()); } catch (NoSuchPaddingException e) { logger.error("NoSuchPaddingException.", e); throw new UnrecoverableKeyException(e.getMessage()); } catch (IllegalBlockSizeException e) { logger.error("IllegalBlockSizeException.", e); throw new UnrecoverableKeyException(e.getMessage()); } catch (BadPaddingException e) { logger.error("BadPaddingException.", e); throw new UnrecoverableKeyException(e.getMessage()); } catch (IOException e) { logger.error("IOException.", e); throw new UnrecoverableKeyException(e.getMessage()); } }