void ItemAttributeMgr::Clear(Attr attr) { PyRep *oldValue = NULL; if(GetNotify() == true && !IsRechargable(attr)) { // get old value oldValue = PyGet(attr); } // clear the attribute EVEAdvancedAttributeMgr::Clear(attr); // delete the attribute from DB (no matter if it really is there) if(GetSave() == true) { m_factory.db().EraseAttribute(m_item.itemID(), attr); } if(GetNotify() == true) { std::map<Attr, TauCap>::const_iterator i = m_tauCap.find(attr); if(i != m_tauCap.end()) { // build the special list for rechargables PyList *l = new PyList; l->AddItem( PyGet( attr ) ); l->AddItemLong( Win32TimeNow() ); l->AddItem( _PyGet( GetReal( i->second.tau ) / 5.0 ) ); l->AddItem( PyGet( i->second.cap ) ); oldValue = l; } // send change _SendAttributeChange(attr, oldValue, new PyFloat(GetReal(attr))); } }
void ItemAttributeMgr::SetIntEx(Attr attr, const int_t &v, bool persist) { PyRep *oldValue = NULL; if(GetNotify() == true && !IsRechargable(attr)) { // get old value oldValue = PyGet(attr); } // set the attribute value EVEAdvancedAttributeMgr::SetInt(attr, v); // check if we shall save to DB if(GetSave() == true && (persist || IsPersistent(attr))) { // save to DB m_factory.db().UpdateAttribute_int(m_item.itemID(), attr, v); } if(GetNotify() == true) { std::map<Attr, TauCap>::const_iterator i = m_tauCap.find(attr); if(i != m_tauCap.end()) { // build the special list for rechargables PyList *l = new PyList; l->AddItemInt( v ); l->AddItemLong( Win32TimeNow() ); l->AddItem( _PyGet( GetReal( i->second.tau ) / 5.0 ) ); l->AddItem( PyGet( i->second.cap ) ); oldValue = l; } // send change _SendAttributeChange(attr, oldValue, new PyFloat(v)); } }
bp::object PyHandle::GetAttribute( const char *name ) { if( hasattr(PyGet(), name) ) return PyGet().attr("__getattribute__")(name); boost::python::object self = boost::python::object( boost::python::handle<>( boost::python::borrowed(GetPySelf()) ) ); Assert( self.ptr() != NULL ); return builtins.attr("object").attr("__getattribute__")(self, name); }
static PyObject *authGSSServerStep(PyObject *self, PyObject *args) { gss_server_state *state; PyObject *pystate; char *challenge = NULL; int result = 0; if (!PyArg_ParseTuple(args, "Os", &pystate, &challenge)) { return NULL; } if (!PyCheck(pystate)) { PyErr_SetString(PyExc_TypeError, "Expected a context object"); return NULL; } state = PyGet(pystate, gss_server_state); if (state == NULL) { return NULL; } result = authenticate_gss_server_step(state, challenge); if (result == AUTH_GSS_ERROR) { return NULL; } return Py_BuildValue("i", result); }
static PyObject *authGSSClientWrapIov(PyObject *self, PyObject *args) { gss_client_state *state; PyObject *pystate; char *challenge = NULL; int protect = 1; int result = 0; int pad_len = 0; if (!PyArg_ParseTuple(args, "Os|i", &pystate, &challenge, &protect)) { return NULL; } if (!PyCheck(pystate)) { PyErr_SetString(PyExc_TypeError, "Expected a context object"); return NULL; } state = PyGet(pystate, gss_client_state); if (state == NULL) { return NULL; } result = authenticate_gss_client_wrap_iov(state, challenge, protect, &pad_len); if (result == AUTH_GSS_ERROR) { return NULL; } return Py_BuildValue("ii", result, pad_len); }
boost::python::object PyHandle::Str() { if( Get() ) { bp::object pyinst = PyGet(); return pyinst.attr("__str__")(); } return boost::python::object( "None" ); }
static PyObject* authGSSWinRMEncryptMessage(PyObject* self, PyObject* args) { char *input = NULL; char *header = NULL; int header_len = 0; char *enc_output = NULL; int enc_output_len = 0; PyObject *pystate = NULL; gss_client_state *state = NULL; int result = 0; PyObject *pyresult = NULL; // NB: use et so we get a copy of the string (since gss_wrap_iov mutates it), and so we're certain it's always // a UTF8 byte string if (! PyArg_ParseTuple(args, "Oet", &pystate, "UTF-8", &input)) { pyresult = NULL; goto end; } if (!PyCheck(pystate)) { PyErr_SetString(PyExc_TypeError, "Expected a context object"); pyresult = NULL; goto end; } state = PyGet(pystate, gss_client_state); if (state == NULL) { pyresult = NULL; goto end; } result = encrypt_message(state, input, &header, &header_len, &enc_output, &enc_output_len); if (result == AUTH_GSS_ERROR) { pyresult = NULL; goto end; } #if PY_MAJOR_VERSION >= 3 pyresult = Py_BuildValue("y# y#", enc_output, enc_output_len, header, header_len); #else pyresult = Py_BuildValue("s# s#", enc_output, enc_output_len, header, header_len); #endif end: if (input) { PyMem_Free(input); } if (header) { free(header); } if (enc_output) { free(enc_output); } return pyresult; }
/* * EVEAdvancedAttributeMgr */ void EVEAdvancedAttributeMgr::EncodeAttributes(std::map<int32, PyRep *> &into) const { // integers first { std::map<Attr, int_t>::const_iterator cur, end; cur = m_ints.begin(); end = m_ints.end(); for(; cur != end; cur++) { if(into.find(cur->first) != into.end()) PyDecRef( into[cur->first] ); into[cur->first] = PyGet(cur->first); } } // then reals { std::map<Attr, real_t>::const_iterator cur, end; cur = m_reals.begin(); end = m_reals.end(); for(; cur != end; cur++) { if(into.find(cur->first) != into.end()) PyDecRef( into[cur->first] ); into[cur->first] = PyGet(cur->first); } } }
static PyObject *authGSSServerTargetName(PyObject *self, PyObject *args) { gss_server_state *state; PyObject *pystate; if (!PyArg_ParseTuple(args, "O", &pystate)) { return NULL; } if (!PyCheck(pystate)) { PyErr_SetString(PyExc_TypeError, "Expected a context object"); return NULL; } state = PyGet(pystate, gss_server_state); if (state == NULL) { return NULL; } return Py_BuildValue("s", state->targetname); }
static PyObject *authGSSClientResponse(PyObject *self, PyObject *args) { gss_client_state *state; PyObject *pystate; if (!PyArg_ParseTuple(args, "O", &pystate)) { return NULL; } if (!PyCheck(pystate)) { PyErr_SetString(PyExc_TypeError, "Expected a context object"); return NULL; } state = PyGet(pystate, gss_client_state); if (state == NULL) { return NULL; } return Py_BuildValue("s", state->response); }
static PyObject *authGSSClientStep(PyObject *self, PyObject *args, PyObject* keywds) { gss_client_state *state; PyObject *pystate; char *challenge = NULL; PyObject *pychan_bindings = NULL; struct gss_channel_bindings_struct *channel_bindings; static char *kwlist[] = {"state", "challenge", "channel_bindings", NULL}; int result = 0; if (! PyArg_ParseTupleAndKeywords(args, keywds, "Os|O", kwlist, &pystate, &challenge, &pychan_bindings)) { return NULL; } if (!PyCheck(pystate)) { PyErr_SetString(PyExc_TypeError, "Expected a context object"); return NULL; } state = PyGet(pystate, gss_client_state); if (state == NULL) { return NULL; } if (pychan_bindings == NULL) { channel_bindings = GSS_C_NO_CHANNEL_BINDINGS; } else { if (!PyCheck(pychan_bindings)) { PyErr_SetString(PyExc_TypeError, "Expected a gss_channel_bindings_struct object"); return NULL; } channel_bindings = PyGet(pychan_bindings, struct gss_channel_bindings_struct); } result = authenticate_gss_client_step(state, challenge, channel_bindings); if (result == AUTH_GSS_ERROR) { return NULL; } return Py_BuildValue("i", result); }
static PyObject* authGSSClientInit(PyObject* self, PyObject* args, PyObject* keywds) { const char *service = NULL; const char *principal = NULL; gss_client_state *state; PyObject *pystate; gss_OID mech_oid = GSS_C_NO_OID; PyObject *pymech_oid = NULL; static char *kwlist[] = {"service", "principal", "gssflags", "mech_oid", NULL}; long int gss_flags = GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG; int result = 0; if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|zlO", kwlist, &service, &principal, &gss_flags, &pymech_oid)) { return NULL; } if (pymech_oid != NULL) { if (!PyCheck(pymech_oid)) { PyErr_SetString(PyExc_TypeError, "Invalid type for mech_oid"); return NULL; } mech_oid = PyGet(pymech_oid, gss_OID_desc); if (mech_oid == NULL) { PyErr_SetString(PyExc_TypeError, "Invalid value for mech_oid"); return NULL; } } state = (gss_client_state *) malloc(sizeof(gss_client_state)); pystate = PyNew(state, &destruct_client); result = authenticate_gss_client_init(service, principal, gss_flags, mech_oid, state); if (result == AUTH_GSS_ERROR) { return NULL; } return Py_BuildValue("(iN)", result, pystate); }
bool PyHandle::operator!=( bp::object val ) const { return PyGet().ptr() != val.ptr(); }
bool PyHandle::operator!=( const PyHandle &val ) const { return PyGet().ptr() != val.PyGet().ptr(); }
void PyHandle::SetAttr( const char *name, bp::object v ) { PyGet().attr("__setattr__")(name, v); }
static PyObject* authGSSWinRMDecryptMessage(PyObject* self, PyObject* args) { char *header = NULL; int header_len = 0; char *enc_data = NULL; int enc_data_len = 0; PyObject *pystate = NULL; PyObject *pyheader = NULL; PyObject *pyenc_data = NULL; gss_client_state *state = NULL; char *dec_output = NULL; int dec_output_len = 0; int result = 0; PyObject *pyresult = 0; // NB: since the sig/data strings are arbitrary binary and don't conform to // a valid encoding, none of the normal string marshaling types will work. We'll // have to extract the data later. if (! PyArg_ParseTuple(args, "OOO", &pystate, &pyenc_data, &pyheader)) { pyresult = NULL; goto end; } if (!PyCheck(pystate)) { PyErr_SetString(PyExc_TypeError, "Expected a context object"); pyresult = NULL; goto end; } state = PyGet(pystate, gss_client_state); if (state == NULL) { pyresult = NULL; goto end; } // request the length and copy the header and encrypted input data from the Python strings header_len = (int) PyBytes_Size(pyheader); header = malloc(header_len); memcpy(header, PyBytes_AsString(pyheader), header_len); enc_data_len = (int) PyBytes_Size(pyenc_data); enc_data = malloc(enc_data_len); memcpy(enc_data, PyBytes_AsString(pyenc_data), enc_data_len); result = decrypt_message(state, header, header_len, enc_data, enc_data_len, &dec_output, &dec_output_len); if (result == AUTH_GSS_ERROR) { pyresult = NULL; goto end; } #if PY_MAJOR_VERSION >= 3 pyresult = Py_BuildValue("y#", dec_output, dec_output_len); #else pyresult = Py_BuildValue("s#", dec_output, dec_output_len); #endif end: if (header) { free(header); } if (enc_data) { free(enc_data); } if (dec_output) { free(dec_output); } return pyresult; }