Search in sources :

Example 1 with SaslResponse

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

the class AMQPConnection_1_0Impl method receiveSaslResponse.

@Override
public void receiveSaslResponse(final SaslResponse saslResponse) {
    assertState(ConnectionState.AWAIT_SASL_RESPONSE);
    final Binary responseBinary = saslResponse.getResponse();
    byte[] response = responseBinary == null ? new byte[0] : responseBinary.getArray();
    processSaslResponse(response);
}
Also used : Binary(org.apache.qpid.server.protocol.v1_0.type.Binary)

Example 2 with SaslResponse

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

the class SaslResponse method toString.

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

Example 3 with SaslResponse

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

the class Interaction method copySaslResponse.

private SaslResponse copySaslResponse(final SaslResponse saslResponse) {
    final SaslResponse saslResponseCopy = new SaslResponse();
    saslResponseCopy.setResponse(saslResponse.getResponse());
    return saslResponseCopy;
}
Also used : SaslResponse(org.apache.qpid.server.protocol.v1_0.type.security.SaslResponse)

Example 4 with SaslResponse

use of org.apache.qpid.server.protocol.v1_0.type.security.SaslResponse 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 {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
    try (FrameTransport transport = new FrameTransport(addr, true).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) InetSocketAddress(java.net.InetSocketAddress) 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)2 InetSocketAddress (java.net.InetSocketAddress)1 SASLEndpoint (org.apache.qpid.server.protocol.v1_0.SASLEndpoint)1 SaslChallenge (org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge)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 SaslResponse (org.apache.qpid.server.protocol.v1_0.type.security.SaslResponse)1 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)1 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)1 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)1 Test (org.junit.Test)1