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"
|
2010-01-22 15:55:11 +01:00
|
|
|
|
|
|
|
namespace Auth {
|
|
|
|
|
|
|
|
bool legacy(Plugin* plugin);
|
|
|
|
|
|
|
|
class WriterImplementation : public WriterInterface, public Firebird::PermanentStorage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WriterImplementation(Firebird::MemoryPool&, bool svcFlag);
|
2010-01-24 16:18:43 +01:00
|
|
|
|
2010-01-22 15:55:11 +01:00
|
|
|
void store(Firebird::ClumpletWriter& to);
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
void add(const char* name, const char* method, const char* details);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Firebird::AuthWriter body;
|
|
|
|
unsigned int sequence;
|
|
|
|
unsigned char tag;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DpbImplementation : public DpbInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DpbImplementation(Firebird::ClumpletWriter& base);
|
|
|
|
|
|
|
|
int find(UCHAR tag);
|
2010-01-26 16:18:45 +01:00
|
|
|
void add(UCHAR tag, const void* bytes, unsigned int count);
|
2010-01-22 15:55:11 +01:00
|
|
|
void drop();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Firebird::ClumpletWriter* body;
|
|
|
|
};
|
|
|
|
|
|
|
|
//#define AUTH_DEBUG
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
class DebugServer : public ServerPlugin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ServerInstance* instance();
|
2010-01-27 17:51:26 +01:00
|
|
|
void getName(const char** data, unsigned short* dataSize);
|
2010-01-22 15:55:11 +01:00
|
|
|
void release();
|
|
|
|
};
|
|
|
|
|
|
|
|
class DebugClient : public ClientPlugin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ClientInstance* instance();
|
2010-01-27 17:51:26 +01:00
|
|
|
void getName(const char** data, unsigned short* dataSize);
|
2010-01-22 15:55:11 +01:00
|
|
|
void release();
|
|
|
|
};
|
|
|
|
|
|
|
|
class DebugServerInstance : public ServerInstance
|
|
|
|
{
|
|
|
|
public:
|
2010-01-26 16:18:45 +01:00
|
|
|
DebugServerInstance();
|
|
|
|
|
2010-01-22 15:55:11 +01:00
|
|
|
Result startAuthentication(bool isService, const char* dbName,
|
|
|
|
const unsigned char* dpb, unsigned int dpbSize,
|
|
|
|
WriterInterface* writerInterface);
|
|
|
|
Result contAuthentication(WriterInterface* writerInterface,
|
|
|
|
const unsigned char* data, unsigned int size);
|
2010-01-27 17:51:26 +01:00
|
|
|
void getData(const unsigned char** data, unsigned short* dataSize);
|
2010-01-22 15:55:11 +01:00
|
|
|
void 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
|
|
|
};
|
|
|
|
|
|
|
|
class DebugClientInstance : public ClientInstance
|
|
|
|
{
|
|
|
|
public:
|
2010-01-26 16:18:45 +01:00
|
|
|
DebugClientInstance();
|
|
|
|
|
2010-01-22 15:55:11 +01:00
|
|
|
Result startAuthentication(bool isService, const char* dbName, DpbInterface* dpb);
|
|
|
|
Result contAuthentication(const unsigned char* data, unsigned int size);
|
2010-01-27 17:51:26 +01:00
|
|
|
void getData(const unsigned char** data, unsigned short* dataSize);
|
2010-01-22 15:55:11 +01:00
|
|
|
void 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
|