Cyberduck Mountain Duck CLI

Changeset 43644


Ignore:
Timestamp:
Jan 8, 2018 2:14:43 PM (4 months ago)
Author:
dkocher
Message:

Remove exceptions and return boolean values only.

Location:
shelves/01.2018
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • shelves/01.2018

    • Property subgit:lock changed from commit:56679839799fd3e6057190c539b73edfe0353fde timestamp:2018-01-08T21:15:29.064 to commit:df64a291c7e4e032326e5ea13504a60fd9ee9eca timestamp:2018-01-08T21:15:30.948
  • shelves/01.2018/core/src/main/csharp/ch/cyberduck/core/credentialmanager/WinCredentialManager.cs

    r43641 r43644  
    240240            NativeCode.NativeCredential ncred = cred.GetNativeCredential();
    241241            // Write the info into the CredMan storage.
    242             bool written = NativeCode.CredWrite(ref ncred, 0);
    243             int lastError = Marshal.GetLastWin32Error();
    244             if (written)
    245             {
    246                 return true;
    247             }
    248             else
    249             {
    250                 string message = string.Format("CredWrite failed with the error code {0}.", lastError);
    251                 throw new Exception(message);
    252             }
     242            return NativeCode.CredWrite(ref ncred, 0);
    253243        }
    254244
     
    278268                    StringBuilder userBuilder = new StringBuilder();
    279269                    StringBuilder domainBuilder = new StringBuilder();
    280                     var ret1 = NativeCode.CredUIParseUserName(user, userBuilder, int.MaxValue, domainBuilder,
    281                         int.MaxValue);
    282                     int lastError = Marshal.GetLastWin32Error();
    283 
    284                     //assuming invalid account name to be not meeting condition for CredUIParseUserName
     270                    var code = NativeCode.CredUIParseUserName(user, userBuilder, int.MaxValue, domainBuilder, int.MaxValue);
     271                    //assuming invalid account name to be not meeting condition for CredUIParseUserName
    285272                    //"The name must be in UPN or down-level format, or a certificate"
    286                     if (ret1 == NativeCode.CredentialUIReturnCodes.InvalidAccountName)
     273                    if (code == NativeCode.CredentialUIReturnCodes.InvalidAccountName)
    287274                        userBuilder.Append(user);
    288                     else if ((uint) ret1 > 0)
    289                         throw new Win32Exception(lastError, "CredUIParseUserName threw an error");
    290 
    291                     username = userBuilder.ToString();
    292                     domain = domainBuilder.ToString();
     275                    else if (code == NativeCode.CredentialUIReturnCodes.Success)
     276                        username = userBuilder.ToString();
     277                        domain = domainBuilder.ToString();
    293278                }
    294279            }
     
    305290        {
    306291            // Make the API call using the P/Invoke signature
    307             var ret = NativeCode.CredDelete(Target, NativeCode.CredentialType.Generic, 0);
    308             int lastError = Marshal.GetLastWin32Error();
    309             if (!ret)
    310                 throw new Win32Exception(lastError, "CredDelete threw an error");
    311             return ret;
     292            return NativeCode.CredDelete(Target, NativeCode.CredentialType.Generic, 0);
    312293        }
    313294
Note: See TracChangeset for help on using the changeset viewer.
swiss made software