Search in sources :

Example 46 with Binary

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());
}
Also used : Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 47 with Binary

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()));
}
Also used : Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 48 with Binary

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()));
}
Also used : Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 49 with Binary

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());
}
Also used : Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 50 with Binary

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();
    }
}
Also used : SaslOutcome(org.apache.qpid.server.protocol.v1_0.type.security.SaslOutcome) SASLFrame(org.apache.qpid.server.protocol.v1_0.framing.SASLFrame) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) SubjectAuthenticationResult(org.apache.qpid.server.security.auth.SubjectAuthenticationResult)

Aggregations

Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)104 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)46 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)45 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)43 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)42 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)37 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)32 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)29 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)29 Test (org.junit.Test)29 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)28 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)23 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)22 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)21 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)19 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)16 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)13 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)12 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)12 HashMap (java.util.HashMap)11