Ejemplo n.º 1
0
PyObject *xmlsec_KeyInfoCtxDebugXmlDump(PyObject *self, PyObject *args) {
  PyObject *keyInfoCtx_obj, *output_obj;
  xmlSecKeyInfoCtxPtr keyInfoCtx;
  FILE *output;

  if (CheckArgs(args, "OF:keyInfoCtxDebugXmlDump")) {
    if (!PyArg_ParseTuple(args, "OO:keyInfoCtxDebugXmlDump",
			  &keyInfoCtx_obj, &output_obj))
      return NULL;
  }
  else return NULL;

  keyInfoCtx = xmlSecKeyInfoCtxPtr_get(keyInfoCtx_obj);
  output = PythonFile_get(output_obj);
  xmlSecKeyInfoCtxDebugXmlDump(keyInfoCtx, output);

  Py_INCREF(Py_None);
  return (Py_None);
}
Ejemplo n.º 2
0
/**
 * xmlSecEncCtxDebugXmlDump:
 * @encCtx:             the pointer to <enc:EncryptedData/> processing context.
 * @output:             the pointer to output FILE.
 *
 * Prints the debug information about @encCtx to @output in XML format.
 */
void
xmlSecEncCtxDebugXmlDump(xmlSecEncCtxPtr encCtx, FILE* output) {
    xmlSecAssert(encCtx != NULL);
    xmlSecAssert(output != NULL);

    switch(encCtx->mode) {
    case xmlEncCtxModeEncryptedData:
        if(encCtx->operation == xmlSecTransformOperationEncrypt) {
            fprintf(output, "<DataEncryptionContext ");
        } else {
            fprintf(output, "<DataDecryptionContext ");
        }
        break;
    case xmlEncCtxModeEncryptedKey:
        if(encCtx->operation == xmlSecTransformOperationEncrypt) {
            fprintf(output, "<KeyEncryptionContext ");
        } else {
            fprintf(output, "<KeyDecryptionContext ");
        }
        break;
    }
    fprintf(output, "status=\"%s\" >\n", (encCtx->resultReplaced) ? "replaced" : "not-replaced" );

    fprintf(output, "<Flags>%08x</Flags>\n", encCtx->flags);
    fprintf(output, "<Flags2>%08x</Flags2>\n", encCtx->flags2);

    fprintf(output, "<Id>");
    xmlSecPrintXmlString(output, encCtx->id);
    fprintf(output, "</Id>");

    fprintf(output, "<Type>");
    xmlSecPrintXmlString(output, encCtx->type);
    fprintf(output, "</Type>");

    fprintf(output, "<MimeType>");
    xmlSecPrintXmlString(output, encCtx->mimeType);
    fprintf(output, "</MimeType>");

    fprintf(output, "<Encoding>");
    xmlSecPrintXmlString(output, encCtx->encoding);
    fprintf(output, "</Encoding>");

    fprintf(output, "<Recipient>");
    xmlSecPrintXmlString(output, encCtx->recipient);
    fprintf(output, "</Recipient>");

    fprintf(output, "<CarriedKeyName>");
    xmlSecPrintXmlString(output, encCtx->carriedKeyName);
    fprintf(output, "</CarriedKeyName>");

    fprintf(output, "<KeyInfoReadCtx>\n");
    xmlSecKeyInfoCtxDebugXmlDump(&(encCtx->keyInfoReadCtx), output);
    fprintf(output, "</KeyInfoReadCtx>\n");

    fprintf(output, "<KeyInfoWriteCtx>\n");
    xmlSecKeyInfoCtxDebugXmlDump(&(encCtx->keyInfoWriteCtx), output);
    fprintf(output, "</KeyInfoWriteCtx>\n");

    fprintf(output, "<EncryptionTransformCtx>\n");
    xmlSecTransformCtxDebugXmlDump(&(encCtx->transformCtx), output);
    fprintf(output, "</EncryptionTransformCtx>\n");

    if(encCtx->encMethod != NULL) {
        fprintf(output, "<EncryptionMethod>\n");
        xmlSecTransformDebugXmlDump(encCtx->encMethod, output);
        fprintf(output, "</EncryptionMethod>\n");
    }

    if(encCtx->encKey != NULL) {
        fprintf(output, "<EncryptionKey>\n");
        xmlSecKeyDebugXmlDump(encCtx->encKey, output);
        fprintf(output, "</EncryptionKey>\n");
    }

    if((encCtx->result != NULL) &&
            (xmlSecBufferGetData(encCtx->result) != NULL) &&
            (encCtx->resultBase64Encoded != 0)) {

        fprintf(output, "<Result>");
        fwrite(xmlSecBufferGetData(encCtx->result),
               xmlSecBufferGetSize(encCtx->result), 1,
               output);
        fprintf(output, "</Result>\n");
    }

    switch(encCtx->mode) {
    case xmlEncCtxModeEncryptedData:
        if(encCtx->operation == xmlSecTransformOperationEncrypt) {
            fprintf(output, "</DataEncryptionContext>\n");
        } else {
            fprintf(output, "</DataDecryptionContext>\n");
        }
        break;
    case xmlEncCtxModeEncryptedKey:
        if(encCtx->operation == xmlSecTransformOperationEncrypt) {
            fprintf(output, "</KeyEncryptionContext>\n");
        } else {
            fprintf(output, "</KeyDecryptionContext>\n");
        }
        break;
    }
}