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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations