AlpineV2ServerInternalImpl.mesa
Carl Hauser, November 13, 1987 1:33:48 pm PST
DIRECTORY
CHNameP2V0,
AEToCrAE,
AuthenticationP14V2,
AlpineP2202V2,
AlpineEnvironment,
AlpineFile,
AlpineV2ServerInternal,
ClientMap,
GVNames,
RPC,
CardTab;
AlpineV2ServerInternalImpl: CEDAR MONITOR
IMPORTS AlpineFile, AlpineP2202V2, CardTab, ClientMap, GVNames, RPC, AEToCrAE
EXPORTS AlpineV2ServerInternal
~ BEGIN
OPEN ATC: AEToCrAE;
sessions: CardTab.Ref ← CardTab.Create[];
sessionNumber: CARD ← 0;
LocalSessionInfo: TYPE = RECORD [
service: CHNameP2V0.ThreePartName,
credentials: AuthenticationP14V2.Credentials,
gvCredentials: AlpineP2202V2.GVCredentials,
conversation: RPC.Conversation];
Error: ERROR ~ CODE;
CreateSession: PUBLIC ENTRY PROC [service: CHNameP2V0.ThreePartName,
credentials: AuthenticationP14V2.Credentials,
gvCredentials: AlpineP2202V2.GVCredentials]
RETURNS
[session: AlpineP2202V2.Session] ~ {
ENABLE UNWIND => NULL;
conversation: RPC.Conversation ← RPC.GenerateConversation[];
IF GVNames.Authenticate[gvCredentials.name, gvCredentials.pwd] # individual THEN RETURN WITH ERROR AlpineP2202V2.AuthenticationError[credentialsInvalid];
TRUSTED {ClientMap.Register[conversation, gvCredentials.name]};
[] ← CardTab.Insert[sessions, sessionNumber, NEW[LocalSessionInfo ← [service, credentials, [gvCredentials.name, NIL], conversation]]];
session ← [token: LOOPHOLE[sessionNumber], verifier: NIL];
sessionNumber ← sessionNumber.SUCC;
};
DestroySession: PUBLIC ENTRY PROC [session: AlpineP2202V2.Session] ~ {
ENABLE UNWIND => NULL;
[] ← CardTab.Delete[sessions, LOOPHOLE[session.token]];
};
Conversation: PUBLIC ENTRY PROC [session: AlpineP2202V2.Session]
RETURNS
[conversation: RPC.Conversation] ~ {
ENABLE UNWIND => NULL;
found: BOOL;
ref: REF;
[found, ref] ← CardTab.Fetch[sessions, LOOPHOLE[session.token]];
IF NOT found THEN RETURN WITH ERROR AlpineP2202V2.ConnectionError[otherCallProblem];
conversation ← NARROW[ref, REF LocalSessionInfo].conversation;
};
DoWork: PUBLIC PROC [work: PROC] ~ {
accessReason: AlpineEnvironment.NeededAccess;
lockReason: AlpineEnvironment.LockFailure;
operationReason: AlpineEnvironment.OperationFailure;
unknownReason: AlpineEnvironment.UnknownType;
{
ENABLE {
AlpineFile.AccessFailed => {accessReason ← missingAccess; GOTO accessFailed};
AlpineFile.LockFailed => {lockReason ← why; GOTO lockFailed};
AlpineFile.OperationFailed => {operationReason ← why; GOTO operationFailed};
AlpineFile.PossiblyDamaged => {GOTO possiblyDamaged};
AlpineFile.StaticallyInvalid => {GOTO staticallyInvalid};
AlpineFile.Unknown => {unknownReason ← what; GOTO unknown};
};
work[];
EXITS
accessFailed => ERROR AlpineP2202V2.AccessFailed[ATC.NeededAccess[accessReason]];
lockFailed => ERROR AlpineP2202V2.LockFailed[ATC.LockFailure[lockReason]];
operationFailed => ERROR AlpineP2202V2.OperationFailed[ATC.OperationFailure[operationReason]];
possiblyDamaged => ERROR AlpineP2202V2.PossiblyDamaged;
staticallyInvalid => ERROR AlpineP2202V2.StaticallyInvalid;
unknown => ERROR AlpineP2202V2.Unknown[ATC.UnknownType[unknownReason]];
};
};
END.