Ejemplo n.º 1
0
 def remote_add_service_description(ss_api_config, security_server_conf, client_conf, service_description_conf):
     code = service_description_conf['rest_service_code'] if service_description_conf['rest_service_code'] else None
     description_add = ServiceDescriptionAdd(url=service_description_conf['url'],
                                             rest_service_code=code,
                                             ignore_warnings=True,
                                             type=service_description_conf['type'])
     clients_api = ClientsApi(ApiClient(ss_api_config))
     try:
         client_controller = ClientController()
         client = client_controller.find_client(clients_api, security_server_conf, client_conf)
         if client:
             try:
                 response = clients_api.add_client_service_description(client.id, body=description_add)
                 if response:
                     BaseController.log_info("Added service description with type '" + response.type + "' and url '" + response.url +
                                             "' (got full id " + response.id + ")")
             except ApiException as err:
                 if err.status == 409:
                     BaseController.log_info(ServiceController.SERVICE_DESCRIPTION_FOR + "'" + client_controller.partial_client_id(client_conf) +
                                             "' with url '" + description_add.url +
                                             "' and type '" + description_add.type + "' already exists.")
                 else:
                     BaseController.log_api_error('ClientsApi->add_client_service_description', err)
     except ApiException as find_err:
         BaseController.log_api_error(ClientController.CLIENTS_API_FIND_CLIENTS, find_err)
 def remote_add_endpoints_access(self, ss_api_config, security_server_conf,
                                 client_conf, service_description_conf):
     try:
         client_controller = ClientController()
         clients_api = ClientsApi(ApiClient(ss_api_config))
         client = client_controller.find_client(clients_api,
                                                security_server_conf,
                                                client_conf)
         if client:
             service_clients_candidates = client_controller.get_clients_service_client_candidates(
                 clients_api, client.id, [])
             try:
                 service_controller = ServiceController()
                 clients_api = ClientsApi(ApiClient(ss_api_config))
                 service_description = service_controller.get_client_service_description(
                     clients_api, client, service_description_conf)
                 if service_description.type != ServiceType().WSDL:
                     self.remote_add_endpoint_access(
                         ss_api_config, service_description,
                         service_description_conf,
                         service_clients_candidates)
             except ApiException as find_err:
                 BaseController.log_api_error(
                     ClientController.
                     CLIENTS_API_GET_CLIENT_SERVICE_DESCRIPTION, find_err)
     except ApiException as find_err:
         BaseController.log_api_error(
             ClientController.CLIENTS_API_FIND_CLIENTS, find_err)
 def remote_add_service_endpoints(self, ss_api_config, security_server_conf,
                                  client_conf, service_description_conf,
                                  endpoint_conf):
     try:
         clients_api = ClientsApi(ApiClient(ss_api_config))
         client_controller = ClientController()
         client = client_controller.find_client(clients_api,
                                                security_server_conf,
                                                client_conf)
         if client:
             try:
                 service_description = ServiceController(
                 ).get_client_service_description(clients_api, client,
                                                  service_description_conf)
                 if service_description:
                     if service_description.type == ServiceType().WSDL:
                         BaseController.log_info(
                             "Wrong service description, endpoints for WSDL services are not"
                             " allowed, skipped endpoint creation " +
                             EndpointController.FOR_SERVICE + "'" +
                             service_description.url + "'")
                     else:
                         self.remote_add_endpoint(ss_api_config,
                                                  service_description,
                                                  service_description_conf,
                                                  endpoint_conf)
             except ApiException as find_err:
                 BaseController.log_api_error(
                     ClientController.
                     CLIENTS_API_GET_CLIENT_SERVICE_DESCRIPTION, find_err)
     except ApiException as find_err:
         BaseController.log_api_error(
             ClientController.CLIENTS_API_FIND_CLIENTS, find_err)
Ejemplo n.º 4
0
    def remote_register_client(self, ss_api_config, security_server_conf, client_conf):
        clients_api = ClientsApi(ApiClient(ss_api_config))
        try:
            client = self.find_client(clients_api, security_server_conf, client_conf)
            if client:
                if ClientStatus.SAVED != client.status:
                    BaseController.log_info(
                        security_server_conf['name'] + ": " + self.partial_client_id(client_conf) + " already registered."
                    )
                    return

                try:
                    clients_api.register_client(id=client.id)
                    BaseController.log_info("Registered client " + self.partial_client_id(client_conf))
                except ApiException as reg_err:
                    BaseController.log_api_error('ClientsApi->register_client', reg_err)
        except ApiException as find_err:
            BaseController.log_api_error(ClientController.CLIENTS_API_FIND_CLIENTS, find_err)
Ejemplo n.º 5
0
    def remote_update_client(self, ss_api_config, security_server_conf, client_conf):
        clients_api = ClientsApi(ApiClient(ss_api_config))
        try:
            client = self.find_client(clients_api, security_server_conf, client_conf)
            if client:
                if client.status not in [ClientStatus.SAVED, ClientStatus.REGISTERED, ClientStatus.REGISTRATION_IN_PROGRESS]:
                    BaseController.log_info(
                        security_server_conf['name'] + ": " + self.partial_client_id(client_conf) + " not added/registered yet."
                    )
                    return

                try:
                    client.connection_type = convert_swagger_enum(ConnectionType, client_conf['connection_type'])
                    response = clients_api.update_client(client.id, body=client)
                    BaseController.log_info("Updated client " + self.partial_client_id(client_conf) + " connection type")
                    return response
                except ApiException as reg_err:
                    BaseController.log_api_error('ClientsApi->update_client', reg_err)
        except ApiException as find_err:
            BaseController.log_api_error(ClientController.CLIENTS_API_FIND_CLIENTS, find_err)
Ejemplo n.º 6
0
    def remote_add_client(self, ss_api_config, client_conf):
        conn_type = convert_swagger_enum(ConnectionType, client_conf['connection_type'])
        client = Client(member_class=client_conf['member_class'],
                        member_code=client_conf['member_code'],
                        connection_type=conn_type,
                        member_name=client_conf['member_name'],
                        subsystem_code=client_conf['subsystem_code'] if 'subsystem_code' in client_conf else None,
                        owner=False,
                        has_valid_local_sign_cert=False)

        client_add = ClientAdd(client=client, ignore_warnings=True)
        clients_api = ClientsApi(ApiClient(ss_api_config))
        try:
            response = clients_api.add_client(body=client_add)
            BaseController.log_info("Added client subsystem " + self.partial_client_id(client_conf) + " (got full id " + response.id + ")")
            return response
        except ApiException as err:
            if err.status == 409:
                BaseController.log_info("Client for '" + self.partial_client_id(client_conf) + "' already exists.")
            else:
                BaseController.log_api_error('ClientsApi->add_client', err)
Ejemplo n.º 7
0
 def remote_update_service_parameters(self, ss_api_config, security_server_conf, client_conf, service_description_conf):
     clients_api = ClientsApi(ApiClient(ss_api_config))
     try:
         client_controller = ClientController()
         client = client_controller.find_client(clients_api, security_server_conf, client_conf)
         if client:
             try:
                 service_description = self.get_client_service_description(clients_api, client, service_description_conf)
                 if service_description:
                     for service in service_description.services:
                         self.remote_update_service_parameter(ss_api_config, service_description_conf, service)
             except ApiException as find_err:
                 BaseController.log_api_error(ClientController.CLIENTS_API_GET_CLIENT_SERVICE_DESCRIPTION, find_err)
     except ApiException as find_err:
         BaseController.log_api_error(ClientController.CLIENTS_API_FIND_CLIENTS, find_err)
Ejemplo n.º 8
0
 def remote_enable_service_description(self, ss_api_config, security_server_conf, client_conf, service_description_conf):
     clients_api = ClientsApi(ApiClient(ss_api_config))
     service_descriptions_api = ServiceDescriptionsApi(ApiClient(ss_api_config))
     try:
         client_controller = ClientController()
         client = client_controller.find_client(clients_api, security_server_conf, client_conf)
         if client:
             try:
                 service_description = self.get_client_service_description(clients_api, client, service_description_conf)
                 if service_description:
                     try:
                         service_descriptions_api.enable_service_description(service_description.id)
                         BaseController.log_info(ServiceController.SERVICE_DESCRIPTION_FOR + "'" + client_controller.partial_client_id(client_conf) +
                                                 "' with id: '" + service_description.id + "' enabled successfully.")
                     except ApiException as err:
                         if err.status == 409:
                             BaseController.log_info(ServiceController.SERVICE_DESCRIPTION_FOR + "'" + client_controller.partial_client_id(client_conf) +
                                                     "' with id: '" + service_description.id + "' already enabled.")
                         else:
                             BaseController.log_api_error('ServiceDescriptionsApi->enable_service_description', err)
             except ApiException as find_err:
                 BaseController.log_api_error(ClientController.CLIENTS_API_GET_CLIENT_SERVICE_DESCRIPTION, find_err)
     except ApiException as find_err:
         BaseController.log_api_error(ClientController.CLIENTS_API_FIND_CLIENTS, find_err)