This article targets: TIBCO Spotfire 2.1 and forward
From the day we released the platform APIs for TIBCO Spotfire, the most requested API feature with regards to connectivity has been to be able to query the Analytics Server URL and the user’s login name. This has actually been possible for quite some time using the ConnectivityService and the standard .NET User Operations Framework. The following snippet illustrates usage of the API in a tool that writes out the connectivity status of the application, the server URL, the username, and whether or not the user is an administrator.
public sealed class ConnectivityInformationTool : CustomTool<AnalysisApplication>
{
public ConnectivityInformationTool() : base("Connectivity Information")
{
// Empty
}
protected override void ExecuteCore(AnalysisApplication context)
{
ConnectivityService service = context.GetService<ConnectivityService>();
if (service.IsOnline)
{
// Print out info from the connectivity service
Trace.WriteLine("Application is online");
Trace.WriteLine("Server URL: " + service.ServerUri);
// Print out user info
IPrincipal userPrincipal = Thread.CurrentPrincipal;
IIdentity userIdentity = userPrincipal.Identity;
Trace.WriteLine("Current User: " + userIdentity.Name);
Trace.WriteLineIf(userIdentity.IsAuthenticated, "User is authenticated");
// The authentication states if the user was authenticated with
// * a username and password, Windows Integrated Authentication, etc.
Trace.WriteLine("Authentication Type: " + userIdentity.AuthenticationType);
// Detect wether or not the user is an admin
Trace.WriteLineIf(userPrincipal.IsInRole("administrator"), "User is an administrator");
}
else
{
Trace.WriteLine("Application is offline");
}
}
}