Ejemplo n.º 1
0
BioAPI_RETURN BioAPI
BioAPI_EnumModules(BioAPI_BSP_SCHEMA * BspSchemaArray,
									uint32 ArraySize,
									uint32 * ElementsNeeded,
									uint32 * NumElementsReturned)

{
	BioAPI_RETURN err;
	MDSU_CONTEXT MdsuContext;
	BioAPI_BSP_SCHEMA BioAPICapTemplate;
	BioAPI_BSP_SCHEMA BioAPICapData;
	BioAPI_BSP_SCHEMA * CurrentSchemaPtr;
	uint32 Count;

	/* Initialize in case of early return (usually caused by no installed modules) */
	*NumElementsReturned = 0;
	*ElementsNeeded = 0;

	if((err = MDSU_Init(&MdsuContext,
					&BioAPIMemoryFuncs,
					&bioapi_UUID,
					MDS_CDSA_DIRECTORY,
					(CSSM_DB_ACCESS_READ | CSSM_DB_ACCESS_WRITE),
					BIOAPI_MDS_COMMIT_SIZE)) != BioAPI_OK)
		return err;

	/* Handle the simple case first...NULL passed for BspSchemaArray */
	if(BspSchemaArray == NULL)
	{
		Count = 0;
		BioAPICapTemplate.SpecVersion.Major = BioAPI_MAJOR;
		BioAPICapTemplate.SpecVersion.Minor = BioAPI_MINOR;
		err = MDSU_FindFirst(&MdsuContext,
								 &IfiMdsuBioAPIBspCapabilitySchema,
								 &BioAPICapTemplate,
								 MDSU_BIOAPI_BSP_CAP_SPECVERSION,
								 &BioAPICapData,
								 NULL);
		if (CSSM_OK != err)
		{
			MDSU_Term( &MdsuContext );
			if (CSSMERR_DL_ENDOFDATA == err)
				return BioAPIERR_H_FRAMEWORK_FUNCTION_FAILED;
			return err;
		}
		while(CSSM_OK == err)
		{
			Count ++;
			err = MDSU_FindNext(&MdsuContext,
								&BioAPICapData,
								NULL);
		}
		*ElementsNeeded = Count;
	}
	else
	{
		if(ArraySize == 0)
			return BioAPI_ERRCODE_INVALID_DATA;
		Count = 0;
		CurrentSchemaPtr = BspSchemaArray;
		BioAPICapTemplate.SpecVersion.Major = BioAPI_MAJOR;
		BioAPICapTemplate.SpecVersion.Minor = BioAPI_MINOR;
		err = MDSU_FindFirst(&MdsuContext,
								 &IfiMdsuBioAPIBspCapabilitySchema,
								 &BioAPICapTemplate,
								 MDSU_BIOAPI_BSP_CAP_SPECVERSION,
								 &BioAPICapData,
								 NULL);
		if (CSSM_OK != err)
		{
			MDSU_Term( &MdsuContext );
			return err;
		}
		while(CSSM_OK == err)
		{
			Count ++;
			if(Count <= ArraySize)
			{
				memcpy(CurrentSchemaPtr, &BioAPICapData, sizeof(BioAPI_BSP_SCHEMA));
				CurrentSchemaPtr++;
			}
			err = MDSU_FindNext(&MdsuContext,
								&BioAPICapData,
								NULL);
		}
		if(Count > ArraySize)
		{
			*NumElementsReturned = ArraySize;
		}
		else
		{
			*NumElementsReturned = Count;
		}
		*ElementsNeeded = Count;
	}
	MDSU_Term( &MdsuContext );
	return (BioAPI_OK);

}
Ejemplo n.º 2
0
BioAPI_RETURN BioAPI
BioAPI_EnumDevices(const BioAPI_UUID *uuid,
									BioAPI_DEVICE_SCHEMA * DeviceSchemaArray,
									uint32 ArraySize,
									uint32 * ElementsNeeded,
									uint32 * NumElementsReturned)

{
	BioAPI_RETURN err;
	MDSU_CONTEXT MdsuContext;
	BioAPI_DEVICE_SCHEMA DeviceTemplate;
	BioAPI_DEVICE_SCHEMA DeviceData;
	BioAPI_DEVICE_SCHEMA * CurrentSchemaPtr;
	uint32 Count;

	/* Initialize in case of early return (usually caused by no installed devices) */
	*NumElementsReturned = 0;
	*ElementsNeeded = 0;

	if((err = MDSU_Init(&MdsuContext,
					&BioAPIMemoryFuncs,
					uuid,
					MDS_CDSA_DIRECTORY,
					(CSSM_DB_ACCESS_READ | CSSM_DB_ACCESS_WRITE),
					BIOAPI_MDS_COMMIT_SIZE)) != BioAPI_OK)
		return err;

	/* Handle the simple case first...NULL passed for DeviceSchemaArray */
	if(DeviceSchemaArray == NULL)
	{
		Count = 0;
		BioAPI_CopyUuid (DeviceTemplate.ModuleId, uuid);
		ERR(err = MDSU_FindFirst(&MdsuContext,
								 &IfiMdsuBioAPIBspDeviceSchema,
								 &DeviceTemplate,
								 MDSU_BIOAPI_DEV_MODULEID,
								 &DeviceData,
								 NULL));
		if (CSSM_OK != err)
		{
			MDSU_Term( &MdsuContext );
			return err;
		}
		while(CSSM_OK == err)
		{
			Count ++;
			err = MDSU_FindNext(&MdsuContext,
								&DeviceData,
								NULL);
		}
		*ElementsNeeded = Count;
	}
	else
	{
		if(ArraySize == 0)
			return BioAPI_ERRCODE_INVALID_DATA;
		Count = 0;
		CurrentSchemaPtr = DeviceSchemaArray;
		BioAPI_CopyUuid (DeviceTemplate.ModuleId, uuid);
		err = MDSU_FindFirst(&MdsuContext,
								 &IfiMdsuBioAPIBspCapabilitySchema,
								 &DeviceTemplate,
								 MDSU_BIOAPI_DEV_MODULEID,
								 &DeviceData,
								 NULL);
		if (CSSM_OK != err)
		{
			MDSU_Term( &MdsuContext );
			return err;
		}
		while(CSSM_OK == err)
		{
			Count ++;
			if(Count <= ArraySize)
			{
				memcpy(CurrentSchemaPtr, &DeviceData, sizeof(BioAPI_DEVICE_SCHEMA));
				CurrentSchemaPtr++;
			}
			err = MDSU_FindNext(&MdsuContext,
								&DeviceData,
								NULL);
		}
		if(Count > ArraySize)
		{
			*NumElementsReturned = ArraySize;
		}
		else
		{
			*NumElementsReturned = Count;
		}
		*ElementsNeeded = Count;
	}
	MDSU_Term( &MdsuContext );
	return (BioAPI_OK);

}
Ejemplo n.º 3
0
BioAPI_RETURN BioAPI INSTALL_ENTRY_NAME(
						const char *szModuleName,
						const char *szSearchPath,
						BioAPI_DATA *pCredential,
						INSTALL_ACTION Action,
						BioAPI_INSTALL_ERROR *pError )
{
	BioAPI_RETURN rv = BioAPI_OK;
	MDSU_CONTEXT MDSUContext;
	MDSU_CDSA_COMMON_SCHEMA Common;
	MDSU_CDSA_DL_PRIMARY_SCHEMA DLPrimary;
	MDSU_CDSA_DL_ENC_PRODUCT_SCHEMA DLEncProduct;


	/* Initialize the MDS update */
	if ( ( rv = MDSU_Init( &MDSUContext,
						   &Addin_APIMemFuncs,
						   &MODULE_GUID,
						   MDS_CDSA_DIRECTORY,
						   ( CSSM_DB_ACCESS_READ |
							 CSSM_DB_ACCESS_WRITE ),
						   DL_MDS_COMMIT_SIZE ) ) != CSSM_OK )
	{
		sprintf( pError->ErrorString, "MDS Error (Init): %X\n", rv );
		pError->ErrorCode = rv;
		return rv;
	}

	/* Place code to remove existing entries here */
	if ( ( rv = __CleanMDS( &MDSUContext ) ) != CSSM_OK )
	{
		sprintf( pError->ErrorString, "MDS Error (Clean): %X\n", rv );
		pError->ErrorCode = rv;
		MDSU_Term( &MDSUContext );
		return rv;
	}
	if ( Action == INSTALL_ACTION_UNINSTALL )
	{
		MDSU_Term( &MDSUContext );
		return rv;
	}

	/* Fill in the "easy" common schema structure */
	memcpy( &Common.ModuleID, &MODULE_GUID, sizeof(MODULE_GUID) );
	Common.Manifest = *pCredential;
	strcpy( Common.ModuleName, szModuleName );
	strcpy( Common.Path, szSearchPath );
	Common.CDSAVersion.Major = CSSM_MAJOR;
	Common.CDSAVersion.Minor = CSSM_MINOR;
	strcpy( Common.Desc, ADDIN_NAME );
	Common.DynamicFlag = CSSM_FALSE;
	Common.MultiThreadFlag = CSSM_FALSE;
	Common.ServiceMask = CSSM_SERVICE_DL;

	/* Insert the common schema record into the MDS */
	rv = MDSU_UpdateSchema( &MDSUContext,
							&IfiMdsuCdsadirCommonSchema,
							&Common,
							NULL );
	if ( rv != CSSM_OK )
	{
		sprintf( pError->ErrorString, "MDS Error (common-DL): %X\n", rv );
		pError->ErrorCode = rv;
		MDSU_Term( &MDSUContext );
		return rv;
	}

	/* Fill in the DL primary schema data */
	memcpy( &DLPrimary.ModuleID, &MODULE_GUID, sizeof(MODULE_GUID) );
	DLPrimary.SSID = ADDIN_DL_SUBSERVICE_ID;
	DLPrimary.Manifest.Data = NULL;
	DLPrimary.Manifest.Length = 0;
	strcpy( DLPrimary.ModuleName, szModuleName );
	DLPrimary.ProductVersion.Major = INTEL_FF_DSM_MAJOR_VER;
	DLPrimary.ProductVersion.Minor = INTEL_FF_DSM_MINOR_VER;
	strcpy( DLPrimary.Vendor, ADDIN_VENDOR_NAME );
	DLPrimary.DLType = CSSM_DL_FFS;
	DLPrimary.QueryLimitsFlag = CSSM_TRUE;
	memset(DLPrimary.SampleTypes, 0,
				sizeof(CSSM_SAMPLE_TYPE)*MDSU_MAX_VALUE_COUNT);
	DLPrimary.NumSampleTypes = 0;
	memset(DLPrimary.AclSubjectTypes, 0,
				  sizeof(CSSM_ACL_SUBJECT_TYPE)*MDSU_MAX_VALUE_COUNT);
	DLPrimary.NumAclSubjectTypes = 0;
	memset(DLPrimary.AclAuthTags, 0,
				sizeof(CSSM_ACL_AUTHORIZATION_TAG)*MDSU_MAX_VALUE_COUNT);
	DLPrimary.NumAclAuthTags = 0;
	DLPrimary.ConjunctiveOps[0] = CSSM_DB_NONE;
	DLPrimary.ConjunctiveOps[1] = CSSM_DB_AND;
	DLPrimary.ConjunctiveOps[2] = CSSM_DB_OR;
	DLPrimary.NumConjunctiveOps = 3;
	DLPrimary.RelationalOps[0] = CSSM_DB_EQUAL;
	DLPrimary.RelationalOps[1] = CSSM_DB_NOT_EQUAL;
	DLPrimary.NumRelationalOps = 2;

	/* Write the data to MDS */
	rv = MDSU_UpdateSchema( &MDSUContext,
							&IfiMdsuCdsadirDLPrimarySchema,
							&DLPrimary,
							NULL );
	if ( rv != CSSM_OK )
	{
		sprintf( pError->ErrorString, "MDS Error (DL Primary): %X\n", rv );
		pError->ErrorCode = rv;
		MDSU_Revert( &MDSUContext );
		MDSU_Term( &MDSUContext );
		return rv;
	}

	/* Fill in the DL encapsulated product schema data */
	memcpy( &DLEncProduct.ModuleID, &MODULE_GUID, sizeof(MODULE_GUID) );
	DLEncProduct.SSID = ADDIN_DL_SUBSERVICE_ID;
	strcpy( DLEncProduct.ProductDesc, "Intel FlatFile DL" );
	DLEncProduct.ProductVersion.Major = ADDIN_PRODUCT_VERSION_MAJOR;
	DLEncProduct.ProductVersion.Minor = ADDIN_PRODUCT_VERSION_MINOR;
	strcpy( DLEncProduct.ProductVendor, ADDIN_VENDOR_NAME );
	DLEncProduct.ProductFlags = 0;
	strcpy( DLEncProduct.StandardDesc, "Flatfile" );
	DLEncProduct.StandardVersion.Major = 0;
	DLEncProduct.StandardVersion.Minor = 0;
	DLEncProduct.Protocol = CSSM_NET_PROTO_NONE;
	DLEncProduct.RetrievalMode = 0;

	/* Write the data to MDS */
	rv = MDSU_UpdateSchema( &MDSUContext,
							&IfiMdsuCdsadirDLEncProductSchema,
							&DLEncProduct,
							NULL );
	if ( rv != CSSM_OK )
	{
		sprintf( pError->ErrorString, "MDS Error (DL Enc): %X\n", rv );
		pError->ErrorCode = rv;
		MDSU_Revert( &MDSUContext );
		MDSU_Term( &MDSUContext );
		return rv;
	}

	/* Commit the records */
	MDSU_Commit( &MDSUContext );

	/* Shut down the MDS connection */
	MDSU_Term( &MDSUContext );

	return BioAPI_OK;
}