You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2016/05/31 16:34:58 UTC
svn commit: r1746301 - in /directory/shared/branches/shared-value:
dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/
ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/
ldap/codec/core/src/main/java...
Author: elecharny
Date: Tue May 31 16:34:58 2016
New Revision: 1746301
URL: http://svn.apache.org/viewvc?rev=1746301&view=rev
Log:
o Don't allow <= or >= Filters when we don't have an ORDERING matching rule defined for the AttributeType
Modified:
directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java
directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/SearchRequestDsml.java
directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java
directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java
directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/GreaterEqNode.java
directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LessEqNode.java
directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterNodeEqualityTest.java
Modified: directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java?rev=1746301&r1=1746300&r2=1746301&view=diff
==============================================================================
--- directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java (original)
+++ directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java Tue May 31 16:34:58 2016
@@ -47,6 +47,8 @@ import org.apache.directory.api.ldap.cod
import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
+import org.apache.directory.api.ldap.model.filter.ExprNode;
import org.apache.directory.api.ldap.model.message.AbandonRequestImpl;
import org.apache.directory.api.ldap.model.message.AddRequestImpl;
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
@@ -2812,12 +2814,21 @@ public final class Dsmlv2Grammar extends
container.getBatchRequest().getCurrentRequest();
SearchRequest searchRequest = searchRequestDecorator.getDecorated();
- if ( searchRequestDecorator.getFilterNode() == null )
+ try
{
- throw new IllegalStateException( "No filter element present in the DSML search request" );
+ ExprNode exprNode = searchRequestDecorator.getFilterNode();
+
+ if ( exprNode == null )
+ {
+ throw new IllegalStateException( "No filter element present in the DSML search request" );
+ }
+
+ searchRequest.setFilter( exprNode );
+ }
+ catch ( LdapSchemaException lse )
+ {
+
}
-
- searchRequest.setFilter( searchRequestDecorator.getFilterNode() );
}
};
Modified: directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/SearchRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/SearchRequestDsml.java?rev=1746301&r1=1746300&r2=1746301&view=diff
==============================================================================
--- directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/SearchRequestDsml.java (original)
+++ directory/shared/branches/shared-value/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/SearchRequestDsml.java Tue May 31 16:34:58 2016
@@ -29,6 +29,7 @@ import org.apache.directory.api.ldap.cod
import org.apache.directory.api.ldap.codec.api.LdapCodecConstants;
import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
import org.apache.directory.api.ldap.model.filter.AndNode;
import org.apache.directory.api.ldap.model.filter.ApproximateNode;
import org.apache.directory.api.ldap.model.filter.BranchNode;
@@ -117,7 +118,7 @@ public class SearchRequestDsml
*
* @return the expression node for the root of the filter expression tree.
*/
- public ExprNode getFilterNode()
+ public ExprNode getFilterNode() throws LdapSchemaException
{
return transform( topFilter );
}
@@ -197,7 +198,7 @@ public class SearchRequestDsml
* @return An ExprNode
*/
@SuppressWarnings({ "rawtypes" })
- private ExprNode transform( Filter filter )
+ private ExprNode transform( Filter filter ) throws LdapSchemaException
{
if ( filter != null )
{
Modified: directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java?rev=1746301&r1=1746300&r2=1746301&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java (original)
+++ directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java Tue May 31 16:34:58 2016
@@ -24,6 +24,7 @@ import org.apache.directory.api.asn1.Dec
import org.apache.directory.api.asn1.ber.grammar.GrammarAction;
import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator;
+import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
import org.apache.directory.api.ldap.model.message.SearchRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,7 +70,14 @@ public class InitSearchRequestAttributeD
SearchRequestDecorator searchRequestDecorator = container.getMessage();
SearchRequest searchRequest = searchRequestDecorator.getDecorated();
- searchRequest.setFilter( searchRequestDecorator.getFilterNode() );
+ try
+ {
+ searchRequest.setFilter( searchRequestDecorator.getFilterNode() );
+ }
+ catch ( LdapSchemaException lse )
+ {
+ throw new DecoderException( lse.getMessage(), lse );
+ }
// We can have an END transition
container.setGrammarEndAllowed( true );
Modified: directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java?rev=1746301&r1=1746300&r2=1746301&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java (original)
+++ directory/shared/branches/shared-value/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java Tue May 31 16:34:58 2016
@@ -48,6 +48,7 @@ import org.apache.directory.api.ldap.cod
import org.apache.directory.api.ldap.codec.search.SubstringFilter;
import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
import org.apache.directory.api.ldap.model.filter.AndNode;
import org.apache.directory.api.ldap.model.filter.ApproximateNode;
import org.apache.directory.api.ldap.model.filter.BranchNode;
@@ -147,7 +148,7 @@ public class SearchRequestDecorator exte
*
* @return the expression node for the root of the filter expression tree.
*/
- public ExprNode getFilterNode()
+ public ExprNode getFilterNode() throws LdapSchemaException
{
return transform( topFilter );
}
@@ -320,7 +321,7 @@ public class SearchRequestDecorator exte
*/
@SuppressWarnings(
{ "unchecked", "rawtypes" })
- private ExprNode transform( Filter filter )
+ private ExprNode transform( Filter filter ) throws LdapSchemaException
{
if ( filter != null )
{
Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/GreaterEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/GreaterEqNode.java?rev=1746301&r1=1746300&r2=1746301&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/GreaterEqNode.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/GreaterEqNode.java Tue May 31 16:34:58 2016
@@ -21,6 +21,7 @@ package org.apache.directory.api.ldap.mo
import org.apache.directory.api.ldap.model.entry.Value;
+import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
import org.apache.directory.api.ldap.model.schema.AttributeType;
@@ -36,10 +37,17 @@ public class GreaterEqNode<T> extends Si
*
* @param attributeType the attributeType
* @param value the value to test for
+ * @throws LdapSchemaException If the AttributeType does not have an ORDERING MatchingRule
*/
- public GreaterEqNode( AttributeType attributeType, Value value )
+ public GreaterEqNode( AttributeType attributeType, Value value ) throws LdapSchemaException
{
super( attributeType, value, AssertionType.GREATEREQ );
+
+ // Check if the AttributeType has an Ordering MR
+ if ( ( attributeType != null ) && ( attributeType.getOrdering() == null ) )
+ {
+ throw new LdapSchemaException( "There is no ORDERING matchingRule for AttributeType " + attributeType.getName() );
+ }
}
@@ -48,10 +56,17 @@ public class GreaterEqNode<T> extends Si
*
* @param attribute the attribute name
* @param value the value to test for
+ * @throws LdapSchemaException If the AttributeType does not have an ORDERING MatchingRule
*/
- public GreaterEqNode( String attribute, String value )
+ public GreaterEqNode( String attribute, String value ) throws LdapSchemaException
{
super( attribute, value, AssertionType.GREATEREQ );
+
+ // Check if the AttributeType has an Ordering MR
+ if ( ( attributeType != null ) && ( attributeType.getOrdering() == null ) )
+ {
+ throw new LdapSchemaException( "There is no ORDERING matchingRule for AttributeType " + attributeType.getName() );
+ }
}
@@ -60,10 +75,17 @@ public class GreaterEqNode<T> extends Si
*
* @param attribute the attribute name
* @param value the value to test for
+ * @throws LdapSchemaException If the AttributeType does not have an ORDERING MatchingRule
*/
- public GreaterEqNode( String attribute, byte[] value )
+ public GreaterEqNode( String attribute, byte[] value ) throws LdapSchemaException
{
super( attribute, value, AssertionType.GREATEREQ );
+
+ // Check if the AttributeType has an Ordering MR
+ if ( ( attributeType != null ) && ( attributeType.getOrdering() == null ) )
+ {
+ throw new LdapSchemaException( "There is no ORDERING matchingRule for AttributeType " + attributeType.getName() );
+ }
}
Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LessEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LessEqNode.java?rev=1746301&r1=1746300&r2=1746301&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LessEqNode.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/LessEqNode.java Tue May 31 16:34:58 2016
@@ -21,6 +21,7 @@ package org.apache.directory.api.ldap.mo
import org.apache.directory.api.ldap.model.entry.Value;
+import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
import org.apache.directory.api.ldap.model.schema.AttributeType;
@@ -36,10 +37,17 @@ public class LessEqNode<T> extends Simpl
*
* @param attributeType the attributeType
* @param value the value to test for
+ * @throws LdapSchemaException If the AttributeType does not have an ORDERING MatchingRule
*/
- public LessEqNode( AttributeType attributeType, Value value )
+ public LessEqNode( AttributeType attributeType, Value value ) throws LdapSchemaException
{
super( attributeType, value, AssertionType.LESSEQ );
+
+ // Check if the AttributeType has an Ordering MR
+ if ( ( attributeType != null ) && ( attributeType.getOrdering() == null ) )
+ {
+ throw new LdapSchemaException( "There is no ORDERING matchingRule for AttributeType " + attributeType.getName() );
+ }
}
@@ -48,10 +56,17 @@ public class LessEqNode<T> extends Simpl
*
* @param attribute the attribute name
* @param value the value to test for
+ * @throws LdapSchemaException If the AttributeType does not have an ORDERING MatchingRule
*/
- public LessEqNode( String attribute, byte[] value )
+ public LessEqNode( String attribute, byte[] value ) throws LdapSchemaException
{
super( attribute, value, AssertionType.LESSEQ );
+
+ // Check if the AttributeType has an Ordering MR
+ if ( ( attributeType != null ) && ( attributeType.getOrdering() == null ) )
+ {
+ throw new LdapSchemaException( "There is no ORDERING matchingRule for AttributeType " + attributeType.getName() );
+ }
}
@@ -60,10 +75,17 @@ public class LessEqNode<T> extends Simpl
*
* @param attribute the attribute name
* @param value the value to test for
+ * @throws LdapSchemaException If the AttributeType does not have an ORDERING MatchingRule
*/
- public LessEqNode( String attribute, String value )
+ public LessEqNode( String attribute, String value ) throws LdapSchemaException
{
super( attribute, value, AssertionType.LESSEQ );
+
+ // Check if the AttributeType has an Ordering MR
+ if ( ( attributeType != null ) && ( attributeType.getOrdering() == null ) )
+ {
+ throw new LdapSchemaException( "There is no ORDERING matchingRule for AttributeType " + attributeType.getName() );
+ }
}
Modified: directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterNodeEqualityTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterNodeEqualityTest.java?rev=1746301&r1=1746300&r2=1746301&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterNodeEqualityTest.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterNodeEqualityTest.java Tue May 31 16:34:58 2016
@@ -23,7 +23,7 @@ package org.apache.directory.api.ldap.mo
import com.mycila.junit.concurrent.Concurrency;
import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-import org.apache.directory.api.ldap.model.entry.Value;
+import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,7 +41,7 @@ import static org.junit.Assert.assertFal
public class FilterNodeEqualityTest
{
@Test
- public void testEqualityEquals()
+ public void testEqualityEquals() throws LdapSchemaException
{
EqualityNode<String> eqNode1 = new EqualityNode<String>( "attr1", "test" );
EqualityNode<String> eqNode2 = new EqualityNode<String>( "attr1", "test" );
@@ -65,7 +65,7 @@ public class FilterNodeEqualityTest
@Test
- public void testGreaterEqEquals()
+ public void testGreaterEqEquals() throws LdapSchemaException
{
GreaterEqNode<String> greaterEqNode1 = new GreaterEqNode<String>( "attr1", "test" );
GreaterEqNode<String> greaterEqNode2 = new GreaterEqNode<String>( "attr1", "test" );
@@ -82,7 +82,7 @@ public class FilterNodeEqualityTest
@Test
- public void testLessEqEquals()
+ public void testLessEqEquals() throws LdapSchemaException
{
LessEqNode<String> lessEqNode1 = new LessEqNode<String>( "attr1", "test" );
LessEqNode<String> lessEqNode2 = new LessEqNode<String>( "attr1", "test" );