use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testUserIdConversionWhenLengthExceeds255.
public void testUserIdConversionWhenLengthExceeds255() {
final String userId = generateLongString();
Properties properties = new Properties();
properties.setUserId(new Binary(userId.getBytes()));
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertNull("Unexpected user-id", convertedProperties.getUserId());
}
use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testMessageIdBinaryConversionWhenNonUtf8.
public void testMessageIdBinaryConversionWhenNonUtf8() {
final byte[] messageId = new byte[] { (byte) 0xc3, 0x28 };
Properties properties = new Properties();
properties.setMessageId(new Binary(messageId));
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertTrue("Unexpected messageId", Arrays.equals(messageId, convertedProperties.getMessageId().getBytes()));
}
use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testCorrelationIdBinaryConversionWhenNotUtf8.
public void testCorrelationIdBinaryConversionWhenNotUtf8() {
final byte[] testCorrelationId = new byte[] { (byte) 0xc3, 0x28 };
final Binary correlationId = new Binary(testCorrelationId);
Properties properties = new Properties();
properties.setCorrelationId(correlationId);
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertTrue("Unexpected correlationId", Arrays.equals(testCorrelationId, convertedProperties.getCorrelationId().getBytes()));
}
use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testUserIdConversion.
public void testUserIdConversion() {
final String userId = "test-userId";
Properties properties = new Properties();
properties.setUserId(new Binary(userId.getBytes()));
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertEquals("Unexpected user-id", userId, convertedProperties.getUserIdAsString());
}
use of org.apache.qpid.amqp_1_0.type.Binary in project qpid-broker-j by apache.
the class AMQPConnection_1_0Impl method processSaslResponse.
private void processSaslResponse(final byte[] response) {
byte[] challenge = null;
SubjectAuthenticationResult authenticationResult = _successfulAuthenticationResult;
if (authenticationResult == null) {
authenticationResult = _subjectCreator.authenticate(_saslNegotiator, response != null ? response : new byte[0]);
challenge = authenticationResult.getChallenge();
}
if (authenticationResult.getStatus() == AuthenticationResult.AuthenticationStatus.SUCCESS) {
final boolean finalChallenge = challenge != null && challenge.length != 0;
_successfulAuthenticationResult = authenticationResult;
if (_sendSaslFinalChallengeAsChallenge && finalChallenge) {
continueSaslNegotiation(challenge);
} else {
setSubject(_successfulAuthenticationResult.getSubject());
SaslOutcome outcome = new SaslOutcome();
outcome.setCode(SaslCode.OK);
if (finalChallenge) {
outcome.setAdditionalData(new Binary(challenge));
}
send(new SASLFrame(outcome), null);
_saslComplete = true;
_connectionState = ConnectionState.AWAIT_AMQP_HEADER;
disposeSaslNegotiator();
}
} else if (authenticationResult.getStatus() == AuthenticationResult.AuthenticationStatus.CONTINUE) {
continueSaslNegotiation(challenge);
} else {
handleSaslError();
}
}
Aggregations