constexpr char WIFI[] = "http://tizen.org/feature/network.wifi";
constexpr char ETHERNET[] = "http://tizen.org/feature/network.ethernet";
-int has_feature(const char *feature) {
+bool has_feature(const char *feature) {
#ifdef NO_FEATURE_CHECK
+ LogWarning("Skipping feature check for " << feature);
(void)feature;
- return WAUTHN_ERROR_NONE;
+ return true;
#else
bool is_supported;
if (SYSTEM_INFO_ERROR_NONE
!= system_info_get_platform_bool(feature, &is_supported)) {
- LogWarning("Failed to check feature " << feature);
- return WAUTHN_ERROR_UNKNOWN;
+ LogError("Failed to check feature " << feature);
+ return false;
}
if (!is_supported) {
LogWarning("Unsupported feature " << feature);
- return WAUTHN_ERROR_NOT_SUPPORTED;
+ return false;
}
- return WAUTHN_ERROR_NONE;
+ return true;
#endif
}
-int check_network_features() {
- if ((has_feature(TELEPHONY) != WAUTHN_ERROR_NONE) &&
- has_feature(WIFI) != WAUTHN_ERROR_NONE &&
- has_feature(ETHERNET) != WAUTHN_ERROR_NONE)
- return WAUTHN_ERROR_NOT_SUPPORTED;
- return WAUTHN_ERROR_NONE;
+bool check_network_features() {
+ return has_feature(TELEPHONY) || has_feature(WIFI) || has_feature(ETHERNET);
}
-int check_features() {
-#ifdef NO_FEATURE_CHECK
- LogWarning("Skip to check features");
- return WAUTHN_ERROR_NONE;
-#else
- int ret = WAUTHN_ERROR_NONE;
- if (((ret = has_feature(WEBAUTHN)) != WAUTHN_ERROR_NONE) ||
- ((ret = has_feature(BLUETOOTH)) != WAUTHN_ERROR_NONE) ||
- ((ret = check_network_features()) != WAUTHN_ERROR_NONE))
- {
- LogError("Features are not supported");
- return ret;
- }
- return WAUTHN_ERROR_NONE;
-#endif
+bool check_features() {
+ return has_feature(WEBAUTHN) && has_feature(BLUETOOTH) && check_network_features();
}
} // namespace
WEBAUTHN_API
int wauthn_set_api_version(int api_version_number) {
- int ret = has_feature(WEBAUTHN);
- if (ret != WAUTHN_ERROR_NONE)
- {
- LogError(get_error_message(ret));
- return ret;
+ if (!has_feature(WEBAUTHN)) {
+ LogError("Required feature is missing");
+ return WAUTHN_ERROR_NOT_SUPPORTED;
}
if (api_version_number != WAUTHN_API_VERSION_NUMBER)
WEBAUTHN_API
int wauthn_supported_authenticators(unsigned int *supported) {
- int ret = has_feature(WEBAUTHN);
- if (ret != WAUTHN_ERROR_NONE)
- {
- LogError(get_error_message(ret));
- return ret;
+ if (!has_feature(WEBAUTHN)) {
+ LogError("Required feature is missing");
+ return WAUTHN_ERROR_NOT_SUPPORTED;
}
if (supported == nullptr)
int wauthn_make_credential(const wauthn_client_data_s *client_data,
const wauthn_pubkey_cred_creation_options_s *options,
wauthn_mc_callbacks_s *callbacks) {
- int ret = check_features();
- if (ret != WAUTHN_ERROR_NONE)
- return ret;
+ if (!check_features()) {
+ LogError("Required feature is missing");
+ return WAUTHN_ERROR_NOT_SUPPORTED;
+ }
return try_catch([&]() -> int {
CheckParameters(client_data, options, callbacks);
int wauthn_get_assertion(const wauthn_client_data_s *client_data,
const wauthn_pubkey_cred_request_options_s *options,
wauthn_ga_callbacks_s *callbacks) {
- int ret = check_features();
- if (ret != WAUTHN_ERROR_NONE)
- return ret;
+ if (!check_features()) {
+ LogError("Required feature is missing");
+ return WAUTHN_ERROR_NOT_SUPPORTED;
+ }
return try_catch([&]() -> int {
CheckParameters(client_data, options, callbacks);