当前位置: 首页>>代码示例>>Java>>正文


Java Sasl.server方法代码示例

本文整理汇总了Java中org.apache.qpid.proton.engine.Sasl.server方法的典型用法代码示例。如果您正苦于以下问题:Java Sasl.server方法的具体用法?Java Sasl.server怎么用?Java Sasl.server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.qpid.proton.engine.Sasl的用法示例。


在下文中一共展示了Sasl.server方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: channelActive

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
@Override
public void channelActive(ChannelHandlerContext ctx) {
    synchronized (lock) {
        System.out.println("ACTIVE");
        transport = Transport.Factory.create();
        transport.setContext(ctx);

        Sasl sasl = transport.sasl();
        sasl.setMechanisms("ANONYMOUS");
        sasl.server();
        sasl.done(Sasl.PN_SASL_OK);

        connection = Connection.Factory.create();
        collector = Collector.Factory.create();
        connection.collect(collector);
        transport.bind(connection);

        // XXX: really we should fire both of these off of an
        //      initial transport event
        write(ctx);
        int capacity = transport.capacity();
        if (capacity > 0) {
            ctx.read();
        }
    }
}
 
开发者ID:rhs,项目名称:qpid-proton-netty,代码行数:27,代码来源:ProtonNettyHandler.java

示例2: selected

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
public void selected() throws IOException {
    SocketChannel sock = socket.accept();
    System.out.println("ACCEPTED: " + sock);
    Connection conn = Connection.Factory.create();
    conn.collect(collector);
    Transport transport = Transport.Factory.create();
    Sasl sasl = transport.sasl();
    sasl.setMechanisms("ANONYMOUS");
    sasl.server();
    sasl.done(Sasl.PN_SASL_OK);
    transport.bind(conn);
    new ChannelHandler(sock, SelectionKey.OP_READ, transport);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:14,代码来源:Driver.java

示例3: testOptionalChallengeResponseStepOmitted

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
/** 5.3.2 SASL Negotiation. ...challenge/response step can occur zero or more times*/
@Test
public void testOptionalChallengeResponseStepOmitted() throws Exception
{
    getClient().transport = Proton.transport();
    getServer().transport = Proton.transport();

    Sasl clientSasl = getClient().transport.sasl();
    clientSasl.client();
    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());

    Sasl serverSasl = getServer().transport.sasl();
    serverSasl.server();
    serverSasl.setMechanisms(TESTMECH1);
    assertEquals("Server should not yet know the remote's chosen mechanism.",
                 0,
                 serverSasl.getRemoteMechanisms().length);

    pumpClientToServer();
    pumpServerToClient();

    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());
    clientSasl.setMechanisms(TESTMECH1);

    pumpClientToServer();

    serverSasl.done(SaslOutcome.PN_SASL_OK);
    pumpServerToClient();

    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_OK, clientSasl.getOutcome());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:32,代码来源:SaslTest.java

示例4: testAuthenticationFails

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
/**
 *  5.3.3.6 Connection authentication failed due to an unspecified problem with the supplied credentials.
 */
@Test
public void testAuthenticationFails() throws Exception
{
    getClient().transport = Proton.transport();
    getServer().transport = Proton.transport();

    Sasl clientSasl = getClient().transport.sasl();
    clientSasl.client();
    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());

    Sasl serverSasl = getServer().transport.sasl();
    serverSasl.server();
    serverSasl.setMechanisms(TESTMECH1);

    pumpClientToServer();
    pumpServerToClient();

    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());
    clientSasl.setMechanisms(TESTMECH1);

    pumpClientToServer();

    serverSasl.done(SaslOutcome.PN_SASL_AUTH);
    pumpServerToClient();
    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_AUTH, clientSasl.getOutcome());

}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:31,代码来源:SaslTest.java

示例5: MockNetworkChannel

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
public MockNetworkChannel(NetworkListener listener, Handler handler) {
    this.listener = listener;
    this.handler = handler;
    collector = Proton.collector();
    connection = Proton.connection();
    transport = Proton.transport();
    connection.collect(collector);
    connection.setHostname("localhost");
    connection.setContainer("some container");
    transport.bind(connection);
    Sasl sasl = transport.sasl();
    sasl.server();
    sasl.setMechanisms("ANONYMOUS");
    sasl.done(Sasl.SaslOutcome.PN_SASL_OK);
}
 
开发者ID:mqlight,项目名称:java-mqlight,代码行数:16,代码来源:MockNetworkChannel.java

示例6: run

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
@Override
public void run(Selectable selectable) {
    Reactor reactor = selectable.getReactor();
    try {
        SocketChannel socketChannel = ((ServerSocketChannel)selectable.getChannel()).accept();
        if (socketChannel == null) {
            throw new ReactorInternalException("Selectable readable, but no socket to accept");
        }
        Handler handler = BaseHandler.getHandler(AcceptorImpl.this);
        if (handler == null) {
            handler = reactor.getHandler();
        }
        Connection conn = reactor.connection(handler);
        Record conn_recs = conn.attachments();
        conn_recs.set(CONNECTION_ACCEPTOR_KEY, Acceptor.class, AcceptorImpl.this);
        InetSocketAddress peerAddr = (InetSocketAddress)socketChannel.getRemoteAddress();
        if (peerAddr != null) {
            Address addr = new Address();
            addr.setHost(peerAddr.getHostString());
            addr.setPort(Integer.toString(peerAddr.getPort()));
            conn_recs.set(ReactorImpl.CONNECTION_PEER_ADDRESS_KEY, Address.class, addr);
        }
        Transport trans = Proton.transport();

        int maxFrameSizeOption = reactor.getOptions().getMaxFrameSize();
        if (maxFrameSizeOption != 0) {
            trans.setMaxFrameSize(maxFrameSizeOption);
        }

        if(reactor.getOptions().isEnableSaslByDefault()) {
            Sasl sasl = trans.sasl();
            sasl.server();
            sasl.setMechanisms("ANONYMOUS");
            sasl.done(SaslOutcome.PN_SASL_OK);
        }
        trans.bind(conn);
        IOHandler.selectableTransport(reactor, socketChannel.socket(), trans);
    } catch(IOException ioException) {
        sel.error();
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:42,代码来源:AcceptorImpl.java

示例7: testSaslNegotiation

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
/** 5.3.2 SASL Negotiation. */
@Test
public void testSaslNegotiation() throws Exception
{
    getClient().transport = Proton.transport();
    getServer().transport = Proton.transport();

    Sasl clientSasl = getClient().transport.sasl();
    clientSasl.client();
    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());

    Sasl serverSasl = getServer().transport.sasl();
    serverSasl.server();
    serverSasl.setMechanisms(TESTMECH1, TESTMECH2);
    assertEquals("Server should not yet know the remote's chosen mechanism.",
                 0,
                 serverSasl.getRemoteMechanisms().length);

    pumpClientToServer();
    pumpServerToClient();

    assertArrayEquals("Client should now know the server's mechanisms.",
                      new String[]{TESTMECH1, TESTMECH2},
                      clientSasl.getRemoteMechanisms());
    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());
    clientSasl.setMechanisms(TESTMECH1);

    pumpClientToServer();

    assertArrayEquals("Server should now know the client's chosen mechanism.",
                      new String[]{TESTMECH1},
                      serverSasl.getRemoteMechanisms());

    serverSasl.send(CHALLENGE_BYTES, 0, CHALLENGE_BYTES.length);

    pumpServerToClient();

    byte[] clientReceivedChallengeBytes = new byte[clientSasl.pending()];
    clientSasl.recv(clientReceivedChallengeBytes, 0, clientReceivedChallengeBytes.length);

    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());
    assertArrayEquals("Client should now know the server's challenge",
                      CHALLENGE_BYTES,
                      clientReceivedChallengeBytes);

    clientSasl.send(RESPONSE_BYTES, 0, RESPONSE_BYTES.length);

    pumpClientToServer();

    byte[] serverReceivedResponseBytes = new byte[serverSasl.pending()];
    serverSasl.recv(serverReceivedResponseBytes, 0, serverReceivedResponseBytes.length);

    assertArrayEquals("Server should now know the client's response",
                      RESPONSE_BYTES,
                      serverReceivedResponseBytes);

    serverSasl.done(SaslOutcome.PN_SASL_OK);
    pumpServerToClient();

    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_OK, clientSasl.getOutcome());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:62,代码来源:SaslTest.java

示例8: testOutcomeAdditionalData

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
/**
 *  5.3.3.5 The additional-data field carries additional data on successful authentication outcome as specified
 *  by the SASL specification [RFC4422].
 */
@Test
public void testOutcomeAdditionalData() throws Exception
{
    getClient().transport = Proton.transport();
    getServer().transport = Proton.transport();

    Sasl clientSasl = getClient().transport.sasl();
    clientSasl.client();
    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());

    Sasl serverSasl = getServer().transport.sasl();
    serverSasl.server();
    serverSasl.setMechanisms(TESTMECH1);

    pumpClientToServer();
    pumpServerToClient();

    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());
    clientSasl.setMechanisms(TESTMECH1);

    pumpClientToServer();

    serverSasl.send(CHALLENGE_BYTES, 0, CHALLENGE_BYTES.length);

    pumpServerToClient();

    byte[] clientReceivedChallengeBytes = new byte[clientSasl.pending()];
    clientSasl.recv(clientReceivedChallengeBytes, 0, clientReceivedChallengeBytes.length);

    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_NONE, clientSasl.getOutcome());
    clientSasl.send(RESPONSE_BYTES, 0, RESPONSE_BYTES.length);

    pumpClientToServer();

    byte[] serverReceivedResponseBytes = new byte[serverSasl.pending()];
    serverSasl.recv(serverReceivedResponseBytes, 0, serverReceivedResponseBytes.length);

    serverSasl.send(ADDITIONAL_DATA_BYTES, 0, ADDITIONAL_DATA_BYTES.length);
    serverSasl.done(SaslOutcome.PN_SASL_OK);
    pumpServerToClient();

    byte[] clientReceivedAdditionalDataBytes = new byte[clientSasl.pending()];
    clientSasl.recv(clientReceivedAdditionalDataBytes, 0, clientReceivedAdditionalDataBytes.length);

    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_OK, clientSasl.getOutcome());
    assertArrayEquals("Client should now know the serrver's additional-data",
                      ADDITIONAL_DATA_BYTES,
                      clientReceivedAdditionalDataBytes);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:54,代码来源:SaslTest.java

示例9: testSaslNegotiationUsingListener

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
@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());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:50,代码来源:SaslTest.java


注:本文中的org.apache.qpid.proton.engine.Sasl.server方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。