Consider a scenario where you need to call a web panel inside an SDPanel using the Component domain. The web panel, as well as the Smart Devices app, has Integrated Security enabled.
Once the user has logged into the Smart Devices app, he shouldn't be asked to log in again into the web panel and should be able to use the same credentials.
The solution consists of sharing the GAMSession Token of the web panel. After having validated it, it can be used to go on with the execution.
As any private object automatically validates security before the Start Event, you need to set the GAMSession Token before its execution. The only valid way to do that is to validate the GAMSession Token in a public web panel and then call the private web panel.
The ValidAccessToken method of the GAMRepository object is useful for validating the GAMSession Token and setting it in the environment.
So, the steps of the solution are as follows:
- Create a public web panel (Integrated Security Level property = None) which is called directly by the SDPanel using the Component domain and receives as parameter the GAMSession Token. The public web panel (let's call it "auxWBP") is used as a "bridge" and redirects to the private web panel (Integrated Security Level property = Authentication / Authorization).
Note that for security reasons, the URL to be redirected can be hard-coded. In this example, its value has been loaded in the &url variable, and &SessionSTR is received as a parameter.
&ValidAccessToken = GAMRepository.ValidAccessToken(&SessionSTR,&GAMSession,&Errors) //&Errors is a collection of GAMError
if &ValidAccessToken //If the session token received as a parameter is valid
else //If the session token received as a parameter is not valid
- The SDPanel loads the GAMSession in a &GAMSession variable and calls the auxWBP web panel in the Start Event, passing the GAMSession Token as a parameter.
&UrlToCall is a variable based on the Component Domain:
So, the Start Event code of the SDPanel is as follows:
&GAMSession = GAMSession.Get(&Errors) //&Errors is a collection of GAMError
&UrlToCall = auxWBP.Link(&GAMSession.Token.ToString())
Download the sample from Sample: How to get the SD credentials in a web panel component.