2010-01-22 15:55:11 +01:00
|
|
|
/*
|
|
|
|
* PROGRAM: Firebird authentication
|
|
|
|
* MODULE: Auth.cpp
|
|
|
|
* 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): ______________________________________.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "firebird.h"
|
2010-10-12 10:02:57 +02:00
|
|
|
#include "../common/Auth.h"
|
2010-01-22 15:55:11 +01:00
|
|
|
#include "../jrd/ibase.h"
|
2010-07-23 14:04:18 +02:00
|
|
|
#include "../common/classes/ImplementHelper.h"
|
2011-06-08 08:38:32 +02:00
|
|
|
#include "../common/utils_proto.h"
|
2010-01-22 15:55:11 +01:00
|
|
|
|
2011-08-09 14:11:17 +02:00
|
|
|
using namespace Firebird;
|
|
|
|
|
2010-01-22 15:55:11 +01:00
|
|
|
namespace Auth {
|
|
|
|
|
2011-01-14 18:31:40 +01:00
|
|
|
WriterImplementation::WriterImplementation(bool svcFlag)
|
2011-08-09 14:11:17 +02:00
|
|
|
: current(*getDefaultMemoryPool(), ClumpletReader::WideUnTagged, MAX_DPB_SIZE),
|
|
|
|
result(*getDefaultMemoryPool(), ClumpletReader::WideUnTagged, MAX_DPB_SIZE),
|
|
|
|
method(*getDefaultMemoryPool()),
|
2011-05-19 18:24:46 +02:00
|
|
|
sequence(0), tag(svcFlag ? isc_spb_auth_block : isc_dpb_auth_block)
|
2010-01-22 15:55:11 +01:00
|
|
|
{ }
|
|
|
|
|
2011-08-09 14:11:17 +02:00
|
|
|
void WriterImplementation::store(ClumpletWriter& to)
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
2011-08-09 14:11:17 +02:00
|
|
|
putLevel();
|
2010-01-22 15:55:11 +01:00
|
|
|
to.deleteWithTag(tag);
|
2011-08-09 14:11:17 +02:00
|
|
|
to.insertBytes(tag, result.getBuffer(), result.getBufferLength());
|
2010-01-22 15:55:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void WriterImplementation::reset()
|
|
|
|
{
|
2011-08-09 14:11:17 +02:00
|
|
|
result.clear();
|
|
|
|
current.clear();
|
2010-01-22 15:55:11 +01:00
|
|
|
sequence = 0;
|
|
|
|
}
|
|
|
|
|
2011-08-09 14:11:17 +02:00
|
|
|
void WriterImplementation::add(const char* name)
|
|
|
|
{
|
|
|
|
putLevel();
|
|
|
|
|
|
|
|
current.clear();
|
|
|
|
current.insertString(AuthReader::AUTH_NAME, name);
|
|
|
|
fb_assert(method.hasData());
|
|
|
|
if (method.hasData())
|
|
|
|
{
|
|
|
|
current.insertString(AuthReader::AUTH_METHOD, method);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriterImplementation::setMethod(const char* m)
|
|
|
|
{
|
|
|
|
method = m;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriterImplementation::putLevel()
|
|
|
|
{
|
|
|
|
current.rewind();
|
|
|
|
if (current.isEof())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
result.insertBytes(sequence++, current.getBuffer(), current.getBufferLength());
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriterImplementation::setAttribute(unsigned char tag, const char* value)
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
2011-08-09 14:11:17 +02:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
current.insertString(tag, value);
|
|
|
|
}
|
2010-01-22 15:55:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-09 14:11:17 +02:00
|
|
|
DpbImplementation::DpbImplementation(ClumpletWriter& base)
|
2010-01-22 15:55:11 +01:00
|
|
|
: body(&base)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
int DpbImplementation::find(UCHAR tag)
|
|
|
|
{
|
|
|
|
return body->find(tag) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2010-01-26 16:18:45 +01:00
|
|
|
void DpbImplementation::add(UCHAR tag, const void* bytes, unsigned int count)
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
|
|
|
body->insertBytes(tag, bytes, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DpbImplementation::drop()
|
|
|
|
{
|
|
|
|
body->deleteClumplet();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 18:31:40 +01:00
|
|
|
bool legacy(const char* nm)
|
2010-01-22 15:55:11 +01:00
|
|
|
{
|
|
|
|
const char* legacyTrusted = "WIN_SSPI";
|
|
|
|
|
2011-06-08 08:38:32 +02:00
|
|
|
return fb_utils::stricmp(legacyTrusted, nm) == 0;
|
2010-01-22 15:55:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Auth
|