Skip to content

Commit b81a199

Browse files
committed
Moved profile cmdlets into core clr
1 parent c371971 commit b81a199

Some content is hidden

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

52 files changed

+18045
-14
lines changed

src/CLU/CLUCoreCLR.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.WindowsAzure.Comm
77
EndProject
88
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.Common.Authentication", "Commands.Common.Authentication\Commands.Common.Authentication.xproj", "{4CE82310-D016-497D-93A0-0323A3E62064}"
99
EndProject
10+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Common.Resources", "Microsoft.Azure.Commands.Common.Resources\Microsoft.Azure.Commands.Common.Resources.xproj", "{447889D2-370A-461B-ADA3-E892C22E2C05}"
11+
EndProject
12+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Profile", "Microsoft.Azure.Commands.Profile\Microsoft.Azure.Commands.Profile.xproj", "{45B05B68-516F-4D74-897F-56D12894946C}"
13+
EndProject
1014
Global
1115
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1216
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +25,14 @@ Global
2125
{4CE82310-D016-497D-93A0-0323A3E62064}.Debug|Any CPU.Build.0 = Debug|Any CPU
2226
{4CE82310-D016-497D-93A0-0323A3E62064}.Release|Any CPU.ActiveCfg = Release|Any CPU
2327
{4CE82310-D016-497D-93A0-0323A3E62064}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{447889D2-370A-461B-ADA3-E892C22E2C05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{447889D2-370A-461B-ADA3-E892C22E2C05}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{447889D2-370A-461B-ADA3-E892C22E2C05}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{447889D2-370A-461B-ADA3-E892C22E2C05}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{45B05B68-516F-4D74-897F-56D12894946C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{45B05B68-516F-4D74-897F-56D12894946C}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{45B05B68-516F-4D74-897F-56D12894946C}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{45B05B68-516F-4D74-897F-56D12894946C}.Release|Any CPU.Build.0 = Release|Any CPU
2436
EndGlobalSection
2537
GlobalSection(SolutionProperties) = preSolution
2638
HideSolutionNode = FALSE

src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Common.Authentication.Models;
16-
using Microsoft.Azure.Common.Authentication.Properties;
1716
using System;
17+
using Commands.Common.Authentication.Properties;
1818

1919
namespace Microsoft.Azure.Common.Authentication
2020
{

src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Common.Authentication.Models;
16-
using Microsoft.Azure.Common.Authentication.Properties;
1716
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1817
using Microsoft.Rest;
1918
using System;
2019
using System.Collections.Generic;
2120
using System.Security;
2221
using System.Security.Cryptography.X509Certificates;
22+
using Commands.Common.Authentication.Properties;
2323

2424
namespace Microsoft.Azure.Common.Authentication
2525
{

src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Common.Authentication.Models;
16-
using Microsoft.Azure.Common.Authentication.Properties;
1716
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1817
using Microsoft.Rest;
1918
using System;
2019
using System.Runtime.InteropServices;
20+
using Commands.Common.Authentication.Properties;
2121
using Microsoft.Rest.Azure.Authentication;
2222

2323
namespace Microsoft.Azure.Common.Authentication

src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Common.Authentication.Models;
16-
using Microsoft.Azure.Common.Authentication.Properties;
1716
using System;
1817
using System.Linq;
1918
using System.Management.Automation;
2019
using System.Security;
20+
using Commands.Common.Authentication.Properties;
2121
using Microsoft.IdentityModel.Clients.ActiveDirectory;
2222
using Microsoft.Rest;
2323
using Microsoft.Rest.Azure.Authentication;

src/CLU/Commands.Common.Authentication/ClientFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Common.Authentication.Models;
16-
using Microsoft.Azure.Common.Authentication.Properties;
1716
using Microsoft.Rest;
1817
using System;
1918
using System.Collections.Generic;
@@ -24,6 +23,7 @@
2423
using System.Net.Http;
2524
using System.Net.Http.Headers;
2625
using System.Reflection;
26+
using Commands.Common.Authentication.Properties;
2727

2828
namespace Microsoft.Azure.Common.Authentication.Factories
2929
{

src/CLU/Commands.Common.Authentication/JsonUtilities.cs

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

15-
using Microsoft.Azure.Common.Authentication.Properties;
1615
using Newtonsoft.Json;
1716
using Newtonsoft.Json.Linq;
1817
using System;
1918
using System.Collections.Generic;
2019
using System.Diagnostics.CodeAnalysis;
20+
using Commands.Common.Authentication.Properties;
2121

2222
namespace Microsoft.Azure.Common.Authentication
2323
{

src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs

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

15-
using Microsoft.Azure.Common.Authentication.Properties;
1615
using Microsoft.Azure.Common.Authentication.Utilities;
1716
using System;
1817
using System.Collections.Generic;
18+
using Commands.Common.Authentication.Properties;
1919

2020
namespace Microsoft.Azure.Common.Authentication.Models
2121
{

src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs

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

15-
using Microsoft.Azure.Common.Authentication.Properties;
1615
using Microsoft.Rest;
1716
using Newtonsoft.Json;
1817
using System;
1918
using System.Collections.Generic;
2019
using System.Linq;
20+
using Commands.Common.Authentication.Properties;
2121

2222
namespace Microsoft.Azure.Common.Authentication.Models
2323
{

src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs

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

15-
using Microsoft.Azure.Common.Authentication.Properties;
1615
using System;
1716
using System.IO;
1817
using System.Security.Cryptography.X509Certificates;
1918
using System.Text;
19+
using Commands.Common.Authentication.Properties;
2020

2121
namespace Microsoft.Azure.Common.Authentication.Models
2222
{

src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/CLU/Commands.Common.Authentication/Validate.cs

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

15-
using Microsoft.Azure.Common.Authentication.Properties;
1615
using System;
1716
using System.IO;
1817
using System.Linq;
18+
using Commands.Common.Authentication.Properties;
1919

2020
namespace Microsoft.Azure.Common.Authentication
2121
{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Linq;
17+
using Microsoft.Azure.Common.Authentication;
18+
19+
namespace Microsoft.Azure.Commands.ResourceManager.Common
20+
{
21+
public static class AccessTokenExtensions
22+
{
23+
public static string GetDomain(this IAccessToken token)
24+
{
25+
if( token != null && token.UserId !=null && token.UserId.Contains('@'))
26+
{
27+
return token.UserId.Split(
28+
new[] { '@' },
29+
StringSplitOptions.RemoveEmptyEntries).Last();
30+
}
31+
32+
return null;
33+
}
34+
}
35+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using Microsoft.Azure.Commands.Common.Resources.Properties;
17+
using Microsoft.Azure.Common.Authentication.Models;
18+
using Microsoft.IdentityModel.Clients.ActiveDirectory;
19+
20+
namespace Microsoft.Azure.Commands.ResourceManager.Common
21+
{
22+
public static class AzureRMProfileExtensions
23+
{
24+
/// <summary>
25+
/// Set the context for the current profile, preserving token cache information
26+
/// </summary>
27+
/// <param name="profile">The profile to change the context for</param>
28+
/// <param name="newContext">The new context, with no token cache information.</param>
29+
public static void SetContextWithCache(this AzureRMProfile profile, AzureContext newContext)
30+
{
31+
if (profile == null)
32+
{
33+
throw new ArgumentNullException("profile", Resources.ProfileCannotBeNull);
34+
}
35+
36+
if (newContext == null)
37+
{
38+
throw new ArgumentNullException("newContext", Resources.ContextCannotBeNull);
39+
}
40+
41+
newContext.TokenCache = TokenCache.DefaultShared.Serialize();
42+
profile.Context = newContext;
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)