Remove Uncovered API's From OAuth2 (#849)
authorchauhan321 <39993408+chauhan321@users.noreply.github.com>
Thu, 23 May 2019 07:06:36 +0000 (12:36 +0530)
committerWonYoung Choi <wy80.choi@samsung.com>
Thu, 23 May 2019 07:06:36 +0000 (16:06 +0900)
* Remove Uncovered API's From OAuth2

Signed-off-by: kamaljeet <kamal.jc@samsung.com>
* Removed Uncovered API's From Oauth2 solved build error

src/Tizen.Account.OAuth2/Tizen.Account.OAuth2/AuthorizationResponse.cs
src/Tizen.Account.OAuth2/Tizen.Account.OAuth2/Authorizer.cs
src/Tizen.Account.OAuth2/Tizen.Account.OAuth2/ClientCredentialsAuthorizer.cs
src/Tizen.Account.OAuth2/Tizen.Account.OAuth2/CodeGrantAuthorizer.cs
src/Tizen.Account.OAuth2/Tizen.Account.OAuth2/ImplicitGrantAuthorizer.cs
src/Tizen.Account.OAuth2/Tizen.Account.OAuth2/ResourceOwnerPwdCredentialsAuthorizer.cs

index c12422a..c1fe528 100755 (executable)
@@ -42,39 +42,6 @@ namespace Tizen.Account.OAuth2
             Dispose(false);
         }
 
-        /// <summary>
-        /// The authroization code.
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        public string Code { get; internal set; }
-
-        /// <summary>
-        /// The state parameter present in authorization request.
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        /// <remarks>
-        /// The value can be null depending on the server specifications.
-        /// </remarks>
-        public string State { get; internal set; }
-
-        /// <summary>
-        /// Custom key-value parameter received from service provider
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        /// <remarks>
-        /// The return value can be null depending on the server specifications.
-        /// </remarks>
-        public string GetCustomValue(string key)
-        {
-            IntPtr value = IntPtr.Zero;
-            int ret = Interop.Response.GetCustomData(_responseHandle, key, out value);
-            if (ret != (int)OAuth2Error.None)
-            {
-                Log.Error(ErrorFactory.LogTag, "Interop failed");
-                throw ErrorFactory.GetException(ret);
-            }
-            return Marshal.PtrToStringAnsi(value);
-        }
 
         /// <summary>
         /// Releases any unmanaged resources used by this object.
index bf0496c..e7363dc 100755 (executable)
@@ -68,31 +68,6 @@ namespace Tizen.Account.OAuth2
             }
         }
 
-        /// <summary>
-        /// Authorizes the client with access toekn / authorizaion code in Implicit and Authorization Code grant flows respectively.
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        /// <see cref="CodeGrantAuthorizer.AuthorizeAsync(AuthorizationRequest)"/>
-        /// <see cref="ImplicitGrantAuthorizer.AuthorizeAsync(AuthorizationRequest)"/>
-        /// <param name="request">An authorization request</param>
-        /// <returns> The authorization response from server</returns>
-        public virtual Task<AuthorizationResponse> AuthorizeAsync(AuthorizationRequest request)
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// Gets the access token in OAuth2 supported grant flows except Implicit Grant flow.
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        /// <see cref="CodeGrantAuthorizer.AuthorizeAsync(AuthorizationRequest)"/>
-        /// <see cref="ImplicitGrantAuthorizer.AuthorizeAsync(AuthorizationRequest)"/>
-        /// <param name="request">A token request</param>
-        /// <returns>The response from server</returns>
-        public virtual Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
-        {
-            throw new NotImplementedException();
-        }
 
         /// <summary>
         /// Releases any unmanaged resources used by this object.
index b9d8f1c..a004b8a 100755 (executable)
@@ -40,7 +40,7 @@ namespace Tizen.Account.OAuth2
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <exception cref="InvalidOperationException">Thrown when the operation is not supported</exception>
-        public override Task<AuthorizationResponse> AuthorizeAsync(AuthorizationRequest request)
+        public  Task<AuthorizationResponse> AuthorizeAsync(AuthorizationRequest request)
         {
             Log.Error(ErrorFactory.LogTag, "Authorization is not supported in this flow");
             throw new InvalidOperationException();
@@ -67,7 +67,7 @@ namespace Tizen.Account.OAuth2
         /// <privilege>http://tizen.org/privilege/internet</privilege>
         /// <exception cref="ArgumentException">Thrown when method failed due to invalid argumets</exception>
         /// <exception cref="OAuth2Exception">Thrown when method fails due to server error</exception>
-        public override async Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
+        public  async Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
         {
             IntPtr requestHandle = GetRequestHandle(request as ClientCredentialsTokenRequest);
             return await Task.Run(() => GetAccessToken(requestHandle));
index bb7f1b5..6fe6467 100755 (executable)
@@ -36,20 +36,7 @@ namespace Tizen.Account.OAuth2
 
         }
 
-        /// <summary>
-        /// Retrieves authorization code asynchronously. The authroization request parameters should be as defined in https://tools.ietf.org/html/rfc6749#section-4.1.1
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        /// <param name="request">The authorization request <see cref="CodeGrantAuthorizationRequest"/></param>
-        /// <returns>The response containing authorization code.</returns>
-        /// <privilege>http://tizen.org/privilege/internet</privilege>
-        /// <exception cref="ArgumentException">Thrown when method failed due to invalid argumets</exception>
-        /// <exception cref="OAuth2Exception">Thrown when method fails due to server error</exception>
-        public override async Task<AuthorizationResponse> AuthorizeAsync(AuthorizationRequest request)
-        {
-            IntPtr requestHandle = GetRequestHandle(request as CodeGrantAuthorizationRequest);
-            return await Task.Run(() => GetAuthorizationResponse(requestHandle));
-        }
+
 
         /// <summary>
         /// Retrieves access token by exchanging authorization code received using <see cref="AuthorizeAsync(AuthorizationRequest)"/>.
@@ -61,41 +48,12 @@ namespace Tizen.Account.OAuth2
         /// <privilege>http://tizen.org/privilege/internet</privilege>
         /// <exception cref="ArgumentException">Thrown when method failed due to invalid argumets</exception>
         /// <exception cref="OAuth2Exception">Thrown when method fails due to server error</exception>
-        public override async Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
+        public  async Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
         {
             IntPtr requestHandle = GetRequestHandle(request as CodeGrantTokenRequest);
             return await Task.Run(() => GetAccessTokenByCode(requestHandle) );
         }
 
-        /// <summary>
-        /// Clears the cookies
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        public void ClearCookies()
-        {
-            int ret = (int)OAuth2Error.None;
-            ret = Interop.Manager.ClearCookies(_managerHandle);
-            if (ret != (int)OAuth2Error.None)
-            {
-                Log.Error(ErrorFactory.LogTag, "Interop failed");
-                throw ErrorFactory.GetException(ret);
-            }
-        }
-
-        /// <summary>
-        /// Clear the cache
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        public void ClearCache()
-        {
-            int ret = (int)OAuth2Error.None;
-            ret = Interop.Manager.ClearCache(_managerHandle);
-            if (ret != (int)OAuth2Error.None)
-            {
-                Log.Error(ErrorFactory.LogTag, "Interop failed");
-                throw ErrorFactory.GetException(ret);
-            }
-        }
 
         // Fill device request handle for Authorization code grant
         private IntPtr GetRequestHandle(CodeGrantAuthorizationRequest request)
@@ -280,64 +238,5 @@ namespace Tizen.Account.OAuth2
             return requestHandle;
         }
 
-        private AuthorizationResponse GetAuthorizationResponse(IntPtr requestHandle)
-        {
-            AuthorizationResponse response = null;
-            int ret = (int)OAuth2Error.None;
-            IntPtr error = IntPtr.Zero;
-
-            Interop.Manager.Oauth2AuthGrantCallback authGrantCb = (IntPtr responseHandle, IntPtr usrData) =>
-            {
-                if (responseHandle == IntPtr.Zero)
-                {
-                    Log.Error(ErrorFactory.LogTag, "Error occured");
-                    throw (new ArgumentNullException());
-                }
-
-                Interop.Response.GetError(responseHandle, out error);
-                if (error == IntPtr.Zero)
-                {
-                    Log.Warn(ErrorFactory.LogTag, "Error occured");
-                    throw ErrorFactory.GetException(error);
-                }
-                else
-                {
-                    IntPtr authorizationCode;
-                    ret = Interop.Response.GetAuthorizationCode(responseHandle, out authorizationCode);
-                    if (ret != (int)OAuth2Error.None)
-                    {
-                        Log.Error(ErrorFactory.LogTag, "Interop failed");
-                        throw ErrorFactory.GetException(ret);
-                    }
-
-                    IntPtr state;
-                    ret = Interop.Response.GetState(responseHandle, out state);
-                    if (ret != (int)OAuth2Error.None)
-                    {
-                        Log.Error(ErrorFactory.LogTag, "Interop failed");
-                        throw ErrorFactory.GetException(ret);
-                    }
-
-                    response = new AuthorizationResponse(responseHandle) { Code = Marshal.PtrToStringAnsi(authorizationCode), State = Marshal.PtrToStringAnsi(state) };
-                }
-            };
-
-            ret = Interop.Manager.RequestAuthorizationGrant(_managerHandle, requestHandle, authGrantCb, IntPtr.Zero);
-            Interop.Request.Destroy(requestHandle);
-            if (ret != (int)OAuth2Error.None || error != IntPtr.Zero)
-            {
-                if (error != IntPtr.Zero)
-                {
-                    throw ErrorFactory.GetException(error);
-                }
-                else
-                {
-                    Log.Error(ErrorFactory.LogTag, "Interop failed");
-                    throw ErrorFactory.GetException(ret);
-                }
-            }
-
-            return response;
-        }
     }
 }
index c59dbee..5e06c42 100755 (executable)
@@ -37,26 +37,11 @@ namespace Tizen.Account.OAuth2
         }
 
         /// <summary>
-        /// Retrieves access token asynchronously. The authroization request parameters should be as defined in https://tools.ietf.org/html/rfc6749#section-4.2.1
-        /// </summary>
-        /// <since_tizen> 3 </since_tizen>
-        /// <param name="request">The authorization request <see cref="ImplicitGrantAuthorizationRequest"/></param>
-        /// <returns>The response containing access token.</returns>
-        /// <privilege>http://tizen.org/privilege/internet</privilege>
-        /// <exception cref="ArgumentException">Thrown when method failed due to invalid argumets</exception>
-        /// <exception cref="OAuth2Exception">Thrown when method fails due to server error</exception>
-        public new virtual async Task<TokenResponse> AuthorizeAsync(AuthorizationRequest request)
-        {
-            IntPtr requestHandle = GetRequestHandle(request as ImplicitGrantAuthorizationRequest);
-            return await Task.Run(() => GetAuthorizationResponse(requestHandle));
-        }
-
-        /// <summary>
         /// Access token can be retreived implicitly using <see cref="AuthorizeAsync"/> in this flow.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <exception cref="InvalidOperationException">Thrown when the operation is not supported</exception>
-        public override Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
+        public Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
         {
             Log.Error(ErrorFactory.LogTag, "Obtain token directly from authorization grant ");
             throw new InvalidOperationException();
index 27ae244..9cfed28 100755 (executable)
@@ -41,7 +41,7 @@ namespace Tizen.Account.OAuth2
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <exception cref="InvalidOperationException">Thrown when the operation is not supported</exception>
-        public override Task<AuthorizationResponse> AuthorizeAsync(AuthorizationRequest request)
+        public  Task<AuthorizationResponse> AuthorizeAsync(AuthorizationRequest request)
         {
             Log.Error(ErrorFactory.LogTag, "Authorization is not supported in this flow");
             throw new InvalidOperationException();
@@ -57,7 +57,7 @@ namespace Tizen.Account.OAuth2
         /// <privilege>http://tizen.org/privilege/internet</privilege>
         /// <exception cref="ArgumentException">Thrown when method failed due to invalid argumets</exception>
         /// <exception cref="OAuth2Exception">Thrown when method fails due to server error</exception>
-        public override async Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
+        public async Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
         {
             IntPtr requestHandle = GetRequestHandle(request as ResourceOwnerPwdCredentialsTokenRequest);
             return await Task.Run(() => GetAccessToken(requestHandle));