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