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;
}
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();
}
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();
}
}
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();
}
}
Aggregations