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