8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-29 06:43:03 +01:00
firebird-mirror/src/auth/trusted/AuthSspi.h

70 lines
1.6 KiB
C
Raw Normal View History

2006-12-17 10:09:39 +01:00
#ifndef AUTH_SSPI_H
#define AUTH_SSPI_H
2006-12-08 19:38:15 +01:00
#include <firebird.h>
#ifdef TRUSTED_AUTH
#include <../common/classes/fb_string.h>
#include <../common/classes/array.h>
#include <../jrd/ibase.h>
#define SECURITY_WIN32
#include <windows.h>
#include <Security.h>
#include <stdio.h>
class AuthSspi
{
private:
enum {BUFSIZE = 4096};
SecHandle secHndl;
bool hasCredentials;
CtxtHandle ctxtHndl;
bool hasContext;
Firebird::string ctName;
2008-01-16 06:58:53 +01:00
bool wheel;
2007-01-26 02:24:48 +01:00
// Handle of library
static HINSTANCE library;
2007-01-26 02:24:48 +01:00
// declare entries, required from secur32.dll
ACQUIRE_CREDENTIALS_HANDLE_FN_A fAcquireCredentialsHandle;
DELETE_SECURITY_CONTEXT_FN fDeleteSecurityContext;
FREE_CREDENTIALS_HANDLE_FN fFreeCredentialsHandle;
QUERY_CONTEXT_ATTRIBUTES_FN_A fQueryContextAttributes;
FREE_CONTEXT_BUFFER_FN fFreeContextBuffer;
INITIALIZE_SECURITY_CONTEXT_FN_A fInitializeSecurityContext;
ACCEPT_SECURITY_CONTEXT_FN fAcceptSecurityContext;
2007-02-02 11:56:53 +01:00
bool checkAdminPrivilege(PCtxtHandle phContext) const;
bool initEntries();
2006-12-08 19:38:15 +01:00
public:
typedef Firebird::Array<unsigned char> DataHolder;
AuthSspi();
~AuthSspi();
2008-12-05 01:56:15 +01:00
// true when has non-empty security context,
2006-12-17 16:51:27 +01:00
// ready to be sent to the other side
2006-12-17 10:09:39 +01:00
bool isActive() const
2006-12-08 19:38:15 +01:00
{
return hasContext;
}
2006-12-17 16:51:27 +01:00
// prepare security context to be sent to the server (used by client)
2006-12-08 19:38:15 +01:00
bool request(DataHolder& data);
2008-12-05 01:56:15 +01:00
2006-12-17 16:51:27 +01:00
// accept security context from the client (used by server)
2006-12-08 19:38:15 +01:00
bool accept(DataHolder& data);
2006-12-17 16:51:27 +01:00
2006-12-20 09:22:16 +01:00
// returns Windows user name, matching accepted security context
2008-01-16 06:58:53 +01:00
bool getLogin(Firebird::string& login, bool& wh);
2006-12-08 19:38:15 +01:00
};
2006-12-10 01:16:00 +01:00
#endif // TRUSTED_AUTH
2006-12-17 10:09:39 +01:00
#endif // AUTH_SSPI_H