def register_user(self, certificate = "", rsa_private_key = ""):

        # If default or not all parameters are provided, short circuit and
        # return anonymous user id
        if certificate == "" or rsa_private_key == "":
            return {"ooi_id": "ANONYMOUS", "user_is_admin": false, "user_already_registered": true, "user_is_early_adopter": false, "user_is_data_provider": false, "user_is_marine_operator": false}
        # Else, delegate to Identity Registry
        else:
            # Extract subject from certificate
            # Force conversion to str since it comes across the wire as unicode
            x509 = X509.load_cert_string(str(certificate), format=1)

            subject = str(x509.get_subject())
            is_existing_user = False
            try:
               userinfo = self.clients.identity_registry.find_user_by_subject(subject)
               log.debug("User found")
               is_existing_user = True
            # TODO figure out right exception to catch
            except NotFound as ex:
                # TODO for now just going to use CN portion of subject
                # as new user name
                subj_name = subject.split("/CN=")[-1]
                try:
                    userinfo = self.clients.identity_registry.create_user(subj_name)
                    log.debug("User create succeeded")
                except Exception as ex:
                    # TODO throw exception
                    log.error("Create failed")

            ret = {"ooi_id": userinfo._id}
            ret["user_already_registered"] = is_existing_user
            ret["user_is_admin"] = userinfo.roles.find("ADMIN") != -1
            ret["user_is_early_adopter"] = userinfo.roles.find("EARLY_ADOPTER") != -1
            ret["user_is_data_provider"] = userinfo.roles.find("DATA_PROVIDER") != -1
            ret["user_is_marine_operator"] = userinfo.roles.find("MARINE_OPERATOR") != -1

            return ret
This op is overloaded.  If the user has never been seen before,
dataset/ETHPy150Open ooici/pyon/prototype/app_integration_service.py/AppIntegrationService.register_user