To use the C SSO API, the am_sso_init() routine needs to be called before any other routines. This interface initializes the internal SSO module. At the end of all SSO routines, am_cleanup() should be called to cleanup the internal SSO module. Code Example 4-5 on page 90 is a code sample for these interfaces.
am_sso_init() initializes internal data structures for talking to the Session Service. It takes a properties input parameter that contains name value pairs from a configuration or properties file, and returns a status on the success or failure of the initialization.
am_cleanup() cleans up all internal data structures created by am_sso_init, am_auth_init, or am_policy_init. am_cleanup() needs to be called only once when using any of the Access Manager C API interfaces (authentication, SSO or policy).
#include <am_sso.h> 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; } |