Try OpenEdge Now
skip to main content
Customization Guide
Single Sign-on for Business Process Server : Example of OpenEdge client-side code
 

Example of OpenEdge client-side code

The following example illustrates an OpenEdge client-side code implementation to support SSO for user authentication into the Business Process Server. The code block uses the Connect( ) and GetClientPrincipal( ) methods added to the Progress.BPM.UserSession class for user authentication using a Client-Principal object.
For more information on these methods of the Progress.BPM.UserSession class, see the OpenEdge Development: ABL Reference guide.
DEF VAR plOK AS LOG NO-UNDO.
DEFINE VARIABLE pURL AS CHAR INITIAL "-URL SBMServerDC://<localhost>:18793/".
DEFINE VARIABLE pUserSession AS Progress.BPM.UserSession.
DEFINE VARIABLE retStr AS CHARACTER.
DEFINE VARIABLE tmpStr AS CHARACTER.
DEFINE VARIABLE hCP AS HANDLE NO-UNDO.
DEFINE VARIABLE dac AS CHARACTER INITIAL "oebpm".

OUTPUT TO bpm_client_sealed.out APPEND.

PUT UNFORMATTED "-- bpm_client_sealed.p start -------------------------" SKIP.

/* create a domain registry in code */

plOK = SECURITY-POLICY:REGISTER-DOMAIN ("bpm", dac).
IF plOK
THEN DO:
plOK = SECURITY-POLICY:LOCK-REGISTRATION().
IF plOK
THEN PUT UNFORMATTED "domain registry OK." SKIP.
ELSE DO:
PUT UNFORMATTED "lock-registration() failed." SKIP.
QUIT.
END.
END.
ELSE DO:
PUT UNFORMATTED "register-domain() failed." SKIP.
QUIT.
END.

/* create client principal */
CREATE CLIENT-PRINCIPAL hCP.
hCP:INITIALIZE("oebpmuser@bpm", "12345", ?, "oebpmuser").

plOK = hCP:SEAL(dac).

/* create BPM UserSession */

PUT UNFORMATTED "before CONNECT() : hCP= " hCP
" session-id= " hCP:SESSION-ID
" login-state= " hCP:LOGIN-STATE
SKIP.

pUserSession = NEW Progress.BPM.UserSession(pURL).

PAUSE.

/* connect to BPM server using CP as credentials */

plOK = pUserSession:Connect(hCP).

IF plOK THEN
PUT UNFORMATTED "Connected to BPM Server OK." SKIP.
ELSE DO:
PUT UNFORMATTED "Connect to BPM Server FAILED." SKIP.
QUIT.
END.

PUT UNFORMATTED "after CONNECT() : hCP= " hCP
" session-id= " hCP:SESSION-ID
" login-state= " hCP:LOGIN-STATE
SKIP.

plOK = hCP:VALIDATE-SEAL(dac).

IF plOK THEN
PUT UNFORMATTED "sealed CP received from BPM Server is VALID." SKIP.
ELSE DO:
PUT UNFORMATTED "sealed CP received from BPM Server is INVALID." SKIP.
pUserSession:Disconnect(TRUE).
QUIT.
END.

IF (plOK)
THEN DO:
PAUSE.
hCP = pUserSession:GetClientPrincipal().
PUT UNFORMATTED
"after GetClientPrincipal() : hCP= " hCP
" session-id= " hCP:SESSION-ID
" login-state= " hCP:LOGIN-STATE
SKIP.
END.

IF (plOK)
THEN DO:
pUserSession:Disconnect(TRUE).
PUT UNFORMATTED "Disconnected from BPM Server OK." SKIP.
END.

DELETE OBJECT hCP.
PUT UNFORMATTED "-- bpm_client_sealed.p end -------------------------" SKIP.
OUTPUT CLOSE.
QUIT.