Breadcrumb
- Sabre Red 360 Software Development Kit Help
- Desktop Red Apps
- Communications in Red Apps
- Overview of Authentication, Authorization, and Registration
- Authenticating and Requesting Authorization to Use Services
Authenticating and Requesting Authorization to Use Services
The steps in this procedure show how a Red App authenticates in SRWRuntime and requests authorization to use a service.
You need the following values:
-
RequestorId
or Red App ID. The Red App ID is passed in the Java code as aRequestorId
, and this ID is also passed inredapp.xml
. Sabre assigns a Red App ID to your Red App to uniquely identify your app. -
Service context name. This is the service name that your Red App will access. All Red Apps that use communications services register a service context name with SRWRuntime. The service context name is passed in the Java code, and in the
redapp.xml
file as thename
attribute of theAuthorization
entry. Every service that is registered with SRWRuntime has a unique name. -
threshold
. The threshold is the quantity of operations on the service. This value is passed in the Java code andredapp.xml
. In theAuthorization
entity, you define the quantity of operations in thethreshold
attribute, with an optionalmetric
attribute, expressed either as transactions per second (tps) or transactions per minute (tpm).
If you do not add the metric
attribute, the default is transactions per second.
-
Using Eclipse, add the following required dependencies to your plug-in project:
-
com.sabre.edge.cf.core
-
com.sabre.edge.cf.model
-
com.sabre.edge.platform.core.common
-
-
Get the authentication token service. This service obtains the token for your Red App. It is recommended that you load this service once and store it in a class attribute, for example, your Red App Activator. Sample code for the AbstractEdgeBaseNonUIPlugin class that exposes the getServiceReference method is shown below.
public class Activator extends AbstractEdgeBaseNonUIPlugin
{
private static Activator plugin;
private IAuthenticationTokenService tokenService;
@Override
public void start(BundleContext context) throws Exception
{
super.start(context);
plugin = this;
}
@Override
public void stop(BundleContext context) throws Exception
{
super.stop(context);
plugin = null;
super.stop(context);
}
public static Activator getDefault()
{
return plugin;
}
public String getToken()
{
if (tokenService == null)
{
tokenService = getServiceReference(IAuthenticationTokenService.class);
}
return tokenService.getToken();
}
}
-
Create a ServiceContext object. This object passes information to the Bus. ServiceContext context = new ServiceContext();
-
Set the service ContextName, RequestorId, and Token attributes of the service context object. An example is shown below.
context.setContextName("ServiceContextName"); context.setRequestorId("Red App ID"); context.setToken(Activator.getDefault().getToken());
-
Set other required service context attributes, such as the request object. The service context attributes that you are required to set depend on the services that your Red App uses. To obtain the service context attributes, see the topics that are dedicated to those services.
-
Invoke the process() method on an SRWRuntime instance.
-
Add a redapp.xml file. To the RedApp entity in the file, add one Authorization child element for each service that your Red App will access. In Authorization, a Red App requests authorization to use a service. Add the name attribute to each Authorization entity. An example of a request for authorization is shown below.
Note
|
You can specify threshold as either tps or tpm. Building a redapp.xml file explains variations that are based on service. |
<CFBundle>
<RedApp id="Red App ID" >
<Authorization name="ContextName" threshold="1" />
</RedApp>
</CFBundle>
-
Add redapp.xml to the bin.includes list in build.xml of the plug-in that has communications. This ensures that your redapp.xml file is included when you create an exported jar file.
-
Using Eclipse, add the com.sabre.edge.cf.redapp extension point to the plugin.xml of the plug-in that is registering services, registering event listeners, or consuming services. This extension point triggers SRWRuntime to search for redapp.xml.