use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class InitAbandonRequest method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<AbandonRequestDecorator> container) throws DecoderException {
// Create the AbandonRequest LdapMessage instance and store it in the container
AbandonRequest internalAbandonRequest = new AbandonRequestImpl();
internalAbandonRequest.setMessageId(container.getMessageId());
AbandonRequestDecorator abandonRequest = new AbandonRequestDecorator(container.getLdapCodecService(), internalAbandonRequest);
container.setMessage(abandonRequest);
// The current TLV should be a integer
// We get it and store it in MessageId
TLV tlv = container.getCurrentTLV();
BerValue value = tlv.getValue();
if ((value == null) || (value.getData() == null)) {
String msg = I18n.err(I18n.ERR_04075);
LOG.error(msg);
// This will generate a PROTOCOL_ERROR
throw new DecoderException(msg);
}
try {
int abandonnedMessageId = IntegerDecoder.parse(value, 0, Integer.MAX_VALUE);
abandonRequest.setAbandoned(abandonnedMessageId);
if (IS_DEBUG) {
LOG.debug("AbandonMessage Id has been decoded : {}", Integer.valueOf(abandonnedMessageId));
}
container.setGrammarEndAllowed(true);
return;
} catch (IntegerDecoderException ide) {
LOG.error(I18n.err(I18n.ERR_04076, Strings.dumpBytes(value.getData()), ide.getMessage()));
// This will generate a PROTOCOL_ERROR
throw new DecoderException(ide.getMessage(), ide);
}
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class AddAddRequestAttributeType method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<AddRequestDecorator> container) throws DecoderException {
AddRequestDecorator addRequest = container.getMessage();
TLV tlv = container.getCurrentTLV();
// Store the type. It can't be null.
if (tlv.getLength() == 0) {
String msg = I18n.err(I18n.ERR_04086);
LOG.error(msg);
AddResponseImpl response = new AddResponseImpl(addRequest.getMessageId());
throw new ResponseCarryingException(msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, addRequest.getEntry().getDn(), null);
}
String type = Strings.utf8ToString(tlv.getValue().getData());
try {
addRequest.addAttributeType(type);
} catch (LdapException ne) {
String msg = I18n.err(I18n.ERR_04087);
LOG.error(msg);
AddResponseImpl response = new AddResponseImpl(addRequest.getMessageId());
throw new ResponseCarryingException(msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, addRequest.getEntry().getDn(), ne);
}
if (IS_DEBUG) {
LOG.debug("Adding type {}", type);
}
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class InitAddRequest method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<AddRequestDecorator> container) throws DecoderException {
// Now, we can allocate the AddRequest Object
int messageId = container.getMessageId();
AddRequest internalAddRequest = new AddRequestImpl();
internalAddRequest.setMessageId(messageId);
AddRequestDecorator addRequest = new AddRequestDecorator(container.getLdapCodecService(), internalAddRequest);
container.setMessage(addRequest);
// We will check that the request is not null
TLV tlv = container.getCurrentTLV();
if (tlv.getLength() == 0) {
String msg = I18n.err(I18n.ERR_04084);
LOG.error(msg);
// Will generate a PROTOCOL_ERROR
throw new DecoderException(msg);
}
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class StoreAddRequestEntryName method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<AddRequestDecorator> container) throws DecoderException {
AddRequestDecorator addRequest = container.getMessage();
TLV tlv = container.getCurrentTLV();
// Store the entry. It can't be null
if (tlv.getLength() == 0) {
String msg = I18n.err(I18n.ERR_04085);
LOG.error(msg);
AddResponseImpl response = new AddResponseImpl(addRequest.getMessageId());
// Not 100% sure though ...
throw new ResponseCarryingException(msg, response, ResultCodeEnum.NAMING_VIOLATION, Dn.EMPTY_DN, null);
} else {
Dn entryDn = null;
byte[] dnBytes = tlv.getValue().getData();
String dnStr = Strings.utf8ToString(dnBytes);
try {
entryDn = new Dn(dnStr);
} catch (LdapInvalidDnException ine) {
String msg = "Invalid Dn given : " + dnStr + " (" + Strings.dumpBytes(dnBytes) + ") is invalid";
LOG.error("{} : {}", msg, ine.getMessage());
AddResponseImpl response = new AddResponseImpl(addRequest.getMessageId());
throw new ResponseCarryingException(msg, response, ResultCodeEnum.INVALID_DN_SYNTAX, Dn.EMPTY_DN, ine);
}
addRequest.setEntryDn(entryDn);
}
LOG.debug("Adding an entry with Dn : {}", addRequest.getEntry());
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class InitBindRequest method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<BindRequestDecorator> container) throws DecoderException {
// Create the BindRequest LdapMessage instance and store it in the container
BindRequest internalBindRequest = new BindRequestImpl();
internalBindRequest.setMessageId(container.getMessageId());
BindRequestDecorator bindRequest = new BindRequestDecorator(container.getLdapCodecService(), internalBindRequest);
container.setMessage(bindRequest);
// We will check that the request is not null
TLV tlv = container.getCurrentTLV();
if (tlv.getLength() == 0) {
String msg = I18n.err(I18n.ERR_04077);
LOG.error(msg);
// This will generate a PROTOCOL_ERROR
throw new DecoderException(msg);
}
}
Aggregations