use of org.apache.directory.api.ldap.model.message.ResultResponse in project directory-ldap-api by apache.
the class InitReferrals method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<MessageDecorator<? extends Message>> container) throws DecoderException {
TLV tlv = container.getCurrentTLV();
// If we hae a Referrals sequence, then it should not be empty
if (tlv.getLength() == 0) {
String msg = I18n.err(I18n.ERR_04011);
LOG.error(msg);
// This will generate a PROTOCOL_ERROR
throw new DecoderException(msg);
}
ResultResponse response = (ResultResponse) container.getMessage();
LdapResult ldapResult = response.getLdapResult();
Referral referral = new ReferralImpl();
ldapResult.setReferral(referral);
if (IS_DEBUG) {
LOG.debug("Initialising a referrals list");
}
}
use of org.apache.directory.api.ldap.model.message.ResultResponse in project directory-ldap-api by apache.
the class StoreErrorMessage method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<MessageDecorator<? extends Message>> container) throws DecoderException {
// Get the Value and store it in the BindResponse
TLV tlv = container.getCurrentTLV();
String errorMessage;
// message
if (tlv.getLength() == 0) {
errorMessage = "";
} else {
errorMessage = Strings.utf8ToString(tlv.getValue().getData());
}
ResultResponse response = (ResultResponse) container.getMessage();
LdapResult ldapResult = response.getLdapResult();
ldapResult.setDiagnosticMessage(errorMessage);
// We can have an END transition
container.setGrammarEndAllowed(true);
if (IS_DEBUG) {
LOG.debug("The error message is : " + errorMessage);
}
}
use of org.apache.directory.api.ldap.model.message.ResultResponse in project directory-ldap-api by apache.
the class StoreMatchedDN method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<MessageDecorator<? extends Message>> container) throws DecoderException {
// Get the Value and store it in the BindResponse
TLV tlv = container.getCurrentTLV();
Dn matchedDn;
ResultCodeEnum resultCode;
ResultResponse response = (ResultResponse) container.getMessage();
LdapResult ldapResult = response.getLdapResult();
resultCode = ldapResult.getResultCode();
// Dn
if (tlv.getLength() == 0) {
matchedDn = Dn.EMPTY_DN;
} else {
switch(resultCode) {
case NO_SUCH_OBJECT:
case ALIAS_PROBLEM:
case INVALID_DN_SYNTAX:
case ALIAS_DEREFERENCING_PROBLEM:
byte[] dnBytes = tlv.getValue().getData();
String dnStr = Strings.utf8ToString(dnBytes);
try {
matchedDn = new Dn(dnStr);
} catch (LdapInvalidDnException ine) {
// This is for the client side. We will never decode LdapResult on the server
String msg = I18n.err(I18n.ERR_04013, dnStr, Strings.dumpBytes(dnBytes), ine.getLocalizedMessage());
LOG.error(msg);
throw new DecoderException(I18n.err(I18n.ERR_04014, ine.getLocalizedMessage()), ine);
}
break;
default:
LOG.warn("The matched Dn should not be set when the result code is not one of NoSuchObject," + " AliasProblem, InvalidDNSyntax or AliasDreferencingProblem");
matchedDn = Dn.EMPTY_DN;
break;
}
}
if (IS_DEBUG) {
LOG.debug("The matchedDn is " + matchedDn);
}
ldapResult.setMatchedDn(matchedDn);
}
use of org.apache.directory.api.ldap.model.message.ResultResponse in project directory-ldap-api by apache.
the class AbstractPasswordPolicyResponder method process.
/**
* {@inheritDoc}
*/
@Override
public final PasswordWarning process(PasswordPolicyOperation operation) throws PasswordException {
try {
ResultResponse response = operation.process();
PasswordPolicy passwordPolicy = getPasswordPolicy(response);
ResultCodeEnum resultCode = response.getLdapResult().getResultCode();
if (resultCode == ResultCodeEnum.SUCCESS) {
return success(passwordPolicy);
} else {
throw fail(response, passwordPolicy, resultCode);
}
} catch (LdapException e) {
throw new PasswordException().setLdapException(e);
}
}
use of org.apache.directory.api.ldap.model.message.ResultResponse in project directory-ldap-api by apache.
the class StoreResultCode method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<MessageDecorator<? extends Message>> container) throws DecoderException {
// The current TLV should be a integer
// We get it and store it in MessageId
TLV tlv = container.getCurrentTLV();
BerValue value = tlv.getValue();
ResultCodeEnum resultCode = ResultCodeEnum.SUCCESS;
try {
resultCode = ResultCodeEnum.getResultCode(IntegerDecoder.parse(value, 0, ResultCodeEnum.E_SYNC_REFRESH_REQUIRED.getResultCode()));
} catch (IntegerDecoderException ide) {
LOG.error(I18n.err(I18n.ERR_04018, Strings.dumpBytes(value.getData()), ide.getMessage()));
throw new DecoderException(ide.getMessage(), ide);
}
if (IS_DEBUG) {
LOG.debug("The result code is set to " + resultCode);
}
ResultResponse response = (ResultResponse) container.getMessage();
LdapResult ldapResult = response.getLdapResult();
ldapResult.setResultCode(resultCode);
}
Aggregations