Search in sources :

Example 91 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class SCRAMServerFinalMessageTestCase method testSCRAMSHA1SuccessfulBindWithExtensions.

/**
 * Tests the behavior when creating a server final message for a
 * SCRAM-SHA-1 bind request with a successful bind that includes extensions.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSCRAMSHA1SuccessfulBindWithExtensions() throws Exception {
    final SCRAMSHA1BindRequest bindRequest = new SCRAMSHA1BindRequest("user", "pencil");
    final SCRAMClientFirstMessage clientFirstMessage = new SCRAMClientFirstMessage(bindRequest, "fyko+d2lbbFgONRv9qkxdawL");
    final String serverFirstMessageString = "r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92," + "i=4096";
    final BindResult serverFirstBindResult = new BindResult(1, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFirstMessageString));
    final SCRAMServerFirstMessage serverFirstMessage = new SCRAMServerFirstMessage(bindRequest, clientFirstMessage, serverFirstBindResult);
    final SCRAMClientFinalMessage clientFinalMessage = new SCRAMClientFinalMessage(bindRequest, clientFirstMessage, serverFirstMessage);
    final String serverFinalMessageString = "v=rmF9pqV8S7suAoZWja4dJRkFsKQ=,foo=bar,abc=123";
    final BindResult serverFinalBindResult = new BindResult(2, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFinalMessageString));
    final SCRAMServerFinalMessage serverFinalMessage = new SCRAMServerFinalMessage(bindRequest, clientFirstMessage, clientFinalMessage, serverFinalBindResult);
    assertNotNull(serverFinalMessage.getBindRequest());
    assertNotNull(serverFinalMessage.getClientFirstMessage());
    assertNotNull(serverFinalMessage.getClientFinalMessage());
    assertNotNull(serverFinalMessage.getServerSignatureBase64());
    assertEquals(serverFinalMessage.getServerSignatureBase64(), "rmF9pqV8S7suAoZWja4dJRkFsKQ=");
    assertNotNull(serverFinalMessage.getServerFinalMessage());
    assertEquals(serverFinalMessage.getServerFinalMessage(), "v=rmF9pqV8S7suAoZWja4dJRkFsKQ=,foo=bar,abc=123");
    assertNotNull(serverFinalMessage.toString());
    assertEquals(serverFinalMessage.toString(), "v=rmF9pqV8S7suAoZWja4dJRkFsKQ=,foo=bar,abc=123");
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 92 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class SCRAMServerFinalMessageTestCase method testSCRAMSHA256SuccessfulBindNoExtensions.

/**
 * Tests the behavior when creating a server first message for a
 * SCRAM-SHA-256 bind request.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSCRAMSHA256SuccessfulBindNoExtensions() throws Exception {
    final SCRAMSHA256BindRequest bindRequest = new SCRAMSHA256BindRequest("user", "pencil");
    final SCRAMClientFirstMessage clientFirstMessage = new SCRAMClientFirstMessage(bindRequest, "rOprNGfwEbeRWgbNEkqO");
    final String serverFirstMessageString = "r=rOprNGfwEbeRWgbNEkqO%hvYDpWUa2RaTCAfuxFIlj)hNlF$k0," + "s=W22ZaJ0SNY7soEsUEjb6gQ==,i=4096";
    final BindResult serverFirstBindResult = new BindResult(1, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFirstMessageString));
    final SCRAMServerFirstMessage serverFirstMessage = new SCRAMServerFirstMessage(bindRequest, clientFirstMessage, serverFirstBindResult);
    final SCRAMClientFinalMessage clientFinalMessage = new SCRAMClientFinalMessage(bindRequest, clientFirstMessage, serverFirstMessage);
    final String serverFinalMessageString = "v=6rriTRBi23WpRR/wtup+mMhUZUn/dB5nLTJRsjl95G4=";
    final BindResult serverFinalBindResult = new BindResult(2, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFinalMessageString));
    final SCRAMServerFinalMessage serverFinalMessage = new SCRAMServerFinalMessage(bindRequest, clientFirstMessage, clientFinalMessage, serverFinalBindResult);
    assertNotNull(serverFinalMessage.getBindRequest());
    assertNotNull(serverFinalMessage.getClientFirstMessage());
    assertNotNull(serverFinalMessage.getClientFinalMessage());
    assertNotNull(serverFinalMessage.getServerSignatureBase64());
    assertEquals(serverFinalMessage.getServerSignatureBase64(), "6rriTRBi23WpRR/wtup+mMhUZUn/dB5nLTJRsjl95G4=");
    assertNotNull(serverFinalMessage.getServerFinalMessage());
    assertEquals(serverFinalMessage.getServerFinalMessage(), "v=6rriTRBi23WpRR/wtup+mMhUZUn/dB5nLTJRsjl95G4=");
    assertNotNull(serverFinalMessage.toString());
    assertEquals(serverFinalMessage.toString(), "v=6rriTRBi23WpRR/wtup+mMhUZUn/dB5nLTJRsjl95G4=");
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 93 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class SCRAMServerFinalMessageTestCase method testSCRAMSHA1NonSuccessfulBindNoCredentials.

/**
 * Tests the behavior when creating a server final message for a
 * SCRAM-SHA-1 bind request with a non-successful bind that does not include
 * any SASL credentials.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPBindException.class })
public void testSCRAMSHA1NonSuccessfulBindNoCredentials() throws Exception {
    final SCRAMSHA1BindRequest bindRequest = new SCRAMSHA1BindRequest("user", "pencil");
    final SCRAMClientFirstMessage clientFirstMessage = new SCRAMClientFirstMessage(bindRequest, "fyko+d2lbbFgONRv9qkxdawL");
    final String serverFirstMessageString = "r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92," + "i=4096";
    final BindResult serverFirstBindResult = new BindResult(1, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFirstMessageString));
    final SCRAMServerFirstMessage serverFirstMessage = new SCRAMServerFirstMessage(bindRequest, clientFirstMessage, serverFirstBindResult);
    final SCRAMClientFinalMessage clientFinalMessage = new SCRAMClientFinalMessage(bindRequest, clientFirstMessage, serverFirstMessage);
    final BindResult serverFinalBindResult = new BindResult(2, ResultCode.INVALID_CREDENTIALS, null, null, null, null, null);
    new SCRAMServerFinalMessage(bindRequest, clientFirstMessage, clientFinalMessage, serverFinalBindResult);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 94 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class SCRAMServerFinalMessageTestCase method testSCRAMSHA1SuccessfulBindNoExtensions.

/**
 * Tests the behavior when creating a server final message for a
 * SCRAM-SHA-1 bind request with a successful bind that doesn't have any
 * extensions.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSCRAMSHA1SuccessfulBindNoExtensions() throws Exception {
    final SCRAMSHA1BindRequest bindRequest = new SCRAMSHA1BindRequest("user", "pencil");
    final SCRAMClientFirstMessage clientFirstMessage = new SCRAMClientFirstMessage(bindRequest, "fyko+d2lbbFgONRv9qkxdawL");
    final String serverFirstMessageString = "r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92," + "i=4096";
    final BindResult serverFirstBindResult = new BindResult(1, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFirstMessageString));
    final SCRAMServerFirstMessage serverFirstMessage = new SCRAMServerFirstMessage(bindRequest, clientFirstMessage, serverFirstBindResult);
    final SCRAMClientFinalMessage clientFinalMessage = new SCRAMClientFinalMessage(bindRequest, clientFirstMessage, serverFirstMessage);
    final String serverFinalMessageString = "v=rmF9pqV8S7suAoZWja4dJRkFsKQ=";
    final BindResult serverFinalBindResult = new BindResult(2, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFinalMessageString));
    final SCRAMServerFinalMessage serverFinalMessage = new SCRAMServerFinalMessage(bindRequest, clientFirstMessage, clientFinalMessage, serverFinalBindResult);
    assertNotNull(serverFinalMessage.getBindRequest());
    assertNotNull(serverFinalMessage.getClientFirstMessage());
    assertNotNull(serverFinalMessage.getClientFinalMessage());
    assertNotNull(serverFinalMessage.getServerSignatureBase64());
    assertEquals(serverFinalMessage.getServerSignatureBase64(), "rmF9pqV8S7suAoZWja4dJRkFsKQ=");
    assertNotNull(serverFinalMessage.getServerFinalMessage());
    assertEquals(serverFinalMessage.getServerFinalMessage(), "v=rmF9pqV8S7suAoZWja4dJRkFsKQ=");
    assertNotNull(serverFinalMessage.toString());
    assertEquals(serverFinalMessage.toString(), "v=rmF9pqV8S7suAoZWja4dJRkFsKQ=");
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 95 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class SCRAMServerFinalMessageTestCase method testSCRAMSHA1NonSuccessfulBindWithErrorCredentialsWithExtensions.

/**
 * Tests the behavior when creating a server final message for a
 * SCRAM-SHA-1 bind request with a non-successful bind that has valid error
 * credentials and also includes extensions.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPBindException.class })
public void testSCRAMSHA1NonSuccessfulBindWithErrorCredentialsWithExtensions() throws Exception {
    final SCRAMSHA1BindRequest bindRequest = new SCRAMSHA1BindRequest("user", "pencil");
    final SCRAMClientFirstMessage clientFirstMessage = new SCRAMClientFirstMessage(bindRequest, "fyko+d2lbbFgONRv9qkxdawL");
    final String serverFirstMessageString = "r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92," + "i=4096";
    final BindResult serverFirstBindResult = new BindResult(1, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFirstMessageString));
    final SCRAMServerFirstMessage serverFirstMessage = new SCRAMServerFirstMessage(bindRequest, clientFirstMessage, serverFirstBindResult);
    final SCRAMClientFinalMessage clientFinalMessage = new SCRAMClientFinalMessage(bindRequest, clientFirstMessage, serverFirstMessage);
    final BindResult serverFinalBindResult = new BindResult(2, ResultCode.INVALID_CREDENTIALS, "This is the diagnostic message", null, null, null, new ASN1OctetString("e=invalid-proof,foo=bar,abc=123"));
    new SCRAMServerFinalMessage(bindRequest, clientFirstMessage, clientFinalMessage, serverFinalBindResult);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Aggregations

ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1173 Test (org.testng.annotations.Test)852 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)382 Control (com.unboundid.ldap.sdk.Control)310 ASN1Element (com.unboundid.asn1.ASN1Element)237 ArrayList (java.util.ArrayList)204 NotNull (com.unboundid.util.NotNull)191 LDAPException (com.unboundid.ldap.sdk.LDAPException)142 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)133 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)99 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)92 IOException (java.io.IOException)88 ASN1Integer (com.unboundid.asn1.ASN1Integer)80 ExtendedRequest (com.unboundid.ldap.sdk.ExtendedRequest)69 DN (com.unboundid.ldap.sdk.DN)65 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)64 ByteArrayInputStream (java.io.ByteArrayInputStream)56 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)53 ASN1Boolean (com.unboundid.asn1.ASN1Boolean)52 AuthorizationIdentityResponseControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityResponseControl)49