DIRECTORY Arpa USING [MyAddress], BasicTime USING [earliestGMT, GMT, Now, Period, TimeNotKnown], RefText USING [New], Rope USING [ROPE], SunRPCAuth USING [AuthenticateProc, Conversation, Error, Flavor, InitiateProc, nullFlavor, OpaqueValue, Register, shortFlavor, SweepProc] ; SunRPCAuthShortImpl: CEDAR MONITOR IMPORTS Arpa, BasicTime, RefText, SunRPCAuth EXPORTS SunRPCAuth ~ { ROPE: TYPE ~ Rope.ROPE; Flavor: TYPE ~ SunRPCAuth.Flavor; shortFlavor: Flavor ~ SunRPCAuth.shortFlavor; nullFlavor: Flavor ~ SunRPCAuth.nullFlavor; OpaqueValue: TYPE ~ SunRPCAuth.OpaqueValue; nullOpaqueValue: OpaqueValue ¬ RefText.New[0]; ClientConversation: TYPE ~ SunRPCAuth.Conversation; ServerConversation: TYPE ~ SunRPCAuth.Conversation; myHostId: CARD ¬ LOOPHOLE[Arpa.MyAddress[]]; tableSize: CARDINAL ~ 31; initialTtl: CARDINAL ¬ 120; Headers: TYPE ~ REF HeadersObject; HeadersObject: TYPE ~ ARRAY [0 .. tableSize) OF Handle; headers: Headers ¬ NEW[HeadersObject]; Handle: TYPE ~ REF Object; Object: TYPE ~ RECORD [ next: Handle, keyValue: KeyValue, ttl: CARDINAL ¬ initialTtl, c: ServerConversation ]; Key: TYPE ~ REF KeyObject; KeyObject: TYPE ~ RECORD [ dummy1, dummy2: CARDINAL, value: KeyValue ]; KeyValue: TYPE ~ RECORD [ hostId: CARD32, timestamp: CARD32 ]; Insert: ENTRY PROC [hdrs: Headers, h: Handle] ~ { i: CARDINAL ~ h.keyValue.timestamp MOD tableSize; h.next ¬ hdrs[i]; hdrs[i] ¬ h; }; Lookup: ENTRY PROC [hdrs: Headers, k: Key] RETURNS [h: Handle] ~ { i: CARDINAL ~ k.value.timestamp MOD tableSize; FOR h ¬ hdrs[i], h.next WHILE h # NIL DO IF h.keyValue = k.value THEN RETURN; ENDLOOP; }; Delete: ENTRY PROC [hdrs: Headers, k: Key] ~ { i: CARDINAL ~ k.value.timestamp MOD tableSize; prev, p: Handle; p ¬ hdrs[i]; DO IF p = NIL THEN RETURN; IF p.keyValue = k.value THEN EXIT; prev ¬ p; p ¬ p.next; ENDLOOP; IF prev = NIL THEN hdrs[i] ¬ p.next ELSE prev.next ¬ p.next; }; Sweep: SunRPCAuth.SweepProc ~ { FOR i: CARDINAL IN [0 .. tableSize) DO SweepInner[NARROW[registrationData], i, secondsSinceLastSweep]; ENDLOOP; }; SweepInner: ENTRY PROC [hdrs: Headers, i: CARDINAL, secs: CARD] ~ { prev, p: Handle; prev ¬ NIL; p ¬ hdrs[i]; WHILE p # NIL DO IF p.ttl > secs THEN { p.ttl ¬ p.ttl - secs; prev ¬ p; p ¬ p.next; } ELSE { IF prev = NIL THEN hdrs[i] ¬ p.next ELSE prev.next ¬ p.next; p ¬ p.next; }; ENDLOOP; }; lastTimestamp: CARD32 ¬ 0; GetNewTimestamp: ENTRY PROC RETURNS [timestamp: CARD] ~ { timestamp ¬ BasicTime.Period[from~BasicTime.earliestGMT, to~BasicTime.Now[] ! BasicTime.TimeNotKnown => { timestamp ¬ lastTimestamp; CONTINUE; } ]; IF timestamp <= lastTimestamp THEN timestamp ¬ lastTimestamp+1; lastTimestamp ¬ timestamp; }; CreateShort: PUBLIC PROC [c: ServerConversation] RETURNS [replyVerifier: OpaqueValue] ~ { key: Key; h: Handle; replyVerifier ¬ RefText.New[BYTES[KeyValue]]; replyVerifier.length ¬ BYTES[KeyValue]; TRUSTED { key ¬ LOOPHOLE[replyVerifier] }; key.value.hostId ¬ myHostId; key.value.timestamp ¬ GetNewTimestamp[]; h ¬ NEW[Object ¬ [keyValue~key.value, c~c]]; Insert[headers, h]; }; DestroyShort: PUBLIC PROC [verifier: OpaqueValue] ~ { IF verifier.length >= BYTES[KeyValue] THEN TRUSTED { Delete[headers, LOOPHOLE[verifier, Key]]; }; }; ShortInitiate: SunRPCAuth.InitiateProc ~ { ERROR SunRPCAuth.Error[$shortInitiateIsIllegal]; }; ShortAuthenticate: SunRPCAuth.AuthenticateProc ~ { h: Handle; IF credentials.length >= BYTES[KeyValue] THEN { TRUSTED { h ¬ Lookup[NARROW[registrationData], LOOPHOLE[credentials]] }; IF h # NIL THEN RETURN [result~ok, replyFlavor~nullFlavor, replyVerifier~nullOpaqueValue, c~h.c]; }; RETURN [result~badCredentials, replyFlavor~nullFlavor, replyVerifier~NIL, c~NIL]; }; RegisterShort: PROC ~ { SunRPCAuth.Register[shortFlavor, ShortInitiate, ShortAuthenticate, Sweep, headers]; }; }... h SunRPCAuthShortImpl.mesa Copyright Σ 1989, 1991, 1992 by Xerox Corporation. All rights reserved. Demers, January 9, 1988 8:21:01 am PST Willie-Sue, March 16, 1989 7:02:37 pm PST Willie-s, August 21, 1991 12:29 pm PDT Types Parameters Table Management The following must be LOOPHOLE compatible with TEXT[BYTES[KeyValue]]: Client Interface Registration ΚΆ•NewlineDelimiter –(cedarcode) style™codešœ™Kšœ Οeœ=™HK™&K™)K™&K˜—˜ KšœΟkœ ˜Kšœ žœžœ˜>Kšœžœ˜Kšœžœžœ˜Kšœ žœy˜‰K˜K˜—šΟnœžœž˜"Kšžœ%˜,Kšžœ ˜K˜head™Kšžœžœžœ˜K˜Kšœžœ˜!K˜Kšœ-˜-Kšœ+˜+K˜Kšœ žœ˜+K˜Kšœ.˜.K˜Kšœžœ˜3Kšœžœ˜3—™ Kšœ žœžœ˜,Kšœ žœ˜Kšœ žœ˜—™Kšœ žœžœ˜"Kšœžœžœžœ˜7Kšœžœ˜&K˜Kšœžœžœ˜šœžœžœ˜K˜ K˜Kšœžœ˜Kšœ˜K˜—K˜šœΟc7™EKšœžœžœ ˜šœ žœžœ ˜Kšœžœ˜Kšœ˜K˜K˜——šœ žœžœ˜Kšœžœ˜Kšœ ž˜K˜K˜—šŸœžœžœ˜1Kšœžœžœ ˜1K˜K˜ K˜K˜—šŸœžœžœžœ˜BKšœžœžœ ˜.šžœžœžœž˜(Kšžœžœžœ˜$Kšžœ˜—K˜K˜—šŸœžœžœ˜.Kšœžœžœ ˜.K˜Kšœ ˜ šž˜Kšžœžœžœžœ˜Kšžœžœžœ˜"K˜Kšžœ˜—šžœž˜ Kšžœ˜Kšžœ˜—K˜K˜—šŸœ˜šžœžœžœž˜&Kšœ?˜?Kšžœ˜—K˜K˜—š Ÿ œžœžœžœžœ˜CK˜Kšœžœ˜šžœžœž˜šžœ ˜šžœ˜K˜K˜K˜—šžœ˜Kšžœžœžœžœ˜