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


Java Transport类代码示例

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


Transport类属于org.apache.qpid.proton.engine包,在下文中一共展示了Transport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Override
public void init(final NetSocket socket, final ProtonConnection protonConnection, final Transport transport) {
    LOG.debug("initializing SASL authenticator");
    this.protonConnection = protonConnection;
    this.sasl = transport.sasl();
    // TODO determine supported mechanisms dynamically based on registered AuthenticationService implementations
    sasl.server();
    sasl.allowSkip(false);
    sasl.setMechanisms(MECHANISM_EXTERNAL, MECHANISM_PLAIN);
    if (socket.isSsl()) {
        LOG.debug("client connected using TLS, extracting client certificate chain");
        try {
            peerCertificateChain = socket.peerCertificateChain();
            LOG.debug("found valid client certificate DN [{}]", peerCertificateChain[0].getSubjectDN());
        } catch (SSLPeerUnverifiedException e) {
            LOG.debug("could not extract client certificate chain, maybe TLS based client auth is not required");
        }
    }
}
 
开发者ID:eclipse,项目名称:hono,代码行数:20,代码来源:HonoSaslAuthenticator.java

示例2: performSaslSteps

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
private void performSaslSteps(Connection connection, InputStream in,
                              OutputStream out,
                              SaslMechanism mechanism) throws IOException, LoginException {
    Transport transport = connection.getTransport();
    Sasl sasl = transport.sasl();
    do {

        readFromNetwork(connection, in, () ->
            !(EnumSet.of(PN_SASL_PASS, PN_SASL_FAIL).contains(sasl.getState())
            || (sasl.getState() == PN_SASL_STEP && sasl.pending() > 0)));

        if (sasl.pending() > 0) {
            byte[] challenge = new byte[sasl.pending()];
            byte[] response = mechanism.getResponse(challenge);
            if (sasl.getState() == PN_SASL_STEP) {
                sasl.send(response, 0, response.length);
                writeToNetwork(connection, out);
            }
        }

    } while (sasl.getState() == PN_SASL_STEP);
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:23,代码来源:SaslDelegatingLogin.java

示例3: readFromNetwork

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
private void readFromNetwork(Connection connection, InputStream in, BooleanSupplier test) throws IOException, LoginException {
    Transport transport = connection.getTransport();
    while(test.getAsBoolean()) {
        ByteBuffer buf = transport.getInputBuffer();
        byte[] tmpBuf = new byte[buf.remaining()];
        int bytesRead = in.read(tmpBuf);
        LOG.tracev("read {0} bytes", bytesRead);
        if (bytesRead == -1) {
            throw new LoginException("Unexpected EOS experienced when authenticating using SASL delegation");
        } else {
            buf.put(tmpBuf, 0, bytesRead);
            TransportResult result = transport.processInput();
            if(!result.isOk()) {
                LoginException e = new LoginException("Unexpected error when authenticating using SASL delegation");
                e.initCause(result.getException());
                throw e;
            }
        }

    }

}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:23,代码来源:SaslDelegatingLogin.java

示例4: create

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Override
public ProtonSaslAuthenticator create() {
    return new ProtonSaslAuthenticator() {
        @Override
        public void init(NetSocket socket, ProtonConnection protonConnection, Transport transport) {
        }

        @Override
        public void process(Handler<Boolean> completionHandler) {
            completionHandler.handle(true);
        }

        @Override
        public boolean succeeded() {
            return true;
        }
    };
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:19,代码来源:DummySaslAuthenticatorFactory.java

示例5: pourAll

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
/**
 * Pours the contents of {@code source} into {@code destinationTransportInput}, calling
 * the TransportInput many times if necessary.  If the TransportInput returns a {@link org.apache.qpid.proton.engine.TransportResult}
 * other than ok, data may remain in source.
 */
public static int pourAll(ByteBuffer source, TransportInput destinationTransportInput) throws TransportException
{
    int capacity = destinationTransportInput.capacity();
    if (capacity == Transport.END_OF_STREAM)
    {
        if (source.hasRemaining()) {
            throw new IllegalStateException("Destination has reached end of stream: " +
                                            destinationTransportInput);
        } else {
            return Transport.END_OF_STREAM;
        }
    }

    int total = source.remaining();

    while(source.hasRemaining() && destinationTransportInput.capacity() > 0)
    {
        pour(source, destinationTransportInput.tail());
        destinationTransportInput.process();
    }

    return total - source.remaining();
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:29,代码来源:ByteBufferUtils.java

示例6: recv

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
int recv(final byte[] bytes, int offset, int size)
{
    final int consumed;
    if (_data != null)
    {
        //TODO - should only be if no bytes left
        consumed = Math.min(size, _dataSize);

        System.arraycopy(_data, _offset, bytes, offset, consumed);
        _offset += consumed;
        _dataSize -= consumed;
    }
    else
    {
        _dataSize = consumed = 0;
    }

    return (_complete && consumed == 0) ? Transport.END_OF_STREAM : consumed;  //TODO - Implement
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:20,代码来源:DeliveryImpl.java

示例7: pending

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Override
public int pending()
{
    if (isOutputInSaslMode() || _outputBuffer.position() != 0)
    {
        fillOutputBuffer();
        _head.limit(_outputBuffer.position());

        if (_head_closed && _outputBuffer.position() == 0)
        {
            return Transport.END_OF_STREAM;
        }
        else
        {
            return _outputBuffer.position();
        }
    }
    else
    {
        return _underlyingOutput.pending();
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:23,代码来源:SaslImpl.java

示例8: pending

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Override
public int pending()
{
    try {
        wrapOutput();
    } catch (SSLException e) {
        _logger.log(Level.WARNING, e.getMessage());
        _head_closed = true;
    }

    _head.limit(_outputBuffer.position());

    if (_head_closed && _outputBuffer.position() == 0) {
        return Transport.END_OF_STREAM;
    }

    return _outputBuffer.position();
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:19,代码来源:SimpleSslTransportWrapper.java

示例9: getConnection

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Override
public Connection getConnection()
{
    if (context instanceof Connection) {
        return (Connection) context;
    } else if (context instanceof Transport) {
        Transport transport = getTransport();
        if (transport == null) {
            return null;
        }
        return ((TransportImpl) transport).getConnectionImpl();
    } else {
        Session ssn = getSession();
        if (ssn == null) {
            return null;
        }
        return ssn.getConnection();
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:20,代码来源:EventImpl.java

示例10: getTransport

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Override
public Transport getTransport()
{
    if (context instanceof Transport) {
        return (Transport) context;
    } else if (context instanceof Connection) {
        return ((Connection)context).getTransport();
    } else {
        Session session = getSession();
        if (session == null) {
            return null;
        }

        Connection connection = session.getConnection();
        if (connection == null) {
            return null;
        }

        return connection.getTransport();
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:22,代码来源:EventImpl.java

示例11: getReactor

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Override
public Reactor getReactor() {
    if (context instanceof Reactor) {
        return (Reactor) context;
    } else if (context instanceof Task) {
        return ((Task)context).getReactor();
    } else if (context instanceof Transport) {
        return ((TransportImpl)context).getReactor();
    } else if (context instanceof Delivery) {
        return ((Delivery)context).getLink().getSession().getConnection().getReactor();
    } else if (context instanceof Link) {
        return ((Link)context).getSession().getConnection().getReactor();
    } else if (context instanceof Session) {
        return ((Session)context).getConnection().getReactor();
    } else if (context instanceof Connection) {
        return ((Connection)context).getReactor();
    } else if (context instanceof Selectable) {
        return ((Selectable)context).getReactor();
    }
    return null;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:22,代码来源:EventImpl.java

示例12: testOutputTooBigToBeWrittenInOneGo

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Test
public void testOutputTooBigToBeWrittenInOneGo()
{
    int smallMaxFrameSize = 512;
    _transport = new TransportImpl(smallMaxFrameSize);

    Connection conn = new ConnectionImpl();
    _transport.bind(conn);

    // Open frame sized in order to produce a frame that will almost fill output buffer
    conn.setHostname(stringOfLength("x", 500));
    conn.open();

    // Close the connection to generate a Close frame which will cause an overflow
    // internally - we'll get the remaining bytes on the next interaction.
    conn.close();

    ByteBuffer buf = _transport.getOutputBuffer();
    assertEquals("Expecting buffer to be full", smallMaxFrameSize, buf.remaining());
    buf.position(buf.limit());
    _transport.outputConsumed();

    buf  = _transport.getOutputBuffer();
    assertTrue("Expecting second buffer to have bytes", buf.remaining() > 0);
    assertTrue("Expecting second buffer to not be full", buf.remaining() < Transport.MIN_MAX_FRAME_SIZE);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:27,代码来源:TransportImplTest.java

示例13: testGetTransportWithDeliveryContext

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Test
public void testGetTransportWithDeliveryContext()
{
    Transport transport = Transport.Factory.create();
    Connection connection = Connection.Factory.create();
    transport.bind(connection);

    Session session = connection.session();
    Sender sender = session.sender("mySender");

    Delivery delivery = sender.delivery("tag".getBytes());

    EventImpl event = createEvent(delivery, Event.Type.DELIVERY);

    assertNotNull("No transport returned", event.getTransport());
    assertSame("Incorrect transport returned", transport, event.getTransport());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:18,代码来源:EventImplTest.java

示例14: test

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Test
public void test()
{
    Connection connection1 = Proton.connection();
    Connection connection2 = Proton.connection();;
    Transport transport1 = Proton.transport();
    transport1.bind(connection1);

    Transport transport2 = Proton.transport();
    transport2.bind(connection2);

    assertEquals(EndpointState.UNINITIALIZED, connection1.getLocalState());
    assertEquals(EndpointState.UNINITIALIZED, connection1.getRemoteState());

    connection1.open();
    connection2.open();
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:18,代码来源:SimpleTest.java

示例15: onSaslInit

import org.apache.qpid.proton.engine.Transport; //导入依赖的package包/类
@Override
public void onSaslInit(Sasl s, Transport t)
{
    assertArrayEquals("Server should now know the client's chosen mechanism.",
            new String[]{TESTMECH1}, s.getRemoteMechanisms());

    byte[] serverReceivedInitialBytes = new byte[s.pending()];
    s.recv(serverReceivedInitialBytes, 0, serverReceivedInitialBytes.length);

    assertArrayEquals("Server should now know the client's initial response.",
            INITIAL_RESPONSE_BYTES, serverReceivedInitialBytes);

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

    assertFalse("Should not have already received init", initReceived.getAndSet(true));
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:17,代码来源:SaslTest.java


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