...
Blok kódu | ||||
---|---|---|---|---|
| ||||
INT _CNT_sessions ;kontajner vsetkych aktivnych session vsetkych pouzivatelov ; metoda jr zaregistrovana v Smart Web aplikacii ako "logOn" metoda ktora sa vola po kazdej uspesnej autentifikacii RPC PROCEDURE logOn(IN TEXT _UserName, IN TEXT _UserPass, IN TEXT _X509CertificateBase64, BOOL _Ok) INT _hobj_session BOOL _bFound _Ok := @TRUE ;------- Vkladanie session do kontajnera --------- _hobj_session := %GetRPCCallerProcess() ; kontrola existencie session, nesmie existovat, opacny stav je chyba CNT_FIND _CNT_sessions, _hobj_session, _UserName, _bFound IF _bFound THEN LOGEX "ERR: uz existuje rovnaka SESSION pouzivatela: " + %IToStr(_hobj_session) PRIORITY _LOG_PRTY_ERROR _Ok := @FALSE RETURN ENDIF ; registracia volanie metody onSessionClosed pri "zmene session", t.j. bud standardne odhlasenie alebo akekolvek ukoncenie session _Ok := %OpenRefToObject(_hobj_session, @TRUE) IF !_Ok THEN LOGEX "ERR: neznama SESSION pre otvorenie: " + %IToStr(_hobj_session) PRIORITY _LOG_PRTY_ERROR RETURN ENDIF ON CHANGE (_hobj_session) GOTO onSessionClosed ; vlozenie mapovania "session HOBJ -> user name" do kontainera CNT_INSERT _CNT_sessions, _hobj_session, _UserName END logOn ; zrusena session pouzivatela (odhlasenim alebo inym dovodom zrusenia session pouzivatela) PROCEDURE onSessionClosed(IN INT _procValue, IN ALIAS _hobj, IN INT _row, _col) BOOL _bFound INT _hobj_session TEXT _userName _hobj_session := _hobj\HBJ CNT_FIND _CNT_sessions, _hobj_session, _userName, _bFound IF ! _bFound THEN LOGEX "ERR: neznama SESSION bola ukoncena " + %IToStr(_hobj_session) PRIORITY _LOG_PRTY_ERROR RETURN ENDIF CNT_DELETE _CNT_sessions, _hobj_session %CloseRefToObject(_hobj_session) ON CHANGE (_hobj_session) GOTO onSessionClosed NONE END onSessionClosed ; RPC metóda vráti meno aktuálne prihláseného používateľa RPC PROCEDURE getCurrentUserName(TEXT _userName) INT _hobj_session BOOL _bFound _hobj_session := %GetRPCCallerProcess() CNT_FIND _CNT_sessions, _hobj_session, _userName, _bFound IF ! _bFound THEN LOGEX "ERR: neznama SESSION bola ukoncena " + %IToStr(_hobj_session) PRIORITY _LOG_PRTY_ERROR RETURN ENDIF END getCurrentUserName BEGIN CNT_CREATE _CNT_sessions END |
...