Skip to content

Commit 367d457

Browse files
ogailogail
authored andcommitted
Refactor Microsoft.Azure.Common.Extensions project
1 parent 016d848 commit 367d457

File tree

375 files changed

+7097
-539
lines changed

Some content is hidden

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

375 files changed

+7097
-539
lines changed

src/AzurePowershell.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StreamAnalytics",
151151
EndProject
152152
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StreamAnalytics.Test", "ResourceManager\StreamAnalytics\Commands.StreamAnalytics.Test\Commands.StreamAnalytics.Test.csproj", "{7E6683BE-ECFF-4709-89EB-1325E9E70512}"
153153
EndProject
154+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Extensions", "Common\Azure.Common.Extensions\Common.Extensions.csproj", "{B95C489C-8CB7-4DCF-8D5F-B9AEBDBBAF89}"
155+
EndProject
154156
Global
155157
GlobalSection(SolutionConfigurationPlatforms) = preSolution
156158
Debug|Any CPU = Debug|Any CPU
@@ -361,6 +363,10 @@ Global
361363
{7E6683BE-ECFF-4709-89EB-1325E9E70512}.Debug|Any CPU.Build.0 = Debug|Any CPU
362364
{7E6683BE-ECFF-4709-89EB-1325E9E70512}.Release|Any CPU.ActiveCfg = Release|Any CPU
363365
{7E6683BE-ECFF-4709-89EB-1325E9E70512}.Release|Any CPU.Build.0 = Release|Any CPU
366+
{B95C489C-8CB7-4DCF-8D5F-B9AEBDBBAF89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
367+
{B95C489C-8CB7-4DCF-8D5F-B9AEBDBBAF89}.Debug|Any CPU.Build.0 = Debug|Any CPU
368+
{B95C489C-8CB7-4DCF-8D5F-B9AEBDBBAF89}.Release|Any CPU.ActiveCfg = Release|Any CPU
369+
{B95C489C-8CB7-4DCF-8D5F-B9AEBDBBAF89}.Release|Any CPU.Build.0 = Release|Any CPU
364370
EndGlobalSection
365371
GlobalSection(SolutionProperties) = preSolution
366372
HideSolutionNode = FALSE

src/Common/Commands.Common/Authentication/AadAuthenticationException.cs renamed to src/Common/Azure.Common.Extensions/Authentication/AadAuthenticationException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
using System;
1616

17-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
17+
namespace Microsoft.Azure.Common.Extensions.Authentication
1818
{
1919
/// <summary>
2020
/// Base class representing an exception that occurs when

src/Common/Commands.Common/Authentication/AccessTokenCredential.cs renamed to src/Common/Azure.Common.Extensions/Authentication/AccessTokenCredential.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.WindowsAzure;
1516
using System;
1617
using System.Net.Http;
1718
using System.Net.Http.Headers;
1819
using System.Threading;
1920
using System.Threading.Tasks;
2021

21-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
22+
namespace Microsoft.Azure.Common.Extensions.Authentication
2223
{
2324
public class AccessTokenCredential : SubscriptionCloudCredentials
2425
{

src/Common/Commands.Common/Authentication/AdalConfiguration.cs renamed to src/Common/Azure.Common.Extensions/Authentication/AdalConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
using System;
1616
using System.Linq;
1717

18-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
18+
namespace Microsoft.Azure.Common.Extensions.Authentication
1919
{
2020
/// <summary>
2121
/// Class storing the configuration information needed

src/Common/Commands.Common/Authentication/AdalTokenProvider.cs renamed to src/Common/Azure.Common.Extensions/Authentication/AdalTokenProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
using System;
1616
using System.Security;
1717
using System.Windows.Forms;
18-
using Microsoft.WindowsAzure.Commands.Common.Models;
19-
using Microsoft.WindowsAzure.Commands.Common.Properties;
18+
using Microsoft.Azure.Common.Extensions.Models;
19+
using Microsoft.Azure.Common.Extensions.Properties;
2020

21-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
21+
namespace Microsoft.Azure.Common.Extensions.Authentication
2222
{
2323
/// <summary>
2424
/// A token provider that uses ADAL to retrieve

src/Common/Commands.Common/Authentication/ConsoleParentWindow.cs renamed to src/Common/Azure.Common.Extensions/Authentication/ConsoleParentWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using System.Runtime.InteropServices;
1717
using System.Windows.Forms;
1818

19-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
19+
namespace Microsoft.Azure.Common.Extensions.Authentication
2020
{
2121
/// <summary>
2222
/// An implementation of <see cref="IWin32Window"/> that gives the

src/Common/Commands.Common/Authentication/CredStore.cs renamed to src/Common/Azure.Common.Extensions/Authentication/CredStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using System.Runtime.ConstrainedExecution;
1717
using System.Runtime.InteropServices;
1818

19-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
19+
namespace Microsoft.Azure.Common.Extensions.Authentication
2020
{
2121
/// <summary>
2222
/// Class wrapping PInvoke signatures for Windows Credential store

src/Common/Commands.Common/Authentication/IAccessToken.cs renamed to src/Common/Azure.Common.Extensions/Authentication/IAccessToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
using System;
1616

17-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
17+
namespace Microsoft.Azure.Common.Extensions.Authentication
1818
{
1919
public interface IAccessToken
2020
{

src/Common/Commands.Common/Authentication/ITokenProvider.cs renamed to src/Common/Azure.Common.Extensions/Authentication/ITokenProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System.Security;
16-
using Microsoft.WindowsAzure.Commands.Common.Models;
16+
using Microsoft.Azure.Common.Extensions.Models;
1717

18-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
18+
namespace Microsoft.Azure.Common.Extensions.Authentication
1919
{
2020
/// <summary>
2121
/// This interface represents objects that can be used

src/Common/Commands.Common/Authentication/LoginType.cs renamed to src/Common/Azure.Common.Extensions/Authentication/LoginType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
15+
namespace Microsoft.Azure.Common.Extensions.Authentication
1616
{
1717
public enum LoginType
1818
{

src/Common/Commands.Common/Authentication/ProtectedFileTokenCache.cs renamed to src/Common/Azure.Common.Extensions/Authentication/ProtectedFileTokenCache.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
using System.IO;
1717
using System.Security.Cryptography;
1818
using Microsoft.IdentityModel.Clients.ActiveDirectory;
19-
using Microsoft.WindowsAzure.Commands.Common;
19+
using Microsoft.Azure.Common.Extensions;
2020

21-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
21+
namespace Microsoft.Azure.Common.Extensions.Authentication
2222
{
2323
/// <summary>
2424
/// An implementation of the Adal token cache that stores the cache items
2525
/// in the DPAPI-protected file.
2626
/// </summary>
2727
public class ProtectedFileTokenCache : TokenCache
2828
{
29-
private static readonly string CacheFileName = Path.Combine(AzurePowerShell.ProfileDirectory, "TokenCache.dat");
29+
private static readonly string CacheFileName = Path.Combine(AzureSession.ProfileDirectory, AzureSession.TokenCacheFile);
3030

3131
private static readonly object fileLock = new object();
3232

src/Common/Commands.Common/Authentication/ServicePrincipalKeyStore.cs renamed to src/Common/Azure.Common.Extensions/Authentication/ServicePrincipalKeyStore.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
using System;
1616
using System.Runtime.InteropServices;
1717
using System.Security;
18-
using Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication;
18+
using Microsoft.Azure.Common.Extensions.Authentication;
1919
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
2020

21-
namespace Microsoft.WindowsAzure.Commands.Common.Authentication
21+
namespace Microsoft.Azure.Common.Extensions.Authentication
2222
{
2323
/// <summary>
2424
/// Helper class to store service principal keys and retrieve them
@@ -27,7 +27,7 @@ namespace Microsoft.WindowsAzure.Commands.Common.Authentication
2727
public static class ServicePrincipalKeyStore
2828
{
2929
private const string keyStoreUserName = "PowerShellServicePrincipalKey";
30-
private const string targetNamePrefix = "AzurePowershell:target=";
30+
private const string targetNamePrefix = "AzureSession:target=";
3131

3232
public static void SaveKey(string appId, string tenantId, SecureString serviceKey)
3333
{

src/Common/Commands.Common/Authentication/ServicePrincipalTokenProvider.cs renamed to src/Common/Azure.Common.Extensions/Authentication/ServicePrincipalTokenProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
using System.Collections.Generic;
1717
using System.Security;
1818
using Microsoft.IdentityModel.Clients.ActiveDirectory;
19-
using Microsoft.WindowsAzure.Commands.Common.Authentication;
20-
using Microsoft.WindowsAzure.Commands.Common.Models;
21-
using Microsoft.WindowsAzure.Commands.Common.Properties;
19+
using Microsoft.Azure.Common.Extensions.Authentication;
20+
using Microsoft.Azure.Common.Extensions.Models;
21+
using Microsoft.Azure.Common.Extensions.Properties;
2222

23-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
23+
namespace Microsoft.Azure.Common.Extensions.Authentication
2424
{
2525
internal class ServicePrincipalTokenProvider : ITokenProvider
2626
{

src/Common/Commands.Common/Authentication/ShowDialog.cs renamed to src/Common/Azure.Common.Extensions/Authentication/ShowDialog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
15+
namespace Microsoft.Azure.Common.Extensions.Authentication
1616
{
1717
public enum ShowDialog
1818
{

src/Common/Commands.Common/Authentication/UserTokenProvider.cs renamed to src/Common/Azure.Common.Extensions/Authentication/UserTokenProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
using System.Threading;
1919
using System.Windows.Forms;
2020
using Microsoft.IdentityModel.Clients.ActiveDirectory;
21-
using Microsoft.WindowsAzure.Commands.Common.Models;
22-
using Microsoft.WindowsAzure.Commands.Common.Properties;
21+
using Microsoft.Azure.Common.Extensions.Models;
22+
using Microsoft.Azure.Common.Extensions.Properties;
2323

24-
namespace Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication
24+
namespace Microsoft.Azure.Common.Extensions.Authentication
2525
{
2626
/// <summary>
2727
/// A token provider that uses ADAL to retrieve

src/Common/Commands.Common/AzureSession.cs renamed to src/Common/Azure.Common.Extensions/AzureSession.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,25 @@
1414

1515
using System;
1616
using System.Collections.Generic;
17-
using Microsoft.WindowsAzure.Commands.Common.Common;
18-
using Microsoft.WindowsAzure.Commands.Common.Factories;
19-
using Microsoft.WindowsAzure.Commands.Common.Models;
20-
using Microsoft.WindowsAzure.Commands.Common.Properties;
21-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
22-
using Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication;
23-
24-
namespace Microsoft.WindowsAzure.Commands.Common
17+
using Microsoft.Azure.Common.Extensions.Factories;
18+
using Microsoft.Azure.Common.Extensions.Models;
19+
using Microsoft.Azure.Common.Extensions.Properties;
20+
using Microsoft.Azure.Common.Extensions;
21+
using Microsoft.Azure.Common.Extensions.Authentication;
22+
23+
namespace Microsoft.Azure.Common.Extensions
2524
{
2625
public static class AzureSession
2726
{
2827
static AzureSession()
2928
{
30-
ClientFactory = new AzurePowerShellClientFactory();
29+
ClientFactory = new ClientFactory();
3130
AuthenticationFactory = new AuthenticationFactory();
3231
CurrentContext = new AzureContext();
3332
CurrentContext.Environment = AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud];
3433
}
3534

36-
public static AzureContext CurrentContext {get; private set; }
35+
public static AzureContext CurrentContext { get; private set; }
3736

3837
public static void SetCurrentContext(AzureSubscription subscription, AzureEnvironment environment, AzureAccount account)
3938
{
@@ -89,5 +88,15 @@ public static void SetCurrentContext(AzureSubscription subscription, AzureEnviro
8988
public static IClientFactory ClientFactory { get; set; }
9089

9190
public static IAuthenticationFactory AuthenticationFactory { get; set; }
91+
92+
public static string ProfileDirectory { get; set; }
93+
94+
public static string TokenCacheFile { get; set; }
95+
96+
public static string ProfileFile { get; set; }
97+
98+
public static string OldProfileFileBackup { get; set; }
99+
100+
public static string OldProfileFile { get; set; }
92101
}
93102
}

0 commit comments

Comments
 (0)