Search in sources :

Example 96 with ASN1OctetString

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

the class SCRAMServerFinalMessageTestCase method testSCRAMSHA1NonSuccessfulBindWithErrorCredentials.

/**
 * Tests the behavior when creating a server final message for a
 * SCRAM-SHA-1 bind request with a non-successful bind that has some other
 * unexpected type of credentials.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPBindException.class })
public void testSCRAMSHA1NonSuccessfulBindWithErrorCredentials() 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, new ASN1OctetString("some unexpected form of credentials"));
    new SCRAMServerFinalMessage(bindRequest, clientFirstMessage, clientFinalMessage, serverFinalBindResult);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 97 with ASN1OctetString

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

the class SCRAMServerFirstMessageTestCase method testCredentialsNoSalt.

/**
 * Tests the behavior when trying to create a server first message from a bind
 * response with a message that does not include a salt.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPBindException.class })
public void testCredentialsNoSalt() throws Exception {
    final SCRAMSHA256BindRequest bindRequest = new SCRAMSHA256BindRequest("user", "pencil");
    final SCRAMClientFirstMessage clientFirstMessage = new SCRAMClientFirstMessage(bindRequest, "rOprNGfwEbeRWgbNEkqO");
    final String serverFirstMessageString = "r=rOprNGfwEbeRWgbNEkqO%hvYDpWUa2RaTCAfuxFIlj)hNlF$k0,i=4096";
    final BindResult serverFirstBindResult = new BindResult(1, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFirstMessageString));
    new SCRAMServerFirstMessage(bindRequest, clientFirstMessage, serverFirstBindResult);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 98 with ASN1OctetString

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

the class SCRAMServerFirstMessageTestCase method testCredentialsDoesNotStartWithNonce.

/**
 * Tests the behavior when trying to create a server first message from a bind
 * response with a message that does not start with a nonce.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPBindException.class })
public void testCredentialsDoesNotStartWithNonce() throws Exception {
    final SCRAMSHA256BindRequest bindRequest = new SCRAMSHA256BindRequest("user", "pencil");
    final SCRAMClientFirstMessage clientFirstMessage = new SCRAMClientFirstMessage(bindRequest, "rOprNGfwEbeRWgbNEkqO");
    final String serverFirstMessageString = "s=W22ZaJ0SNY7soEsUEjb6gQ==,i=4096";
    final BindResult serverFirstBindResult = new BindResult(1, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFirstMessageString));
    new SCRAMServerFirstMessage(bindRequest, clientFirstMessage, serverFirstBindResult);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 99 with ASN1OctetString

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

the class SCRAMServerFirstMessageTestCase method testCredentialsSaltNotBase64.

/**
 * Tests the behavior when trying to create a server first message from a bind
 * response with a message whose salt is not valid base 64.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPBindException.class })
public void testCredentialsSaltNotBase64() 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=not~valid~base64,i=4096";
    final BindResult serverFirstBindResult = new BindResult(1, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(serverFirstMessageString));
    new SCRAMServerFirstMessage(bindRequest, clientFirstMessage, serverFirstBindResult);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 100 with ASN1OctetString

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

the class TestSASLBindRequestTestCase method testBindRequestWithCredentials.

/**
 * Tests a bind request with credentials.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testBindRequestWithCredentials() throws Exception {
    TestSASLBindRequest bindRequest = new TestSASLBindRequest(new ASN1OctetString("saslCredentials"), new Control("1.2.3.4"), new Control("1.2.3.5", false, new ASN1OctetString("controlValue")));
    bindRequest = bindRequest.duplicate();
    assertNotNull(bindRequest.getSASLMechanismName());
    assertEquals(bindRequest.getSASLMechanismName(), "TEST");
    assertNotNull(bindRequest.toString());
    final ArrayList<String> toCodeLines = new ArrayList<String>(10);
    bindRequest.toCode(toCodeLines, "foo", 0, false);
    assertFalse(toCodeLines.isEmpty());
    toCodeLines.clear();
    bindRequest.toCode(toCodeLines, "bar", 4, true);
    assertFalse(toCodeLines.isEmpty());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ArrayList(java.util.ArrayList) 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