Example usage for org.bouncycastle.util Strings fromByteArray

List of usage examples for org.bouncycastle.util Strings fromByteArray

Introduction

In this page you can find the example usage for org.bouncycastle.util Strings fromByteArray.

Prototype

public static String fromByteArray(byte[] bytes) 

Source Link

Document

Convert an array of 8 bit characters into a string.

Usage

From source file:de.carne.certmgr.store.provider.bouncycastle.BouncyCastleASN1Decoder.java

License:Open Source License

@Override
public String asn1EncodeAsciiString() throws IOException {
    return Strings.fromByteArray(ensureType(ASN1OctetString.class).getOctets());
}

From source file:ezbake.frack.accumulo.ledger.LedgerCrypto.java

License:Apache License

private void initializeEncryption() {
    try {/*from  w  w w  .  j av  a  2s . c o  m*/
        // Try to get the private key if it exists
        InputStream is = this.getClass().getResourceAsStream(LedgerCrypto.PRIV_KEY_FILEPATH);

        if (is == null) {
            log.warn("Did not find private key: " + LedgerCrypto.PRIV_KEY_FILEPATH);
        }

        byte[] bytes = ByteStreams.toByteArray(is);
        String key = Strings.fromByteArray(bytes);

        if (bytes.length > 0) {
            crypto = new RSAKeyCrypto(key, true);
            return;
        } else {
            log.warn("No private key file found, messages will not be decrypted");
        }
    } catch (Exception e) {
        log.error("Could not initialize encryption.", e);
        throw new RuntimeException(e);
    }
}