From 4047160be8f8b4b2b6379afa0b9cc71214baa792 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Mon, 24 Dec 2012 16:30:43 +0100 Subject: [PATCH] test: server: Implement authentication with commercial certificate New implemementation server_certificate_with_password_authentication() has been added. --- .../certificate_user_password_authentication.c | 4 +-- test/simline/server.c | 40 ++++++++++++++++++---- test/simline/server.h | 10 +++++- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/test/simline/certificate_user_password_authentication.c b/test/simline/certificate_user_password_authentication.c index 10b41ce..f328509 100644 --- a/test/simline/certificate_user_password_authentication.c +++ b/test/simline/certificate_user_password_authentication.c @@ -99,8 +99,8 @@ int main(int argc, char **argv) { .passphrase = NULL }; error = start_server(&server_process, &url, - server_basic_authentication, &server_arguments, - &tls_arguments); + server_certificate_with_password_authentication, + &server_arguments, &tls_arguments); if (error == -1) { isds_ctx_free(&context); isds_cleanup(); diff --git a/test/simline/server.c b/test/simline/server.c index 9a526aa..9a47eef 100644 --- a/test/simline/server.c +++ b/test/simline/server.c @@ -34,6 +34,7 @@ static const char *asws_path = "/asws/changePassword"; static const char *ws_path = "/apps/DS/dz"; static const char *ws_base_path_basic = "/"; +static const char *ws_base_path_commercial_certificate_with_password = "/certds/"; static const char *ws_base_path_otp = "/apps/"; static const char *authorization_cookie_name = "IPCZ-X-COOKIE"; @@ -182,15 +183,17 @@ static void do_ws(const struct http_connection *connection, /* Do the server protocol. * @connection is HTTP connection - * @server_arguments is pointer to structure: + * @server_arguments is pointer to structure arguments_basic_authentication * @request is parsed HTTP client request + * @prefix is HTTP URI path prefix (directory) where all ISDS services live * @return 0 to accept new client, return -1 in case of fatal error. */ -int server_basic_authentication(const struct http_connection *connection, - const void *server_arguments, const struct http_request *request) { +static int server_prefixed_basic_authentication( + const struct http_connection *connection, const void *server_arguments, + const struct http_request *request, const char *prefix) { const struct arguments_basic_authentication *arguments = (const struct arguments_basic_authentication *) server_arguments; - if (NULL == arguments || NULL == request) { + if (NULL == arguments || NULL == request || NULL == prefix) { return -1; } @@ -202,7 +205,7 @@ int server_basic_authentication(const struct http_connection *connection, arguments->username, arguments->password)) { case HTTP_ERROR_SUCCESS: do_ws(connection, arguments->services, request, - ws_base_path_basic); + prefix); break; case HTTP_ERROR_CLIENT: if (arguments->isds_deviations) @@ -220,7 +223,7 @@ int server_basic_authentication(const struct http_connection *connection, } } else { do_ws(connection, arguments->services, request, - ws_base_path_basic); + prefix); } } else { /* HTTP method unsupported per ISDS specification */ @@ -232,6 +235,31 @@ int server_basic_authentication(const struct http_connection *connection, } +/* Do the server protocol. + * @connection is HTTP connection + * @server_arguments is pointer to structure arguments_basic_authentication + * @request is parsed HTTP client request + * @return 0 to accept new client, return -1 in case of fatal error. */ +int server_basic_authentication(const struct http_connection *connection, + const void *server_arguments, const struct http_request *request) { + return server_prefixed_basic_authentication(connection, server_arguments, + request, ws_base_path_basic); +} + + +/* Do the server protocol. + * @connection is HTTP connection + * @server_arguments is pointer to structure arguments_basic_authentication + * @request is parsed HTTP client request + * @return 0 to accept new client, return -1 in case of fatal error. */ +int server_certificate_with_password_authentication( + const struct http_connection *connection, + const void *server_arguments, const struct http_request *request) { + return server_prefixed_basic_authentication(connection, server_arguments, + request, ws_base_path_commercial_certificate_with_password); +} + + /* Process first phase of TOTP request */ static void do_as_sendsms(const struct http_connection *connection, const struct http_request *request, diff --git a/test/simline/server.h b/test/simline/server.h index 5976192..4cc4b94 100644 --- a/test/simline/server.h +++ b/test/simline/server.h @@ -50,12 +50,20 @@ struct arguments_basic_authentication { /* Do the server protocol. * @connection is HTTP connection - * @server_arguments is pointer to structure: + * @server_arguments is pointer to structure arguments_basic_authentication * @request is parsed HTTP client request * @return 0 to accept new client, return -1 in case of fatal error. */ int server_basic_authentication(const struct http_connection *connection, const void *server_arguments, const struct http_request *request); +/* Do the server protocol. + * @connection is HTTP connection + * @server_arguments is pointer to structure arguments_basic_authentication + * @request is parsed HTTP client request + * @return 0 to accept new client, return -1 in case of fatal error. */ +int server_certificate_with_password_authentication( + const struct http_connection *connection, + const void *server_arguments, const struct http_request *request); struct arguments_otp_authentication { enum auth_otp_method method; /* Selects OTP method to enable */ -- 2.11.4.GIT