When implementing single sign-on, am_sso_init() must be called before any other am_sso_* functions to initialize the internal data structures. At the end of all single sign-on routines, am_cleanup() should be called for cleanup. Following is a code sample using these functions.
For more information on am_cleanup(), see Chapter 9, Additional Data Types and Functions.
#include <am_sso.h>
boolean_t agentInitialized = B_FALSE;
const char* prop_file = "../../config/OpenSSOAgentBootstrap.properties";
const char* config_file = "../../config/OpenSSOConfiguration.properties";
am_web_init (prop_file, config_file);
am_agent_init(&agentinitialized)
int main() {
am_properties_t *properties;
am_status_t status;
/* create a properties handle */
status = am_properties_create(&properties);
if (status != AM_SUCCESS) {
printf("am_properties_create failed.\\n");
exit(1);
}
/* load properties from a properties file */
status = am_properties_load(properties, "./myPropertiesFile");
if (status != AM_SUCCESS) {
printf("am_properties_load failed.\\n");
exit(1);
}
/* initialize SSO module */
status = am_sso_init(properties);
if (status != AM_SUCCESS) {
printf("am_sso_init failed.\\n");
return 1;
}
/* login through auth module, and do auth functions.
* ...
*/
/* do sso functions
* ...
*/
/* done - cleanup. */
status = am_cleanup();
if (status != AM_SUCCESS) {
printf("am_cleanup failed!\\n");
return 1;
}
/* free memory for properties */
status = am_properties_destroy(properties);
if (status != AM_SUCCESS) {
printf("Failed to free properties.\\n");
return 1;
}
/* exit program successfully. */
return 0;
}