Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit 3b75464

Browse files
author
J Wyman
committed
Clean up source code and licenses.
Ran CodeMaid, also corrected/added missing licenses.
1 parent 2145692 commit 3b75464

File tree

127 files changed

+407
-306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+407
-306
lines changed

Assets/head_css.html

+10-11
Large diffs are not rendered by default.

Bitbucket.Authentication.Test/packages.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net452" />
99
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net452" />
1010
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net452" developmentDependency="true" />
11-
</packages>
11+
</packages>

Bitbucket.Authentication/App.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace Atlassian.Bitbucket.Authentication
3131
/// Dummy Application used to load the AppResources.xaml and keep the WPF designer happy while
3232
/// keeping this project as a Library rather than an Windows.Application.
3333
/// </summary>
34-
public partial class App: Application
34+
public partial class App : Application
3535
{
3636
}
3737
}

Bitbucket.Authentication/Authentication.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Atlassian.Bitbucket.Authentication
3636
/// <see cref="IAuthentication"/> and providing functionality to manage credentials for Bitbucket
3737
/// hosting service.
3838
/// </summary>
39-
public class Authentication: BaseAuthentication, IAuthentication
39+
public class Authentication : BaseAuthentication, IAuthentication
4040
{
4141
public const string BitbucketBaseUrlHost = "bitbucket.org";
4242

@@ -106,7 +106,8 @@ public override void DeleteCredentials(TargetUri targetUri, string username)
106106
Trace.WriteLine($"host refresh credentials deleted for {refreshTargetUri.ActualUri}");
107107
}
108108

109-
// if we deleted per user then we shoudl try and delete the host level credentials too if they match the username
109+
// if we deleted per user then we shoudl try and delete the host level credentials too if
110+
// they match the username
110111
if (targetUri.TargetUriContainsUsername)
111112
{
112113
var hostTargetUri = targetUri.GetHostTargetUri();
@@ -436,7 +437,6 @@ public async Task<Credential> ValidateCredentials(TargetUri targetUri, string us
436437
userSpecificTargetUri = targetUri.GetPerUserTargetUri(username);
437438
}
438439

439-
440440
if (await BitbucketAuthority.ValidateCredentials(userSpecificTargetUri, username, credentials))
441441
{
442442
return credentials;

Bitbucket.Authentication/AuthenticationResult.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public AuthenticationResult(AuthenticationResultType type, Token accessToken,
9191
public string RemoteUsername { get; internal set; }
9292

9393
/// <summary>
94-
/// Flag indicating if the results is a success
94+
/// Flag indicating if the results is a success
9595
/// </summary>
9696
public bool IsSuccess { get { return Type.Equals(AuthenticationResultType.Success); } }
9797

Bitbucket.Authentication/Authority.cs

+4-7
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
**/
2525

2626
using System;
27-
using System.Net;
28-
using System.Net.Http;
2927
using System.Text;
3028
using System.Threading;
3129
using System.Threading.Tasks;
@@ -40,7 +38,7 @@ namespace Atlassian.Bitbucket.Authentication
4038
/// Implementation of <see cref="IAuthority"/> representing the Bitbucket APIs as the authority
4139
/// that can provide and validate credentials for Bitbucket.
4240
/// </summary>
43-
internal class Authority: IAuthority
41+
internal class Authority : IAuthority
4442
{
4543
/// <summary>
4644
/// The root URL for Bitbucket REST API calls.
@@ -87,7 +85,7 @@ public async Task<AuthenticationResult> AcquireToken(TargetUri targetUri, string
8785
var authHeader = GetBearerHeaderAuthHeader(result.Token.Value);
8886
var userResult = await RestClient.TryGetUser(targetUri, RequestTimeout, restRootUri, authHeader);
8987

90-
if(!userResult.IsSuccess)
88+
if (!userResult.IsSuccess)
9189
{
9290
Trace.WriteLine($"oauth user check failed");
9391
return new AuthenticationResult(AuthenticationResultType.Failure);
@@ -102,7 +100,6 @@ public async Task<AuthenticationResult> AcquireToken(TargetUri targetUri, string
102100

103101
// everything is hunky dory
104102
return result;
105-
106103
}
107104
catch (Exception ex)
108105
{
@@ -178,7 +175,7 @@ private static string GetBearerHeaderAuthHeader(string secret)
178175
}
179176

180177
/// <summary>
181-
/// Get the HTTP encoded version of the Credentials secret
178+
/// Get the HTTP encoded version of the Credentials secret
182179
/// </summary>
183180
private static string GetEncodedCredentials(string username, Credential credentials)
184181
{
@@ -188,7 +185,7 @@ private static string GetEncodedCredentials(string username, Credential credenti
188185
}
189186

190187
/// <summary>
191-
/// Get the HTTP encoded version of the Credentials secret
188+
/// Get the HTTP encoded version of the Credentials secret
192189
/// </summary>
193190
private static string GetEncodedCredentials(string user, string password)
194191
{

Bitbucket.Authentication/BasicAuth/BasicAuthAuthenticator.cs

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Net;
5-
using System.Net.Http;
62
using System.Text;
7-
using System.Threading;
83
using System.Threading.Tasks;
94
using Atlassian.Bitbucket.Authentication.Rest;
105
using Microsoft.Alm.Authentication;
116
using Microsoft.Alm.Git;
127

138
namespace Atlassian.Bitbucket.Authentication.BasicAuth
149
{
15-
class BasicAuthAuthenticator
10+
internal class BasicAuthAuthenticator
1611
{
1712
public async Task<AuthenticationResult> GetAuthAsync(TargetUri targetUri, TokenScope scope, int requestTimeout, Uri restRootUrl, string username, string password)
1813
{
1914
// use the provided username and password and attempt a Basic Auth request to a known
2015
// REST API resource.
21-
16+
2217
string basicAuthValue = string.Format("{0}:{1}", username, password);
2318
byte[] authBytes = Encoding.UTF8.GetBytes(basicAuthValue);
2419
basicAuthValue = Convert.ToBase64String(authBytes);
@@ -28,11 +23,10 @@ public async Task<AuthenticationResult> GetAuthAsync(TargetUri targetUri, TokenS
2823

2924
if (result.Type.Equals(AuthenticationResultType.Success))
3025
{
31-
// Success with username/passord indicates 2FA is not on so
32-
// the 'token' is actually the password if we had a
33-
// successful call then the password is good.
26+
// Success with username/passord indicates 2FA is not on so the 'token' is actually
27+
// the password if we had a successful call then the password is good.
3428
var token = new Token(password, TokenType.Personal);
35-
if(!string.IsNullOrWhiteSpace(result.RemoteUsername) && !username.Equals(result.RemoteUsername))
29+
if (!string.IsNullOrWhiteSpace(result.RemoteUsername) && !username.Equals(result.RemoteUsername))
3630
{
3731
Trace.WriteLine($"Remote username [{result.RemoteUsername}] != [{username}] supplied username");
3832
return new AuthenticationResult(AuthenticationResultType.Success, token, result.RemoteUsername);

Bitbucket.Authentication/Controls/CredentialsControl.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
2525
**/
2626
-->
27-
<sharedControls:DialogUserControl
27+
<sharedControls:DialogUserControl
2828
x:Class="Atlassian.Bitbucket.Authentication.Controls.CredentialsControl"
2929
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3030
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

Bitbucket.Authentication/Controls/CredentialsControl.xaml.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
**/
2525

2626
using System;
27-
using GitHub.Shared.Helpers;
2827
using GitHub.Shared.Controls;
28+
using GitHub.Shared.Helpers;
2929

3030
namespace Atlassian.Bitbucket.Authentication.Controls
3131
{
3232
/// <summary>
3333
/// Defines the UI used to prompt users for username/password credentials for Bitbucket accounts.
3434
/// </summary>
35-
public partial class CredentialsControl: DialogUserControl
35+
public partial class CredentialsControl : DialogUserControl
3636
{
3737
public CredentialsControl()
3838
{

Bitbucket.Authentication/Controls/HorizontalShadowDivider.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
2525
**/
2626
-->
27-
<UserControl
27+
<UserControl
2828
x:Class="Atlassian.Bitbucket.Authentication.Controls.HorizontalShadowDivider"
2929
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3030
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

Bitbucket.Authentication/Controls/HorizontalShadowDivider.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Atlassian.Bitbucket.Authentication.Controls
44
{
5-
public partial class HorizontalShadowDivider: UserControl
5+
public partial class HorizontalShadowDivider : UserControl
66
{
77
public HorizontalShadowDivider()
88
{

Bitbucket.Authentication/Controls/OAuthControl.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
2525
**/
2626
-->
27-
<sharedControls:DialogUserControl
27+
<sharedControls:DialogUserControl
2828
x:Class="Atlassian.Bitbucket.Authentication.Controls.OAuthControl"
2929
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3030
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

Bitbucket.Authentication/Controls/OAuthControl.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace Atlassian.Bitbucket.Authentication.Controls
3030
/// <summary>
3131
/// Defines the UI used to prompt a user to run the OAuth authorization process.
3232
/// </summary>
33-
public partial class OAuthControl: DialogUserControl
33+
public partial class OAuthControl : DialogUserControl
3434
{
3535
public OAuthControl()
3636
{

Bitbucket.Authentication/Controls/Text/ValidationMessage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
namespace Atlassian.Bitbucket.Authentication.Controls
3434
{
35-
public class ValidationMessage: UserControl
35+
public class ValidationMessage : UserControl
3636
{
3737
private const double defaultTextChangeThrottle = 0.2;
3838

Bitbucket.Authentication/Rest/RestClient.cs

+19-19
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@ public static async Task<AuthenticationResult> TryGetUser(TargetUri targetUri, i
3434
{
3535
case HttpStatusCode.OK:
3636
case HttpStatusCode.Created:
37-
{
38-
Trace.WriteLine("authentication success: new password token created.");
37+
{
38+
Trace.WriteLine("authentication success: new password token created.");
3939

4040
// Get useername to cross check against supplied one
41-
var responseText = await response.Content.ReadAsStringAsync();
42-
var username = FindUsername(responseText);
43-
return new AuthenticationResult(AuthenticationResultType.Success, username);
44-
}
41+
var responseText = await response.Content.ReadAsStringAsync();
42+
var username = FindUsername(responseText);
43+
return new AuthenticationResult(AuthenticationResultType.Success, username);
44+
}
4545

4646
case HttpStatusCode.Forbidden:
47-
{
48-
// A 403/Forbidden response indicates the username/password
49-
// are recognized and good but 2FA is on in which case we
50-
// want to indicate that with the TwoFactor result
51-
Trace.WriteLine("two-factor app authentication code required");
52-
return new AuthenticationResult(AuthenticationResultType.TwoFactor);
53-
}
47+
{
48+
// A 403/Forbidden response indicates the username/password are
49+
// recognized and good but 2FA is on in which case we want to
50+
// indicate that with the TwoFactor result
51+
Trace.WriteLine("two-factor app authentication code required");
52+
return new AuthenticationResult(AuthenticationResultType.TwoFactor);
53+
}
5454
case HttpStatusCode.Unauthorized:
55-
{
56-
// username or password are wrong.
57-
Trace.WriteLine("authentication unauthorised");
58-
return new AuthenticationResult(AuthenticationResultType.Failure);
59-
}
55+
{
56+
// username or password are wrong.
57+
Trace.WriteLine("authentication unauthorised");
58+
return new AuthenticationResult(AuthenticationResultType.Failure);
59+
}
6060

6161
default:
6262
// any unexpected result can be treated as a failure.
@@ -82,4 +82,4 @@ private static string FindUsername(string responseText)
8282
return null;
8383
}
8484
}
85-
}
85+
}

Bitbucket.Authentication/TokenScope.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
2525
**/
2626

27-
using System;
2827
using System.Collections.Generic;
2928
using System.Runtime.CompilerServices;
3029
using ScopeSet = System.Collections.Generic.HashSet<string>;
@@ -34,7 +33,7 @@ namespace Atlassian.Bitbucket.Authentication
3433
/// <summary>
3534
/// Defines the available scopes associated with OAuth tokens in Bitbucket.
3635
/// </summary>
37-
public sealed class TokenScope: Microsoft.Alm.Authentication.TokenScope
36+
public sealed class TokenScope : Microsoft.Alm.Authentication.TokenScope
3837
{
3938
public static readonly TokenScope None = new TokenScope(string.Empty);
4039

Bitbucket.Authentication/ViewModels/CredentialsViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Atlassian.Bitbucket.Authentication.ViewModels
3434
/// <summary>
3535
/// The ViewModel behind the Basic Auth username/password UI prompt.
3636
/// </summary>
37-
public class CredentialsViewModel: DialogViewModel
37+
public class CredentialsViewModel : DialogViewModel
3838
{
3939
public CredentialsViewModel() : this(string.Empty)
4040
{

Bitbucket.Authentication/ViewModels/OAuthViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace Atlassian.Bitbucket.Authentication.ViewModels
3232
/// <summary>
3333
/// The ViewModel behind the OAuth UI prompt
3434
/// </summary>
35-
public class OAuthViewModel: DialogViewModel
35+
public class OAuthViewModel : DialogViewModel
3636
{
3737
private bool _resultType;
3838

Bitbucket.Authentication/Views/CredentialsWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
2525
**/
2626
-->
27-
<sharedControls:AuthenticationDialogWindow
27+
<sharedControls:AuthenticationDialogWindow
2828
x:Class="Atlassian.Bitbucket.Authentication.Views.CredentialsWindow"
2929
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3030
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

Bitbucket.Authentication/Views/CredentialsWindow.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Atlassian.Bitbucket.Authentication.Views
4242
/// prompted with a second UI to ask for OAuth authorisation <see cref="OAuthWindow"/>.
4343
/// </para>
4444
/// </summary>
45-
partial class CredentialsWindow: AuthenticationDialogWindow
45+
partial class CredentialsWindow : AuthenticationDialogWindow
4646
{
4747
public CredentialsWindow()
4848
{

Bitbucket.Authentication/Views/OAuthWindow.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace Atlassian.Bitbucket.Authentication.Views
3535
/// enabled on their account. Prompts the user to run the OAuth authorization process.
3636
/// </para>
3737
/// </summary>
38-
public partial class OAuthWindow: AuthenticationDialogWindow
38+
public partial class OAuthWindow : AuthenticationDialogWindow
3939
{
4040
public OAuthWindow()
4141
{
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net451" developmentDependency="true" />
4-
</packages>
4+
</packages>

Cli-Askpass/PasswordBoxHintAdorner.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
namespace Microsoft.Alm.Gui
3333
{
3434
[System.Runtime.InteropServices.ComVisible(false)]
35-
public class PasswordBoxHintAdorner: Adorner
35+
public class PasswordBoxHintAdorner : Adorner
3636
{
3737
public PasswordBoxHintAdorner(UIElement adornedElement, string hintText, Style hintStyle, VisibilityDelegate visibilityCallback)
3838
: base(adornedElement)

Cli-Askpass/Program.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ internal Program()
5151

5252
internal static bool TryParseUrlCredentials(string targetUrl, out string username, out string password)
5353
{
54-
// config stored credentials come in the format of <username>[:<password>]@<url>
55-
// with password being optional scheme terminator is actually "://" so we need
56-
// adjust to get the correct index
54+
// config stored credentials come in the format of <username>[:<password>]@<url> with
55+
// password being optional scheme terminator is actually "://" so we need adjust to get
56+
// the correct index
5757
int schemeTerminator = targetUrl.IndexOf(':') + 2;
5858
int credentialTerminator = targetUrl.IndexOf('@', schemeTerminator + 1);
5959

6060
if (credentialTerminator > 0)
6161
{
62-
// only check within the credential portion of the url, don't look past the
63-
// '@' because the port token is the same as the username / password seperator.
62+
// only check within the credential portion of the url, don't look past the '@'
63+
// because the port token is the same as the username / password seperator.
6464
int credentialLength = credentialTerminator - schemeTerminator;
6565
credentialLength = Math.Max(0, credentialLength);
6666

Cli-Askpass/UserPromptDialog.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace Microsoft.Alm.Gui
3333
/// Interaction logic for PassphraseWindow.xaml
3434
/// </summary>
3535
[System.Runtime.InteropServices.ComVisible(false)]
36-
public partial class UserPromptDialog: Window
36+
public partial class UserPromptDialog : Window
3737
{
3838
public const string HintTextPassphrase = "SSH Passphrase";
3939
public const string HintTextPassword = "Password";

Cli-Askpass/packages.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net451" developmentDependency="true" />
4-
</packages>
4+
</packages>

Cli-CredentialHelper.Test/packages.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
1111
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
1212
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
13-
</packages>
13+
</packages>

0 commit comments

Comments
 (0)