Search in sources :

Example 51 with Binary

use of org.apache.qpid.server.protocol.v1_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 52 with Binary

use of org.apache.qpid.server.protocol.v1_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 53 with Binary

use of org.apache.qpid.server.protocol.v1_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 54 with Binary

use of org.apache.qpid.server.protocol.v1_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 55 with Binary

use of org.apache.qpid.server.protocol.v1_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)50 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)47 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)45 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)43 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)42 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)32 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)32 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)32 Test (org.junit.Test)32 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)31 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)25 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)24 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)23 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)22 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)17 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)16 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)14 HashMap (java.util.HashMap)13 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)13