List of usage examples for com.rabbitmq.client LongString getBytes
public byte[] getBytes();
From source file:io.bigwig.sasl.PublicKeyMechanism.java
License:Mozilla Public License
@Override public LongString handleChallenge(LongString challenge, String username, String password) { if (challenge == null) { return LongStringHelper.asLongString(username); } else {/* w w w . jav a2s . com*/ Signature signer; try { signer = Signature.getInstance("SHA512WITHECDSA", "BC"); } catch (NoSuchAlgorithmException e) { log.error("Could not load DSA algorithm"); throw new RuntimeException(e); } catch (NoSuchProviderException e) { log.error("Could load Bouncy Castle provider"); throw new RuntimeException(e); } try { signer.initSign(privateKey); } catch (InvalidKeyException e) { log.error("Private key was invalid: {}", e.getMessage()); throw new RuntimeException(e); } try { signer.update(challenge.getBytes()); byte[] sig = signer.sign(); log.debug("Signature: {}", encoder.encode(sig)); return LongStringHelper.asLongString(sig); } catch (SignatureException e) { log.error("Failed to sign nonce: {} ", e.getMessage()); throw new RuntimeException(e); } } }
From source file:org.springframework.amqp.rabbit.support.DefaultMessagePropertiesConverter.java
License:Apache License
/** * Converts a LongString value to either a String or DataInputStream based on a length-driven threshold. If the * length is 1024 bytes or less, a String will be returned, otherwise a DataInputStream is returned. *//*from ww w.j a v a2s. co m*/ private Object convertLongString(LongString longString, String charset) { try { if (longString.length() <= 1024) { return new String(longString.getBytes(), charset); } else { return longString.getStream(); } } catch (Exception e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } }