Search a data object and read its content

5/10/2011 12:12:34 PM
Gravatar
Total Posts 26

Search a data object and read its content

Dear Ugo: I have tried to create a new data object with a photo file and all works perfectly. My doubt is in relation to find it again and "export" it to a file again. I can find the data object without problems with the following snippet:

Dim PlantillaDatos As New CryptokiCollection
PlantillaDatos.Add(New ObjectAttribute(ObjectAttribute.CKA_CLASS, CryptokiObject.CKO_DATA))
PlantillaDatos.Add(New ObjectAttribute(ObjectAttribute.CKA_LABEL, "Foto"))
Dim Colecciónobjetos As CryptokiCollection, objeto As Object
Colecciónobjetos = sess.Objects.Find(PlantillaDatos, 10)
If Colecciónobjetos.Count > 0 Then
        For Each objeto In Colecciónobjetos
              MessageBox.Show(objeto.label) 'Show the label for the data object

              'I create the file in my hard disk.
              Dim s As FileStream = New FileStream("d:\temp\foto1.bmp", FileMode.Create)

              ?????????????????????????
              s.Close()
        Next
End If
 

I don´t know how to extract the byte array from the data object in order to create the file again in my hard disk.

 

Thank you very much in advanced.

5/10/2011 12:36:54 PM
Gravatar
Total Posts 26

Re: Search a data object and read its content

Ugo, I´m very sorry, but I found the solution to my own question. I have to use Data Class. Thank you very much.