Exemplo n.º 1
0
def autogenerate():
    """Function that generates the LDAP schemas for OpenDJ, OpenLDAP from the
    gluu_schema.json and custom_schema.json and puts them in their respective
    folders.
    """
    openldap_folder = os.path.join(os.path.dirname(localdir),
                                   'static/openldap/')
    opendj_folder = os.path.join(os.path.dirname(localdir), 'static/opendj/')

    fp = open(os.path.join(localdir, 'gluu_schema.json'), 'r')
    gluu_json = fp.read()
    fp.close()
    gen = SchemaGenerator(gluu_json)
    with open(os.path.join(openldap_folder, 'gluu.schema'), 'w') as f:
        f.write(gen.generate_schema().encode('utf-8'))
    with open(os.path.join(opendj_folder, '101-ox.ldif'), 'w') as f:
        f.write(gen.generate_ldif().encode('utf-8'))

    fp = open(os.path.join(localdir, 'custom_schema.json'), 'r')
    custom_json = fp.read()
    fp.close()
    gen = SchemaGenerator(custom_json)
    with open(os.path.join(openldap_folder, 'custom.schema'), 'w') as f:
        f.write(gen.generate_schema().encode('utf-8'))
    with open(os.path.join(opendj_folder, '77-customAttributes.ldif'), 'w') \
            as f:
        f.write(gen.generate_ldif().encode('utf-8'))
Exemplo n.º 2
0
def generate(infile, schema_type=None):
    """Function generates the LDAP schema definitions from the JSON data

    Args:
        schema_type (str): The schema type to be generated (opendj)
    """
    fp = open(infile, 'r')
    json_text = fp.read()
    fp.close()
    gen = SchemaGenerator(json_text)
    if schema_type == 'opendj':
        schema_str = gen.generate_ldif()
    else:
        schema_str = gen.generate_schema()
    print(schema_str)
def generate(infile, schema_type=None):
    """Function generates the LDAP schema definitions from the JSON data

    Args:
        schema_type (str): The schema type to be generated (opendj)
    """
    fp = open(infile, 'r')
    json_text = fp.read()
    fp.close()
    gen = SchemaGenerator(json_text)
    if schema_type == 'opendj':
        schema_str = gen.generate_ldif()
    else:
        schema_str = gen.generate_schema()
    print schema_str.encode('utf-8')
def autogenerate():
    """Function that generates the LDAP schemas for OpenDJ from the
    gluu_schema.json and custom_schema.json and puts them in their respective
    folders.
    """
    opendj_folder = os.path.join(os.path.dirname(localdir), 'static/opendj/')

    fp = open(os.path.join(localdir, 'gluu_schema.json'), 'r')
    gluu_json = fp.read()
    fp.close()
    gen = SchemaGenerator(gluu_json)
    with open(os.path.join(opendj_folder, '101-ox.ldif'), 'w') as f:
        f.write(gen.generate_ldif().encode('utf-8'))

    fp = open(os.path.join(localdir, 'custom_schema.json'), 'r')
    custom_json = fp.read()
    fp.close()
    gen = SchemaGenerator(custom_json)
    with open(os.path.join(opendj_folder, '77-customAttributes.ldif'), 'w') \
            as f:
        f.write(gen.generate_ldif().encode('utf-8'))
Exemplo n.º 5
0
def autogenerate():
    """Function that generates the LDAP schemas for OpenDJ from the
    jans_schema.json and custom_schema.json and puts them in their respective
    folders.
    """
    opendj_folder = os.path.join(os.path.dirname(localdir), 'static/opendj/')

    fp = open(os.path.join(localdir, 'jans_schema.json'), 'r')
    jans_json = fp.read()
    fp.close()
    gen = SchemaGenerator(jans_json)
    with open(os.path.join(opendj_folder, '101-ox.ldif'), 'w') as f:
        f.write(gen.generate_ldif())

    fp = open(os.path.join(localdir, 'custom_schema.json'), 'r')
    custom_json = fp.read()
    fp.close()
    gen = SchemaGenerator(custom_json)
    with open(os.path.join(opendj_folder, '77-customAttributes.ldif'), 'w') \
            as f:
        f.write(gen.generate_ldif())