removed more adapter stuff

pull/2/head
Falk Werner 4 years ago
parent 03c25f3e13
commit bf55851376

@ -1,4 +0,0 @@
/build/
/.vscode/
/subprojects/*
!/subprojects/*.wrap

@ -1,32 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/api.h
/// \brief API define for webfuse adapter.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_API_H
#define WF_ADAPTER_API_H
//------------------------------------------------------------------------------
/// \def WF_API
/// \brief Marks public symbols of libwebfuse_adapter.
//------------------------------------------------------------------------------
#ifndef WF_API
#define WF_API
#endif
//------------------------------------------------------------------------------
/// \def WF_EXPORT
/// \brief Marks exported symbols as visible.
///
/// Set WF_API to WF_EXPORT when building libwebfuse_adapter.so to export
/// public symbols.
//------------------------------------------------------------------------------
#ifndef WF_EXPORT
#ifdef __GNUC__
#define WF_EXPORT __attribute__ ((visibility ("default")))
#else
#define WF_EXPORT
#endif
#endif
#endif

@ -1,41 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/authenticate.h
/// \brief Authenticate function.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_AUTHENTICATE_H
#define WF_ADAPTER_AUTHENTICATE_H
#ifndef __cplusplus
#include <stdbool.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
struct wf_credentials;
//------------------------------------------------------------------------------
/// \brief Authentication function type.
///
/// Functions of this type are used to authenticate a user by some provided
/// credentials.
///
/// \param credentials credentials to authenticate the user
/// \param user_data context of the authentication function
/// \return true, if authentication was successful, false otherwise
///
/// \see wf_server_config_add_authenticator
/// \see wf_server_protocol_add_authenticator
//------------------------------------------------------------------------------
typedef bool wf_authenticate_fn(
struct wf_credentials const * credentials,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,159 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/client.h
/// \brief Adapter client.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_CLIENT_H
#define WF_ADAPTER_CLIENT_H
#include <webfuse/adapter/api.h>
#include <webfuse/adapter/client_callback.h>
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \struct wf_client
/// \brief Adapter client
///
/// An adapter client is used to connect to a remote provider server, e.g. a
/// cloud service, an request a filesystem to inject.
//------------------------------------------------------------------------------
struct wf_client;
//------------------------------------------------------------------------------
/// \brief Created a new instance of an adapter client.
///
/// During creation, the client is initialized in the following order:
/// - WF_CLIENT_INIT is triggered to initialize custom data
/// - WF_CLIENT_GET_TLS_CONFIG is triggered to query TLS configuration
/// - internal initialization is performed
/// - WF_CLIENT_CREATED is triggered
///
/// Therefore, the client should not be used, unless WF_CLIENT_CREATED is
/// triggered.
///
/// When TLS configuration is queried, a pointer to an instance if
/// \see wf_client_tlsconfig is provided to be set by the user.
///
/// \param callback Pointer to the callback function.
/// \param user_data Pointer to user data.
///
/// \return Newly created instance of an adapter client.
//------------------------------------------------------------------------------
extern WF_API struct wf_client *
wf_client_create(
wf_client_callback_fn * callback,
void * user_data);
//------------------------------------------------------------------------------
/// \brief Disposes an adapter client.
///
/// \param client Pointer to the client.
//------------------------------------------------------------------------------
extern WF_API void
wf_client_dispose(
struct wf_client * client);
//------------------------------------------------------------------------------
/// \brief Get user data.
///
/// \param client Pointer to the client.
//------------------------------------------------------------------------------
extern WF_API void *
wf_client_get_userdata(
struct wf_client * client);
//------------------------------------------------------------------------------
/// \brief Triggers the client.
///
/// \param client Pointer to the client.
//------------------------------------------------------------------------------
extern WF_API void
wf_client_service(
struct wf_client * client);
//------------------------------------------------------------------------------
/// \brief Interrupts a service call.
///
/// Wakes up the client.
///
/// \note This is the only function that can be used safely from another
// thread.
///
/// \param client Pointer to the client.
//------------------------------------------------------------------------------
extern WF_API void
wf_client_interrupt(
struct wf_client * client);
//------------------------------------------------------------------------------
/// \brief Connects to a foreign server.
///
/// Starts to connect. The callback is triggered, when connect is finised:
/// - WF_CLIENT_CONNECTED on success
/// - WF_CLIENT_DISCONNECTED on connect error
///
/// \param client Pointer to the client.
/// \param url URL of the remote ppovider.
//------------------------------------------------------------------------------
extern WF_API void
wf_client_connect(
struct wf_client * client,
char const * url);
//------------------------------------------------------------------------------
/// \brief Disconnects from the foreign server.
///
/// The event WF_CLIENT_DISCONNECTED is triggered, when disconnected.
///
/// \param client Pointer to the client.
//------------------------------------------------------------------------------
extern WF_API void
wf_client_disconnect(
struct wf_client * client);
//------------------------------------------------------------------------------
/// \brief Authenticated the client.
///
/// During authentication, credentials are queries via
/// WF_CLIENT_AUTHENTICATE_GET_CREDENTIALS event. In that case a pointer to an
/// instance of wf_client_tlsconfig is provided to set credentials.
///
/// When authentications finishes, an event is triggered:
/// - WF_CLIENT_AUTHENTICATED on success
/// - WF_CLIENT_AUTHENTICATION_FAILED on failure
///
/// \param client Pointer to the client.
//------------------------------------------------------------------------------
extern WF_API void
wf_client_authenticate(
struct wf_client * client);
//------------------------------------------------------------------------------
/// \brief Add a filesystem.
///
/// After add filesystem finished, an event is triggered:
/// - WF_CLIENT_FILESYSTEM_ADDED on success
/// - WF_CLIENT_FILESYSTEM_ADD_FAILED on failure
///
/// \note Currently, only one file system is supported by the client.
///
/// \param client Pointer to the client.
/// \param local_path Local path where the filesystem should be places
/// (must be an exististing and empty directory).
/// \param name Name of the filesystem (identifier sent to the provider).
//------------------------------------------------------------------------------
extern WF_API void
wf_client_add_filesystem(
struct wf_client * client,
char const * local_path,
char const * name);
#ifdef __cplusplus
}
#endif
#endif

@ -1,53 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/client_callbak.h
/// \brief Callback of adapter clients.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_CLIENT_CALLBACK_H
#define WF_ADAPTER_CLIENT_CALLBACK_H
#ifdef __cplusplus
extern "C"
{
#endif
#define WF_CLIENT_INIT 0x0001 ///< Out-most initialization of a client
#define WF_CLIENT_CLEANUP 0x0002 ///< Out-most cleanup of a client
#define WF_CLIENT_CREATED 0x0003 ///< Client is fully initialized an can be used
#define WF_CLIENT_CONNECTED 0x0011 ///< Connection to a foreign provider established
#define WF_CLIENT_DISCONNECTED 0x0012 ///< Connection closed or connect failed
#define WF_CLIENT_AUTHENTICATED 0x0021 ///< Authentication succeeded
#define WF_CLIENT_AUTHENTICATION_FAILED 0x0022 ///< Authentication failed
#define WF_CLIENT_AUTHENTICATE_GET_CREDENTIALS 0x0023 ///< Query credentials (\see wf_client_authenticate)
#define WF_CLIENT_FILESYSTEM_ADDED 0x0031 ///< File system added successfully
#define WF_CLIENT_FILESYSTEM_ADD_FAILED 0x0032 ///< Failed to add file system
#define WF_CLIENT_GET_TLS_CONFIG 0x0041 ///< Query TLS config (\see wf_client_create)
struct wf_client;
//------------------------------------------------------------------------------
/// \brief Client callback function
///
/// This function is triggered whenever an event occurs the client should
/// be aware of.
///
/// \param client Pointer to the client
/// \param reason Event, that triggered the callback
/// \param args Event-specific arguments
//------------------------------------------------------------------------------
typedef void wf_client_callback_fn(
struct wf_client * client,
int reason,
void * args);
#ifdef __cplusplus
}
#endif
#endif

@ -1,69 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/client_tslconfig.h
/// \brief Configuration of TLS (Transport Layer Security) for adapter clients.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_CLIENT_TLSCONFIG_H
#define WF_ADAPTER_CLIENT_TLSCONFIG_H
#include <webfuse/adapter/api.h>
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \struct wf_client_tlsconfig
/// \brief TLS configuration of the client.
///
/// TLS configuration is queried during initialization of a client via
/// WF_CLIENT_GET_TLS_CONFIG event.
///
/// \see WF_CLIENT_GET_TLS_CONFIG
/// \see wf_client_create
//------------------------------------------------------------------------------
struct wf_client_tlsconfig;
//------------------------------------------------------------------------------
/// \brief Sets the path to the private key.
///
/// \note To enable TLS both, key_path and cert_path, must be specified.
///
/// \param config Pointer to config.
/// \param key_path Path to private key file (in PEM format).
//------------------------------------------------------------------------------
extern WF_API void
wf_client_tlsconfig_set_keypath(
struct wf_client_tlsconfig * config,
char const * key_path);
//------------------------------------------------------------------------------
/// \brief Sets the path to the clients certificate.
///
/// \note To enable TLS both, key_path and cert_path, must be specified.
///
/// \param config Pointer to the config.
/// \param cert_path Path the the clients certificate (in PEM format).
//------------------------------------------------------------------------------
extern WF_API void
wf_client_tlsconfig_set_certpath(
struct wf_client_tlsconfig * config,
char const * cert_path);
//------------------------------------------------------------------------------
/// \brief Sets the path the CA file.
///
/// \param config Pointer to the config.
/// \param cafile_path Path to CA file (in PEM format).
//------------------------------------------------------------------------------
extern WF_API void
wf_client_tlsconfig_set_cafilepath(
struct wf_client_tlsconfig * config,
char const * cafile_path);
#ifdef __cplusplus
}
#endif
#endif

@ -1,95 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/credentials.h
/// \brief Credentials used for user authentication.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_CREDENTIALS_H
#define WF_ADAPTER_CREDENTIALS_H
#include "webfuse/adapter/api.h"
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \struct wf_credentials
/// \brief Credentials used for user authentication.
///
/// Credentials are used during authentication to authenticate a user.
/// In order to support multiple types of credentials, e.g. username + password,
/// certifactes and / or authentication tokens, credentials are modelled as
/// opaque type with some access functions.
///
/// \see wf_authenticate_fn
/// \see wf_credentials_type
/// \see wf_credentials_get
//------------------------------------------------------------------------------
struct wf_credentials;
//------------------------------------------------------------------------------
/// \brief Returns the type of the credentials object.
///
/// The type of the credentials objects defines, which keys are available
/// for a given instance.
///
/// \note When an authenticate function is called, the credentials type
/// matches the type provided during _add_authenticator function call.
/// Therefore, it is not necessary to check credentials type within
/// the authenticate function.
///
/// \note Within webfuse protocol documentation, only one type of credentials
/// is described byte now: username
///
/// \param credentials Pointer to credentials object
/// \return type of the credentials object
///
/// \see wf_server_config_add_authenticator
/// \see wf_server_protocol_add_authenticator
/// \see wf_authenticate_fn
//------------------------------------------------------------------------------
extern WF_API char const * wf_credentials_type(
struct wf_credentials const * credentials);
//------------------------------------------------------------------------------
/// \brief Return the value of a credentials item identified by the provided
/// key.
///
/// \param credentials Pointer to credentials object.
/// \param key String to identify the item.
/// \return value of credentials item or null, if there is no item with that
/// key
//------------------------------------------------------------------------------
extern WF_API char const * wf_credentials_get(
struct wf_credentials const * credentials,
char const * key);
//------------------------------------------------------------------------------
/// \brief Sets the type of the credentials.
///
/// \param credentials Pointer to credentials object.
/// \param type Type of credentials.
//------------------------------------------------------------------------------
extern WF_API void wf_credentials_set_type(
struct wf_credentials * credentials,
char const * type);
//------------------------------------------------------------------------------
/// \brief Adds an item to credentials
///
/// \param credentials Pointer to credentials object.
/// \param key String to identify the item.
/// \param key Value of the item.
//------------------------------------------------------------------------------
extern WF_API void wf_credentials_add(
struct wf_credentials * credentials,
char const * key,
char const * value);
#ifdef __cplusplus
}
#endif
#endif

@ -1,84 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/mountpoint.h
/// \brief Mointpoint.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_MOUNTPOINT_H
#define WF_ADAPTER_MOUNTPOINT_H
#include <webfuse/adapter/api.h>
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \struct wf_mountpoint
/// \brief Mointpoint.
//------------------------------------------------------------------------------
struct wf_mountpoint;
//------------------------------------------------------------------------------
/// \brief Disposes the user defined context of a mountpoint.
///
/// \param user_data user defined context of the mointpoint.
///
/// \see wf_mountpoint_set_userdata
//------------------------------------------------------------------------------
typedef void
wf_mountpoint_userdata_dispose_fn(
void * user_data);
//------------------------------------------------------------------------------
/// \brief Creates a mountpoint.
///
/// \param path local path of the mounpoint
/// \return Newly created mountpoint.
//------------------------------------------------------------------------------
extern WF_API struct wf_mountpoint *
wf_mountpoint_create(
char const * path);
//------------------------------------------------------------------------------
/// \brief Disposes a mountpoint.
///
/// \param mountpoint pointer to the mountpoint
//------------------------------------------------------------------------------
extern WF_API void
wf_mountpoint_dispose(
struct wf_mountpoint * mountpoint);
//------------------------------------------------------------------------------
/// \brief Returns the local path of the mountpoint.
///
/// \param mountpoint pointer to the mountpoint
/// \return local path of the mountpoint
//------------------------------------------------------------------------------
extern WF_API char const *
wf_mountpoint_get_path(
struct wf_mountpoint const * mountpoint);
//------------------------------------------------------------------------------
/// \brief Sets user data of the mointpoint.
///
/// \note This function is intended for custom mountpoint factories to
/// annotate mountpoints with a user specified context.
///
/// \param mounpoint pointer to the mountpoint
/// \param user_data user data
/// \param dispose pointer to dipose function of user data or NULL,
/// if there is no need to dispose user data
//------------------------------------------------------------------------------
extern WF_API void
wf_mountpoint_set_userdata(
struct wf_mountpoint * mointpoint,
void * user_data,
wf_mountpoint_userdata_dispose_fn * dispose);
#ifdef __cplusplus
}
#endif
#endif

@ -1,39 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/mountpoint_factory.h
/// \brief Defines a factory function to create mointpoints.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_MOUNTPOINT_FACTORY_H
#define WF_ADAPTER_MOUNTPOINT_FACTORY_H
#include <webfuse/adapter/api.h>
#ifdef __cplusplus
extern "C"
{
#endif
struct wf_mountpoint;
//------------------------------------------------------------------------------
/// \brief Factory function to create mountpoints.
///
/// \param filesystem name the filesystem
/// \param user_data context of the factory
/// \return newly created mountpoint or NULL, on error
///
/// \see wf_server_config_set_mountpoint_factory
/// \see wf_server_protocol_create
//------------------------------------------------------------------------------
typedef struct wf_mountpoint *
wf_create_mountpoint_fn(
char const * filesystem,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,87 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/server.h
/// \brief Adapter server.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_SERVER_H
#define WF_ADAPTER_SERVER_H
#include "webfuse/adapter/api.h"
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \struct wf_server
/// \brief Webfuse adapter server object.
//------------------------------------------------------------------------------
struct wf_server;
struct wf_server_config;
//------------------------------------------------------------------------------
/// \brief Creates a new server.
///
/// \param config pointer to server configuration.
/// \return newly created server or NULL in case of an error
//------------------------------------------------------------------------------
extern WF_API struct wf_server * wf_server_create(
struct wf_server_config * config);
//------------------------------------------------------------------------------
/// \brief Disposes a server.
///
/// \note server configuration is not managed by server.
///
/// \param server pointer to server
//------------------------------------------------------------------------------
extern WF_API void wf_server_dispose(
struct wf_server * server);
//------------------------------------------------------------------------------
/// \brief Triggers the server.
///
/// This function must be invoked in a loop while the server is running. It
/// makes the server wait for the next event and processes it.
///
/// \param server pointer to server
///
/// \see wf_server_interrupt
//------------------------------------------------------------------------------
extern WF_API void wf_server_service(
struct wf_server * server);
//------------------------------------------------------------------------------
/// \brief Interrupts wf_server_service
///
/// This function can be used from another thread.
///
/// \param server pointer to server
///
/// \see wf_server_service
//------------------------------------------------------------------------------
extern WF_API void wf_server_interrupt(
struct wf_server * server);
//------------------------------------------------------------------------------
/// \brief Returns the port number used by the server
///
/// This function can be used to determine the port number of the server,
/// if it was configured to let the system choose a free port.
//
/// \param server pointer to server
/// \return Port number used by the server.
///
/// \see wf_server_config_set_port
//------------------------------------------------------------------------------
extern WF_API int wf_server_get_port(
struct wf_server const * server);
#ifdef __cplusplus
}
#endif
#endif

@ -1,155 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/server_config.h
/// \brief Server configuration.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_SERVER_CONFIG_H
#define WF_ADAPTER_SERVER_CONFIG_H
#include "webfuse/adapter/api.h"
#include "webfuse/adapter/authenticate.h"
#include "webfuse/adapter/mountpoint_factory.h"
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \struct wf_server_config
/// \brief Holds configuration of webfuse adapter server.
//------------------------------------------------------------------------------
struct wf_server_config;
//------------------------------------------------------------------------------
/// \brief Creates a new server configuration.
///
/// \return newly created server configuration
//------------------------------------------------------------------------------
extern WF_API struct wf_server_config * wf_server_config_create(void);
//------------------------------------------------------------------------------
/// \brief Disposes a server configuration.
///
/// \note Contexts of mounpoint factory and added authenticators are not
/// disposed by default.
///
/// \param config pointer of configuration object
///
/// \see wf_server_config_set_mountpoint_factory
/// \see wf_server_config_add_authenticator
//------------------------------------------------------------------------------
extern WF_API void wf_server_config_dispose(
struct wf_server_config * config);
//------------------------------------------------------------------------------
/// \brief Sets the mountpoint factory of the configuration.
///
/// The mountpoint factory is called when a authenticated user adds a
/// filesystem.
///
/// \note The user is responsible to manage the lifetime of the mountpoint
/// factory.
///
/// \note A valid configuration needs either a mountpoint or a mounpoint
/// factory.
///
/// \param config pointer of configuration object
/// \param create_mountpoint factory function to create a mountpoint
/// \param user_data context of mountpoint factory
//------------------------------------------------------------------------------
extern WF_API void wf_server_config_set_mountpoint_factory(
struct wf_server_config * config,
wf_create_mountpoint_fn * create_mountpoint,
void * user_data);
//------------------------------------------------------------------------------
/// \brief Sets the path of HTTP servers root context.
///
/// Webfuse adapter server is capable of serving static HTTP context. This
/// function is used to specify the path of HTTP servers root context.
/// If not specified, no HTTP content is served.
///
/// \param config pointer of configuration object
/// \param document_root path to static HTTP content
//------------------------------------------------------------------------------
extern WF_API void wf_server_config_set_documentroot(
struct wf_server_config * config,
char const * document_root);
//------------------------------------------------------------------------------
/// \brief Sets the path to the servers private key.
///
/// \note To enable TLS, private key and server certificate must be set.
/// Otherwise, only plain HTTP is supported.
///
/// \param config pointer of configuration object
/// \param key_path path to servers private key (pem file)
//------------------------------------------------------------------------------
extern WF_API void wf_server_config_set_keypath(
struct wf_server_config * config,
char const * key_path);
//------------------------------------------------------------------------------
/// \brief Sets path to servers certificate.
///
/// \note To enable TLS, private key and server certificate must be set.
/// Otherwise, only plain HTTP is supported.
///
/// \param config pointer of configuration object
/// \param cert_path path to servers certificate (pem file)
//------------------------------------------------------------------------------
extern WF_API void wf_server_config_set_certpath(
struct wf_server_config * config,
char const * cert_path);
//------------------------------------------------------------------------------
/// \brief Sets the virtual hostname of the websockets server.
///
/// \param config pointer of configuration object
/// \param vhost_name virtual hostname of the websockets server
//------------------------------------------------------------------------------
extern WF_API void wf_server_config_set_vhostname(
struct wf_server_config * config,
char const * vhost_name);
//------------------------------------------------------------------------------
/// \brief Sets the port number of the websockets server.
///
/// Note: Set port number to 0 to let system choose a free port.
///
/// \param config pointer of configuration object
/// \param port port number of the websockets server
//------------------------------------------------------------------------------
extern WF_API void wf_server_config_set_port(
struct wf_server_config * config,
int port);
//------------------------------------------------------------------------------
/// \brief Adds an authenticator.
///
/// Authenticators are used to authenticate users by some provided credentials.
/// Multiple providers can be specified to support different types of
/// credentials.
///
/// \note Adding multiple providers for the same credentials type results
/// in undefined behavior.
///
/// \note The user is responsible to manage the lifetime of user data.
///
/// \param config pointer to configuration object
/// \param type type of the credentials the authenticator supports
/// \param authenticate function called to authenticate a user
/// \param user_data context of authenticate function
//------------------------------------------------------------------------------
extern WF_API void wf_server_config_add_authenticator(
struct wf_server_config * config,
char const * type,
wf_authenticate_fn * authenticate,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,97 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file adapter/server_protocol.h
/// \brief Provides low level access to libwebsockets protocol.
///
/// By default, libwebfuse encapsulates libwebsockets protocol by \ref
/// wf_server. But sometimes it might come in handy to have access to
/// libwebsockets protocol. This allows to integrate libwebfuse in existing
/// libwebsockets applications.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_SERVER_PROTOCOL_H
#define WF_ADAPTER_SERVER_PROTOCOL_H
#include <webfuse/adapter/api.h>
#include <webfuse/adapter/authenticate.h>
#include <webfuse/adapter/mountpoint_factory.h>
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
/// \struct wf_server_protocol
/// \brief Opaque webfuse server protocol.
//------------------------------------------------------------------------------
struct wf_server_protocol;
//------------------------------------------------------------------------------
/// \struct lws_protocols
/// \brief Forward declaration of libwebsockets protocols structure.
//------------------------------------------------------------------------------
struct lws_protocols;
//------------------------------------------------------------------------------
/// \brief Creates a new protocol by a mountpoint factory.
///
/// \note This function might be renamed in future releases.
///
/// \note The user is responsible to manage the lifetime of mountpoint factory.
///
/// \param create_mountpoint factory function to create mountpoints
/// \param create_mountpoint_context context of mountpoint factory
//------------------------------------------------------------------------------
extern WF_API struct wf_server_protocol * wf_server_protocol_create(
wf_create_mountpoint_fn * create_mountpoint,
void * create_mountpoint_context);
//------------------------------------------------------------------------------
/// \brief Disposes a protocol.
///
/// \note Contexts of mountpoint factory and added authenticators are not
/// managed by dispose.
///
/// \param protocol pointer to protocol
//------------------------------------------------------------------------------
extern WF_API void wf_server_protocol_dispose(
struct wf_server_protocol * protocol);
//------------------------------------------------------------------------------
/// \brief Intializes a libwebsockets protocol structure.
///
/// \param protocol pointer to protocol
/// \param lws_protocols pointer to libwebsockets protocol structure
//------------------------------------------------------------------------------
extern WF_API void wf_server_protocol_init_lws(
struct wf_server_protocol * protocol,
struct lws_protocols * lws_protocol);
//------------------------------------------------------------------------------
/// \brief Adds an authenticator.
///
/// Authenticators are used to authenticate users by some provided credentials.
/// Multiple providers can be specified to support different types of
/// credentials.
///
/// \note Adding multiple providers for the same credentials type results
/// in undefined behavior.
///
/// \note The user is responsible to manage the lifetime of user data.
///
/// \param protocol pointer to protocol
/// \param type type of the credentials the authenticator supports
/// \param authenticate function called to authenticate a user
/// \param user_data context of authenticate function
//------------------------------------------------------------------------------
extern WF_API void wf_server_protocol_add_authenticator(
struct wf_server_protocol * protocol,
char const * type,
wf_authenticate_fn * authenticate,
void * user_data);
#ifdef __cplusplus
}
#endif
#endif

@ -1,25 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// \file webfuse_adapter.h
/// \brief Convenience header to include all functionality of libfuse_adapter.
////////////////////////////////////////////////////////////////////////////////
#ifndef WF_ADAPTER_H
#define WF_ADAPTER_H
#include <webfuse/core/status.h>
#include <webfuse/core/protocol_names.h>
#include <webfuse/adapter/api.h>
#include <webfuse/adapter/server.h>
#include <webfuse/adapter/server_config.h>
#include <webfuse/adapter/server_protocol.h>
#include <webfuse/adapter/authenticate.h>
#include <webfuse/adapter/credentials.h>
#include <webfuse/adapter/mountpoint.h>
#include <webfuse/adapter/client.h>
#include <webfuse/adapter/client_callback.h>
#include <webfuse/adapter/client_tlsconfig.h>
#endif

@ -143,7 +143,6 @@ alltests = executable('alltests',
'test/webfuse/utils/ws_server2.cc',
'test/webfuse/utils/jansson_test_environment.cc',
'test/webfuse/mocks/fake_invokation_context.cc',
'test/webfuse/mocks/mock_authenticator.cc',
'test/webfuse/mocks/mock_request.cc',
'test/webfuse/mocks/mock_provider_client.cc',
'test/webfuse/mocks/mock_provider.cc',

@ -1,44 +0,0 @@
#include "webfuse/mocks/mock_adapter_client_callback.hpp"
#include "webfuse/adapter/client.h"
extern "C"
{
static void
webfuse_test_MockAdapterClientCallback_callback(
wf_client * client,
int reason,
void * args)
{
void * user_data = wf_client_get_userdata(client);
auto * callback = reinterpret_cast<webfuse_test::MockAdapterClientCallback*>(user_data);
callback->Invoke(client, reason, args);
}
}
namespace webfuse_test
{
MockAdapterClientCallback::MockAdapterClientCallback()
{
}
MockAdapterClientCallback::~MockAdapterClientCallback()
{
}
void * MockAdapterClientCallback::GetUserData()
{
return reinterpret_cast<void*>(this);
}
wf_client_callback_fn * MockAdapterClientCallback::GetCallbackFn()
{
return &webfuse_test_MockAdapterClientCallback_callback;
}
}

@ -1,22 +0,0 @@
#ifndef WF_MOCK_ADAPTER_CLIENT_CALLBACK_HPP
#define WF_MOCK_ADAPTER_CLIENT_CALLBACK_HPP
#include <gmock/gmock.h>
#include "webfuse/adapter/client_callback.h"
namespace webfuse_test
{
class MockAdapterClientCallback
{
public:
MockAdapterClientCallback();
virtual ~MockAdapterClientCallback();
MOCK_METHOD3(Invoke, void (wf_client *, int, void *));
void * GetUserData();
wf_client_callback_fn * GetCallbackFn();
};
}
#endif

@ -1,42 +0,0 @@
#include "webfuse/mocks/mock_authenticator.hpp"
#define WF_AUTHENTICATOR_COUNT 3
namespace
{
webfuse_test::Authenticator * g_authenticators[WF_AUTHENTICATOR_COUNT];
}
namespace webfuse_test
{
void set_authenticator(Authenticator * authenticator)
{
set_authenticator(0, authenticator);
}
void set_authenticator(size_t i, Authenticator * authenticator)
{
g_authenticators[i] = authenticator;
}
bool authenticate(struct wf_credentials const * creds, void * user_data)
{
return g_authenticators[0]->authenticate(creds, user_data);
}
bool authenticate_1(struct wf_credentials const * creds, void * user_data)
{
return g_authenticators[1]->authenticate(creds, user_data);
}
bool authenticate_2(struct wf_credentials const * creds, void * user_data)
{
return g_authenticators[2]->authenticate(creds, user_data);
}
}

@ -1,34 +0,0 @@
#ifndef MOCK_AUTHENTICATOR_H
#define MOCK_AUTHENTICATOR_H
#include <gmock/gmock.h>
#include "webfuse/adapter/impl/authenticator.h"
namespace webfuse_test
{
class Authenticator
{
public:
virtual ~Authenticator() { }
virtual bool authenticate(
struct wf_credentials const * credentials,
void * user_data) = 0;
};
class MockAuthenticator: public Authenticator
{
public:
MOCK_METHOD2(authenticate, bool (struct wf_credentials const * credentials, void * user_data));
};
void set_authenticator(Authenticator * authenticator);
void set_authenticator(size_t index, Authenticator * authenticator);
bool authenticate(struct wf_credentials const * creds, void * user_data);
bool authenticate_1(struct wf_credentials const * creds, void * user_data);
bool authenticate_2(struct wf_credentials const * creds, void * user_data);
}
#endif
Loading…
Cancel
Save