Types
ROPE: TYPE ~ Rope.ROPE;
Flavor: TYPE ~ SunRPCAuth.Flavor;
nullFlavor: Flavor ~ SunRPCAuth.nullFlavor;
OpaqueValue: TYPE ~ REF TEXT;
nullOpaqueValue: OpaqueValue ¬ RefText.New[0];
Conversation: TYPE ~ REF ConversationObject;
ConversationObject: TYPE ~ SunRPCAuth.ConversationObject;
Procs: TYPE ~ REF ProcsObject;
ProcsObject: TYPE ~ SunRPCAuth.ProcsObject;
GetCredentialsAndNextVerifierProc: TYPE ~ SunRPCAuth.GetCredentialsAndNextVerifierProc;
CheckReplyVerifierProc: TYPE ~ SunRPCAuth.CheckReplyVerifierProc;
NoShortcutProc: TYPE ~ SunRPCAuth.NoShortcutProc;
TerminateProc: TYPE ~ SunRPCAuth.TerminateProc;
InitiateProc: TYPE ~ SunRPCAuth.InitiateProc;
AuthenticateProc: TYPE ~ SunRPCAuth.AuthenticateProc;
SweepProc: TYPE ~ SunRPCAuth.SweepProc;
AuthenticateResult: TYPE ~ SunRPCAuth.AuthenticateResult;
Error: PUBLIC ERROR [code: ATOM] ~ CODE;
Registration
Registrations: TYPE ~ ARRAY [0..numFlavors) OF Registration;
Registration: TYPE ~ REF RegistrationObject;
RegistrationObject:
TYPE ~
RECORD [
initiateProc: InitiateProc,
authenticateProc: AuthenticateProc,
sweepProc: SweepProc,
data: REF
];
registrations: REF Registrations ¬ NEW[Registrations];
Register:
PUBLIC
PROC [flavor: Flavor, initiate: InitiateProc, authenticate: AuthenticateProc, sweep: SweepProc, registrationData:
REF] ~ {
flavorIndex: CARD ¬ flavor;
registration: Registration ¬ NIL;
IF flavorIndex >= numFlavors THEN ERROR Error[$flavorOutOfRange];
IF (initiate #
NIL)
AND (authenticate #
NIL)
THEN {
registration ¬ NEW[RegistrationObject];
registration.initiateProc ¬ initiate;
registration.authenticateProc ¬ authenticate;
registration.sweepProc ¬ sweep;
registration.data ¬ registrationData;
};
registrations[flavorIndex] ¬ registration;
};
Servers
Authenticate:
PUBLIC
PROC [cFlavor: Flavor, credentials: OpaqueValue, vFlavor: Flavor, verifier: OpaqueValue]
RETURNS [result: AuthenticateResult, replyFlavor: Flavor, replyVerifier: OpaqueValue, c: Conversation]
~ {
flavorIndex: CARD;
registration: Registration;
IF ((flavorIndex ¬ cFlavor) >= numFlavors)
OR ((registration ¬ registrations[flavorIndex]) =
NIL)
THEN RETURN [result~badCredentials, replyFlavor~nullFlavor, replyVerifier~NIL, c~NIL];
[result, replyFlavor, replyVerifier, c] ¬ registration.authenticateProc[cFlavor, credentials, vFlavor, verifier, registration.data];
};
Clients
Initiate:
PUBLIC
PROC [flavor: Flavor, myName, myPassword:
ROPE, hisName:
ROPE]
RETURNS [c: Conversation] ~ {
flavorIndex: CARD;
registration: Registration;
IF (flavorIndex ¬ flavor) >= numFlavors THEN ERROR Error[$flavorOutOfRange];
IF (registration ¬ registrations[flavorIndex]) = NIL THEN ERROR Error[$flavorNotRegistered];
c ¬ registration.initiateProc[flavor, myName, myPassword, hisName, registration.data];
};
Null Flavor
nullClientConversation: Conversation;
nullClientProcs: Procs;
nullServerConversation: Conversation;
NullInitiate: InitiateProc ~ { RETURN[nullClientConversation] };
NullNoShortcut: NoShortcutProc ~ { RETURN [FALSE] };
NullTerminate: TerminateProc ~ { NULL };
NullGetCredentialsAndNextVerifier: GetCredentialsAndNextVerifierProc ~ {
cFlavor ¬ vFlavor ¬ nullFlavor;
credentials ¬ nullOpaqueValue;
verifier ¬ nullOpaqueValue;
};
NullCheckReplyVerifier: CheckReplyVerifierProc ~ {
RETURN[ok] };
NullAuthenticate: AuthenticateProc ~ {
RETURN [result~ok, replyFlavor~nullFlavor, replyVerifier~nullOpaqueValue, c~nullServerConversation];
};
RegisterNull:
PROC ~ {
nullClientProcs ¬ NEW[ProcsObject ¬ [NullGetCredentialsAndNextVerifier, NullCheckReplyVerifier, NullNoShortcut, NullTerminate]];
nullClientConversation ¬ NEW[ConversationObject ¬ [nullFlavor, nullClientProcs, NIL]];
nullServerConversation ¬ NEW[ConversationObject ¬ [nullFlavor, NIL, NIL]];
Register[nullFlavor, NullInitiate, NullAuthenticate, NIL, NIL];
};
}...