Search in sources :

Example 1 with SaslChallenge

use of org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge in project qpid-broker-j by apache.

the class AMQPConnection_1_0Impl method continueSaslNegotiation.

private void continueSaslNegotiation(final byte[] challenge) {
    SaslChallenge challengeBody = new SaslChallenge();
    challengeBody.setChallenge(new Binary(challenge));
    send(new SASLFrame(challengeBody));
    _connectionState = ConnectionState.AWAIT_SASL_RESPONSE;
}
Also used : SaslChallenge(org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge) SASLFrame(org.apache.qpid.server.protocol.v1_0.framing.SASLFrame) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary)

Example 2 with SaslChallenge

use of org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge in project qpid-broker-j by apache.

the class SaslChallenge method toString.

@Override
public String toString() {
    StringBuilder builder = new StringBuilder("SaslChallenge{");
    final int origLength = builder.length();
    if (_challenge != null) {
        if (builder.length() != origLength) {
            builder.append(',');
        }
        builder.append("challenge=").append(_challenge);
    }
    builder.append('}');
    return builder.toString();
}
Also used : SASLEndpoint(org.apache.qpid.server.protocol.v1_0.SASLEndpoint)

Example 3 with SaslChallenge

use of org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge in project qpid-broker-j by apache.

the class SaslTest method clientSendsSaslChallenge.

@Test
@SpecificationTest(section = "5.3.2", description = "SASL Negotiation")
public void clientSendsSaslChallenge() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin(), BrokerAdmin.PortType.AMQP).connect()) {
        SaslChallenge saslChallenge = new SaslChallenge();
        saslChallenge.setChallenge(new Binary(new byte[] {}));
        transport.newInteraction().protocolHeader(SASL_AMQP_HEADER_BYTES).negotiateProtocol().consumeResponse().consumeResponse(SaslMechanisms.class).sendPerformative(saslChallenge).sync();
        transport.assertNoMoreResponsesAndChannelClosed();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) SaslChallenge(org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 4 with SaslChallenge

use of org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge in project qpid-broker-j by apache.

the class SaslTest method saslSuccessfulAuthenticationWithChallengeResponse.

@Test
@SpecificationTest(section = "5.3.2", description = "SASL Negotiation [...] challenge/response step occurs once")
public void saslSuccessfulAuthenticationWithChallengeResponse() throws Exception {
    assumeThat(getBrokerAdmin().isSASLMechanismSupported(CRAM_MD5.toString()), is(true));
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin(), BrokerAdmin.PortType.AMQP).connect()) {
        final Interaction interaction = transport.newInteraction();
        final byte[] saslHeaderResponse = interaction.protocolHeader(SASL_AMQP_HEADER_BYTES).negotiateProtocol().consumeResponse().getLatestResponse(byte[].class);
        assertThat(saslHeaderResponse, is(equalTo(SASL_AMQP_HEADER_BYTES)));
        SaslMechanisms saslMechanismsResponse = interaction.consumeResponse().getLatestResponse(SaslMechanisms.class);
        assertThat(Arrays.asList(saslMechanismsResponse.getSaslServerMechanisms()), hasItem(CRAM_MD5));
        SaslChallenge saslChallenge = interaction.saslMechanism(CRAM_MD5).saslInit().consumeResponse().getLatestResponse(SaslChallenge.class);
        assertThat(saslChallenge.getChallenge(), is(notNullValue()));
        byte[] response = generateCramMD5ClientResponse(_username, _password, saslChallenge.getChallenge().getArray());
        final SaslOutcome saslOutcome = interaction.saslResponseResponse(new Binary(response)).saslResponse().consumeResponse().getLatestResponse(SaslOutcome.class);
        assertThat(saslOutcome.getCode(), equalTo(SaslCode.OK));
        final byte[] headerResponse = interaction.protocolHeader(AMQP_HEADER_BYTES).negotiateProtocol().consumeResponse().getLatestResponse(byte[].class);
        assertThat(headerResponse, is(equalTo(AMQP_HEADER_BYTES)));
        transport.assertNoMoreResponses();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) SaslOutcome(org.apache.qpid.server.protocol.v1_0.type.security.SaslOutcome) SaslChallenge(org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) SaslMechanisms(org.apache.qpid.server.protocol.v1_0.type.security.SaslMechanisms) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)3 SaslChallenge (org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge)3 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)2 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)2 Test (org.junit.Test)2 SASLEndpoint (org.apache.qpid.server.protocol.v1_0.SASLEndpoint)1 SASLFrame (org.apache.qpid.server.protocol.v1_0.framing.SASLFrame)1 SaslMechanisms (org.apache.qpid.server.protocol.v1_0.type.security.SaslMechanisms)1 SaslOutcome (org.apache.qpid.server.protocol.v1_0.type.security.SaslOutcome)1 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)1