コード例 #1
0
    def install(self):

        self.run([paths.cmd_chmod , 'g+w', self.pylib_folder])
        self.logIt("Copying casa.war into jetty webapps folder...")
        self.installJettyService(self.jetty_app_configuration['casa'])

        jettyServiceWebapps = os.path.join(self.casa_jetty_dir, 'webapps')
        self.copyFile(self.source_files[0][0], jettyServiceWebapps)

        jettyServiceOxAuthCustomLibsPath = os.path.join(self.jetty_base,
                                                        "oxauth", 
                                                        "custom/libs"
                                                        )

        twillo_package = base.determine_package(os.path.join(Config.distGluuFolder, 'twilio-*.jar'))
        self.copyFile(twillo_package, jettyServiceOxAuthCustomLibsPath)

        jsmpp_package = base.determine_package(os.path.join(Config.distGluuFolder, 'jsmpp-*.jar'))
        self.copyFile(jsmpp_package, jettyServiceOxAuthCustomLibsPath)

        self.run([paths.cmd_chown, '-R', 'jetty:jetty', jettyServiceOxAuthCustomLibsPath])

        #Adding twilio jar path to oxauth.xml
        oxauth_xml_fn = os.path.join(self.jetty_base,  'oxauth/webapps/oxauth.xml')
        if os.path.exists(oxauth_xml_fn):
            
            class CommentedTreeBuilder(ElementTree.TreeBuilder):
                def comment(self, data):
                    self.start(ElementTree.Comment, {})
                    self.data(data)
                    self.end(ElementTree.Comment)

            parser = ElementTree.XMLParser(target=CommentedTreeBuilder())
            tree = ElementTree.parse(oxauth_xml_fn, parser)
            root = tree.getroot()

            xml_headers = '<?xml version="1.0"  encoding="ISO-8859-1"?>\n<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">\n\n'

            for element in root:
                if element.tag == 'Set' and element.attrib.get('name') == 'extraClasspath':
                    break
            else:
                element = ElementTree.SubElement(root, 'Set', name='extraClasspath')
                element.text = ''

            extraClasspath_list = element.text.split(',')

            for ecp in extraClasspath_list[:]:
                if (not ecp) or re.search('twilio-(.*)\.jar', ecp) or re.search('jsmpp-(.*)\.jar', ecp):
                    extraClasspath_list.remove(ecp)

            extraClasspath_list.append('./custom/libs/{}'.format(os.path.basename(twillo_package)))
            extraClasspath_list.append('./custom/libs/{}'.format(os.path.basename(jsmpp_package)))
            element.text = ','.join(extraClasspath_list)

            self.writeFile(oxauth_xml_fn, xml_headers+ElementTree.tostring(root).decode('utf-8'))
        
        self.import_oxd_certificate()
        
        self.enable('casa')
コード例 #2
0
    def init(self, install_dir=INSTALL_DIR):

        self.install_dir = install_dir
        self.thread_queue = None
        self.jetty_user = '******'
        self.dump_config_on_error = False

        self.ldapBinFolder = os.path.join(self.ldapBaseFolder, 'bin')
        if base.snap:
            self.ldapBaseFolder = os.path.join(base.snap_common, 'opendj')
            self.jetty_user = '******'

        #create dummy progress bar that logs to file in case not defined
        progress_log_file = os.path.join(self.install_dir, 'logs',
                                         'progress-bar.log')

        class DummyProgress:

            services = []

            def register(self, installer):
                pass

            def before_start(self):
                pass

            def start(self):
                pass

            def progress(self, service_name, msg, incr=False):
                with open(progress_log_file, 'a') as w:
                    w.write("{}: {}\n".format(service_name, msg))

        self.pbar = DummyProgress()

        self.properties_password = None
        self.noPrompt = False

        self.distAppFolder = os.path.join(self.distFolder, 'app')
        self.distJansFolder = os.path.join(self.distFolder, 'jans')
        self.distTmpFolder = os.path.join(self.distFolder, 'tmp')

        self.downloadWars = None
        self.templateRenderingDict = {
            'oxauthClient_2_inum': 'AB77-1A2B',
            'oxauthClient_3_inum': '3E20',
            'oxauthClient_4_inum': 'FF81-2D39',
            'idp_attribute_resolver_ldap.search_filter':
            '(|(uid=$requestContext.principalName)(mail=$requestContext.principalName))',
            'oxd_port': '8443',
        }

        # java commands
        self.cmd_java = os.path.join(self.jre_home, 'bin/java')
        self.cmd_keytool = os.path.join(self.jre_home, 'bin/keytool')
        self.cmd_jar = os.path.join(self.jre_home, 'bin/jar')
        os.environ['OPENDJ_JAVA_HOME'] = self.jre_home

        # Component ithversions
        self.apache_version = None
        self.opendj_version = None

        #passwords
        self.ldapPass = None
        self.admin_password = None
        self.admin_password = ''
        self.cb_password = None
        self.encoded_cb_password = ''

        #DB installation types
        self.wrends_install = InstallTypes.LOCAL
        self.cb_install = InstallTypes.NONE
        self.rdbm_install = False

        self.couchbase_buckets = []

        #rdbm
        self.rdbm_install_type = InstallTypes.NONE
        self.rdbm_type = 'mysql'
        self.rdbm_host = 'localhost'
        self.rdbm_port = 3306
        self.rdbm_db = 'jans'
        self.rdbm_user = None
        self.rdbm_password = None
        self.static_rdbm_dir = os.path.join(self.install_dir, 'static/rdbm')

        #spanner
        self.spanner_project = 'jans-project'
        self.spanner_instance = 'jans-instance'
        self.spanner_database = 'jansdb'
        self.spanner_emulator_host = None
        self.google_application_credentials = None

        # Jans components installation status
        self.loadData = True
        self.installJans = True
        self.installJre = True
        self.installJetty = True
        self.installNode = False
        self.installJython = True
        self.installOxAuth = True
        self.installOxTrust = True
        self.installHttpd = True
        self.installSaml = False
        self.installOxAuthRP = False
        self.installPassport = False
        self.installJansRadius = False
        self.installScimServer = True
        self.installFido2 = True
        self.installConfigApi = True
        self.installCasa = False
        self.installOxd = False
        self.installEleven = False
        self.installJansCli = False
        self.loadTestData = False
        self.allowPreReleasedFeatures = False
        self.installAdminUI = False

        # backward compatibility
        self.os_type = base.os_type
        self.os_version = base.os_version
        self.os_initdaemon = base.os_initdaemon

        self.persistence_type = 'ldap'

        self.setup_properties_fn = os.path.join(self.install_dir,
                                                'setup.properties')
        self.savedProperties = os.path.join(self.install_dir,
                                            'setup.properties.last')

        self.jansOptBinFolder = os.path.join(self.jansOptFolder, 'bin')
        self.jansOptSystemFolder = os.path.join(self.jansOptFolder, 'system')
        self.jansOptPythonFolder = os.path.join(self.jansOptFolder, 'python')
        self.configFolder = os.path.join(self.jansBaseFolder, 'conf')

        self.jans_properties_fn = os.path.join(self.configFolder,
                                               'jans.properties')
        self.jans_hybrid_roperties_fn = os.path.join(self.configFolder,
                                                     'jans-hybrid.properties')

        self.cache_provider_type = 'NATIVE_PERSISTENCE'

        self.java_type = 'jre'

        self.hostname = None
        self.ip = None
        self.orgName = None
        self.countryCode = None
        self.city = None
        self.state = None
        self.admin_email = None
        self.encoded_ox_ldap_pw = None
        self.encode_salt = None
        self.admin_inum = None

        self.jans_max_mem = int(base.current_mem_size * .85 *
                                1000)  # 85% of physical memory
        self.calculate_mem()

        self.ldapBaseFolderldapPass = None

        self.outputFolder = os.path.join(self.install_dir, 'output')
        self.templateFolder = os.path.join(self.install_dir, 'templates')
        self.staticFolder = os.path.join(self.install_dir, 'static')

        self.extensionFolder = os.path.join(self.staticFolder, 'extension')

        self.encoded_ldapTrustStorePass = None

        self.ldapCertFn = self.opendj_cert_fn = os.path.join(
            self.certFolder, 'opendj.crt')
        self.ldapTrustStoreFn = self.opendj_p12_fn = os.path.join(
            self.certFolder, 'opendj.pkcs12')

        self.oxd_package = base.determine_package(
            os.path.join(Config.distJansFolder, 'oxd-server*.tgz'))

        self.opendj_p12_pass = None

        self.ldap_binddn = 'cn=directory manager'
        self.ldap_hostname = 'localhost'
        self.couchbase_hostname = 'localhost'
        self.ldap_port = '1389'
        self.ldaps_port = '1636'
        self.ldap_admin_port = '4444'

        self.ldap_user_home = self.ldapBaseFolder
        self.ldapPassFn = os.path.join(self.ldap_user_home, '.pw')
        self.ldap_backend_type = 'je'

        self.jansScriptFiles = [
            os.path.join(self.install_dir, 'static/scripts/logmanager.sh'),
            os.path.join(self.install_dir, 'static/scripts/testBind.py')
        ]

        self.redhat_services = ['httpd', 'rsyslog']
        self.debian_services = ['apache2', 'rsyslog']

        self.defaultTrustStoreFN = os.path.join(self.jre_home,
                                                'jre/lib/security/cacerts')
        self.defaultTrustStorePW = 'changeit'

        # Stuff that gets rendered; filename is necessary. Full path should
        # reflect final path if the file must be copied after its rendered.

        self.jans_python_readme = os.path.join(self.jansOptPythonFolder,
                                               'libs/python.txt')
        self.ox_ldap_properties = os.path.join(self.configFolder,
                                               'jans-ldap.properties')
        self.jansCouchebaseProperties = os.path.join(
            self.configFolder, 'jans-couchbase.properties')
        self.jansRDBMProperties = os.path.join(self.configFolder,
                                               'jans-sql.properties')
        self.jansSpannerProperties = os.path.join(self.configFolder,
                                                  'jans-spanner.properties')

        self.ldif_base = os.path.join(self.outputFolder, 'base.ldif')
        self.ldif_attributes = os.path.join(self.outputFolder,
                                            'attributes.ldif')
        self.ldif_scopes = os.path.join(self.outputFolder, 'scopes.ldif')

        self.ldif_metric = os.path.join(self.staticFolder,
                                        'metric/o_metric.ldif')
        self.ldif_site = os.path.join(self.install_dir,
                                      'static/cache-refresh/o_site.ldif')
        self.ldif_configuration = os.path.join(self.outputFolder,
                                               'configuration.ldif')

        self.system_profile_update_init = os.path.join(self.outputFolder,
                                                       'system_profile_init')
        self.system_profile_update_systemd = os.path.join(
            self.outputFolder, 'system_profile_systemd')

        ### rsyslog file customised for init.d
        self.rsyslogUbuntuInitFile = os.path.join(
            self.install_dir, 'static/system/ubuntu/rsyslog')
        self.ldap_setup_properties = os.path.join(self.templateFolder,
                                                  'opendj-setup.properties')

        # OpenID key generation default setting
        self.default_openid_jks_dn_name = 'CN=Jans Auth CA Certificates'
        self.default_key_algs = 'RS256 RS384 RS512 ES256 ES384 ES512'
        self.default_key_expiration = 365

        self.post_messages = []

        self.ldif_files = [
            self.ldif_base,
            self.ldif_attributes,
            self.ldif_scopes,
            self.ldif_site,
            self.ldif_metric,
            self.ldif_configuration,
        ]

        self.ce_templates = {
            self.jans_python_readme: True,
            self.ox_ldap_properties: True,
            self.ldap_setup_properties: False,
            self.etc_hostname: False,
            self.ldif_base: False,
            self.ldif_attributes: False,
            self.ldif_scopes: False,
            self.network: False,
            self.jans_properties_fn: True,
        }

        self.service_requirements = {
            'opendj': ['', 70],
            'jans-auth': ['opendj', 72],
            'jans-fido2': ['opendj', 73],
            'identity': ['opendj oxauth', 74],
            'jans-scim': ['opendj oxauth', 75],
            'idp': ['opendj oxauth', 76],
            'casa': ['opendj oxauth', 78],
            'oxd-server': ['opendj oxauth', 80],
            'passport': ['opendj oxauth', 82],
            'jans-auth-rp': ['opendj oxauth', 84],
            'jans-radius': ['opendj oxauth', 86],
            'jans-eleven': ['opendj oxauth', 79],
        }

        self.install_time_ldap = None

        self.couchbaseBucketDict = OrderedDict((
            ('default', {
                'ldif': [
                    self.ldif_base,
                    self.ldif_attributes,
                    self.ldif_scopes,
                    self.ldif_configuration,
                    self.ldif_metric,
                ],
                'memory_allocation':
                100,
                'mapping':
                '',
                'document_key_prefix': []
            }),
            ('user', {
                'ldif': [],
                'memory_allocation': 300,
                'mapping': 'people, groups, authorizations',
                'document_key_prefix':
                ['groups_', 'people_', 'authorizations_'],
            }),
            ('site', {
                'ldif': [self.ldif_site],
                'memory_allocation': 100,
                'mapping': 'cache-refresh',
                'document_key_prefix': ['site_', 'cache-refresh_'],
            }),
            ('cache', {
                'ldif': [],
                'memory_allocation': 100,
                'mapping': 'cache',
                'document_key_prefix': ['cache_'],
            }),
            ('token', {
                'ldif': [],
                'memory_allocation': 300,
                'mapping': 'tokens',
                'document_key_prefix': ['tokens_'],
            }),
            ('session', {
                'ldif': [],
                'memory_allocation': 200,
                'mapping': 'sessions',
                'document_key_prefix': [],
            }),
        ))

        self.mappingLocations = {
            group: 'ldap'
            for group in self.couchbaseBucketDict
        }  #default locations are OpenDJ
        self.non_setup_properties = {
            'oxauth_client_jar_fn':
            os.path.join(self.distJansFolder,
                         'jans-auth-client-jar-with-dependencies.jar')
        }
        Config.addPostSetupService = []