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


Java Transport.sasl方法代码示例

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


在下文中一共展示了Transport.sasl方法的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: chooseSaslMechanismAndSendInit

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
private SaslMechanism chooseSaslMechanismAndSendInit(Connection connection, InputStream in, OutputStream out) throws LoginException, IOException {

        Transport transport = connection.getTransport();
        Sasl sasl = transport.sasl();
        SaslMechanism mechanism = null;
        // read from network until we get a sasl-mechanisms
        readFromNetwork(connection, in, () -> sasl.getState() == PN_SASL_IDLE && sasl.getRemoteMechanisms().length == 0);

        for (SaslMechanismFactory factory : saslFactories) {
            if (Arrays.asList(sasl.getRemoteMechanisms()).contains(factory.getName())) {
                mechanism = factory.newInstance(callbackHandler, sharedState, options);
                if (mechanism != null) {
                    sasl.setRemoteHostname(saslHostname);
                    sasl.setMechanisms(factory.getName());
                    byte[] initialResponse = mechanism.getResponse(null);
                    if (initialResponse != null && initialResponse.length != 0) {
                        sasl.send(initialResponse, 0, initialResponse.length);
                    }
                    break;
                }
            }
        }

        if (mechanism == null) {
            throw new LoginException("Unable to authenticate using SASL delegation, no supported mechanisms");
        }

        writeToNetwork(connection, out);
        return mechanism;
    }
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:31,代码来源:SaslDelegatingLogin.java

示例4: init

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Override
public void init(NetSocket socket, ProtonConnection protonConnection, Transport transport) {
    sasl = transport.sasl();
    sasl.server();
    sasl.allowSkip(false);

    sasl.setMechanisms(mechName);

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

示例5: init

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Override
public void init(final NetSocket socket,
                 final ProtonConnection protonConnection,
                 final Transport transport) {
    this.sasl = transport.sasl();
    sasl.server();
    sasl.allowSkip(false);
    sasl.setMechanisms(MECHANISMS.keySet().toArray(new String[MECHANISMS.size()]));
    keycloakSession = keycloakSessionFactory.create();
    connection = protonConnection;
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:12,代码来源:SaslAuthenticator.java

示例6: init

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Override
public void init(final NetSocket socket,
                 final ProtonConnection protonConnection,
                 final Transport transport) {
    sasl = transport.sasl();
    sasl.server();
    sasl.allowSkip(false);
    sasl.setMechanisms(ProtonSaslExternalImpl.MECH_NAME);
    succeeded = false;
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:11,代码来源:ExternalSaslAuthenticator.java

示例7: selected

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的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

示例8: makeTransport

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
private static Transport makeTransport(Connection conn) {
    Transport transport = Transport.Factory.create();
    Sasl sasl = transport.sasl();
    sasl.setMechanisms("ANONYMOUS");
    sasl.client();
    transport.bind(conn);
    return transport;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:9,代码来源:Driver.java

示例9: handleOpen

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
private void handleOpen(Reactor reactor, Event event) {
    Connection connection = event.getConnection();
    if (connection.getRemoteState() != EndpointState.UNINITIALIZED) {
        return;
    }
    // Outgoing Reactor connections set the virtual host automatically using the
    // following rules:
    String vhost = connection.getHostname();
    if (vhost == null) {
        // setHostname never called, use the host from the connection's
        // socket address as the default virtual host:
        String conAddr = reactor.getConnectionAddress(connection);
        if (conAddr != null) {
            Address addr = new Address(conAddr);
            connection.setHostname(addr.getHost());
        }
    } else if (vhost.isEmpty()) {
        // setHostname called explictly with a null string. This allows
        // the application to completely avoid sending a virtual host
        // name
        connection.setHostname(null);
    } else {
        // setHostname set by application - use it.
    }
    Transport transport = Proton.transport();

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

    if (reactor.getOptions().isEnableSaslByDefault()) {
        Sasl sasl = transport.sasl();
        sasl.client();
        sasl.setMechanisms("ANONYMOUS");
    }

    transport.bind(connection);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:40,代码来源:IOHandler.java

示例10: init

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Override
public void init(NetSocket socket, ProtonConnection protonConnection, Transport transport) {
  this.sasl = transport.sasl();
  sasl.server();
  sasl.allowSkip(false);
  sasl.setMechanisms(ProtonSaslAnonymousImpl.MECH_NAME);
  succeeded = false;
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:9,代码来源:ProtonSaslServerAuthenticatorImpl.java

示例11: init

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Override
public void init(NetSocket socket, ProtonConnection protonConnection, Transport transport) {
  this.socket = socket;
  this.connection = protonConnection;
  this.sasl = transport.sasl();
  sasl.client();
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:8,代码来源:ProtonSaslClientAuthenticatorImpl.java

示例12: init

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Override
public void init(NetSocket socket, ProtonConnection protonConnection, Transport transport) {
  this.protonConnection = protonConnection;
  this.sasl = transport.sasl();
  sasl.server();
  sasl.allowSkip(false);
  sasl.setMechanisms(PLAIN);
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:9,代码来源:ProtonServerImplTest.java

示例13: login

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Override
public boolean login() throws LoginException {

    boolean success = false;
    try {
        List<X509Certificate> certs = new ArrayList<>();

        if(isAuthenticatedUsingCerts(certs)) {
            success = populateUserAndRolesFromCert(certs.get(0));
        } else {

            Transport transport = Proton.transport();
            Connection connection = Proton.connection();
            transport.bind(connection);
            Sasl sasl = transport.sasl();
            sasl.client();

            Socket socket = createSocket();

            InputStream in = socket.getInputStream();
            OutputStream out = socket.getOutputStream();

            transport.open();

            // write Headers
            writeToNetwork(connection, out);

            SaslMechanism mechanism = chooseSaslMechanismAndSendInit(connection, in, out);

            performSaslSteps(connection, in, out, mechanism);

            if (isSaslAuthenticated(connection, mechanism)) {
                performConnectionOpen(connection, in, out);
                getUserAndRolesFromConnection(connection);
                success = true;
            } else {
                LOG.debug("Login failed");
            }

            connection.close();
            transport.close();
            socket.close();
        }

    } catch (IOException | UnsupportedCallbackException | InvalidNameException e) {
        LoginException loginException = new LoginException("Exception attempting to authenticate using SASL delegation");
        loginException.initCause(e);
        LOG.warn(e);
        throw loginException;
    }
    loginSucceeded = success;
    return success;
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:54,代码来源:SaslDelegatingLogin.java

示例14: isSaslAuthenticated

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
private boolean isSaslAuthenticated(Connection connection, SaslMechanism mechanism) {
    Transport transport = connection.getTransport();
    Sasl sasl = transport.sasl();
    return sasl.getState() == PN_SASL_PASS && mechanism.completedSuccessfully();
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:6,代码来源:SaslDelegatingLogin.java

示例15: run

import org.apache.qpid.proton.engine.Transport; //导入方法依赖的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


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