mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 20:03:02 +01:00
Make sample of key holder plugin partially usable when chaining plugins
This commit is contained in:
parent
ff37d445ce
commit
c851e3d421
@ -29,6 +29,8 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
IMaster* master = NULL;
|
||||
|
||||
class PluginModule : public IPluginModuleImpl<PluginModule, CheckStatusWrapper>
|
||||
{
|
||||
public:
|
||||
@ -66,7 +68,8 @@ class CryptKeyHolder : public IKeyHolderPluginImpl<CryptKeyHolder, CheckStatusWr
|
||||
{
|
||||
public:
|
||||
explicit CryptKeyHolder(IPluginConfig* cnf) throw()
|
||||
: callbackInterface(this), named(NULL), config(cnf), key(0), owner(NULL)
|
||||
: callbackInterface(this), named(NULL), tempStatus(master->getStatus()),
|
||||
config(cnf), key(0), owner(NULL)
|
||||
{
|
||||
config->addRef();
|
||||
}
|
||||
@ -74,6 +77,7 @@ public:
|
||||
~CryptKeyHolder()
|
||||
{
|
||||
config->release();
|
||||
tempStatus.dispose();
|
||||
}
|
||||
|
||||
// IKeyHolderPlugin implementation
|
||||
@ -108,6 +112,9 @@ public:
|
||||
|
||||
ISC_UCHAR getKey()
|
||||
{
|
||||
if (!key)
|
||||
keyCallback(&tempStatus, NULL);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
@ -177,6 +184,7 @@ private:
|
||||
|
||||
CallbackInterface callbackInterface;
|
||||
NamedCallback *named;
|
||||
CheckStatusWrapper tempStatus;
|
||||
|
||||
IPluginConfig* config;
|
||||
ISC_UCHAR key;
|
||||
@ -212,9 +220,18 @@ int CryptKeyHolder::keyCallback(CheckStatusWrapper* status, ICryptKeyCallback* c
|
||||
{
|
||||
FB_BOOLEAN b = confEntry->getBoolValue();
|
||||
confEntry->release();
|
||||
|
||||
if (b)
|
||||
{
|
||||
key = 0x5a;
|
||||
confEntry = getEntry(status, "Key");
|
||||
if (confEntry)
|
||||
{
|
||||
key = confEntry->getIntValue();
|
||||
confEntry->release();
|
||||
}
|
||||
else
|
||||
key = 0x5a;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -281,8 +298,9 @@ Factory factory;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* master)
|
||||
extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* m)
|
||||
{
|
||||
master = m;
|
||||
IPluginManager* pluginManager = master->getPluginManager();
|
||||
|
||||
module.registerMe(pluginManager);
|
||||
|
@ -5,10 +5,18 @@
|
||||
|
||||
|
||||
|
||||
# Key{Name} - integer value, a key with name "Name" (i.e. when one issues "ALTER DATABASE ENCRYPT ...
|
||||
# KEY Doggy" configuration parameter KeyDoggy should be present).
|
||||
# Key - integer value, a key used to "encrypt" database (i.e. when one issues "ALTER DATABASE ENCRYPT ..."
|
||||
# without KEY clause configuration parameter Key is used). This key can be passed from client to server
|
||||
by the chain of sample key holders.
|
||||
|
||||
#Key = 90
|
||||
|
||||
|
||||
|
||||
# Key{Name} - integer value, a key with name "Name" (i.e. when one issues "ALTER DATABASE ENCRYPT ...
|
||||
# KEY Doggy" configuration parameter KeyDoggy should be present). Such keys can not be passed from client
|
||||
# to server.
|
||||
|
||||
#KeyDoggy = [0 - 255]
|
||||
|
||||
|
||||
@ -19,4 +27,3 @@
|
||||
|
||||
#OnlyOwnKey = true
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user