Exemplo n.º 1
0
 def get_sensitive_data(self, connection_id, verbose_override=None):
     web_request = self._do_api_post(self.url_resolver.get_sensitive_data(connection_id))
     result = SDKResult(web_request.json())
     if result.success:
         data = self.EncryptionManager.aes_decrypt(result.data).decode('utf-8')
         result.data = json.loads(data)
     return result
Exemplo n.º 2
0
    def login(self,  username, password, verbose_override=None):
        """Logs in a user to the DVLS server

        :param username: username of the user to log out
        :param password: password of the user
        :param verbose_override: specify verbose_override=False so that nothing is output to the console
        :return: login succeeded or failed - True or False
        """
        result = SDKResult()
        if self.is_logged_on():
            self.dvls_logger.error("[ApiManager.login] - Unable to log in with '" + username +
                                   "': the previous user is still logged in", verbose_override)
        else:
            self.DvlsRequestHeaders = {'Content-Type': 'application/json'}
            self.EncryptionManager = EncryptionManager(self.server_info, password)

            info = {'UserName': username}
            encrypted_info = self.EncryptionManager.get_encrypted_password()
            info['SafePassword'] = encrypted_info['password']
            info['SafeSessionKey'] = encrypted_info['key']
            data_model = init_model('generated', 'LoginData')
            data_model.RDMOLoginParameters = init_model(
                'generated', 'RDMOLoginParameters')
            data_model.TwoFactorInfo = init_model(
                'generated', 'TwoFactorInfo')
            login_data = fill_data(data_model, info)

            web_request = self._do_api_post_json(self.url_resolver.login_url(), login_data)
            result = SDKResult(web_request.json())
            if result.success:
                self.DvlsUserLoggedIn = username
                self.DvlsTokenID = result.data.get('tokenId')
                self.DvlsRequestHeaders['tokenId'] = self.DvlsTokenID
        return SDKResult(result)
Exemplo n.º 3
0
    def logout(self, username, verbose_override=None):
        """Logs out a user from the DVLS server

        :param username: username of the user to log out
        :param verbose_override: specify verbose_override=False so that nothing is output to the console
        :return: logout succeeded or failed - True or False
        """
        result = SDKResult
        if self.is_logged_on() and self.DvlsUserLoggedIn == username:
            web_request = self._do_api_get(self.url_resolver.logout_url())
            self.DvlsRequestHeaders = None
            self.DvlsTokenID = None
            result = SDKResult(web_request.json())
        else:
                self.dvls_logger.info("[ApiManager.login] - User '" + username + "' is not logged in", verbose_override)
        return result
Exemplo n.º 4
0
 def get_connection_by_id(self, connection_id, verbose_override=None):
     web_request = self._do_api_get(self.url_resolver.connection_byid_url(connection_id))
     return SDKResult(web_request.json())
Exemplo n.º 5
0
 def delete_private_vault_entry(self, entry_id, entry, verbose_override=None):
     web_request = self._do_api_delete(self.url_resolver.delete_private_entry_url(entry_id), entry)
     return SDKResult(web_request.json())
Exemplo n.º 6
0
 def get_security_group_by_name(self, name, verbose_override=None):
     web_request = self._do_api_get(self.url_resolver.security_group_by_name_url(name))
     return SDKResult(web_request.json())
Exemplo n.º 7
0
 def get_users(self, verbose_override=None):
     web_request = self._do_api_get(self.url_resolver.users_url())
     return SDKResult(web_request.json())
Exemplo n.º 8
0
 def get_server_info(self):
     web_request = self._do_api_get(self.url_resolver.server_info_url())
     return SDKResult(web_request.json())
Exemplo n.º 9
0
 def delete_repository_by_id(self, repository_id, verbose_override=None):
     web_request = self._do_api_delete(self.url_resolver.delete_repository_url(repository_id))
     return SDKResult(web_request.json())
Exemplo n.º 10
0
 def get_password_templates(self, verbose_override=None):
     web_request = self._do_api_get(self.url_resolver.password_template_url())
     return SDKResult(web_request.json())
Exemplo n.º 11
0
 def delete_password_template(self, pw_template, verbose_override=None):
     web_request = self._do_api_delete(self.url_resolver.password_template_url(), pw_template)
     return SDKResult(web_request.json())
Exemplo n.º 12
0
 def modify_password_template(self, template_entry):
     web_request = self._do_api_put_json(self.url_resolver.password_template_url(), template_entry)
     return SDKResult(web_request.json())
Exemplo n.º 13
0
 def create_password_template(self, template_entry, verbose_override=None):
     web_request = self._do_api_post_json(self.url_resolver.password_template_url(), template_entry)
     return SDKResult(web_request.json())
Exemplo n.º 14
0
 def get_security_groups_tree(self, verbose_override=None):
     web_request = self._do_api_get(self.url_resolver.security_groups_url())
     return SDKResult(web_request.json())
Exemplo n.º 15
0
 def delete_security_group_by_id(self, sc_id, verbose_override=None):
     web_request = self._do_api_delete(self.url_resolver.delete_security_group_url(sc_id))
     return SDKResult(web_request.json())
Exemplo n.º 16
0
 def modify_security_group(self, group_entry, verbose_override=None):
     web_request = self._do_api_put_json(self.url_resolver.save_security_group_url(), group_entry)
     return SDKResult(web_request.json())
Exemplo n.º 17
0
 def create_repository(self, repository_entry, verbose_override=None):
     web_request = self._do_api_put_json(self.url_resolver.save_repository_url(), repository_entry)
     return SDKResult(web_request.json())
Exemplo n.º 18
0
 def modify_features(self, features, verbose_override=None):
     web_request = self._do_api_put_json(self.url_resolver.features_url(), features)
     return SDKResult(web_request.json())
Exemplo n.º 19
0
 def change_active_repository(self, repository_id, verbose_override):
     web_request = self._do_api_put_json(self.url_resolver.change_repository_url(), repository_id)
     return SDKResult(web_request.json())
Exemplo n.º 20
0
 def create_connection_entry(self, connection_entry, verbose_override=None):
     web_request = self._do_api_post_json(self.url_resolver.save_entry_url(), connection_entry)
     return SDKResult(web_request.json())
Exemplo n.º 21
0
 def modify_credential_entry(self, credential_entry, verbose_override=None):
     web_request = self._do_api_put_json(self.url_resolver.save_entry_url(), credential_entry)
     return SDKResult(web_request.json())
Exemplo n.º 22
0
 def delete_entry(self, name, entry, verbose_override=None):
     web_request = self._do_api_delete(self.url_resolver.connection_byid_url(entry['id']), entry)
     return SDKResult(web_request.json())
Exemplo n.º 23
0
 def get_active_repository_entries(self, repository_id, verbose_override=None):
     web_request = self._do_api_get(self.url_resolver.entries_tree_url(repository_id))
     return SDKResult(web_request.json())
Exemplo n.º 24
0
 def get_private_vault_entries(self, verbose_override=None):
     web_request = self._do_api_get(self.url_resolver.private_vault_tree_url())
     return SDKResult(web_request.json())
Exemplo n.º 25
0
 def delete_user(self, user_id, verbose_override=None):
     web_request = self._do_api_delete(self.url_resolver.delete_user_url(user_id))
     return SDKResult(web_request.json())
Exemplo n.º 26
0
 def save_user(self, user_entry, verbose_override=None):
     web_request = self._do_api_put_json(self.url_resolver.save_user_url(), user_entry)
     return SDKResult(web_request.json())