use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class StoreSearchRequestDerefAlias method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
SearchRequest searchRequest = container.getMessage().getDecorated();
TLV tlv = container.getCurrentTLV();
// We have to check that this is a correct derefAliases
BerValue value = tlv.getValue();
int derefAliases = 0;
try {
derefAliases = IntegerDecoder.parse(value, LdapCodecConstants.NEVER_DEREF_ALIASES, LdapCodecConstants.DEREF_ALWAYS);
} catch (IntegerDecoderException ide) {
String msg = I18n.err(I18n.ERR_04102, value.toString());
LOG.error(msg);
throw new DecoderException(msg, ide);
}
searchRequest.setDerefAliases(AliasDerefMode.getDerefMode(derefAliases));
if (IS_DEBUG) {
switch(derefAliases) {
case LdapCodecConstants.NEVER_DEREF_ALIASES:
LOG.debug("Handling object strategy : NEVER_DEREF_ALIASES");
break;
case LdapCodecConstants.DEREF_IN_SEARCHING:
LOG.debug("Handling object strategy : DEREF_IN_SEARCHING");
break;
case LdapCodecConstants.DEREF_FINDING_BASE_OBJ:
LOG.debug("Handling object strategy : DEREF_FINDING_BASE_OBJ");
break;
case LdapCodecConstants.DEREF_ALWAYS:
LOG.debug("Handling object strategy : DEREF_ALWAYS");
break;
default:
LOG.debug("Handling object strategy : UNKNOWN");
}
}
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class StoreSaslMechanism method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<BindRequestDecorator> container) {
BindRequest bindRequestMessage = container.getMessage();
TLV tlv = container.getCurrentTLV();
// mechanism
if (tlv.getLength() == 0) {
bindRequestMessage.setSaslMechanism("");
} else {
bindRequestMessage.setSaslMechanism(Strings.utf8ToString(tlv.getValue().getData()));
}
// We can have an END transition
container.setGrammarEndAllowed(true);
if (IS_DEBUG) {
LOG.debug("The mechanism is : {}", bindRequestMessage.getSaslMechanism());
}
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class StoreSimpleAuth method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<BindRequestDecorator> container) throws DecoderException {
BindRequest bindRequestMessage = container.getMessage();
TLV tlv = container.getCurrentTLV();
// Allocate the Authentication Object
bindRequestMessage.setSimple(true);
// We have to handle the special case of a 0 length simple
if (tlv.getLength() == 0) {
bindRequestMessage.setCredentials(Strings.EMPTY_BYTES);
} else {
bindRequestMessage.setCredentials(tlv.getValue().getData());
}
// We can have an END transition
container.setGrammarEndAllowed(true);
if (IS_DEBUG) {
LOG.debug("The simple authentication is : {}", Strings.dumpBytes(bindRequestMessage.getCredentials()));
}
}
use of org.apache.directory.api.asn1.ber.tlv.TLV in project directory-ldap-api by apache.
the class StoreVersion method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<BindRequestDecorator> container) throws DecoderException {
BindRequest bindRequestMessage = container.getMessage();
// The current TLV should be a integer between 1 and 127
// We get it and store it in Version
TLV tlv = container.getCurrentTLV();
BerValue value = tlv.getValue();
try {
int version = IntegerDecoder.parse(value, 1, 127);
if (IS_DEBUG) {
LOG.debug("Ldap version ", Integer.valueOf(version));
}
bindRequestMessage.setVersion3(version == 3);
} catch (IntegerDecoderException ide) {
LOG.error(I18n.err(I18n.ERR_04078, 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 InitDelRequest method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<DeleteRequestDecorator> container) throws DecoderException {
// Create the DeleteRequest LdapMessage instance and store it in the container
DeleteRequest internaldelRequest = new DeleteRequestImpl();
internaldelRequest.setMessageId(container.getMessageId());
DeleteRequestDecorator delRequest = new DeleteRequestDecorator(container.getLdapCodecService(), internaldelRequest);
container.setMessage(delRequest);
// And store the Dn into it
// Get the Value and store it in the DelRequest
TLV tlv = container.getCurrentTLV();
// We have to handle the special case of a 0 length matched
// Dn
Dn entry;
if (tlv.getLength() == 0) {
// This will generate a PROTOCOL_ERROR
throw new DecoderException(I18n.err(I18n.ERR_04073));
} else {
byte[] dnBytes = tlv.getValue().getData();
String dnStr = Strings.utf8ToString(dnBytes);
try {
entry = new Dn(dnStr);
} catch (LdapInvalidDnException ine) {
String msg = I18n.err(I18n.ERR_04074, dnStr, Strings.dumpBytes(dnBytes), ine.getLocalizedMessage());
LOG.error(msg);
DeleteResponseImpl response = new DeleteResponseImpl(delRequest.getMessageId());
throw new ResponseCarryingException(msg, response, ResultCodeEnum.INVALID_DN_SYNTAX, Dn.EMPTY_DN, ine);
}
delRequest.setName(entry);
}
// We can have an END transition
container.setGrammarEndAllowed(true);
if (IS_DEBUG) {
LOG.debug("Deleting Dn {}", entry);
}
}
Aggregations