Search in sources :

Example 1 with BindResponseImpl

use of org.apache.directory.api.ldap.model.message.BindResponseImpl in project directory-ldap-api by apache.

the class BindResponseImplTest method testHashCodeSameObj.

/**
 * Tests to make sure the same object has the same hashCode.
 */
@Test
public void testHashCodeSameObj() {
    BindResponseImpl resp = new BindResponseImpl(1);
    assertTrue(resp.hashCode() == resp.hashCode());
}
Also used : BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) Test(org.junit.Test)

Example 2 with BindResponseImpl

use of org.apache.directory.api.ldap.model.message.BindResponseImpl in project directory-ldap-api by apache.

the class BindResponseImplTest method testEqualsWithTheWorks.

/**
 * Tests for equality of two fully loaded identical BindResponse PDUs.
 */
@Test
public void testEqualsWithTheWorks() throws LdapException {
    LdapResultImpl r0 = new LdapResultImpl();
    LdapResultImpl r1 = new LdapResultImpl();
    r0.setDiagnosticMessage("blah blah blah");
    r1.setDiagnosticMessage("blah blah blah");
    r0.setMatchedDn(new Dn("dc=example,dc=com"));
    r1.setMatchedDn(new Dn("dc=example,dc=com"));
    r0.setResultCode(ResultCodeEnum.TIME_LIMIT_EXCEEDED);
    r1.setResultCode(ResultCodeEnum.TIME_LIMIT_EXCEEDED);
    Referral refs0 = new ReferralImpl();
    refs0.addLdapUrl("ldap://someserver.com");
    refs0.addLdapUrl("ldap://anotherserver.org");
    Referral refs1 = new ReferralImpl();
    refs1.addLdapUrl("ldap://someserver.com");
    refs1.addLdapUrl("ldap://anotherserver.org");
    BindResponseImpl resp0 = new BindResponseImpl(1);
    BindResponseImpl resp1 = new BindResponseImpl(1);
    resp0.setServerSaslCreds(PASSWORD);
    resp1.setServerSaslCreds(PASSWORD);
    assertTrue("loaded carbon copies should be equal", resp0.equals(resp1));
    assertTrue("loaded carbon copies should be equal", resp1.equals(resp0));
}
Also used : Referral(org.apache.directory.api.ldap.model.message.Referral) ReferralImpl(org.apache.directory.api.ldap.model.message.ReferralImpl) Dn(org.apache.directory.api.ldap.model.name.Dn) BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) LdapResultImpl(org.apache.directory.api.ldap.model.message.LdapResultImpl) Test(org.junit.Test)

Example 3 with BindResponseImpl

use of org.apache.directory.api.ldap.model.message.BindResponseImpl in project directory-ldap-api by apache.

the class BindResponseImplTest method testEqualsNewWithSameId.

/**
 * Tests to make sure newly created objects with same id are equal.
 */
@Test
public void testEqualsNewWithSameId() {
    BindResponseImpl resp0 = new BindResponseImpl(1);
    BindResponseImpl resp1 = new BindResponseImpl(1);
    assertTrue("default copy with same id should be equal", resp0.equals(resp1));
    assertTrue("default copy with same id should be equal", resp1.equals(resp0));
}
Also used : BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) Test(org.junit.Test)

Example 4 with BindResponseImpl

use of org.apache.directory.api.ldap.model.message.BindResponseImpl in project directory-ldap-api by apache.

the class InitBindResponse method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<BindResponseDecorator> container) {
    // Now, we can allocate the BindResponse Object
    BindResponseDecorator bindResponse = new BindResponseDecorator(container.getLdapCodecService(), new BindResponseImpl(container.getMessageId()));
    container.setMessage(bindResponse);
}
Also used : BindResponseDecorator(org.apache.directory.api.ldap.codec.decorators.BindResponseDecorator) BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl)

Example 5 with BindResponseImpl

use of org.apache.directory.api.ldap.model.message.BindResponseImpl in project directory-ldap-api by apache.

the class InitSaslBind method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<BindRequestDecorator> container) throws DecoderException {
    BindRequest bindRequestMessage = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // We will check that the sasl is not null
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04079);
        LOG.error(msg);
        BindResponseImpl response = new BindResponseImpl(bindRequestMessage.getMessageId());
        throw new ResponseCarryingException(msg, response, ResultCodeEnum.INVALID_CREDENTIALS, bindRequestMessage.getDn(), null);
    }
    bindRequestMessage.setSimple(false);
    if (IS_DEBUG) {
        LOG.debug("The SaslCredential has been created");
    }
}
Also used : ResponseCarryingException(org.apache.directory.api.ldap.codec.api.ResponseCarryingException) BindRequest(org.apache.directory.api.ldap.model.message.BindRequest) BindResponseImpl(org.apache.directory.api.ldap.model.message.BindResponseImpl) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Aggregations

BindResponseImpl (org.apache.directory.api.ldap.model.message.BindResponseImpl)12 Test (org.junit.Test)10 ResponseCarryingException (org.apache.directory.api.ldap.codec.api.ResponseCarryingException)3 ByteBuffer (java.nio.ByteBuffer)2 DecoderException (org.apache.directory.api.asn1.DecoderException)2 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)2 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)2 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)2 BindRequest (org.apache.directory.api.ldap.model.message.BindRequest)2 LdapResultImpl (org.apache.directory.api.ldap.model.message.LdapResultImpl)2 Message (org.apache.directory.api.ldap.model.message.Message)2 Referral (org.apache.directory.api.ldap.model.message.Referral)2 ReferralImpl (org.apache.directory.api.ldap.model.message.ReferralImpl)2 Dn (org.apache.directory.api.ldap.model.name.Dn)2 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)1 MessageDecorator (org.apache.directory.api.ldap.codec.api.MessageDecorator)1 BindRequestDecorator (org.apache.directory.api.ldap.codec.decorators.BindRequestDecorator)1 BindResponseDecorator (org.apache.directory.api.ldap.codec.decorators.BindResponseDecorator)1