| | |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | |
| | | * Retrieves the processed search filter for this control. |
| | | * |
| | | * @return The processed search filter for this control. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while attempting to |
| | | * process the search filter. |
| | | */ |
| | | public SearchFilter getSearchFilter() |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSearchFilter"); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | if (! filter.matchesEntry(entry)) |
| | | { |
| | | setResultCode(ResultCode.ASSERTION_FAILED); |
| | |
| | | } |
| | | } |
| | | |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | if (! filter.matchesEntry(entry)) |
| | | { |
| | | setResultCode(ResultCode.ASSERTION_FAILED); |
| | |
| | | } |
| | | } |
| | | |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | if (! filter.matchesEntry(entry)) |
| | | { |
| | | setResultCode(ResultCode.ASSERTION_FAILED); |
| | |
| | | } |
| | | } |
| | | |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | if (! filter.matchesEntry(currentEntry)) |
| | | { |
| | | setResultCode(ResultCode.ASSERTION_FAILED); |
| | |
| | | } |
| | | } |
| | | |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | if (! filter.matchesEntry(currentEntry)) |
| | | { |
| | | setResultCode(ResultCode.ASSERTION_FAILED); |
| | |
| | | break searchProcessing; |
| | | } |
| | | |
| | | if (filter == null) |
| | | try |
| | | { |
| | | filter = rawFilter.toSearchFilter(); |
| | | if (filter == null) |
| | | { |
| | | filter = rawFilter.toSearchFilter(); |
| | | } |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | assert debugException(CLASS_NAME, "run", de); |
| | | |
| | | setResultCode(de.getResultCode()); |
| | | appendErrorMessage(de.getErrorMessage()); |
| | | setMatchedDN(de.getMatchedDN()); |
| | | setReferralURLs(de.getReferralURLs()); |
| | | |
| | | break searchProcessing; |
| | | } |
| | | |
| | | // Check to see if the client has permission to perform the |
| | |
| | | } |
| | | } |
| | | |
| | | SearchFilter assertionFilter = assertControl.getSearchFilter(); |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | |
| | | SearchFilter assertionFilter = assertControl.getSearchFilter(); |
| | | Entry entry; |
| | | try |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if an LDAP search filter |
| | | * references an unsupported matching rule. It takes a single argument, which |
| | | * is the unrecognized matching rule OID. |
| | | */ |
| | | public static final int MSGID_LDAP_FILTER_UNKNOWN_MATCHING_RULE = |
| | | CATEGORY_MASK_PROTOCOL | SEVERITY_MASK_MILD_ERROR | 385; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if an LDAP search filter |
| | | * has an assertion value without either an attribute type or a matching rule |
| | | * OID. This does not take any arguments. |
| | | */ |
| | | public static final int MSGID_LDAP_FILTER_VALUE_WITH_NO_ATTR_OR_MR = |
| | | CATEGORY_MASK_PROTOCOL | SEVERITY_MASK_MILD_ERROR | 386; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Associates a set of generic messages with the message IDs defined in this |
| | | * class. |
| | | */ |
| | |
| | | "Cannot decode the provided ASN.1 element as an LDAP " + |
| | | "search filter because a problem occurred while trying " + |
| | | "to parse the extensible match sequence elements: %s."); |
| | | registerMessage(MSGID_LDAP_FILTER_UNKNOWN_MATCHING_RULE, |
| | | "The provided LDAP search filter references unknown " + |
| | | "matching rule %s."); |
| | | registerMessage(MSGID_LDAP_FILTER_VALUE_WITH_NO_ATTR_OR_MR, |
| | | "The provided LDAP search filter has an assertion value " + |
| | | "but does not include either an attribute type or a " + |
| | | "matching rule ID."); |
| | | registerMessage(MSGID_LDAP_FILTER_STRING_NULL, |
| | | "Cannot decode the provided string as an LDAP search " + |
| | | "filter because the string was null."); |
| | |
| | | import java.util.List; |
| | | import java.util.StringTokenizer; |
| | | |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.asn1.ASN1Boolean; |
| | | import org.opends.server.protocols.asn1.ASN1Element; |
| | |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.DebugLogCategory; |
| | | import org.opends.server.types.DebugLogSeverity; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.FilterType; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | |
| | | * Directory Server's core processing. |
| | | * |
| | | * @return The generated search filter. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while attempting to |
| | | * construct the search filter. |
| | | */ |
| | | public SearchFilter toSearchFilter() |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "toSearchFilter"); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | AttributeValue value = new AttributeValue(attrType, assertionValue); |
| | | AttributeValue value; |
| | | if (assertionValue == null) |
| | | { |
| | | value = null; |
| | | } |
| | | else if (attrType == null) |
| | | { |
| | | if (matchingRuleID == null) |
| | | { |
| | | int msgID = MSGID_LDAP_FILTER_VALUE_WITH_NO_ATTR_OR_MR; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message, msgID); |
| | | } |
| | | else |
| | | { |
| | | MatchingRule mr = |
| | | DirectoryServer.getMatchingRule(toLowerCase(matchingRuleID)); |
| | | if (mr == null) |
| | | { |
| | | int msgID = MSGID_LDAP_FILTER_UNKNOWN_MATCHING_RULE; |
| | | String message = getMessage(msgID, matchingRuleID); |
| | | throw new DirectoryException(ResultCode.INAPPROPRIATE_MATCHING, |
| | | message, msgID); |
| | | } |
| | | else |
| | | { |
| | | ByteString normalizedValue = mr.normalizeValue(assertionValue); |
| | | value = new AttributeValue(assertionValue, normalizedValue); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | value = new AttributeValue(attrType, assertionValue); |
| | | } |
| | | |
| | | |
| | | ArrayList<ByteString> subAnyComps; |
| | | if (subAnyElements == null) |
| | |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | |
| | | |
| | |
| | | * Creates a new attribute value with the provided information. |
| | | * |
| | | * @param attributeType The attribute type for this attribute |
| | | * value. |
| | | * value. It must not be {@code null}. |
| | | * @param value The value in user-provided form for this |
| | | * attribute value. |
| | | * attribute value. It must not be |
| | | * {@code null}. |
| | | */ |
| | | public AttributeValue(AttributeType attributeType, ByteString value) |
| | | { |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(attributeType), |
| | | String.valueOf(value)); |
| | | |
| | | ensureNotNull(attributeType, value); |
| | | |
| | | this.attributeType = attributeType; |
| | | this.value = value; |
| | | |
| | |
| | | * Creates a new attribute value with the provided information. |
| | | * |
| | | * @param attributeType The attribute type for this attribute |
| | | * value. |
| | | * value. It must not be {@code null}. |
| | | * @param value The value in user-provided form for this |
| | | * attribute value. |
| | | * attribute value. It must not be |
| | | * {@code null}. |
| | | */ |
| | | public AttributeValue(AttributeType attributeType, String value) |
| | | { |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(attributeType), |
| | | String.valueOf(value)); |
| | | |
| | | ensureNotNull(attributeType, value); |
| | | |
| | | this.attributeType = attributeType; |
| | | this.value = new ASN1OctetString(value); |
| | | |
| | |
| | | * byte-for-byte comparison of normalized values. |
| | | * |
| | | * @param value The user-provided form of this value. |
| | | * @param normalizedValue The normalized form of this value. |
| | | * It must not be {@code null}. |
| | | * @param normalizedValue The normalized form of this value. It |
| | | * must not be {@code null}. |
| | | */ |
| | | public AttributeValue(ByteString value, ByteString normalizedValue) |
| | | { |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(value), |
| | | String.valueOf(normalizedValue)); |
| | | |
| | | ensureNotNull(value, normalizedValue); |
| | | |
| | | this.value = value; |
| | | this.normalizedValue = normalizedValue; |
| | | |
| | |
| | | assert debugEnter(CLASS_NAME, "toString", |
| | | "java.lang.StringBuilder"); |
| | | |
| | | value.toString(buffer); |
| | | buffer.append(value.toString()); |
| | | } |
| | | } |
| | | |
| | |
| | | LDAPFilter filter = LDAPFilter.decode( |
| | | "(&" + |
| | | "(cn>=*)" + |
| | | "(:1.2.3.4:=Bob)" + |
| | | "(:2.5.13.2:=Bob)" + |
| | | "(cn:=Jane)" + |
| | | "(|" + |
| | | "(sn<=gh*sh*sl)" + |
| | | "(!(cn:dn:2.4.6.8.19:=Sally))" + |
| | | "(!(cn:dn:2.5.13.5:=Sally))" + |
| | | "(cn~=blvd)" + |
| | | "(cn=*)" + |
| | | ")" + |
| | | "(cn=*n)" + |
| | | "(cn=n*)" + |
| | | "(cn=n*n)" + |
| | | "(:dn:=Sally)" + |
| | | "(:dn:1.2.3.4:=Doe)" + |
| | | "(cn:2.4.6.8.10:=)" + |
| | | "(:dn:1.3.6.1.4.1.1466.109.114.1:=Doe)" + |
| | | "(cn:2.5.13.2:=)" + |
| | | ")"); |
| | | |
| | | SearchFilter searchFilter = filter.toSearchFilter(); |
| | |
| | | |
| | | AttributeValue att1 = new AttributeValue(type, "string"); |
| | | AttributeValue att2 = new AttributeValue(type, "value"); |
| | | AttributeValue att3 = new AttributeValue(null, "again"); |
| | | AttributeValue att3 = new AttributeValue(type, "again"); |
| | | |
| | | ChangeNumber del1 = new ChangeNumber(1, (short) 0, (short) 1); |
| | | ChangeNumber del2 = new ChangeNumber(1, (short) 1, (short) 1); |
| | |
| | | ChangeNumber CNdelete) |
| | | throws Exception |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType("description"); |
| | | ValueInfo valInfo1 = new ValueInfo(value,CNupdate,CNdelete); |
| | | ValueInfo valInfo2 = new ValueInfo(value,CNupdate,CNupdate); |
| | | ValueInfo valInfo3 = new ValueInfo(new AttributeValue(null,"Test"), |
| | | ValueInfo valInfo3 = new ValueInfo(new AttributeValue(type,"Test"), |
| | | CNupdate,CNupdate); |
| | | |
| | | // Check equals |