#include <ictx.h>; int ictxParseAuthContext ( ictxIdContext_t * authContext, ictxParseInfo_t ** parsedContext, ictxError_t * errorInfo )
The ictxParseAuthContext() function parses the information from the authentication context. The parsed information can be used for mapping lookup operations and for auditing purposes.
The return value from the API.
The following example parses an authentication context. Note: Read the Code example disclaimer for important legal information.
#include <ictx.h> #include <string.h> void printData(char * attribute, char * value) { char * actual = NULL; if (NULL == value) actual = "NONE"; else actual = value; printf(" %s: %s\n", attribute, actual); } void printAuthData(ictxAuthenticationInfo_t * authData) { int rc; if (NULL == authData) { printf("No authentication information available.\n"); return; } printf("Authentication information:\n"); printData(" User", authData->user); printData(" Registry", authData->registry); printData(" HostName", authData->hostName); printData(" AuthMech", authData->authMech); printData(" SecurityLabel", authData->securityLabel); printData(" ImplemSpecific", authData->implemSpecific); printf("\n\n"); } void printPremapped(ictxPremappedUserInfo_t * premapped) { printData(" User", premapped->user); printData(" Registry", premapped->registry); printData(" MappingSource", premapped->mappingSource); printData("MappingQualifiers", premapped->mappingQualifiers); printData(" ImplemSpecific", premapped->implemSpecific); } void printApplication(ictxApplicationInfo_t * appInfo) { printData(" Appid", appInfo->appid); printData(" Instance", appInfo->instance); printData(" ImplemSpecific", appInfo->implemSpecific); } void printManifest(ictxManifestInfo_t * manifest) { time_t creationTime; struct tm *timeptr; char dest[50]; // printf("Manifest counter: %d\n", manifest->counter); printf("\n"); //------------------------------------------------------------------ // Convert time to Month Day, year h:m:s //------------------------------------------------------------------ creationTime = manifest->creationTime; timeptr = localtime(&creationTime); dest[0] = 0; strftime(dest,sizeof(dest)-1,"%b %d,%Y %H:%M:%S", timeptr); printf("Creation date: %s\n", dest); printf("Time to Live: %d\n", manifest->timeToLive); if (NULL == manifest->sender) printf(" Sender: NONE.\n"); else { printf(" Sender Information:\n"); printApplication(manifest->sender); } printf("\n"); if (NULL == manifest->receiver) printf(" Receiver: NONE.\n"); else { printf(" Receiver Information:\n"); printApplication(manifest->receiver); } printf("\n"); if (NULL == manifest->premappedUser) printf(" PremappedUser: NONE.\n"); else { printf(" PremappedUser Information:\n"); printPremapped(manifest->premappedUser); } printf("\n\n"); return; } void printManifests(ictxManifestInfo_t ** manifestList) { int i = 0; if (NULL == manifestList) { printf("No manifest information available.\n"); return; } for ( i = 0; manifestList[i] != NULL; i++) { printManifest(manifestList[i]); } return; } int parseAuthContext(ictxIdContext_t * authContext) { int rc; ictxError_t errorInfo; ictxParseInfo_t * parsedContext; /*----------------------------------------------------------------*/ /* Parse authentication context */ /*----------------------------------------------------------------*/ if (0 != (rc = ictxParseAuthContext(authContext, &parsedContext, &errorInfo))) { . . . return -1; } /*----------------------------------------------------------------*/ /* Check status */ /*----------------------------------------------------------------*/ if (0 == parsedContext->statusFlag) printf("\n Parsed results complete.\n"); else printf("\n Parsed results incomplete.\n"); /*----------------------------------------------------------------*/ /* Print parsed results */ /*----------------------------------------------------------------*/ if (ICTX_PARSE_INFO_FORMAT_0 == parsedContext->format) { printAuthData(parsedContext->parseInfo.format0.authData); printManifests(parsedContext->parseInfo.format0.manifestList); } . . . if (0 != (rc = ictxFreeParseInfo(parsedContext, &errorInfo))) { . . . return -1; } return 0; }
Top | Security APIs | APIs by category |