[ 
https://issues.apache.org/jira/browse/KNOX-3604?focusedWorklogId=1056364&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1056364
 ]

ASF GitHub Bot logged work on KNOX-3604:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Nov/26 03:51
            Start Date: 21/Nov/26 03:51
    Worklog Time Spent: 10m 
      Work Description: handavid commented on code in PR #1534:
URL: https://github.com/apache/knox/pull/1534#discussion_r4650388884


##########
gateway-server/src/main/java/org/apache/knox/gateway/services/ldap/backend/LdapProxyBackend.java:
##########
@@ -648,6 +657,46 @@ private static String 
resolvedMatchingRuleOid(SchemaManager schemaManager, Match
         return oid != null && 
schemaManager.getMatchingRuleRegistry().contains(oid) ? oid : null;
     }
 
+    /**
+     * Returns the remote attribute's equality matching rule OID when the 
bundled schema can resolve it.
+     * When the remote type declares no equality, or one the bundled schema 
does not know, this falls
+     * back to octetStringMatch rather than leaving the attribute without an 
equality rule: a strict
+     * schema cannot evaluate an equality filter against an attribute that has 
none, so without the
+     * fallback the imported attribute would register but be unusable in 
equality assertions. This
+     * mirrors the octet string syntax fallback, and matches the convention 
used for the bundled
+     * octet-string attribute types (e.g. objectGUID).
+     */
+    private String resolvedEqualityOid(SchemaManager schemaManager, 
AttributeType remoteType) {
+        final String resolved = resolvedMatchingRuleOid(schemaManager, 
remoteType.getEquality(), remoteType.getEqualityOid());
+        if (resolved != null) {
+            return resolved;
+        }
+        LOG.ldapRemoteAttributeEqualityFallback(getName(), 
remoteType.getName(), String.valueOf(remoteType.getEqualityOid()));
+        return OCTET_STRING_MATCH_OID;

Review Comment:
   yes. I've addressed this in 
[e44ac9f](https://github.com/apache/knox/pull/1534/commits/e44ac9f86a36618756baeee1fecb78dca4b883d8).
 The issue occurs if a remote attribute type has a syntax but not a equality or 
ordering. The previous code defaulted to octetStringMatch, but that is only for 
binary values. RemoteSchemaConverter would call `Entry.contains` for anything 
it thought was "human readable" which would cause a ClassCastException as it 
tried to coerce a `byte[]` into a `String`. This is fixed by only using the 
octetStringMatch when the syntax is octet string and using caseIgnoreMatch 
otherwise.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1056364)
    Time Spent: 1h  (was: 50m)

> Imported remote attribute types support range matches
> -----------------------------------------------------
>
>                 Key: KNOX-3604
>                 URL: https://issues.apache.org/jira/browse/KNOX-3604
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: LDAP
>    Affects Versions: 3.1.0
>            Reporter: David Han
>            Assignee: David Han
>            Priority: Major
>             Fix For: 3.1.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> LdapProxyBackends can be configured to import extra attributes from the 
> remote LDAP. These attribute types cannot be compared if the equality and 
> ordering oid of the attribute type is null. For example, importing the 
> "uSNChanged" attribute from Active Directory cannot be used in search filters 
> with >= or <= like "(uSNChanged>=37510)".
> Augment the imported attributes with some equality and ordering oid if they 
> are not provided by the remote schema.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to