Ejemplo n.º 1
0
def request_pseudonym_certificate(request_arguments):
    request_pseudonym_certificate_return_code = run_java_command(
        "enrollmentResponse")
    if request_pseudonym_certificate_return_code == 1:
        raise SystemError(
            "There was a Java error with the pseudonym certificate request.")
    process = request_arguments['process']
    hostname = get_hostname(process)
    request_arguments['hostname'] = hostname
    file_type = "requestVehiclePseudoCertProvRequest"
    file_to_post = get_file_path('vehicle') + get_file_name(file_type)
    request_arguments['file'] = file_to_post
    scms_request = make_single_http_file_post_request(request_arguments)
    try:
        print scms_request
    except:
        pass
    next_process = "requestVehiclePseudoCertProv"
    signed_pseudo_cert_provisioning_ack_file_name = get_file_path(
        'vehicle') + get_file_name(next_process)
    signed_pseudo_cert_provisioning_ack_file = open(
        signed_pseudo_cert_provisioning_ack_file_name, 'wb')
    signed_pseudo_cert_provisioning_ack_file.write(scms_request.content)
    signed_pseudo_cert_provisioning_ack_file.close()
    provisioning_ack_return_code = run_java_command("provisioningAck")
    if provisioning_ack_return_code == 1:
        raise SystemError(
            "There was a Java error with the provisioning ack process.")
Ejemplo n.º 2
0
def download_pseudonym_certificate_batch(request_arguments):
    download_pseodu_cert_batch_return_code = run_java_command(
        "pseudonymDownload")
    if download_pseodu_cert_batch_return_code == 1:
        raise SystemError(
            "There was a Java error downloading pseudo certificate batch")
    process = request_arguments['process']
    file_and_zip_names = get_download_batch_filenames()
    print file_and_zip_names
    for name_pair in file_and_zip_names:
        headers = {'Content-Type': 'application/octet-stream'}
        request_arguments['hostname'] = get_hostname(process)
        with open(name_pair[0], 'rb') as sa_download_request:
            file_content = sa_download_request.read()
            base64_encoded_file_data = base64.b64encode(file_content)

        hostname = get_hostname("vehicleCertDownload")
        headers['Download-Req'] = base64_encoded_file_data
        scms_request = requests.get(url=hostname,
                                    headers=headers,
                                    verify=False)
        try:
            print scms_request
        except:
            pass
        certificate_batch_folder = open(name_pair[1], 'wb')
        certificate_batch_folder.write(scms_request.content)
        certificate_batch_folder.close()
    run_java_command("certResponse")
Ejemplo n.º 3
0
def run_java_command_and_return_hostname(request_arguments):
    process = request_arguments["process"]
    java_process_return_code = run_java_command(process)
    if java_process_return_code == 1:
        raise SystemError("There was an error with the Java process.")
    request_arguments['hostname'] = get_hostname(process)
    return request_arguments
Ejemplo n.º 4
0
def get_certificate_chain(request_arguments):
    process = "certificateChain"
    hostname = get_hostname(process)
    request_arguments['hostname'] = hostname
    scms_request = make_scms_get_request(request_arguments)
    try:
        print scms_request
    except:
        pass
    certificate_chain_request_path_filename = get_java_created_file_path(
        process) + get_file_name(process)
    certificate_chain_request_file = open(
        certificate_chain_request_path_filename, 'wb')
    certificate_chain_request_file.write(scms_request.content)
    certificate_chain_request_file.close()
    run_java_command("certificateChain")
Ejemplo n.º 5
0
def retrieve_crl(request_arguments):
    request_arguments['hostname'] = get_hostname(request_arguments["process"])
    scms_request = make_scms_get_request(request_arguments)
    scms_request_headers = scms_request.headers
    content_disposition = scms_request_headers["Content-Disposition"]
    crl_list_file_name = content_disposition.split('"')[1]
    full_file_path = get_java_created_file_path(
        request_arguments["process"]) + crl_list_file_name
    with open(full_file_path, "wb") as crl_list_file:
        crl_list_file.write(scms_request.content)
    crl_list_file.close()
    crl_file_name_file = get_java_created_file_path(
        request_arguments["process"]) + "current_crl_file_name.txt"
    with open(crl_file_name_file, 'wb') as crl_file_name:
        crl_file_name.write(crl_list_file_name)
        crl_file_name.close()
    run_java_command(request_arguments["process"])

    print("The CRL file is located at %s") % (full_file_path)
Ejemplo n.º 6
0
def enroll_vehicle(request_arguments):
    enrollment_process_return_code = run_java_command('enrollment')
    if enrollment_process_return_code == 1:
        raise SystemError(
            "There was a Java error with the enrollment process.")
    process = request_arguments['process']
    hostname = get_hostname(process)
    request_arguments['hostname'] = hostname
    request_arguments['file'] = get_file_path('vehicle') + get_file_name(
        process)
    scms_request = make_single_http_file_post_request(request_arguments)
    try:
        print scms_request
    except:
        pass
    file_type = "requestVehiclePseudoCert"
    vehicle_enrollment_request_path_filename = get_file_path(
        'vehicle') + get_file_name(file_type)
    vehicle_enrollment_request_file = open(
        vehicle_enrollment_request_path_filename, 'wb')
    vehicle_enrollment_request_file.write(scms_request.content)
    vehicle_enrollment_request_file.close()
Ejemplo n.º 7
0
def decrypt_message(request_arguments):
    run_java_command(request_arguments["process"])
Ejemplo n.º 8
0
def create_mbr(request_arguments):
    create_mbr_return_code = run_java_command("mbr")
    if create_mbr_return_code == 1:
        raise SystemError(
            "There was a Java error in the MBR creation process.")