Fixes to call Card Selector

This commit is contained in:
Jim Norman 2008-03-11 23:05:34 +00:00
parent 32a045af7c
commit f25fe86e6b
3 changed files with 36 additions and 19 deletions

View File

@ -23,6 +23,7 @@
#include "micasa_types.h"
#include "micasa_mgmd.h"
int launchSelector( void *secretHandle,
int launchSelector( char *pSecretID,
void *secretHandle,
SSCS_BASIC_CREDENTIAL *basicCred);

View File

@ -259,7 +259,8 @@ int getLine(char *line, int max, FILE *fp)
/****************************************************************************
Desc:
****************************************************************************/
int launchSelector(void *secretHandle,
int launchSelector(char* pSecretID,
void *secretHandle,
SSCS_BASIC_CREDENTIAL *basicCred)
{
@ -274,6 +275,8 @@ int launchSelector(void *secretHandle,
int32_t argCount = 0;
void *pArgs[MAXARGS] = {0};
void *pAppliesTo;
int32_t claimCount = 0;
void *pKeys[MAXCLAIMS] = {0};
void *pClaims[MAXCLAIMS] = {0};
@ -291,11 +294,13 @@ int launchSelector(void *secretHandle,
const char line[256];
char claimURI[256];
char claimvalue[256];
char claimURI[256] = {0};
char claimvalue[256] = {0};
int indexToDigitalMeApp = 0;
printf("launchSelector method called\r\n");
if (findDigitalMe(&indexToDigitalMeApp) == 0)
{
// Get a temp name for the token file
@ -326,6 +331,9 @@ int launchSelector(void *secretHandle,
return NSSCS_E_INVALID_SECRET_ID;
}
memset(pKey, 0, NSSCS_MAX_SECRET_ID_LEN);
memset(pValue, 0, NSSCS_MAX_SECRET_BUF_LEN);
// read the mapped pClaims
// enumerate this list looking for username and password
if(!(rcode = miCASA_GetNextSHSEntry(1, secretHandle, &kLen, pKey, &vLen, pValue)))
@ -337,16 +345,13 @@ int launchSelector(void *secretHandle,
break;
}
// Save of key anc claim mapping
if (argCount < MAXCLAIMS)
// Save of key and claim mapping
if (claimCount < MAXCLAIMS)
{
pTempPtr = malloc(sscs_strlen(pValue));
sscs_strncpy(pTempPtr, pKey, sscs_strlen(pKey));
pKeys[claimCount] = pTempPtr;
printf("URI: %s\r\n", pValue);
pTempPtr = malloc(sscs_strlen(pValue));
sscs_strncpy(pTempPtr, pValue, sscs_strlen(pValue));
printf("URI: %s (%d)\r\n", pValue, vLen);
pTempPtr = malloc(vLen);
memset(pTempPtr, 0, vLen);
sscs_strncpy(pTempPtr, pValue, vLen);
pClaims[claimCount++] = pTempPtr;
claimStrLen += sscs_strlen(pValue);
}
@ -360,20 +365,29 @@ int launchSelector(void *secretHandle,
while(rcode == NSSCS_SUCCESS);
}
printf("Launch selector\r\n");
printf("Launching selector\r\n");
// Set up args
pArgs[argCount++] = dmPaths[indexToDigitalMeApp];
pArgs[argCount++] = &DM_GET_TOKEN_ARG_STR;
//pArgs[argCount++] = &DM_RECIPIENT_ARG_STR;
pAppliesTo = malloc(strlen(pSecretID) + 20);
memset(pAppliesTo, 0, strlen(pSecretID) + 20);
sscs_strcpy(pAppliesTo, &DM_RECIPIENT_ARG_STR);
sscs_strcat(pAppliesTo, "=\"");
sscs_strcat(pAppliesTo, pSecretID);
sscs_strcat(pAppliesTo, "\"");
//pArgs[argCount++] = pAppliesTo;
// Setup claims arg
pClaimsStr = malloc(claimStrLen + 10);
pClaimsStr = malloc(claimStrLen + 20);
memset(pClaimsStr, 0, claimStrLen + 20);
sscs_strcpy(pClaimsStr, &DM_REQUIRED_CLAIMS_ARG_STR);
sscs_strcat(pClaimsStr, "=\"");
for (i = 0; i<MAXARGS; i++)
for (i = 0; i<MAXCLAIMS; i++)
{
if (pClaims[i] != NULL)
{
@ -382,7 +396,7 @@ int launchSelector(void *secretHandle,
{
sscs_strcat(pClaimsStr, " ");
}
sscs_strcat(pClaimsStr, pClaims[i]);
sscs_strncat(pClaimsStr, pClaims[i], sscs_strlen(pClaims[i]));
}
}
@ -399,7 +413,7 @@ int launchSelector(void *secretHandle,
// Output file
pFileName = malloc(sscs_strlen(&DM_TOKEN_OUTPUT_FILE_ARG_STR) + sscs_strlen(filename) + 10);
memset(pFileName, 0, sscs_strlen(&DM_TOKEN_OUTPUT_FILE_ARG_STR) + sscs_strlen(filename) + 10);
sscs_strcpy(pFileName, &DM_TOKEN_OUTPUT_FILE_ARG_STR);
sscs_strcat(pFileName, "=\"");
sscs_strcat(pFileName, filename);
@ -459,11 +473,13 @@ Exit:
printf("Free resources\r\n");
if (pClaimsStr)
{
printf("free claimsStr\r\n");
free(pClaimsStr);
}
if (pFileName)
{
printf("free pFileName\r\n");
free(pFileName);
}

View File

@ -3224,7 +3224,7 @@ miCASAGetCredential
if(rcode == NSSCS_SUCCESS)
{
printf("Found mapping, launch card selector\r\n");
rcode = launchSelector(secretHandle, basicCred);
rcode = launchSelector(appSecretID->id, secretHandle, basicCred);
if (rcode == 0)
{
return rcode;