parser = argparse.ArgumentParser() parser.add_argument('-i', dest='issuer', help="issuer id of the OP") parser.add_argument('-c', dest='context', help="OIDC operation") parser.add_argument('-t', dest='target') parser.add_argument(dest="filename") args = parser.parse_args() oa = args.issuer qpoa = quote_plus(oa) _kj = KeyJar() _jwks = json.loads(open(os.path.join('fo_jwks', qpoa)).read()) _kj.import_jwks(_jwks, oa) sign_serv = InternalSigningService(iss=oa, signing_keys=_kj) signer = Signer(sign_serv, ms_dir=os.path.join('ms', qpoa)) _req = open(args.filename, 'r').read() _msg = MetadataStatement() _msg.from_json(_req) _res = signer.create_signed_metadata_statement(_msg, context=args.context) for iss, sms in _res.items(): _qp = quote_plus(iss) _dn = os.path.join(args.target, qpoa, args.context) if not os.path.isdir(_dn): os.makedirs(_dn) _fn = os.path.join(_dn, _qp) _fp = open(_fn, 'w') _fp.write(sms) _fp.close()
import argparse import json import os from oic.utils.keyio import KeyJar from fedoidc import MetadataStatement from fedoidc.signing_service import InternalSigningService parser = argparse.ArgumentParser() parser.add_argument('-r', dest='request') parser.add_argument('-a', dest='alg', default='RS256') parser.add_argument(dest="nickname") args = parser.parse_args() if not os.path.isdir(args.nickname): print('No such entity') exit(-1) kj = KeyJar() iss = open(os.path.join(args.nickname, 'iss')).read() jwks = open(os.path.join(args.nickname, 'jwks')).read() kj.import_jwks(jwks=json.loads(jwks), issuer=iss) sigserv = InternalSigningService(iss=iss, signing_keys=kj, alg=args.alg) msg = MetadataStatement() msg.from_json(open(args.request).read()) print(sigserv(msg))