Example usage for java.security UnrecoverableEntryException UnrecoverableEntryException

List of usage examples for java.security UnrecoverableEntryException UnrecoverableEntryException

Introduction

In this page you can find the example usage for java.security UnrecoverableEntryException UnrecoverableEntryException.

Prototype

public UnrecoverableEntryException(String msg) 

Source Link

Document

Constructs an UnrecoverableEntryException with the specified detail message, which provides more information about why this exception has been thrown.

Usage

From source file:org.hyperic.hq.agent.server.AgentDListProvider.java

protected String getKeyvalsPass()
        throws KeyStoreException, IOException, NoSuchAlgorithmException, UnrecoverableEntryException {
    KeystoreConfig keystoreConfig = new AgentKeystoreConfig();
    KeyStore keystore = KeystoreManager.getKeystoreManager().getKeyStore(keystoreConfig);
    KeyStore.Entry e = keystore.getEntry(keystoreConfig.getAlias(),
            new KeyStore.PasswordProtection(keystoreConfig.getFilePassword().toCharArray()));
    if (e == null) {
        throw new UnrecoverableEntryException("Encryptor password generation failure: No such alias");
    }/*from ww w  .  j  a  v  a2  s  . c om*/
    // XXX scottmf - I'm a bit concerned about this.  I tested the upgrade path on the agent on the new code with the
    // ByteBuffer and it doesn't work, the agent throws a org.jasypt.exceptions.EncryptionOperationNotPossibleException.
    // When I put back the old code with the replaceAll() everything works.
    //final String p = ((PrivateKeyEntry)e).getPrivateKey().toString();
    //return p.replaceAll("[^a-zA-Z0-9]", "_");
    byte[] pk = ((PrivateKeyEntry) e).getPrivateKey().getEncoded();
    ByteBuffer encryptionKey = Charset.forName("US-ASCII").encode(ByteBuffer.wrap(pk).toString());
    return encryptionKey.toString();
}