Exemple #1
0
PyObject *xmlsec_KeyInfoCtxCreate(PyObject *self, PyObject *args) {
  PyObject *mngr_obj;
  xmlSecKeysMngrPtr mngr = NULL;
  xmlSecKeyInfoCtxPtr keyInfoCtx;

  if (CheckArgs(args, "o:keyInfoCtxCreate")) {
    if (!PyArg_ParseTuple(args, "O:keyInfoCtxCreate", &mngr_obj))
      return NULL;
  }
  else return NULL;

  mngr = xmlSecKeysMngrPtr_get(mngr_obj);
  /* mngr may be NULL */
  keyInfoCtx = xmlSecKeyInfoCtxCreate(mngr);

  return (wrap_xmlSecKeyInfoCtxPtr(keyInfoCtx));
}
Exemple #2
0
static xmlSecKeyPtr xmlsec_GetKeyCallback(xmlNodePtr keyInfoNode,
					  xmlSecKeyInfoCtxPtr keyInfoCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(GetKeyCallbacks,
		       keyInfoCtx->keysMngr->keysStore->id->name);

  args = Py_BuildValue((char *) "OO", wrap_xmlNodePtr(keyInfoNode),
		       wrap_xmlSecKeyInfoCtxPtr(keyInfoCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (xmlSecKeyPtr_get(result));
}
Exemple #3
0
static int xmlsec_KeyDataXmlWriteMethod(xmlSecKeyDataId id, xmlSecKeyPtr key,
					xmlNodePtr node,
					xmlSecKeyInfoCtxPtr keyInfoCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyDataXmlWriteMethods, id->name);

  args = Py_BuildValue((char *) "OOOO", wrap_xmlSecKeyDataId(id),
		       wrap_xmlSecKeyPtr(key), wrap_xmlNodePtr(node),
		       wrap_xmlSecKeyInfoCtxPtr(keyInfoCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
Exemple #4
0
static xmlSecKeyPtr xmlsec_KeyStoreFindKeyMethod(xmlSecKeyStorePtr store,
						 xmlChar *name,
						 xmlSecKeyInfoCtxPtr keyInfoCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyStoreFindKeyMethods, store->id->name);

  args = Py_BuildValue((char *) "OsO", wrap_xmlSecKeyStorePtr(store), name,
		       wrap_xmlSecKeyInfoCtxPtr(keyInfoCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  if (result == NULL) {
    return (NULL);
  }
  Py_DECREF(func);
  Py_DECREF(args);

  return (xmlSecKeyPtr_get(result));
}
Exemple #5
0
static int xmlsec_KeyDataBinReadMethod(xmlSecKeyDataId id,
				      xmlSecKeyPtr key,
				      const xmlSecByte *buf,
				      xmlSecSize bufSize,
				      xmlSecKeyInfoCtxPtr keyInfoCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyDataBinReadMethods, id->name);

  args = Py_BuildValue((char *) "OOsiO", wrap_xmlSecKeyDataId(id),
		       wrap_xmlSecKeyPtr(key), buf, bufSize,
		       wrap_xmlSecKeyInfoCtxPtr(keyInfoCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
Exemple #6
0
PyObject *xmlSecDSigCtx_getattr(PyObject *self, PyObject *args) {
  PyObject *dsigCtx_obj;
  xmlSecDSigCtxPtr dsigCtx;
  const char *attr;

  if (CheckArgs(args, "OS:dsigCtxGetAttr")) {
    if (!PyArg_ParseTuple(args, "Os:dsigCtxGetAttr", &dsigCtx_obj, &attr))
      return NULL;
  }
  else return NULL;

  dsigCtx = xmlSecDSigCtxPtr_get(dsigCtx_obj);

  if (!strcmp(attr, "__members__"))
    return Py_BuildValue("[sssssssssssssssssssss]", "flags",
			 "flags2", "keyInfoReadCtx", "keyInfoWriteCtx",
			 "transformCtx", "enabledReferenceUris",
			 "enabledReferenceTransforms",
			 "defSignMethodId",
			 "defC14NMethodId", "defDigestMethodId",
			 "signKey", "operation", "result", "status",
			 "signMethod", "c14nMethod", "preSignMemBufMethod",
			 "signValueNode", "id", "signedInfoReferences",
			 "manifestReferences");
  if (!strcmp(attr, "flags")) return (wrap_int(dsigCtx->flags));
  if (!strcmp(attr, "flags2")) return (wrap_int(dsigCtx->flags2));
  if (!strcmp(attr, "keyInfoReadCtx"))
    return (wrap_xmlSecKeyInfoCtxPtr(&(dsigCtx->keyInfoReadCtx)));
  if (!strcmp(attr, "keyInfoWriteCtx"))
    return (wrap_xmlSecKeyInfoCtxPtr(&(dsigCtx->keyInfoWriteCtx)));
  if (!strcmp(attr, "transformCtx"))
    return (wrap_xmlSecTransformCtxPtr(&(dsigCtx->transformCtx)));
  if (!strcmp(attr, "enabledReferenceUris"))
    return (wrap_int(dsigCtx->enabledReferenceUris));
  if (!strcmp(attr, "enabledReferenceTransforms"))
    return (wrap_xmlSecPtrListPtr(dsigCtx->enabledReferenceTransforms));
  if (!strcmp(attr, "defSignMethodId"))
    return (wrap_xmlSecTransformId(dsigCtx->defSignMethodId));
  if (!strcmp(attr, "defC14NMethodId"))
    return (wrap_xmlSecTransformId(dsigCtx->defC14NMethodId));
  if (!strcmp(attr, "defDigestMethodId"))
    return (wrap_xmlSecTransformId(dsigCtx->defDigestMethodId));
  if (!strcmp(attr, "signKey")) return (wrap_xmlSecKeyPtr(dsigCtx->signKey));
  if (!strcmp(attr, "operation")) return (wrap_int(dsigCtx->operation));
  if (!strcmp(attr, "result")) return (wrap_xmlSecBufferPtr(dsigCtx->result));
  if (!strcmp(attr, "status")) return (wrap_int(dsigCtx->status));
  if (!strcmp(attr, "signMethod"))
    return (wrap_xmlSecTransformPtr(dsigCtx->signMethod));
  if (!strcmp(attr, "c14nMethod"))
    return (wrap_xmlSecTransformPtr(dsigCtx->c14nMethod));
  if (!strcmp(attr, "preSignMemBufMethod"))
    return (wrap_xmlSecTransformPtr(dsigCtx->preSignMemBufMethod));
  if (!strcmp(attr, "signValueNode"))
    return (wrap_xmlNodePtr(dsigCtx->signValueNode));
  if (!strcmp(attr, "id")) return (wrap_xmlCharPtr(dsigCtx->id));
  if (!strcmp(attr, "signedInfoReferences"))
    return (wrap_xmlSecPtrListPtr(&(dsigCtx->signedInfoReferences)));
  if (!strcmp(attr, "manifestReferences"))
    return (wrap_xmlSecPtrListPtr(&(dsigCtx->manifestReferences)));
  Py_INCREF(Py_None);
  return (Py_None);
}
Exemple #7
0
PyObject *xmlSecEncCtx_getattr(PyObject *self, PyObject *args) {
  PyObject *encCtx_obj;
  xmlSecEncCtxPtr encCtx;
  const char *attr;

  if (CheckArgs(args, "OS:encCtxGetAttr")) {
    if (!PyArg_ParseTuple(args, "Os:encCtxGetAttr",
			  &encCtx_obj, &attr))
      return NULL;
  }
  else return NULL;

  encCtx = xmlSecEncCtxPtr_get(encCtx_obj);

  if (!strcmp(attr, "__members__"))
    return Py_BuildValue("[sssssssssssssssssssssss]", "flags",
			 "flags2", "mode", "keyInfoReadCtx", "keyInfoWriteCtx",
			 "transformCtx", "defEncMethodId",
			 "encKey", "operation", "result", "resultBase64Encoded",
			 "resultReplaced", "encMethod",
			 "id", "type", "mimeType", "encoding", "recipient",
			 "carriedKeyName", "encDataNode", "encMethodNode",
			 "keyInfoNode", "cipherValueNode");
  if (!strcmp(attr, "flags"))
    return (wrap_int(encCtx->flags));
  if (!strcmp(attr, "flags2"))
    return (wrap_int(encCtx->flags2));
  if (!strcmp(attr, "mode"))
    return (wrap_int(encCtx->mode));
  if (!strcmp(attr, "keyInfoReadCtx"))
    return (wrap_xmlSecKeyInfoCtxPtr(&(encCtx->keyInfoReadCtx)));
  if (!strcmp(attr, "keyInfoWriteCtx"))
    return (wrap_xmlSecKeyInfoCtxPtr(&(encCtx->keyInfoWriteCtx)));
  if (!strcmp(attr, "transformCtx"))
    return (wrap_xmlSecTransformCtxPtr(&(encCtx->transformCtx)));
  if (!strcmp(attr, "defEncMethodId"))
    return (wrap_xmlSecTransformId(encCtx->defEncMethodId));
  if (!strcmp(attr, "encKey"))
    return (wrap_xmlSecKeyPtr(encCtx->encKey));
  if (!strcmp(attr, "operation"))
    return (wrap_int(encCtx->operation));
  if (!strcmp(attr, "result"))
    return (wrap_xmlSecBufferPtr(encCtx->result));
  if (!strcmp(attr, "resultBase64Encoded"))
    return (wrap_int(encCtx->resultBase64Encoded));
  if (!strcmp(attr, "resultReplaced"))
    return (wrap_int(encCtx->resultReplaced));
  if (!strcmp(attr, "encMethod"))
    return (wrap_xmlSecTransformPtr(encCtx->encMethod));
  if (!strcmp(attr, "id"))
    return (wrap_xmlCharPtr(encCtx->id));
  if (!strcmp(attr, "type"))
    return (wrap_xmlCharPtr(encCtx->type));
  if (!strcmp(attr, "mimeType"))
    return (wrap_xmlCharPtr(encCtx->mimeType));
  if (!strcmp(attr, "encoding"))
    return (wrap_xmlCharPtr(encCtx->encoding));
  if (!strcmp(attr, "recipient"))
    return (wrap_xmlCharPtr(encCtx->recipient));
  if (!strcmp(attr, "carriedKeyName"))
    return (wrap_xmlCharPtr(encCtx->carriedKeyName));
  if (!strcmp(attr, "encDataNode"))
    return (wrap_xmlNodePtr(encCtx->encDataNode));
  if (!strcmp(attr, "encMethodNode"))
    return (wrap_xmlNodePtr(encCtx->encMethodNode));
  if (!strcmp(attr, "keyInfoNode"))
    return (wrap_xmlNodePtr(encCtx->keyInfoNode));
  if (!strcmp(attr, "cipherValueNode"))
    return (wrap_xmlNodePtr(encCtx->cipherValueNode));

  Py_INCREF(Py_None);
  return (Py_None);
}