/// <summary> /// Processes the given FIDO UAF message. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="uafMessage">The FIDO UAF message which is received from the relying party server</param> /// <param name="channelBindng">The channel binding data in JSON format which is received from the relying party server</param> /// <returns>FIDO response message</returns> /// <privilege>http://tizen.org/privilege/fido.client</privilege> /// <feature>http://tizen.org/feature/fido.uaf</feature> /// <exception cref="ArgumentException"> In case of invalid parameter</exception> /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method</exception> /// <exception cref="NotSupportedException">FIDO is not supported</exception> /// <example> /// <code> /// UafMessage uafRequest = new UafMessage() /// { /// Operation = "UafAuthRequestJson" /// }; /// /// var response = await UafClient.ProcessRequestAsync(uafRequest, null); /// </code> /// </example> public static async Task <UafResponse> ProcessRequestAsync(UafMessage uafMessage, string channelBindng) { if (uafMessage == null) { Log.Error(ErrorFactory.LogTag, "Invalid request or request is null"); throw ErrorFactory.GetException((int)FidoErrorCode.InvalidParameter); } IntPtr id = IntPtr.Zero; lock (_taskCompletionMap) { id = (IntPtr)_responseCompletionId++; } TaskCompletionSource <UafResponse> tcsUafResponse = new TaskCompletionSource <UafResponse>(); _taskCompletionMap[id] = tcsUafResponse; int ret = Interop.UafClient.FidoUafGetResponseMessage(uafMessage.Operation, channelBindng, _UafResponseMessageCallback, id); if (ret != (int)FidoErrorCode.None) { Log.Error(ErrorFactory.LogTag, "Interop API failed with error code: [" + ret + "]"); throw ErrorFactory.GetException(ret); } return(await tcsUafResponse.Task.ConfigureAwait(false)); }
/// <summary> /// Checks whether the FIDO message can be processed /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="uafMessage">The FIDO UAF message which is received from the relying party server</param> /// <returns>True if the message can be handled by the device, else false</returns> /// <privilege>http://tizen.org/privilege/fido.client</privilege> /// <feature>http://tizen.org/feature/fido.uaf</feature> /// <exception cref="ArgumentException"> In case of invalid parameter</exception> /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method</exception> /// <exception cref="NotSupportedException">FIDO is not supported</exception> /// <example> /// <code> /// UafMessage uafRequest = new UafMessage() /// { /// Operation = "UafRequestJson" /// }; /// bool response = await UafClient.CheckPolicyAsync(uafRequest); /// </code> /// </example> public static async Task <bool> CheckPolicyAsync(UafMessage uafMessage) { if (uafMessage == null) { Log.Error(ErrorFactory.LogTag, "Invalid request or request is null"); throw ErrorFactory.GetException((int)FidoErrorCode.InvalidParameter); } bool result = false; await Task.Run(() => result = CheckPolicy(uafMessage.Operation)); return(result); }
/// <summary> /// Processes the given FIDO UAF message. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="uafMessage">The FIDO UAF message which is received from the relying party server</param> /// <param name="channelBindng">The channel binding data in JSON format which is received from the relying party server</param> /// <returns>FIDO response message</returns> /// <privilege>http://tizen.org/privilege/fido.client</privilege> /// <feature>http://tizen.org/feature/fido.uaf</feature> /// <exception cref="ArgumentException"> In case of invalid parameter</exception> /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method</exception> /// <exception cref="NotSupportedException">FIDO is not supported</exception> /// <example> /// <code> /// UafMessage uafRequest = new UafMessage() /// { /// Operation = "UafAuthRequestJson" /// }; /// /// var response = await UafClient.ProcessRequestAsync(uafRequest, null); /// </code> /// </example> public static async Task <UafResponse> ProcessRequestAsync(UafMessage uafMessage, string channelBindng) { if (uafMessage == null) { Log.Error(ErrorFactory.LogTag, "Invalid request or request is null"); throw ErrorFactory.GetException((int)FidoErrorCode.InvalidParameter); } TaskCompletionSource <UafResponse> tcs = new TaskCompletionSource <UafResponse>(); Interop.UafClient.FidoUafResponseMessageCallback cb = (int errorCode, string uafResponseJson, IntPtr userData) => { if (uafMessage == null) { Log.Error(ErrorFactory.LogTag, "Invalid request or request is null"); tcs.SetException(ErrorFactory.GetException((int)FidoErrorCode.InvalidParameter)); } if (errorCode != (int)FidoErrorCode.None) { Log.Error(ErrorFactory.LogTag, "Interop callback failed with error code: [" + errorCode + "]"); tcs.SetException(ErrorFactory.GetException(errorCode)); } tcs.SetResult(new UafResponse() { Response = uafResponseJson }); }; int ret = Interop.UafClient.FidoUafGetResponseMessage(uafMessage.Operation, channelBindng, cb, IntPtr.Zero); if (ret != (int)FidoErrorCode.None) { Log.Error(ErrorFactory.LogTag, "Interop API failed with error code: [" + ret + "]"); throw ErrorFactory.GetException(ret); } return(await tcs.Task); }