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


Java Sasl.pending方法代码示例

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


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

示例1: performSaslSteps

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

示例2: onSaslInit

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

示例3: onSaslResponse

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
@Override
public void onSaslResponse(Sasl s, Transport t)
{
    byte[] serverReceivedResponseBytes = new byte[s.pending()];
    s.recv(serverReceivedResponseBytes, 0, serverReceivedResponseBytes.length);

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

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

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

示例4: onSaslChallenge

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
@Override
public void onSaslChallenge(Sasl s, Transport t)
{
    byte[] clientReceivedChallengeBytes = new byte[s.pending()];
    s.recv(clientReceivedChallengeBytes, 0, clientReceivedChallengeBytes.length);

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

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

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

示例5: onSaslOutcome

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
@Override
public void onSaslOutcome(Sasl s, Transport t)
{
    assertEquals("Unexpected SASL outcome at client", SaslOutcome.PN_SASL_OK, s.getOutcome());

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

    assertArrayEquals("Client should now know the server's outcome additional data", clientReceivedAdditionalBytes,
            clientReceivedAdditionalBytes);

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

示例6: evaluatePlainResponse

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
private boolean evaluatePlainResponse(Sasl sasl) {
  byte[] response = new byte[sasl.pending()];
  sasl.recv(response, 0, response.length);

  // Per https://tools.ietf.org/html/rfc4616 the PLAIN message format is: [authzid] UTF8NUL authcid UTF8NUL passwd
  // Break initial response into its constituent parts.
  int authzidTerminatorPos = findNullPosition(response, 0);
  if (authzidTerminatorPos < 0) {
    // Invalid PLAIN encoding, authzid null terminator not found
    return false;
  }

  int authcidTerminatorPos = findNullPosition(response, authzidTerminatorPos + 1);
  if (authcidTerminatorPos < 0) {
    // Invalid PLAIN encoding, authcid null terminator not found
    return false;
  }

  if (authcidTerminatorPos == response.length - 1) {
    // Invalid PLAIN encoding, no password present
    return false;
  }

  // Grab the authcid and password (ignoring authzid if present)
  String authcid = new String(response, authzidTerminatorPos + 1, authcidTerminatorPos - authzidTerminatorPos - 1,
      StandardCharsets.UTF_8);
  String passwd = new String(response, authcidTerminatorPos + 1, response.length - authcidTerminatorPos - 1,
      StandardCharsets.UTF_8);

  // Now verify the given credentials
  if (GOOD_USER.equals(authcid) && PASSWD.equals(passwd)) {
    // Success
    return true;
  }

  return false;
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:38,代码来源:ProtonServerImplTest.java

示例7: handleSaslChallenge

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
public void handleSaslChallenge(Sasl sasl, Transport transport) {
    try {
        if (sasl.pending() >= 0) {
            byte[] challenge = new byte[sasl.pending()];
            sasl.recv(challenge, 0, challenge.length);
            byte[] response = mechanism.getChallengeResponse(challenge);
            if (response != null) {
                sasl.send(response, 0, response.length);
            }
        }
    } catch (Throwable error) {
        recordFailure("Exception while processing SASL step: " + error.getMessage(), error);
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:15,代码来源:AmqpSaslAuthenticator.java

示例8: handleSaslCompletion

import org.apache.qpid.proton.engine.Sasl; //导入方法依赖的package包/类
private void handleSaslCompletion(Sasl sasl) {
    try {
        if (sasl.pending() != 0) {
            byte[] additionalData = new byte[sasl.pending()];
            sasl.recv(additionalData, 0, additionalData.length);
            mechanism.getChallengeResponse(additionalData);
        }
        mechanism.verifyCompletion();
        complete = true;
    } catch (Throwable error) {
        recordFailure("Exception while processing SASL exchange completion: " + error.getMessage(), error);
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:14,代码来源:AmqpSaslAuthenticator.java

示例9: 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

示例10: 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


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