PIBIO_STORAGE_CREATE_DATABASE_FN 콜백 함수(winbio_adapter.h)
새 데이터베이스를 만들고 구성하기 위해 Windows 생체 인식 프레임워크에서 호출됩니다.
구문
PIBIO_STORAGE_CREATE_DATABASE_FN PibioStorageCreateDatabaseFn;
HRESULT PibioStorageCreateDatabaseFn(
[in, out] PWINBIO_PIPELINE Pipeline,
[in] PWINBIO_UUID DatabaseId,
[in] WINBIO_BIOMETRIC_TYPE Factor,
[in] PWINBIO_UUID Format,
[in] LPCWSTR FilePath,
[in] LPCWSTR ConnectString,
[in] SIZE_T IndexElementCount,
[in] SIZE_T InitialSize
)
{...}
매개 변수
[in, out] Pipeline
작업을 수행하는 생체 인식 단위와 연결된 WINBIO_PIPELINE 구조체에 대한 포인터입니다.
[in] DatabaseId
데이터베이스를 고유하게 식별하는 GUID에 대한 포인터입니다. 레지스트리에 데이터베이스를 등록하는 데 사용되는 GUID와 동일합니다.
[in] Factor
이 데이터베이스에 저장된 생체 인식 요소의 유형을 지정하는 WINBIO_BIOMETRIC_TYPE 값입니다. 현재 는 WINBIO_TYPE_FINGERPRINT 만 지원됩니다.
[in] Format
WINBIO_BIR 개체의 VendorDataBlock 멤버에 있는 데이터의 공급업체 정의 형식을 지정하는 GUID 에 대한 포인터입니다.
[in] FilePath
데이터베이스에 대한 정규화된 파일 경로가 포함된 NULL로 종료된 유니코드 문자열에 대한 포인터입니다.
[in] ConnectString
데이터베이스에 대한 NULL 종료 유니코드 연결 문자열 대한 포인터입니다.
[in] IndexElementCount
인덱스 벡터의 요소 수입니다. 이 값은 0보다 크거나 같을 수 있습니다.
[in] InitialSize
데이터베이스의 시작 크기(바이트)를 포함하는 값입니다.
반환 값
함수가 성공하면 S_OK를 반환합니다. 함수가 실패하는 경우 오류를 나타내려면 다음 HRESULT 값 중 하나를 반환해야 합니다.
반환 코드 | 설명 |
---|---|
|
필수 포인터 인수는 NULL입니다. |
|
파이프라인 개체의 StorageContext 멤버는 NULL입니다. |
설명
생체 인식 서비스는 StorageAdapterOpenDatabase 함수가 실패하고 자동 만들기 플래그가 레지스트리의 데이터베이스와 연결된 경우 이 메서드를 호출합니다.
이 함수가 성공하면 데이터베이스가 열린 상태로 남아 있어야 합니다. Windows 생체 인식 프레임워크는 이 함수에 대한 후속 호출을 실행하지 않습니다.
예제
다음 의사 코드는 이 함수의 가능한 구현 중 하나를 보여 줍니다. 이 예제는 컴파일되지 않습니다. 목적에 맞게 조정해야 합니다.
/////////////////////////////////////////////////////////////////////////////////////////
//
// StorageAdapterCreateDatabase
//
// Purpose:
// Creates and configures a new database.
//
// Parameters:
// Pipeline - Pointer to a WINBIO_PIPELINE structure associated with
// the biometric unit performing the operation.
// DatabaseId - Pointer to a GUID that uniquely identifies the database.
// Factor - A WINBIO_BIOMETRIC_TYPE value that specifies the type
// of the biometric factor stored in the database.
// Format - Pointer to a GUID that specifies the vendor-defined format
// of the data
// FilePath - Pointer to the database file path.
// ConnectString - Pointer to the database connection string.
// IndexElementCount - Number of elements in the index vector.
// InitialSize - Beginning size of the database, in bytes.
//
// Note:
// The following example assumes that the database file has the following format:
//
// [protected area]
// [header]
// [record 0]
// [record 1]
// .
// .
// .
// [record N]
//
// It is the responsibility of the storage adapter writer to implement protection
// and to determine how and where encryption keys are stored.
//
static HRESULT
WINAPI
StorageAdapterCreateDatabase(
__inout PWINBIO_PIPELINE Pipeline,
__in PWINBIO_UUID DatabaseId,
__in WINBIO_BIOMETRIC_TYPE Factor,
__in PWINBIO_UUID Format,
__in LPCWSTR FilePath,
__in LPCWSTR ConnectString,
__in SIZE_T IndexElementCount,
__in SIZE_T InitialSize
)
{
UNREFERENCED_PARAMETER(InitialSize);
HRESULT hr = S_OK;
struct _MY_ADAPTER_FILE_HEADER fileHeader = {0};
BOOL fileOpen = FALSE;
HANDLE fileHandle = INVALID_HANDLE_VALUE;
struct _MY_ADAPTER_DPAPI_DATA protectedData = {0};
// Verify that pointer arguments are not NULL.
if (!ARGUMENT_PRESENT(Pipeline) ||
!ARGUMENT_PRESENT(DatabaseId) ||
!ARGUMENT_PRESENT(Format) ||
!ARGUMENT_PRESENT(FilePath) ||
!ARGUMENT_PRESENT(ConnectString))
{
hr = E_POINTER;
goto cleanup;
}
// Retrieve the context from the pipeline.
PWINBIO_STORAGE_CONTEXT storageContext =
(PWINBIO_STORAGE_CONTEXT)Pipeline->StorageContext;
// Verify the pipeline state.
if (storageContext == NULL ||
Pipeline->StorageHandle != INVALID_HANDLE_VALUE)
{
hr = WINBIO_E_INVALID_DEVICE_STATE;
goto cleanup;
}
// Call a custom function (_InitializeFileHeader) to copy database
// attributes into a structure to be used by the file management routines
// in the adapter.
hr = _InitializeFileHeader(
DatabaseId,
Factor,
Format,
IndexElementCount,
&fileHeader
);
if (FAILED(hr))
{
hr = WINBIO_E_DATABASE_CANT_CREATE;
goto cleanup;
}
// Call a custom file management function (_CreateDatabase) to create
// and open the database. Because the database is new, this function
// should generate a random key that can be used to encrypt and
// decrypt biometric templates stored in the database. The key should be
// saved in the protected data area of the file. We recommend that you
// encrypt the key by using the Data Protection API (DPAPI).
hr = _CreateDatabase(
&fileHeader,
FilePath,
&fileHandle,
&protectedData
);
if (FAILED(hr))
{
goto cleanup;
}
fileOpen = TRUE;
// Call a custom function (_InitializeCryptoContext) to extract the template
// decryption key from the protected block of the database and use other
// appropriate values from that block as necessary to set up CNG cryptography
// algorithms. This function should associate the CNG cryptography handles
// with the storage context.
hr = _InitializeCryptoContext(
&protectedData,
&storageContext->CryptoContext
);
if (FAILED(hr))
{
hr = WINBIO_E_DATABASE_CANT_CREATE;
goto cleanup;
}
// Attach the database file handle to the pipeline.
Pipeline->StorageHandle = fileHandle;
fileHandle = INVALID_HANDLE_VALUE;
// Copy various database parameters to the storage context. The following
// example code assumes that the context contains fields for the following
// items:
// - Number of index elements
// - File version number
// - Template format
// - Database ID
// - Database file path
storageContext->IndexElementCount = IndexElementCount;
CopyMemory(
&storageContext->TemplateFormat,
&fileHeader.TemplateFormat,
sizeof(WINBIO_UUID)
);
storageContext->Version = fileHeader.Version;
CopyMemory(
&storageContext->DatabaseId,
DatabaseId,
sizeof(WINBIO_UUID)
);
wcsncpy_s(
storageContext->FilePath,
MAX_PATH+1,
FilePath,
MAX_PATH
);
// TODO: Copy other values as necessary to the storage context (not shown).
cleanup:
if (FAILED(hr))
{
_CleanupCryptoContext(&storageContext->CryptoContext);
if (fileOpen)
{
CloseHandle(fileHandle);
fileHandle = INVALID_HANDLE_VALUE;
}
}
// Call the SecureZeroMemory function to overwrite the template encryption key
// on the stack.
SecureZeroMemory( &protectedData, sizeof(struct _MY_ADAPTER_DPAPI_DATA));
return hr;
}
요구 사항
요구 사항 | 값 |
---|---|
지원되는 최소 클라이언트 | Windows 7 [데스크톱 앱만 해당] |
지원되는 최소 서버 | Windows Server 2008 R2 [데스크톱 앱만 해당] |
대상 플랫폼 | Windows |
헤더 | winbio_adapter.h(Winbio_adapter.h 포함) |