示例#1
0
def __pac_sign(logger, f_xmlin, xid, out_dir, pac_conf):
    """
    Signs xml with pac connector mechanism
    """
    try:
        logger.debug('Getting a pac connector as per config profile')
        pac, err = setup_pac(logger, pac_conf)
        if pac is None:
            raise Exception(err)

        logger.debug('File to sign {}'.format(f_xmlin))

        s_signed = None
        with open(f_xmlin) as f:
            s_signed = pac.stamp(f.read(), xid)
            logger.debug(s_signed)

        f_xmlout = os.path.join(out_dir, xid)
        logger.debug('saving pac xml signed upon {}'.format(f_xmlout))
        with open(f_xmlout, "w") as f:
            f.write(s_signed)

        return ErrorCode.SUCCESS, f_xmlout
    except:
        logger.error(dump_exception())
        return ErrorCode.THIRD_PARTY_ISSUES, None
示例#2
0
def __pac_cancel(logger, t, rfc, pac_conf):
    try:
        logger.debug('Getting a pac connector as per config profile')
        pac, err = setup_pac(logger, pac_conf)
        if pac is None:
            raise Exception(err)

        s_cancel = pac.cancel(t, rfc)
        logger.debug(s_cancel)

        return ErrorCode.SUCCESS
    except:
        logger.error(dump_exception())
        return ErrorCode.THIRD_PARTY_ISSUES
示例#3
0
 def pac_sign(f, resdir):
     try:
         # Here it would be placed, code calling
         # the pac connector mechanism
         logger.debug('Getting a pac connector as per config profile')
         pac, err = setup_pac(logger, pt.tparty.pac)
         if pac is None:
             raise Exception(err)
         logger.debug('File to sign {}'.format(f))
         with open(f) as t:
             signed = pac.stamp(t.read(), 'HARD_XID')
             logger.debug(signed)
         return ErrorCode.SUCCESS, f
     except:
         logger.error(dump_exception())
         return ErrorCode.THIRD_PARTY_ISSUES