Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25147/src
Modified Files:
PyTime.cpp PyWinTypes.h win32security.i
Added Files:
win32security_sspi.cpp win32security_sspi.h
Log Message:
Some excellent sspi additions to win32security, and a number of tests
and demos, originally from Roger Upole.
Index: win32security.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** win32security.i 1 Oct 2004 00:16:20 -0000 1.20
--- win32security.i 6 Mar 2005 23:27:01 -0000 1.21
***************
*** 1,3 ****
--- 1,4 ----
/* File : win32security.i */
+ // $Id$
// @doc
***************
*** 8,12 ****
%}
-
[...1362 lines suppressed...]
+ PyWinObject_FreeWCHAR(((PKERB_PURGE_TKT_CACHE_REQUEST)inputbuf)->RealmName.Buffer);
+ }
+ break;
+ }
+ if (inputbuf!=NULL)
+ free(inputbuf);
+ if (outputbuf!=NULL)
+ (*pfnLsaFreeReturnBuffer)(outputbuf);
+ return ret;
+ }
+ %}
+
#define TOKEN_ADJUST_DEFAULT TOKEN_ADJUST_DEFAULT // Required to change the default ACL, primary group, or owner of an access token.
#define TOKEN_ADJUST_GROUPS TOKEN_ADJUST_GROUPS // Required to change the groups specified in an access token.
***************
*** 2896,2897 ****
--- 3584,3586 ----
#define DISABLE_MAX_PRIVILEGE DISABLE_MAX_PRIVILEGE
#define SANDBOX_INERT SANDBOX_INERT
+
--- NEW FILE: win32security_sspi.cpp ---
// SSPI objects for the win32security module, by Roger Upole
// $Id: win32security_sspi.cpp,v 1.1 2005/03/06 23:27:02 mhammond Exp $
// Currently this file contains only object definitions - the SSPI methods
// themselves are defined in win32security.i. In the future this may change.
// @doc - This file contains autoduck documentation
#include "PyWinTypes.h"
#include "structmember.h"
#include "PyWinObjects.h"
#include "PySecurityObjects.h"
#include "win32security_sspi.h"
#include "schannel.h"
////////////////////////////////////////////////////////////////////////
//
// PySecBufferDesc
//
////////////////////////////////////////////////////////////////////////
[...1179 lines suppressed...]
// @flag SECPKG_CRED_ATTR_NAMES|<o PyUnicode> - returns username that credentials represent
case SECPKG_CRED_ATTR_NAMES:
PSecPkgCredentials_NamesW cn;
cn=(PSecPkgCredentials_NamesW)&buf;
ret=PyWinObject_FromWCHAR(cn->sUserName);
(*psecurityfunctiontable->FreeContextBuffer)(cn->sUserName);
break;
// @flag SECPKG_ATTR_SUPPORTED_ALGS|Not supported yet
case SECPKG_ATTR_SUPPORTED_ALGS: // SecPkgCred_SupportedAlgs:
// @flag SECPKG_ATTR_CIPHER_STRENGTHS|Not supported yet
case SECPKG_ATTR_CIPHER_STRENGTHS: // SecPkgCred_CipherStrengths:
// @flag SECPKG_ATTR_SUPPORTED_PROTOCOLS|Not supported yet
case SECPKG_ATTR_SUPPORTED_PROTOCOLS: // SecPkgCred_SupportedProtocols:
default:
PyErr_SetString(PyExc_NotImplementedError,"Attribute is not supported yet");
}
return ret;
}
--- NEW FILE: win32security_sspi.h ---
// Definitions for the win32security sspi support, by Roger Upole
// $Id: win32security_sspi.h,v 1.1 2005/03/06 23:27:02 mhammond Exp $
#define SECURITY_WIN32
#include "Security.h"
// SecBuffer objects for SSPI functionality
extern __declspec(dllexport) PyTypeObject PySecBufferType;
extern BOOL PyWinObject_AsSecBuffer(PyObject *, PSecBuffer *, BOOL);
extern PyObject *PyWinObject_FromSecBuffer(PSecBuffer);
extern __declspec(dllexport) PyTypeObject PySecBufferDescType;
extern BOOL PyWinObject_AsSecBufferDesc(PyObject *, PSecBufferDesc *, BOOL);
extern PyObject *PyWinObject_FromSecBufferDesc(PSecBufferDesc);
// PyCtxtHandle object for SSPI support
extern __declspec(dllexport) PyTypeObject PyCtxtHandleType;
extern BOOL PyWinObject_AsCtxtHandle(PyObject *, PCtxtHandle *, BOOL);
extern PyObject *PyWinObject_FromCtxtHandle(PCtxtHandle);
extern __declspec(dllexport) PyTypeObject PyCredHandleType;
extern BOOL PyWinObject_AsCredHandle(PyObject *, PCredHandle *, BOOL);
extern PyObject *PyWinObject_FromCredHandle(PCredHandle);
extern PyObject *PyWinObject_FromSecPkgInfo(PSecPkgInfoW psecpkginfo);
extern PyObject *PyWinObject_FromSecHandle(PSecHandle h);
extern PSecurityFunctionTableW psecurityfunctiontable;
#define CHECK_SECURITYFUNCTIONTABLE(fname)if (psecurityfunctiontable==NULL||psecurityfunctiontable->fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname);
class PySecBuffer : public PyObject
{
public:
#ifdef _MSC_VER
#pragma warning( disable : 4251 )
#endif // _MSC_VER
static struct PyMemberDef members[];
static struct PyMethodDef methods[];
#ifdef _MSC_VER
#pragma warning( default : 4251 )
#endif // _MSC_VER
PySecBuffer(PSecBuffer psecbuffer);
PySecBuffer(ULONG cbBuffer, ULONG BufferType);
~PySecBuffer();
static void deallocFunc(PyObject *ob);
static PyObject *getattro(PyObject *self, PyObject *name);
static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue);
static PyObject *tp_new(PyTypeObject *, PyObject *, PyObject *);
static PyObject *Clear(PyObject *self, PyObject *args);
PSecBuffer GetSecBuffer(void);
PyObject *obdummy;
// InitializeSecurityContext and AcceptSecurityContext change the cbBuffer in the structure to reflect
// bytes used, keep our own allocated size
unsigned long maxbufsize;
protected:
SecBuffer secbuffer;
};
class PySecBufferDesc : public PyObject
{
public:
#ifdef _MSC_VER
#pragma warning( disable : 4251 )
#endif // _MSC_VER
static struct PyMemberDef members[];
static struct PyMethodDef methods[];
#ifdef _MSC_VER
#pragma warning( default : 4251 )
#endif // _MSC_VER
// ??? might need this, some protocols will allocate output buffers for you if ISC_REQ_ALLOCATE_MEMORY is specified
PySecBufferDesc(ULONG ulVersion);
PySecBufferDesc(PSecBufferDesc psecbufferdesc);
~PySecBufferDesc();
static void deallocFunc(PyObject *ob);
static PyObject *getattro(PyObject *self, PyObject *name);
static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue);
static PyObject *tp_new(PyTypeObject *, PyObject *, PyObject *);
static PySequenceMethods sequencemethods;
PSecBufferDesc GetSecBufferDesc(void);
PyObject **obBuffers;
unsigned long max_buffers;
static PyObject *append(PyObject *self, PyObject *args);
void modify_in_place(void);
protected:
SecBufferDesc secbufferdesc;
};
class PyCtxtHandle : public PyObject
{
public:
#ifdef _MSC_VER
#pragma warning( disable : 4251 )
#endif // _MSC_VER
static struct PyMemberDef members[];
static struct PyMethodDef methods[];
#ifdef _MSC_VER
#pragma warning( default : 4251 )
#endif // _MSC_VER
PyCtxtHandle(PCtxtHandle pctxthandle);
PyCtxtHandle(void);
~PyCtxtHandle();
static void deallocFunc(PyObject *ob);
static PyObject *getattro(PyObject *self, PyObject *name);
static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue);
static PyObject *tp_new(PyTypeObject *, PyObject *, PyObject *);
static PyObject *MakeSignature(PyObject *self, PyObject *args);
static PyObject *VerifySignature(PyObject *self, PyObject *args);
static PyObject *EncryptMessage(PyObject *self, PyObject *args);
static PyObject *DecryptMessage(PyObject *self, PyObject *args);
static PyObject *Detach(PyObject *self, PyObject *args);
static PyObject *DeleteSecurityContext(PyObject *self, PyObject *args);
static PyObject *CompleteAuthToken(PyObject *self, PyObject *args);
static PyObject *QueryContextAttributes(PyObject *self, PyObject *args);
static PyObject *QuerySecurityContextToken(PyObject *self, PyObject *args);
static PyObject *ImpersonateSecurityContext(PyObject *self, PyObject *args);
static PyObject *RevertSecurityContext(PyObject *self, PyObject *args);
PCtxtHandle GetCtxtHandle(void);
protected:
CtxtHandle ctxthandle;
};
class PyCredHandle : public PyObject
{
public:
#ifdef _MSC_VER
#pragma warning( disable : 4251 )
#endif // _MSC_VER
static struct PyMemberDef members[];
static struct PyMethodDef methods[];
#ifdef _MSC_VER
#pragma warning( default : 4251 )
#endif // _MSC_VER
PyCredHandle(PCredHandle);
PyCredHandle(void);
~PyCredHandle();
static void deallocFunc(PyObject *ob);
static PyObject *getattro(PyObject *self, PyObject *name);
static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue);
static PyObject *tp_new(PyTypeObject *, PyObject *, PyObject *);
static PyObject *Detach(PyObject *self, PyObject *args);
static PyObject *FreeCredentialsHandle(PyObject *self, PyObject *args);
static PyObject *QueryCredentialsAttributes(PyObject *self, PyObject *args);
PCredHandle GetCredHandle(void);
protected:
CredHandle credhandle;
};
Index: PyTime.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** PyTime.cpp 4 Mar 2005 11:56:55 -0000 1.13
--- PyTime.cpp 6 Mar 2005 23:27:01 -0000 1.14
***************
*** 127,130 ****
--- 127,140 ----
}
+ // Converts a TimeStamp, which is in 100 nanosecond units like a FILETIME
+ // See comments in pywintypes.h re LARGE_INTEGER vs TimeStamp
+ PyObject *PyWinObject_FromTimeStamp(const LARGE_INTEGER &ts)
+ {
+ FILETIME ft;
+ ft.dwHighDateTime=ts.HighPart;
+ ft.dwLowDateTime=ts.LowPart;
+ return new PyTime(ft);
+ }
+
BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate)
{
***************
*** 712,716 ****
return PyFloat_FromDouble(PyCE_SystemTimeToCTime(&st));
}
-
//PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate)
//{
--- 722,725 ----
Index: PyWinTypes.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** PyWinTypes.h 30 Nov 2004 21:30:29 -0000 1.25
--- PyWinTypes.h 6 Mar 2005 23:27:01 -0000 1.26
***************
*** 285,288 ****
--- 285,294 ----
PYWINTYPES_EXPORT PyObject *PyWinObject_FromFILETIME(const FILETIME &t);
+ // Converts a TimeStamp, which is in 100 nanosecond units like a FILETIME
+ // TimeStamp is actually defined as a LARGE_INTEGER, so this function will also
+ // accept Windows security "TimeStamp" objects directly - however, we use a
+ // LARGE_INTEGER prototype to avoid pulling in the windows security headers.
+ PYWINTYPES_EXPORT PyObject *PyWinObject_FromTimeStamp(const LARGE_INTEGER &t);
+
PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate);
PYWINTYPES_EXPORT BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate);
|