summaryrefslogtreecommitdiff
path: root/src/Tizen.Account.OAuth2/Interop
diff options
context:
space:
mode:
Diffstat (limited to 'src/Tizen.Account.OAuth2/Interop')
-rw-r--r--src/Tizen.Account.OAuth2/Interop/Interop.Common.cs55
-rw-r--r--src/Tizen.Account.OAuth2/Interop/Interop.Error.cs44
-rw-r--r--src/Tizen.Account.OAuth2/Interop/Interop.Libraries.cs28
-rwxr-xr-xsrc/Tizen.Account.OAuth2/Interop/Interop.Manager.cs70
-rw-r--r--src/Tizen.Account.OAuth2/Interop/Interop.Request.cs129
-rw-r--r--src/Tizen.Account.OAuth2/Interop/Interop.Response.cs62
-rw-r--r--src/Tizen.Account.OAuth2/Interop/Interop.Types.cs38
7 files changed, 426 insertions, 0 deletions
diff --git a/src/Tizen.Account.OAuth2/Interop/Interop.Common.cs b/src/Tizen.Account.OAuth2/Interop/Interop.Common.cs
new file mode 100644
index 0000000..b16906f
--- /dev/null
+++ b/src/Tizen.Account.OAuth2/Interop/Interop.Common.cs
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Contains Interop declarations of OAuth2 classes.
+/// </summary>
+internal static partial class Interop
+{
+ /// <summary>
+ /// Safehandle wrapper for OAuth2 native handles.
+ /// </summary>
+ internal abstract class SafeOauth2Handle : SafeHandle
+ {
+ public SafeOauth2Handle() : base(IntPtr.Zero, true)
+ {
+ }
+
+ public SafeOauth2Handle(IntPtr handle) : base(handle, true)
+ {
+ }
+
+ public override bool IsInvalid
+ {
+ get
+ {
+ return handle == IntPtr.Zero;
+ }
+ }
+
+ public abstract void Destroy();
+
+ protected override bool ReleaseHandle()
+ {
+ Destroy();
+ SetHandle(IntPtr.Zero);
+ return true;
+ }
+ }
+}
diff --git a/src/Tizen.Account.OAuth2/Interop/Interop.Error.cs b/src/Tizen.Account.OAuth2/Interop/Interop.Error.cs
new file mode 100644
index 0000000..de77168
--- /dev/null
+++ b/src/Tizen.Account.OAuth2/Interop/Interop.Error.cs
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Contains Interop declarations of OAuth2 classes.
+/// </summary>
+internal static partial class Interop
+{
+ /// <summary>
+ /// Wrapper class for OAuth2 native API.
+ /// </summary>
+ internal static partial class Error
+ {
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_error_get_code")]
+ internal static extern int GetCode(IntPtr /* oauth2_error_h */ handle, out int serverErrorCode, out int platformErrorCode);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_error_get_description")]
+ internal static extern int GetDescription(IntPtr /* oauth2_error_h */ handle, out string description);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_error_get_uri")]
+ internal static extern int GetUri(IntPtr /* oauth2_error_h */ handle, out string uri);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_error_get_custom_data")]
+ internal static extern int GetCustomData(IntPtr /* oauth2_error_h */ handle, string customKey, out string customValue);
+
+
+ }
+}
diff --git a/src/Tizen.Account.OAuth2/Interop/Interop.Libraries.cs b/src/Tizen.Account.OAuth2/Interop/Interop.Libraries.cs
new file mode 100644
index 0000000..b446467
--- /dev/null
+++ b/src/Tizen.Account.OAuth2/Interop/Interop.Libraries.cs
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+ /// <summary>
+ /// Wrapper class for maintaining names of dependent native libraries.
+ /// </summary>
+ internal static partial class Libraries
+ {
+ public const string OAuth2 = "liboauth2.so.0";
+ public const string Glib = "libglib-2.0.so.0";
+ public const string Libc = "libc.so.6";
+ }
+}
diff --git a/src/Tizen.Account.OAuth2/Interop/Interop.Manager.cs b/src/Tizen.Account.OAuth2/Interop/Interop.Manager.cs
new file mode 100755
index 0000000..3970b6b
--- /dev/null
+++ b/src/Tizen.Account.OAuth2/Interop/Interop.Manager.cs
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Contains Interop declarations of OAuth2 classes.
+/// </summary>
+internal static partial class Interop
+{
+ /// <summary>
+ /// Wrapper class for OAuth2 native API.
+ /// </summary>
+ internal static partial class Manager
+ {
+ [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+ internal delegate void Oauth2TokenCallback(IntPtr /* oauth2_response_h */ response, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+ internal delegate void Oauth2AuthGrantCallback(IntPtr /* oauth2_response_h */ response, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+ internal delegate void Oauth2AccessTokenCallback(IntPtr /* oauth2_response_h */ response, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+ internal delegate void Oauth2RefreshTokenCallback(IntPtr /* oauth2_response_h */ response, IntPtr /* void */ userData);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_manager_create")]
+ internal static extern int Create(out IntPtr /* oauth2_manager_h */ handle);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_manager_destroy")]
+ internal static extern int Destroy(IntPtr /* oauth2_manager_h */ handle);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_manager_request_token")]
+ internal static extern int RequestToken(IntPtr /* oauth2_manager_h */ handle, IntPtr /* oauth2_request_h */ request, Oauth2TokenCallback callback, IntPtr /* void */ userData);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_manager_request_authorization_grant")]
+ internal static extern int RequestAuthorizationGrant(IntPtr /* oauth2_manager_h */ handle, IntPtr /* oauth2_request_h */ request, Oauth2AuthGrantCallback callback, IntPtr /* void */ userData);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_manager_request_access_token")]
+ internal static extern int RequestAccessToken(IntPtr /* oauth2_manager_h */ handle, IntPtr /* oauth2_request_h */ request, Oauth2AccessTokenCallback callback, IntPtr /* void */ userData);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_manager_refresh_access_token")]
+ internal static extern int RefreshAccessToken(IntPtr /* oauth2_manager_h */ handle, IntPtr /* oauth2_request_h */ request, Oauth2RefreshTokenCallback callback, IntPtr /* void */ userData);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_manager_is_request_in_progress")]
+ [return: MarshalAs(UnmanagedType.I1)]
+ internal static extern bool IsRequestInProgress(IntPtr /* oauth2_manager_h */ handle);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_manager_clear_cookies")]
+ internal static extern int ClearCookies(IntPtr /* oauth2_manager_h */ handle);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_manager_clear_cache")]
+ internal static extern int ClearCache(IntPtr /* oauth2_manager_h */ handle);
+ }
+}
diff --git a/src/Tizen.Account.OAuth2/Interop/Interop.Request.cs b/src/Tizen.Account.OAuth2/Interop/Interop.Request.cs
new file mode 100644
index 0000000..c76dba0
--- /dev/null
+++ b/src/Tizen.Account.OAuth2/Interop/Interop.Request.cs
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Contains Interop declarations of OAuth2 classes.
+/// </summary>
+internal static partial class Interop
+{
+ /// <summary>
+ /// Wrapper class for OAuth2 native API.
+ /// </summary>
+ internal static partial class Request
+ {
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_create")]
+ internal static extern int Create(out IntPtr /* oauth2_request_h */ handle);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_destroy")]
+ internal static extern int Destroy(IntPtr /* oauth2_request_h */ handle);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_auth_end_point_url")]
+ internal static extern int SetAuthEndPointUrl(IntPtr /* oauth2_request_h */ handle, string url);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_token_end_point_url")]
+ internal static extern int SetTokenEndPointUrl(IntPtr /* oauth2_request_h */ handle, string url);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_redirection_url")]
+ internal static extern int SetRedirectionUrl(IntPtr /* oauth2_request_h */ handle, string url);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_refresh_token_url")]
+ internal static extern int SetRefreshTokenUrl(IntPtr /* oauth2_request_h */ handle, string url);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_refresh_token")]
+ internal static extern int SetRefreshToken(IntPtr /* oauth2_request_h */ handle, string refreshToken);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_response_type")]
+ internal static extern int SetResponseType(IntPtr /* oauth2_request_h */ handle, ResponseType /* oauth2_response_type_e */ responseType);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_client_id")]
+ internal static extern int SetClientId(IntPtr /* oauth2_request_h */ handle, string clientId);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_client_secret")]
+ internal static extern int SetClientSecret(IntPtr /* oauth2_request_h */ handle, string clientSecret);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_client_authentication_type")]
+ internal static extern int SetClientAuthenticationType(IntPtr /* oauth2_request_h */ handle, int /* oauth2_client_authentication_type_e */ clientAuthType);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_scope")]
+ internal static extern int SetScope(IntPtr /* oauth2_request_h */ handle, string scope);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_state")]
+ internal static extern int SetState(IntPtr /* oauth2_request_h */ handle, string state);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_grant_type")]
+ internal static extern int SetGrantType(IntPtr /* oauth2_request_h */ handle, GrantType /* oauth2_grant_type_e */ grantType);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_authorization_code")]
+ internal static extern int SetAuthorizationCode(IntPtr /* oauth2_request_h */ handle, string code);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_user_name")]
+ internal static extern int SetUserName(IntPtr /* oauth2_request_h */ handle, string userName);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_set_password")]
+ internal static extern int SetPassword(IntPtr /* oauth2_request_h */ handle, string password);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_add_custom_data")]
+ internal static extern int AddCustomData(IntPtr /* oauth2_request_h */ handle, string key, string value);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_auth_end_point_url")]
+ internal static extern int GetAuthEndPointUrl(IntPtr /* oauth2_request_h */ handle, out string url);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_token_end_point_url")]
+ internal static extern int GetTokenEndPointUrl(IntPtr /* oauth2_request_h */ handle, out string url);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_redirection_url")]
+ internal static extern int GetRedirectionUrl(IntPtr /* oauth2_request_h */ handle, out string url);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_refresh_token_url")]
+ internal static extern int GetRefreshTokenUrl(IntPtr /* oauth2_request_h */ handle, out string url);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_refresh_token")]
+ internal static extern int GetRefreshToken(IntPtr /* oauth2_request_h */ handle, out string refreshToken);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_response_type")]
+ internal static extern int GetResponseType(IntPtr /* oauth2_request_h */ handle, out ResponseType /* oauth2_response_type_e */ responseType);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_client_id")]
+ internal static extern int GetClientId(IntPtr /* oauth2_request_h */ handle, out string clientId);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_client_secret")]
+ internal static extern int GetClientSecret(IntPtr /* oauth2_request_h */ handle, out string clientSecret);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_scope")]
+ internal static extern int GetScope(IntPtr /* oauth2_request_h */ handle, out string scope);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_state")]
+ internal static extern int GetState(IntPtr /* oauth2_request_h */ handle, out string state);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_grant_type")]
+ internal static extern int GetGrantType(IntPtr /* oauth2_request_h */ handle, out GrantType /* oauth2_grant_type_e */ grantType);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_authorization_code")]
+ internal static extern int GetAuthorizationCode(IntPtr /* oauth2_request_h */ handle, out string code);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_user_name")]
+ internal static extern int GetUserName(IntPtr /* oauth2_request_h */ handle, out string userName);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_password")]
+ internal static extern int GetPassword(IntPtr /* oauth2_request_h */ handle, out string password);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_request_get_custom_data")]
+ internal static extern int GetCustomData(IntPtr /* oauth2_request_h */ handle, string customKey, out string customValue);
+ }
+}
diff --git a/src/Tizen.Account.OAuth2/Interop/Interop.Response.cs b/src/Tizen.Account.OAuth2/Interop/Interop.Response.cs
new file mode 100644
index 0000000..6131414
--- /dev/null
+++ b/src/Tizen.Account.OAuth2/Interop/Interop.Response.cs
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Contains Interop declarations of OAuth2 classes.
+/// </summary>
+internal static partial class Interop
+{
+ /// <summary>
+ /// Wrapper class for OAuth2 native API.
+ /// </summary>
+ internal static partial class Response
+ {
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_destroy")]
+ internal static extern int Destroy(IntPtr /* oauth2_response_h */ handle);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_get_authorization_code")]
+ internal static extern int GetAuthorizationCode(IntPtr /* oauth2_response_h */ handle, out IntPtr code);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_get_state")]
+ internal static extern int GetState(IntPtr /* oauth2_response_h */ handle, out IntPtr state);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_get_access_token")]
+ internal static extern int GetAccessToken(IntPtr /* oauth2_response_h */ handle, out IntPtr accessToken);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_get_token_type")]
+ internal static extern int GetTokenType(IntPtr /* oauth2_response_h */ handle, out IntPtr tokenType);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_get_expires_in")]
+ internal static extern int GetExpiresIn(IntPtr /* oauth2_response_h */ handle, out long expiresIn);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_get_refresh_token")]
+ internal static extern int GetRefreshToken(IntPtr /* oauth2_response_h */ handle, out IntPtr refreshToken);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_get_scope")]
+ internal static extern int GetScope(IntPtr /* oauth2_response_h */ handle, out IntPtr scope);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_get_error")]
+ internal static extern int GetError(IntPtr /* oauth2_response_h */ handle, out IntPtr /* oauth2_error_h */ error);
+
+ [DllImport(Libraries.OAuth2, EntryPoint = "oauth2_response_get_custom_data")]
+ internal static extern int GetCustomData(IntPtr /* oauth2_response_h */ handle, string customKey, out IntPtr customValue);
+
+
+ }
+}
diff --git a/src/Tizen.Account.OAuth2/Interop/Interop.Types.cs b/src/Tizen.Account.OAuth2/Interop/Interop.Types.cs
new file mode 100644
index 0000000..27bf2cb
--- /dev/null
+++ b/src/Tizen.Account.OAuth2/Interop/Interop.Types.cs
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+/// <summary>
+/// Contains Interop declarations of OAuth2 classes.
+/// </summary>
+internal static partial class Interop
+{
+ internal enum GrantType
+ {
+ AuthCode, // OAUTH2_GRANT_TYPE_AUTH_CODE
+ Password, // OAUTH2_GRANT_TYPE_PASSWORD
+ ClientCredentials, // OAUTH2_GRANT_TYPE_CLIENT_CREDENTIALS
+ Refresh, // OAUTH2_GRANT_TYPE_REFRESH
+ }
+
+ internal enum ResponseType
+ {
+ Code, // OAUTH2_RESPONSE_TYPE_CODE
+ Token, // OAUTH2_RESPONSE_TYPE_TOKEN
+ }
+}