use of org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException in project directory-ldap-api by apache.
the class StoreModifyDnRequestDeleteOldRdn method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<ModifyDnRequestDecorator> container) throws DecoderException {
ModifyDnRequest modifyDnRequest = container.getMessage();
TLV tlv = container.getCurrentTLV();
// We get the value. If it's a 0, it's a FALSE. If it's
// a FF, it's a TRUE. Any other value should be an error,
// but we could relax this constraint. So if we have
// something
// which is not 0, it will be interpreted as TRUE, but we
// will generate a warning.
BerValue value = tlv.getValue();
try {
modifyDnRequest.setDeleteOldRdn(BooleanDecoder.parse(value));
} catch (BooleanDecoderException bde) {
LOG.error(I18n.err(I18n.ERR_04091, Strings.dumpBytes(value.getData()), bde.getMessage()));
// This will generate a PROTOCOL_ERROR
throw new DecoderException(bde.getMessage(), bde);
}
// We can have an END transition
container.setGrammarEndAllowed(true);
if (IS_DEBUG) {
if (modifyDnRequest.getDeleteOldRdn()) {
LOG.debug(" Old Rdn attributes will be deleted");
} else {
LOG.debug(" Old Rdn attributes will be retained");
}
}
}
use of org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException in project directory-ldap-api by apache.
the class StoreSearchRequestTypesOnly method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
SearchRequest searchRequest = container.getMessage().getDecorated();
TLV tlv = container.getCurrentTLV();
// We get the value. If it's a 0, it's a FALSE. If it's
// a FF, it's a TRUE. Any other value should be an error,
// but we could relax this constraint. So if we have
// something
// which is not 0, it will be interpreted as TRUE, but we
// will generate a warning.
BerValue value = tlv.getValue();
try {
searchRequest.setTypesOnly(BooleanDecoder.parse(value));
} catch (BooleanDecoderException bde) {
LOG.error(I18n.err(I18n.ERR_04105, Strings.dumpBytes(value.getData()), bde.getMessage()));
throw new DecoderException(bde.getMessage(), bde);
}
if (IS_DEBUG) {
LOG.debug("The search will return {}", searchRequest.getTypesOnly() ? "only attributs type" : "attributes types and values");
}
}
use of org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException in project directory-ldap-api by apache.
the class StoreControlCriticality method action.
/**
* {@inheritDoc}
*/
public void action(ControlsContainer container) throws DecoderException {
TLV tlv = container.getCurrentTLV();
// Get the current control
Control control = container.getCurrentControl();
// Store the criticality
// We get the value. If it's a 0, it's a FALSE. If it's
// a FF, it's a TRUE. Any other value should be an error,
// but we could relax this constraint. So if we have
// something
// which is not 0, it will be interpreted as TRUE, but we
// will generate a warning.
BerValue value = tlv.getValue();
try {
control.setCritical(BooleanDecoder.parse(value));
} catch (BooleanDecoderException bde) {
LOG.error(I18n.err(I18n.ERR_04100_BAD_CONTROL_CRITICALITY, Strings.dumpBytes(value.getData()), bde.getMessage()));
// This will generate a PROTOCOL_ERROR
throw new DecoderException(bde.getMessage(), bde);
}
// We can have an END transition
container.setGrammarEndAllowed(true);
if (IS_DEBUG) {
LOG.debug("Control criticality : {}", control.isCritical());
}
}
use of org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException in project directory-ldap-api by apache.
the class StoreMatchingRuleDnAttributes method action.
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
SearchRequestDecorator searchRequest = container.getMessage();
TLV tlv = container.getCurrentTLV();
// Store the value.
ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter) searchRequest.getTerminalFilter();
// We get the value. If it's a 0, it's a FALSE. If it's
// a FF, it's a TRUE. Any other value should be an error,
// but we could relax this constraint. So if we have
// something
// which is not 0, it will be interpreted as TRUE, but we
// will generate a warning.
BerValue value = tlv.getValue();
try {
extensibleMatchFilter.setDnAttributes(BooleanDecoder.parse(value));
} catch (BooleanDecoderException bde) {
LOG.error(I18n.err(I18n.ERR_04110, Strings.dumpBytes(value.getData()), bde.getMessage()));
throw new DecoderException(bde.getMessage(), bde);
}
if (IS_DEBUG) {
LOG.debug("Dn Attributes : {}", Boolean.valueOf(extensibleMatchFilter.isDnAttributes()));
}
// unstack the filters if needed
searchRequest.unstackFilters(container);
}
use of org.apache.directory.api.asn1.ber.tlv.BooleanDecoderException in project directory-ldap-api by apache.
the class StoreControlCriticality method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<MessageDecorator<? extends Message>> container) throws DecoderException {
TLV tlv = container.getCurrentTLV();
// Get the current control
MessageDecorator<? extends Message> message = container.getMessage();
Control control = message.getCurrentControl();
// Store the criticality
// We get the value. If it's a 0, it's a FALSE. If it's
// a FF, it's a TRUE. Any other value should be an error,
// but we could relax this constraint. So if we have
// something
// which is not 0, it will be interpreted as TRUE, but we
// will generate a warning.
BerValue value = tlv.getValue();
try {
control.setCritical(BooleanDecoder.parse(value));
} catch (BooleanDecoderException bde) {
LOG.error(I18n.err(I18n.ERR_04100_BAD_CONTROL_CRITICALITY, Strings.dumpBytes(value.getData()), bde.getMessage()));
// This will generate a PROTOCOL_ERROR
throw new DecoderException(bde.getMessage(), bde);
}
// We can have an END transition
container.setGrammarEndAllowed(true);
if (IS_DEBUG) {
LOG.debug("Control criticality : {}", control.isCritical());
}
}
Aggregations