use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class StoreReference method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchResultReferenceDecorator> container) throws DecoderException {
SearchResultReference searchResultReference = container.getMessage();
// Get the Value and store it in the BindRequest
TLV tlv = container.getCurrentTLV();
// Get the referral, or create it if not existing
Referral referral = searchResultReference.getReferral();
if (referral == null) {
referral = new ReferralImpl();
searchResultReference.setReferral(referral);
}
// We have to handle the special case of a 0 length list of referrals
LdapUrl url = LdapUrl.EMPTY_URL;
if (tlv.getLength() == 0) {
referral.addLdapUrl("");
} else {
String urlStr = Strings.utf8ToString(tlv.getValue().getData());
try {
url = new LdapUrl(urlStr);
referral.addLdapUrl(urlStr);
} catch (LdapURLEncodingException luee) {
LOG.error(I18n.err(I18n.ERR_04021, urlStr, luee.getMessage()));
throw new DecoderException(I18n.err(I18n.ERR_04016, luee.getMessage()), luee);
}
}
if (IS_DEBUG) {
LOG.debug("Search reference URL found : {}", url);
}
// We can have an END transition
container.setGrammarEndAllowed(true);
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class BindResponseImplTest method testHashCodeWithTheWorks.
/**
* Tests for equal hashCode of two fully loaded identical BindResponse PDUs.
*/
@Test
public void testHashCodeWithTheWorks() 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(resp0.hashCode() == resp1.hashCode());
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class LdapResultImplTest method testNotEqualsDiffMatchedDn.
/**
* Tests for inequality when the matchedDn properties are not the same.
*/
@Test
public void testNotEqualsDiffMatchedDn() 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=apache,dc=org"));
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");
assertFalse("results with different matchedDn properties " + "should not be equal", r0.equals(r1));
assertFalse("results with different matchedDn properties " + "should not be equal", r1.equals(r0));
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class LdapResultImplTest method testEqualsCarbonCopy.
/**
* Tests two non default carbon copies for equality.
*/
@Test
public void testEqualsCarbonCopy() 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");
assertTrue("exact copy should be equal", r0.equals(r1));
assertTrue("exact copy should be equal", r1.equals(r0));
}
use of org.apache.directory.api.ldap.model.message.ReferralImpl in project directory-ldap-api by apache.
the class LdapResultImplTest method testNotEqualsDiffResultCode.
/**
* Tests for inequality when the resultCode properties are not the same.
*/
@Test
public void testNotEqualsDiffResultCode() 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.SIZE_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");
assertFalse("results with different result codes should not be equal", r0.equals(r1));
assertFalse("results with different result codes should not be equal", r1.equals(r0));
}
Aggregations