Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
TonyLeBlanc Super Contributor.
Super Contributor.
1385 views

Generating a unique access token for use with BIS

Jump to solution

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

0 Likes
1 Solution

Accepted Solutions
Chuck Edgin Absent Member.
Absent Member.

RE: Generating a unique access token for use with BIS

Jump to solution

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
           .

View solution in original post

0 Likes
2 Replies
Chuck Edgin Absent Member.
Absent Member.

RE: Generating a unique access token for use with BIS

Jump to solution

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
           .

View solution in original post

0 Likes
TonyLeBlanc Super Contributor.
Super Contributor.

RE: Generating a unique access token for use with BIS

Jump to solution

That worked well, Chuck, thanks!

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.