Skip to main content

Beginning to implement web services using BIS with Extend; when creating a new session (ie when a user logs in), we want to generate a unique access token for that user (so we can validate subsequent requests to other services, timeout sessions, etc.) - I recall seeing a sample program either in a tutorial, or during a webinar, or maybe at the users conference in Newark, but my memory fails as to where I saw it.

Can anyone point me to a method of generating a unique access token that would be straight-forward to implement in Extend?


Thanks

Tony

Beginning to implement web services using BIS with Extend; when creating a new session (ie when a user logs in), we want to generate a unique access token for that user (so we can validate subsequent requests to other services, timeout sessions, etc.) - I recall seeing a sample program either in a tutorial, or during a webinar, or maybe at the users conference in Newark, but my memory fails as to where I saw it.

Can anyone point me to a method of generating a unique access token that would be straight-forward to implement in Extend?


Thanks

Tony

Here's a callable program that, in turn, calls a Windows API function to generate a UUID, which should be suitable for your needs:

       IDENTIFICATION DIVISION.
       PROGRAM-ID.  UUIDGEN.

       DATA DIVISION.
       Working-Storage Section.
       copy "acucobol.def".
       copy "acugui.def".

       01 WS-UUID-STRUCT.
           03 WS-UUID-DATA1 PIC X(4) COMP-N.   | Hex Value
           03 WS-UUID-DATA2 PIC X(2) COMP-N.   | Hex Value
           03 WS-UUID-DATA3 PIC X(2) COMP-N.   | Hex Value
           03 WS-UUID-DATA4 PIC X(8) COMP-N.   | Hex Value
       01 WS-UUID-STRING    PIC X(4) COMP-N.
       01 WS-UUID-PIC-X36   PIC X(36).   

       01 CALLING-PROGRAM   PIC X(40).
       01 CALLEDBY-STATUS   PIC S99.
           88 IS-CALLED-PROGRAM         VALUE  1.
           88 IS-MAIN-PROGRAM           VALUE  0.

       Linkage Section.
       01 LNK-UUID-PIC-X36  PIC X(36).   

       PROCEDURE DIVISION.
       Main.
           ACCEPT SYSTEM-INFORMATION FROM SYSTEM-INFO
           EVALUATE TRUE
               WHEN OS-IS-WIN-FAMILY
                   PERFORM GENERATE-UUID
                   PERFORM RETURN-RESULTS
               WHEN OTHER
                   DISPLAY "THIS PROGRAM REQUIRES 32-BIT/64-BIT WINDOWS"
                           UPON SYSERR
           END-EVALUATE

           GOBACK
           .


       GENERATE-UUID.
           CALL "Rpcrt4.dll@WINAPI"
           CALL "UuidCreateSequential" USING
                BY REFERENCE WS-UUID-STRUCT
           END-CALL
           CALL "UuidToStringA" USING
                BY REFERENCE WS-UUID-STRUCT
                BY REFERENCE WS-UUID-STRING
           END-CALL
           CALL "C$MEMCPY" USING
                BY REFERENCE     WS-UUID-PIC-X36
                BY VALUE         WS-UUID-STRING
                BY VALUE         36
           END-CALL 
           CANCEL "Rpcrt4.dll@WINAPI"
           .


       RETURN-RESULTS.
           CALL "C$CALLEDBY" USING  CALLING-PROGRAM
                             GIVING CALLEDBY-STATUS
           EVALUATE TRUE
               WHEN IS-CALLED-PROGRAM
                   MOVE WS-UUID-PIC-X36 TO LNK-UUID-PIC-X36
               WHEN IS-MAIN-PROGRAM
                   DISPLAY MESSAGE BOX 
                           WS-UUID-PIC-X36
                           TITLE IS "Unique GUID"
                           ICON IS MB-DEFAULT-ICON
                           TYPE IS MB-OK
           END-EVALUATE
           .


Beginning to implement web services using BIS with Extend; when creating a new session (ie when a user logs in), we want to generate a unique access token for that user (so we can validate subsequent requests to other services, timeout sessions, etc.) - I recall seeing a sample program either in a tutorial, or during a webinar, or maybe at the users conference in Newark, but my memory fails as to where I saw it.

Can anyone point me to a method of generating a unique access token that would be straight-forward to implement in Extend?


Thanks

Tony

That worked well, Chuck, thanks!