2010-01-22 15:55:11 +01:00
|
|
|
/*
|
|
|
|
* PROGRAM: Firebird authentication
|
|
|
|
* MODULE: Auth.h
|
|
|
|
* DESCRIPTION: Implementation of interfaces, passed to plugins
|
|
|
|
* Plugins loader
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Initial
|
|
|
|
* Developer's Public License Version 1.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed AS IS,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing rights
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Alex Peshkov
|
|
|
|
* for the Firebird Open Source RDBMS project.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 Alex Peshkov <peshkoff at mail.ru>
|
|
|
|
* and all contributors signed below.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FB_AUTH_H
|
|
|
|
#define FB_AUTH_H
|
|
|
|
|
|
|
|
#include "../auth/AuthInterface.h"
|
|
|
|
#include "../common/classes/ClumpletWriter.h"
|
|
|
|
#include "../common/classes/init.h"
|
|
|
|
#include "../common/classes/array.h"
|
2010-01-26 16:18:45 +01:00
|
|
|
#include "../common/classes/fb_string.h"
|
2011-01-14 18:31:40 +01:00
|
|
|
#include "../common/classes/ImplementHelper.h"
|
2010-01-22 15:55:11 +01:00
|
|
|
|
|
|
|
namespace Auth {
|
|
|
|
|
2011-01-14 18:31:40 +01:00
|
|
|
bool legacy(const char* nm);
|
2010-01-22 15:55:11 +01:00
|
|
|
|
2011-05-19 18:24:46 +02:00
|
|
|
class WriterImplementation : public Firebird::AutoIface<IWriter, FB_AUTH_WRITER_VERSION>
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-01-14 18:31:40 +01:00
|
|
|
WriterImplementation(bool svcFlag);
|
2010-01-24 16:18:43 +01:00
|
|
|
|
2011-04-08 17:18:50 +02:00
|
|
|
void store(Firebird::ClumpletWriter& to);
|
2011-08-09 14:11:17 +02:00
|
|
|
void setMethod(const char* m);
|
2010-01-22 15:55:11 +01:00
|
|
|
|
2011-04-08 17:18:50 +02:00
|
|
|
// IWriter implementation
|
2011-01-14 18:31:40 +01:00
|
|
|
void FB_CARG reset();
|
2011-08-09 14:11:17 +02:00
|
|
|
void FB_CARG add(const char* name);
|
|
|
|
void FB_CARG setAttribute(unsigned char tag, const char* value);
|
2010-01-22 15:55:11 +01:00
|
|
|
|
|
|
|
private:
|
2011-08-09 14:11:17 +02:00
|
|
|
Firebird::ClumpletWriter current, result;
|
|
|
|
Firebird::string method;
|
2010-01-22 15:55:11 +01:00
|
|
|
unsigned int sequence;
|
|
|
|
unsigned char tag;
|
2011-08-09 14:11:17 +02:00
|
|
|
|
|
|
|
void putLevel();
|
2010-01-22 15:55:11 +01:00
|
|
|
};
|
|
|
|
|
2011-05-19 18:24:46 +02:00
|
|
|
class DpbImplementation : public Firebird::AutoIface<IDpbReader, FB_AUTH_DPB_READER_VERSION>
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DpbImplementation(Firebird::ClumpletWriter& base);
|
|
|
|
|
2011-04-08 17:18:50 +02:00
|
|
|
// IDpbReader implementation
|
2011-01-14 18:31:40 +01:00
|
|
|
int FB_CARG find(UCHAR tag);
|
|
|
|
void FB_CARG add(UCHAR tag, const void* bytes, unsigned int count);
|
|
|
|
void FB_CARG drop();
|
2010-01-22 15:55:11 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Firebird::ClumpletWriter* body;
|
|
|
|
};
|
|
|
|
|
2011-01-14 18:31:40 +01:00
|
|
|
//#define AUTH_DEBUG
|
2010-01-22 15:55:11 +01:00
|
|
|
|
|
|
|
#ifdef AUTH_DEBUG
|
2010-01-24 16:18:43 +01:00
|
|
|
|
2010-01-22 15:55:11 +01:00
|
|
|
// The idea of debug plugin is to send some data from server to client,
|
2010-01-25 07:40:49 +01:00
|
|
|
// modify them on client and return result (which becomes login name) to the server
|
2010-01-22 15:55:11 +01:00
|
|
|
|
2011-04-07 19:16:00 +02:00
|
|
|
class DebugServer : Firebird::StdIface<public Firebird::IPluginFactory, FB_PLUGINS_FACTORY_VERSION>
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-04-08 17:18:50 +02:00
|
|
|
// IPluginFactory implementation
|
2011-04-07 19:16:00 +02:00
|
|
|
Firebird::IInterface* FB_CARG createPlugin(const char* name, const char* configFile);
|
2011-01-14 18:31:40 +01:00
|
|
|
int FB_CARG release();
|
2010-01-22 15:55:11 +01:00
|
|
|
};
|
|
|
|
|
2011-04-07 19:16:00 +02:00
|
|
|
class DebugClient : public Firebird::StdIface<Firebird::IPluginFactory, FB_PLUGINS_FACTORY_VERSION>
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-04-08 17:18:50 +02:00
|
|
|
// IPluginFactory implementation
|
2011-04-07 19:16:00 +02:00
|
|
|
Firebird::IInterface* FB_CARG createPlugin(const char* name, const char* configFile);
|
2011-01-14 18:31:40 +01:00
|
|
|
int FB_CARG release();
|
2010-01-22 15:55:11 +01:00
|
|
|
};
|
|
|
|
|
2011-01-14 18:31:40 +01:00
|
|
|
class DebugServerInstance : public Firebird::StdPlugin<ServerInstance, FB_AUTH_SERVER_VERSION>
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
|
|
|
public:
|
2010-01-26 16:18:45 +01:00
|
|
|
DebugServerInstance();
|
|
|
|
|
2011-04-08 17:18:50 +02:00
|
|
|
// ServerInstance implementation
|
|
|
|
Result FB_CARG startAuthentication(bool isService, const char* dbName,
|
|
|
|
const unsigned char* dpb, unsigned int dpbSize,
|
|
|
|
IWriter* writerInterface);
|
|
|
|
Result FB_CARG contAuthentication(IWriter* writerInterface,
|
|
|
|
const unsigned char* data, unsigned int size);
|
|
|
|
void FB_CARG getData(const unsigned char** data, unsigned short* dataSize);
|
2011-01-14 18:31:40 +01:00
|
|
|
int FB_CARG release();
|
2010-01-24 16:18:43 +01:00
|
|
|
|
2010-01-22 15:55:11 +01:00
|
|
|
private:
|
2010-01-26 16:18:45 +01:00
|
|
|
Firebird::string str;
|
2010-01-22 15:55:11 +01:00
|
|
|
};
|
|
|
|
|
2011-01-14 18:31:40 +01:00
|
|
|
class DebugClientInstance : public Firebird::StdPlugin<ClientInstance, FB_AUTH_CLIENT_VERSION>
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
|
|
|
public:
|
2010-01-26 16:18:45 +01:00
|
|
|
DebugClientInstance();
|
|
|
|
|
2011-04-08 17:18:50 +02:00
|
|
|
// ClientInstance implementation
|
|
|
|
Result FB_CARG startAuthentication(bool isService, const char* dbName, IDpbReader* dpb);
|
|
|
|
Result FB_CARG contAuthentication(const unsigned char* data, unsigned int size);
|
|
|
|
void FB_CARG getData(const unsigned char** data, unsigned short* dataSize);
|
2011-01-14 18:31:40 +01:00
|
|
|
int FB_CARG release();
|
2010-01-24 16:18:43 +01:00
|
|
|
|
2010-01-22 15:55:11 +01:00
|
|
|
private:
|
2010-01-26 16:18:45 +01:00
|
|
|
Firebird::string str;
|
2010-01-22 15:55:11 +01:00
|
|
|
};
|
2010-01-24 16:18:43 +01:00
|
|
|
|
2010-01-22 15:55:11 +01:00
|
|
|
#endif // AUTH_DEBUG
|
|
|
|
|
|
|
|
} // namespace Auth
|
|
|
|
|
|
|
|
|
2010-01-24 16:18:43 +01:00
|
|
|
#endif // FB_AUTH_H
|