|
|
1.1 ! root 1: ! 2: ! 3: PurportedName ::= SEQUENCE OF String ! 4: -- simplication, as attribute types can optionally be ! 5: -- specified ! 6: ! 7: -- Each element of the Purported Name is a string ! 8: -- which has been parsed from the BNF ! 9: ! 10: Attribute ::= SEQUENCE { ! 11: type OBJECT IDENTIFIER, ! 12: value ANY } ! 13: ! 14: RDN ::= Attribute -- simplification, as can be multi-value ! 15: ! 16: DN ::= SEQUENCE OF RDN ! 17: ! 18: Environment ::= SEQUENCE OF DN ! 19: ! 20: ! 21: EnvironmentList ::= SEQUENCE OF SEQUENCE { ! 22: lower-bound INTEGER, ! 23: upper-bound INTEGER, ! 24: environment Environment } ! 25: ! 26: ! 27: friendlyMatch(p: PurportedName; el: EnvironmentList): SET OF DN ! 28: { ! 29: -- Find correct environment ! 30: ! 31: IF length(el) == 0 THEN return(NULL); ! 32: ! 33: IF length(p) <= head(el).upper-bound ! 34: && length(p) >= head(el).lower-bound THEN ! 35: return envMatch (p, head(el).environment); ! 36: ELSE ! 37: return(friendlyMatch(p, tail(el)); ! 38: } ! 39: ! 40: ! 41: envMatch(p: PurportedName; e: Environment): SET OF DN ! 42: { ! 43: -- Check elements of environment ! 44: -- in the defined order ! 45: ! 46: matches: SET OF DN; ! 47: ! 48: IF length(e) == 0 THEN return(NULL); ! 49: ! 50: matches = purportedMatch(head(el).DN, p) ! 51: IF matches != NULL THEN ! 52: return(matches); ! 53: ELSE ! 54: return(envMatch(p, tail(e)); ! 55: } ! 56: ! 57: ! 58: purportedMatch(base: DN; p: PurportedName): SET OF DN ! 59: { ! 60: s: String = head(p); ! 61: matches: SET OF DN = NULL; ! 62: ! 63: IF length(p) == 1 THEN ! 64: IF length(base) == 0 THEN ! 65: IF (matches = rootSearch(s)) != NULL THEN ! 66: return(matches); ! 67: ELSE return(leafSearch(base, s, FALSE); ! 68: ELSE IF length(base) == 1 THEN ! 69: IF (matches = intSearch(base, s)) != NULL THEN ! 70: return(matches); ! 71: ELSE return(leafSearch(base, s, FALSE); ! 72: ELSE ! 73: IF (matches = leafSearch(base, s, TRUE)) != NULL THEN ! 74: return(matches); ! 75: ELSE return(intsearch(base, s); ! 76: ! 77: ! 78: IF length(base) == 0 THEN ! 79: FOR x IN rootSearch(s) DO ! 80: matches += (purportedMatch(x, tail(p)); ! 81: ELSE ! 82: FOR x IN intSearch(base, s) DO ! 83: matches += (purportedMatch(x, tail(p)); ! 84: return(matches); ! 85: } ! 86: ! 87: ! 88: -- General. Might need to tighten the filter for short strings, ! 89: -- in order to stop being flooded. Alternatively, this could be ! 90: -- done if the loose search hists a size limit ! 91: ! 92: rootSearch(s: String): SET OF DN ! 93: { ! 94: IF length == 2 THEN ! 95: return(search(NULL, FALSE, s, {CountryName, ! 96: FriendlyCountryName, OrganizationName}, ! 97: {exact}, {Country, Organisation})); ! 98: ELSE ! 99: return(search(NULL, FALSE, s, {OrganizationName, ! 100: FriendlyCountryName}, {substring, approx}, ! 101: {Country, Organisation})); ! 102: } ! 103: ! 104: ! 105: intSearch( base: DN; s: String) ! 106: { ! 107: IF present(base, OrgUnitName) THEN ! 108: return(search(base, FALSE, s, {OrgUnitName}, ! 109: {substring, approx}, {OrgUnit})); ! 110: ELSE IF present(base, OrganisationName) THEN ! 111: return(search(base, FALSE, {OrgUnitName, ! 112: LocalityName}, {substring, approx}, ! 113: {Organization, OrgUnit, Locality})); ! 114: ELSE IF present(base, LocalityName) THEN ! 115: return(search(base, FALSE, s, {OrganisationName}, ! 116: {substring, approx}, {Locality}); ! 117: ELSE ! 118: return(search(base, false, s, {OrganisationName, ! 119: LocalityName}, {substring, approx}, ! 120: {Organisation, Locality})); ! 121: } ! 122: ! 123: ! 124: present(d: DN; t: AttributeType): BOOLEAN ! 125: { ! 126: FOR x IN d DO ! 127: IF x.type == t THEN return(TRUE); ! 128: return(FALSE); ! 129: } ! 130: ! 131: leafSearch(base: DN; s: String; subtree: BOOLEAN) ! 132: { ! 133: return(search(base, subtree, s, {CommonName, Surname, ! 134: UserId}, {substring, approx})); ! 135: } ! 136: ! 137: ! 138: search(base: DN; subtrees: BOOLEAN; s: string; ! 139: alist SET OF AttributeType; matchtypes SET OF MatchType ! 140: objectClasses SET OF ObjectClass OPTIONAL): SET OF DN ! 141: { ! 142: -- mapped onto Directory Search, with OR conjunction ! 143: -- of filter items ! 144: ! 145: return dNSelect (s, search-results, alist); ! 146: } ! 147: ! 148: read(base: DN; alist SET OF AttributeType): SET OF Attribute; ! 149: { ! 150: -- mapped onto Directory Read ! 151: -- Types repeated to deal with multiple values ! 152: -- This would be implemented by returning selected info ! 153: -- with the search operation ! 154: } ! 155: ! 156: dNSelect(s: String; dlist SET OF DN; alist: SET OF AttributeType): SET OF DN ! 157: { ! 158: exact, good: SET OF DN; ! 159: ! 160: FOR x IN dlist DO ! 161: IF last(DN).Value == s THEN ! 162: exact += x; ! 163: ELSE IF FOR y IN read(x, alist) DO ! 164: IF y.value == s THEN ! 165: good += x; ! 166: ! 167: ! 168: IF exact != NULL THEN return(exact); ! 169: IF good != NULL THEN return(good); ! 170: return(userQuery(dlist)); ! 171: } ! 172: ! 173: ! 174: userQuery(dlist SET OF DN): SET OF DN ! 175: { ! 176: -- pass back up for manual checking ! 177: -- user can strip all matches to force progres.... ! 178: } ! 179: ! 180: ! 181: head() -- return first element of list ! 182: tail() -- return list with first element removed ! 183: length() -- return size of list ! 184: last() -- return last element of list
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.