org.apache.directory.api.ldap.model.filter.NotNode Java Examples
The following examples show how to use
org.apache.directory.api.ldap.model.filter.NotNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchRequestTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test parsing of a request with an Or Filter */ @Test public void testRequestWithNotFilter() { Dsmlv2Parser parser = null; try { parser = newParser(); parser.setInput( SearchRequestTest.class.getResource( "filters/request_with_not.xml" ).openStream(), "UTF-8" ); parser.parse(); } catch ( Exception e ) { fail( e.getMessage() ); } SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest(); ExprNode filter = searchRequest.getFilter(); assertTrue( filter instanceof NotNode ); }
Example #2
Source File: UserGroupService.java From guacamole-client with Apache License 2.0 | 5 votes |
/** * Returns the base search filter which should be used to retrieve user * groups which do not represent Guacamole connections. As excluding the * guacConfigGroup object class may not work as expected if it is not * defined (may always return zero results), it should only be explicitly * excluded if it is expected to have been defined. * * @return * The base search filter which should be used to retrieve user groups. * * @throws GuacamoleException * If guacamole.properties cannot be parsed. */ private ExprNode getGroupSearchFilter() throws GuacamoleException { // Explicitly exclude guacConfigGroup object class only if it should // be assumed to be defined (query may fail due to no such object // class existing otherwise) if (confService.getConfigurationBaseDN() != null) return new NotNode(new EqualityNode("objectClass","guacConfigGroup")); // Read any object as a group if LDAP is not being used for connection // storage (guacConfigGroup) return new PresenceNode("objectClass"); }
Example #3
Source File: NormalizationInterceptor.java From syncope with Apache License 2.0 | 5 votes |
/** * Remove the (ObjectClass=*) node from a NotNode, if we have one. */ private ExprNode handleNotNode( ExprNode node ) { NotNode newNotNode = new NotNode(); for ( ExprNode child : ( ( BranchNode ) node ).getChildren() ) { ExprNode modifiedNode = removeObjectClass( child ); if ( modifiedNode instanceof ObjectClassNode ) { // We don't want any entry which has an ObjectClass, return an undefined node return UndefinedNode.UNDEFINED_NODE; } if ( modifiedNode instanceof UndefinedNode ) { // Here, we will select everything return ObjectClassNode.OBJECT_CLASS_NODE; } newNotNode.addNode( modifiedNode ); } return newNotNode; }
Example #4
Source File: UserGroupService.java From guacamole-client with Apache License 2.0 | 5 votes |
/** * Returns the base search filter which should be used to retrieve user * groups which do not represent Guacamole connections. As excluding the * guacConfigGroup object class may not work as expected if it is not * defined (may always return zero results), it should only be explicitly * excluded if it is expected to have been defined. * * @return * The base search filter which should be used to retrieve user groups. * * @throws GuacamoleException * If guacamole.properties cannot be parsed. */ private ExprNode getGroupSearchFilter() throws GuacamoleException { // Explicitly exclude guacConfigGroup object class only if it should // be assumed to be defined (query may fail due to no such object // class existing otherwise) if (confService.getConfigurationBaseDN() != null) return new NotNode(new EqualityNode("objectClass","guacConfigGroup")); // Read any object as a group if LDAP is not being used for connection // storage (guacConfigGroup) return new PresenceNode("objectClass"); }
Example #5
Source File: SearchRequestFactory.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Encode a Search Filter * * @param buffer The buffer where to put the PDU * @param node The top filter */ private void encodeFilter( Asn1Buffer buffer, ExprNode node ) { switch ( node.getClass().getSimpleName() ) { case "AndNode" : encodeFilter( buffer, ( AndNode ) node, ( byte ) LdapCodecConstants.AND_FILTER_TAG ); break; case "ApproximateNode" : encodeFilter( buffer, ( ApproximateNode<?> ) node, ( byte ) LdapCodecConstants.APPROX_MATCH_FILTER_TAG ); break; case "EqualityNode" : encodeFilter( buffer, ( EqualityNode<?> ) node, ( byte ) LdapCodecConstants.EQUALITY_MATCH_FILTER_TAG ); break; case "ExtensibleNode" : encodeFilter( buffer, ( ExtensibleNode ) node ); break; case "GreaterEqNode" : encodeFilter( buffer, ( GreaterEqNode<?> ) node, ( byte ) LdapCodecConstants.GREATER_OR_EQUAL_FILTER_TAG ); break; case "LessEqNode" : encodeFilter( buffer, ( LessEqNode<?> ) node, ( byte ) LdapCodecConstants.LESS_OR_EQUAL_FILTER_TAG ); break; case "NotNode" : encodeFilter( buffer, ( NotNode ) node, ( byte ) LdapCodecConstants.NOT_FILTER_TAG ); break; case "OrNode" : encodeFilter( buffer, ( OrNode ) node, ( byte ) LdapCodecConstants.OR_FILTER_TAG ); break; case "PresenceNode" : encodeFilter( buffer, ( PresenceNode ) node ); break; case "SubstringNode" : encodeFilter( buffer, ( SubstringNode ) node ); break; default: break; } }
Example #6
Source File: NormalizationInterceptor.java From syncope with Apache License 2.0 | 4 votes |
/** * Remove the (ObjectClass=*) and ( ObjectClass=top) nodes from the filter, if we have one. */ private ExprNode removeObjectClass( ExprNode node ) { if ( node instanceof LeafNode ) { LeafNode leafNode = ( LeafNode ) node; if ( leafNode.getAttributeType() == directoryService.getAtProvider().getObjectClass() ) { if ( leafNode instanceof PresenceNode ) { // We can safely remove the node and return an undefined node return ObjectClassNode.OBJECT_CLASS_NODE; } else if ( leafNode instanceof EqualityNode ) { Value value = ( ( EqualityNode<String> ) leafNode ).getValue(); if ( value.equals( SchemaConstants.TOP_OC ) ) { // Here too we can safely remove the node and return an undefined node return ObjectClassNode.OBJECT_CLASS_NODE; } } } } // -------------------------------------------------------------------- // H A N D L E B R A N C H N O D E S // -------------------------------------------------------------------- if ( node instanceof AndNode ) { return handleAndNode( node ); } else if ( node instanceof OrNode ) { return handleOrNode( node ); } else if ( node instanceof NotNode ) { return handleNotNode( node ); } else { // Failover : we return the initial node as is return node; } }