use of org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException in project directory-ldap-api by apache.
the class StoredProcedureRequestImpl method getParameterValueString.
/**
* Get a parameter value
*
* @param index The position of the parameter in the list of parameters
* @return The paremeter's value
*/
public Object getParameterValueString(int index) {
if (!"java".equals(language)) {
Object obj = parameters.get(index).getValue();
if (obj instanceof byte[]) {
String str = Strings.utf8ToString((byte[]) obj);
String type = (String) getParameterTypeString(index);
if ("int".equals(type)) {
try {
return IntegerDecoder.parse(new BerValue((byte[]) obj));
} catch (IntegerDecoderException e) {
throw new RuntimeException("Failed to decode INTEGER: " + Strings.dumpBytes((byte[]) obj), e);
}
} else {
return str;
}
}
}
return getJavaParameterValue(index);
}
use of org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException 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.IntegerDecoderException 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.IntegerDecoderException 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.IntegerDecoderException in project directory-ldap-api by apache.
the class StoreSearchRequestTimeLimit method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
SearchRequest searchRequest = container.getMessage().getDecorated();
TLV tlv = container.getCurrentTLV();
// The current TLV should be a integer
// We get it and store it in timeLimit
BerValue value = tlv.getValue();
int timeLimit = 0;
try {
timeLimit = IntegerDecoder.parse(value, 0, Integer.MAX_VALUE);
} catch (IntegerDecoderException ide) {
String msg = I18n.err(I18n.ERR_04104, value.toString());
LOG.error(msg);
throw new DecoderException(msg, ide);
}
searchRequest.setTimeLimit(timeLimit);
if (IS_DEBUG) {
LOG.debug("The timeLimit value is set to {} seconds", Integer.valueOf(timeLimit));
}
}
Aggregations