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