- Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathAuth.cpp
131 lines (117 loc) · 2.97 KB
/
Auth.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* 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"
#include"../common/Auth.h"
#include"ibase.h"
#include"../common/classes/ImplementHelper.h"
#include"../common/utils_proto.h"
#include"../common/db_alias.h"
usingnamespaceFirebird;
namespaceAuth {
WriterImplementation::WriterImplementation()
: current(*getDefaultMemoryPool(), ClumpletReader::WideUnTagged, MAX_DPB_SIZE),
result(*getDefaultMemoryPool(), ClumpletReader::WideUnTagged, MAX_DPB_SIZE),
plugin(*getDefaultMemoryPool()), type(*getDefaultMemoryPool()),
sequence(0)
{ }
voidWriterImplementation::store(ClumpletWriter* to, unsignedchar tag)
{
putLevel();
if (to)
{
to->deleteWithTag(tag);
to->insertBytes(tag, result.getBuffer(), result.getBufferLength());
}
}
voidWriterImplementation::reset()
{
result.clear();
current.clear();
sequence = 0;
}
voidWriterImplementation::add(Firebird::CheckStatusWrapper* st, constchar* name)
{
try
{
putLevel();
current.clear();
current.insertString(AuthReader::AUTH_NAME, name, strlen(name));
fb_assert(plugin.hasData());
if (plugin.hasData())
{
current.insertString(AuthReader::AUTH_PLUGIN, plugin);
}
type = "USER";
}
catch (const Firebird::Exception& ex)
{
ex.stuffException(st);
}
}
voidWriterImplementation::setPlugin(constchar* m)
{
plugin = m;
}
voidWriterImplementation::putLevel()
{
current.rewind();
if (current.isEof())
{
return;
}
current.insertString(AuthReader::AUTH_TYPE, type);
result.insertBytes(sequence++, current.getBuffer(), current.getBufferLength());
}
voidWriterImplementation::setType(Firebird::CheckStatusWrapper* st, constchar* value)
{
try
{
if (value)
type = value;
}
catch (const Firebird::Exception& ex)
{
ex.stuffException(st);
}
}
voidWriterImplementation::setDb(Firebird::CheckStatusWrapper* st, constchar* value)
{
try
{
if (value)
{
PathName target;
expandDatabaseName(value, target, NULL);
current.insertString(AuthReader::AUTH_SECURE_DB, target);
}
}
catch (const Firebird::Exception& ex)
{
ex.stuffException(st);
}
}
} // namespace Auth