[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: Single Sign On

Status
Not open for further replies.
I

Irfan

Guest
Blake, As Mike pointed out, it looks there is a problem with your client program and it could not send the values correctly to the PASOE Server. You might already seen the javascript example in the attachment. In-case you want to do something in ABL then I am attching an ABL HTTP Client example also for your reference. /*------------------------------------------------------------------------ File : HTTPSSOClient.p Purpose : Syntax : Description : SSO Client to get the OE CP token and pass it in the header while invoking other OE Services. Author(s) : Created : Tue Feb 14 06:57:01 EST 2017 Notes : ----------------------------------------------------------------------*/ /* *************************** Definitions ************************** */ BLOCK-LEVEL ON ERROR UNDO, THROW. /* ******************** Preprocessor Definitions ******************** */ /* *************************** Main Block *************************** */ USING Progress.Lang.*. using OpenEdge.Core.Collections.IStringStringMap. using OpenEdge.Core.Collections.StringStringMap. using OpenEdge.Net.HTTP.ClientBuilder. using OpenEdge.Net.HTTP.Cookie. using OpenEdge.Net.HTTP.CookieJarBuilder. using OpenEdge.Net.HTTP.ICookieJar. using OpenEdge.Net.HTTP.IHttpClient. using OpenEdge.Net.HTTP.IHttpRequest. using OpenEdge.Net.HTTP.IHttpResponse. using OpenEdge.Net.HTTP.RequestBuilder. using Progress.Json.ObjectModel.JsonObject. using Progress.Lang.Object. using OpenEdge.Core.String. USING OpenEdge.Net.HTTP.Credentials FROM PROPATH. USING OpenEdge.Net.HTTP.IHttpClientLibrary. USING OpenEdge.Net.HTTP.Lib.ClientLibraryBuilder. USING OpenEdge.Net.HTTP.ClientBuilder. def var oClient as IHttpClient. def var oReq as IHttpRequest. def var oReq1 as IHttpRequest. ef var oResp as IHttpResponse. def var oResp1 as IHttpResponse. def var oForm as IStringStringMap. def var oCookies as Cookie extent. def var iLoop as int. DEFINE VARIABLE oLib AS IHttpClientLibrary NO-UNDO. DEFINE variable ssoURL as char no-undo. def var JObj as JsonObject. def var access_token as char. def var serviceURL as char. OUTPUT to "SSOClient.out". // Perform a successful authentication and get a valid access_token serviceURL = " localhost:8810/.../j_spring_security_check" . oForm = new StringStringMap(). oForm:put('j_username', "restuser"). oForm:put('j_password', "password"). oClient = ClientBuilder:Build() :Client. oReq = RequestBuilder:post(serviceURL, oForm) :ContentType('application/x-www-form-urlencoded') :AcceptJson() :Request. do iLoop = extent(oCookies) to 1 by -1: oReq:SetCookie(oCookies[iLoop]). end. oResp = oClient:Execute(oReq). oResp:GetCookies(output oCookies). // Get access_token JObj = cast(oResp:Entity,JSONObject). access_token = JObj:GetCharacter("access_token"). oLib = ClientLibraryBuilder:Build() :Library. Client = ClientBuilder:Build() :Client. // Perform SSO using the token recieved earlier serviceURL = " localhost:8810/.../_oeping" . oReq1 = RequestBuilder :Get(serviceURL) :AddHeader('Authorization','oecp ' + access_token) :AcceptJson() :Request. oResp1 = oClient:Execute(oReq1). // Print the SSO Output for the authorized OE Service if type-of(oResp1:Entity, JsonObject) then do: message String(cast(oResp1:Entity, JsonObject):GETJSONTEXT ()) VIEW-AS ALERT-BOX. end. OUTPUT CLOSE.

Continue reading...
 
Status
Not open for further replies.
Top