The libsecret is a library for storing and retrieving passwords and others secrets. The library uses the Secret Service API provided by Gnome Keyring or KDE Wallet. This library provides an Ada binding to the Secret Service API.
On Ubuntu, you may have to install the following packages:
sudo apt-get install libsecret-1-dev libglib2.0-dev
alr with secretada
The unit tests are built and executed with:
make test
And the samples are built using:
gprbuild -p -Psamples
First, add a with clause for the secret GNAT project, in your GNAT project file add this line:
with "secretada";
You can store a secret by using the following code extract:
with Secret.Services;
with Secret.Attributes;
with Secret.Values;
...
Service : Secret.Services.Service_Type;
List : Secret.Attributes.Map;
Value : Secret.Values.Secret_Type;
...
Service.Initialize;
List.Insert ("secret identification key", "secret identification value");
Value := Secret.Values.Create ("the-secret-to-store");
Service.Store (List, "The secret label (for the keyring manager)", Value);
And you will retrieve it with:
Value := Service.Lookup (List);
if not Value.Is_Null then
Ada.Text_IO.Put_Line (Value.Get_Value);
end if;
The samples provide a simple secret-tool program that allows to create, retrieve or delete a secret from the secret service API. You can add a secret using:
bin/secret-tool set my-secret
and retrieve it later with:
bin/secret-tool get