def generate_issuer_file(config):
    output_handle = open(config.output_file,
                         'w') if config.output_file else sys.stdout
    introductionURL = config.issuer_url + "intro/" if config.issuer_url.endswith(
        '/') else "/intro/"
    currentDate = str(datetime.date.today())

    issuer_json = {
        'id': config.issuer_id,
        'url': config.issuer_url,
        'introductionURL': introductionURL,
        'name': config.issuer_name,
        'email': config.issuer_email,
        'image': helpers.encode_image(config.issuer_logo_file),
        'issuerKeys': [{
            'date': currentDate,
            'key': config.issuer_address
        }],
        'revocationKeys': [{
            'date': currentDate,
            'key': config.revocation_address
        }]
    }

    output_handle.write(json.dumps(issuer_json, indent=2))

    if output_handle is not sys.stdout:
        output_handle.close()
Beispiel #2
0
def generate_issuer_file(config):

    if config.public_key_created:
        issued_on = config.public_key_created
    else:
        issued_on = str(date.today())
    output_handle = open(config.output_file,
                         'w') if config.output_file else sys.stdout

    context = [OPEN_BADGES_V2_CONTEXT_JSON, BLOCKCERTS_V2_CONTEXT_JSON]

    issuer_json = {
        '@context': context,
        'id': config.issuer_id,
        'url': config.issuer_url,
        'name': config.issuer_name,
        'email': config.issuer_email,
        'image': helpers.encode_image(config.issuer_logo_file),
        'publicKey': [{
            '@id': config.issuer_public_key,
            "created": issued_on
        }],
        'revocationList': config.revocation_list_uri,
        'type': ISSUER_TYPE
    }

    if config.intro_url:
        issuer_json['introductionUrl'] = config.intro_url

    output_handle.write(json.dumps(issuer_json, indent=2))

    if output_handle is not sys.stdout:
        output_handle.close()
def create_badge_section(config):
    cert_image_path = os.path.join(config.abs_data_dir, config.cert_image_file)
    issuer_image_path = os.path.join(config.abs_data_dir,
                                     config.issuer_logo_file)
    badge = {
        'type': 'BadgeClass',
        'id': helpers.URN_UUID_PREFIX + config.badge_id,
        'name': config.certificate_title,
        'description': config.certificate_description,
        'image': helpers.encode_image(cert_image_path),
        'issuer': {
            'id': config.issuer_id,
            'type': 'Profile',
            'name': config.issuer_name,
            'url': config.issuer_url,
            'email': config.issuer_email,
            'image': helpers.encode_image(issuer_image_path),
            'revocationList': config.revocation_list
        }
    }

    if config.criteria_narrative:
        badge['criteria'] = {}
        badge['criteria']['narrative'] = config.criteria_narrative

    if config.issuer_signature_lines:
        signature_lines = []
        for signature_line in config.issuer_signature_lines:
            signature_image_path = os.path.join(
                config.abs_data_dir, signature_line['signature_image'])
            signature_lines.append({
                'type': ['SignatureLine', 'Extension'],
                'jobTitle':
                signature_line['job_title'],
                'image':
                helpers.encode_image(signature_image_path),
                'name':
                signature_line['name']
            })
        badge[scope_name('signatureLines')] = signature_lines

    return badge
Beispiel #4
0
def create_assertion_section(config):
    assertion = {
        'type': 'Assertion',
        'issuedOn': '*|DATE|*',
        'uid': '*|CERTUID|*',
        'id': helpers.urljoin_wrapper(config.issuer_certs_url, '*|CERTUID|*')
    }
    if config.issuer_signature_file:
        issuer_image_path = os.path.join(config.abs_data_dir, config.issuer_signature_file)
        assertion['image:signature'] = helpers.encode_image(issuer_image_path)
    return assertion
Beispiel #5
0
def create_certificate_section(config):
    cert_image_path = os.path.join(config.abs_data_dir, config.cert_image_file)
    issuer_image_path = os.path.join(config.abs_data_dir, config.issuer_logo_file)
    certificate = {
        'type': 'Certificate',
        'name': config.certificate_title,
        'image': helpers.encode_image(cert_image_path),
        'description': config.certificate_description,
        'language': config.certificate_language,
        'issuer': {
            'type': 'Issuer',
            'url': config.issuer_url,
            'image': helpers.encode_image(issuer_image_path),
            'email': config.issuer_email,
            'name': config.issuer_name,
            'id': config.issuer_id
        }
    }

    return certificate
def create_assertion_section(config):
    data_dir = config.data_dir
    issuer_image_path = helpers.normalize_data_path(
        data_dir, config.issuer_signature_file)
    assertion = {
        'type': 'Assertion',
        'issuedOn': '*|DATE|*',
        'image:signature': helpers.encode_image(issuer_image_path),
        'uid': '*|CERTUID|*',
        'id': helpers.urljoin_wrapper(config.issuer_certs_url, '*|CERTUID|*')
    }
    return assertion
Beispiel #7
0
def create_certificate():
	certificate = {
		"subtitle": {
	      	"content": config.CERTIFICATE_DATE,
	      	"display": True
	    },
	    "title": config.CERTIFICATE_TITLE,
	    "language": config.CERTIFICATE_LANGUAGE,
	    "image": config.CERTIFICATE_IMAGE,
	    "description": config.CERTIFICATE_DESCRIPTION,
	    "id": config.CERTIFICATE_ID,
	    "issuer": {
	    	"url": config.ISSUER_URL,
	    	"image": helpers.encode_image('img/labcdmx.png'),
	    	"email": config.ISSUER_EMAIL,
	    	"name": config.ISSUER_NAME,
	    	"id": config.ISSUER_ID
	    }
	}
	return certificate
# coding=utf-8

import base64
from datetime import date
import helpers

# ISSUER INFORMATION
ISSUER_URL = "http://labcd.mx"
ISSUER_CERTS_URL = "http://certs.labcd.mx"
ISSUER_PUBLIC_KEY_URL = "http://certs.labcd.mx/keys/labcdmx-certs-public-key.asc"
ISSUER_SIGNATURE_IMAGE = helpers.encode_image("img/signature.png")
ISSUER_EMAIL = "*****@*****.**"
ISSUER_NAME = "Laboratorio para la Ciudad"
ISSUER_ID = "http://certs.labcd.mx/issuer/labcdmx-issuer.json"

# CERTIFICATE INFORMATION
CERTIFICATE_LANGUAGE = "es-MX" #LANGUAGE AND COUNTRY INFORMATION
CERTIFICATE_DESCRIPTION = "En reconocimiento a tu participación en \"ciudad prototipo\", un taller realizado en colaboración con el MIT Media Lab e IDEO con el propósito de explorar, compartir y prototipar nuevas maneras de acercamiento a problemas cotidianos de la ciudad de México mediante la colaboración entre estudiantes, profesionales y especialistas."
CERTIFICATE_DATE = str(date(month=9, day=1, year=2015))+"/"+str(date(month=9, day=4, year=2015))
CERTIFICATE_TITLE = "Ciudad Prototipo"
CERTIFICATE_IMAGE = helpers.encode_image("img/header.png")
CERTIFICATE_ID = ISSUER_CERTS_URL + "/criteria/2015/09/ciudad-prototipo.json"

# EXTENSION INFORMATION
ASSERTION_ENSORERS = [
	{
      "name": "MIT Media Lab",
      "url": "http://media.mit.edu",
      "image": helpers.encode_image("img/medialab.png")
    },
    {