Java Code Examples for org.apache.qpid.proton.engine.Sasl#setListener()

The following examples show how to use org.apache.qpid.proton.engine.Sasl#setListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtonHandler.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void createServerSASL(String[] mechanisms) {
   requireHandler();
   Sasl sasl = transport.sasl();
   sasl.server();
   sasl.setMechanisms(mechanisms);
   sasl.setListener(this);
}
 
Example 2
Source File: SaslTest.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Test
public void testSaslNegotiationUsingListener() throws Exception
{
    getClient().transport = Proton.transport();
    getServer().transport = Proton.transport();

    AtomicBoolean mechanismsReceived = new AtomicBoolean();
    AtomicBoolean challengeReceived = new AtomicBoolean();
    AtomicBoolean outcomeReceived = new AtomicBoolean();

    Sasl clientSasl = getClient().transport.sasl();
    clientSasl.client();
    clientSasl.setListener(new ClientSaslHandling(mechanismsReceived, challengeReceived, outcomeReceived));

    AtomicBoolean initReceived = new AtomicBoolean();
    AtomicBoolean responseReceived = new AtomicBoolean();

    Sasl serverSasl = getServer().transport.sasl();
    serverSasl.server();
    serverSasl.setMechanisms(TESTMECH1, TESTMECH2);
    serverSasl.setListener(new ServerSaslHandling(initReceived, responseReceived));

    pumpClientToServer();
    pumpServerToClient();

    assertTrue("mechanisms were not received by client", mechanismsReceived.get());
    assertFalse("init was received by server", initReceived.get());

    pumpClientToServer();

    assertTrue("init was not received by server", initReceived.get());
    assertFalse("challenge was received by client", challengeReceived.get());

    pumpServerToClient();

    assertTrue("challenge was not received by client", challengeReceived.get());
    assertFalse("response was received by server", responseReceived.get());

    pumpClientToServer();

    assertTrue("response was received by server", responseReceived.get());
    assertFalse("outcome was received by client", outcomeReceived.get());

    pumpServerToClient();

    assertTrue("outcome was received by client", outcomeReceived.get());

    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_OK, clientSasl.getOutcome());
}
 
Example 3
Source File: ProtonHandler.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public void createClientSASL() {
   Sasl sasl = transport.sasl();
   sasl.client();
   sasl.setListener(this);
}