Implement the authentication in the good classes ;)
This commit is contained in:
committed by
Philippe Miossec
parent
fe26b62959
commit
87c62d786d
@@ -38,7 +38,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;VS2010</DefineConstants>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -47,7 +47,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;VS2010</DefineConstants>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.TeamFoundation.Client;
|
||||
using Microsoft.TeamFoundation.Server;
|
||||
using Sep.Git.Tfs.VsCommon;
|
||||
using StructureMap;
|
||||
using Sep.Git.Tfs.Core.TfsInterop;
|
||||
|
||||
namespace Sep.Git.Tfs.Vs2010
|
||||
{
|
||||
@@ -20,5 +24,22 @@ namespace Sep.Git.Tfs.Vs2010
|
||||
}
|
||||
return vsInstallDir;
|
||||
}
|
||||
|
||||
private IGroupSecurityService GroupSecurityService
|
||||
{
|
||||
get { return GetService<IGroupSecurityService>(); }
|
||||
}
|
||||
|
||||
public override IIdentity GetIdentity(string username)
|
||||
{
|
||||
return _bridge.Wrap<WrapperForIdentity, Identity>(Retry.Do(() => GroupSecurityService.ReadIdentity(SearchFactor.AccountName, username, QueryMembership.None)));
|
||||
}
|
||||
|
||||
protected override TfsTeamProjectCollection GetTfsCredential(Uri uri)
|
||||
{
|
||||
return HasCredentials ?
|
||||
new TfsTeamProjectCollection(uri, GetCredential(), new UICredentialsProvider()) :
|
||||
new TfsTeamProjectCollection(uri, new UICredentialsProvider());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ using System.Net;
|
||||
using System.Reflection;
|
||||
using Microsoft.TeamFoundation;
|
||||
using Microsoft.TeamFoundation.Client;
|
||||
using Microsoft.TeamFoundation.Framework.Client;
|
||||
using Microsoft.TeamFoundation.Framework.Common;
|
||||
using Microsoft.TeamFoundation.Server;
|
||||
using Microsoft.TeamFoundation.VersionControl.Client;
|
||||
using Microsoft.TeamFoundation.WorkItemTracking.Client;
|
||||
using Microsoft.Win32;
|
||||
@@ -28,7 +25,7 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
public abstract class TfsHelperBase : ITfsHelper
|
||||
{
|
||||
protected readonly TextWriter _stdout;
|
||||
private readonly TfsApiBridge _bridge;
|
||||
protected readonly TfsApiBridge _bridge;
|
||||
private readonly IContainer _container;
|
||||
protected TfsTeamProjectCollection _server;
|
||||
private static bool _resolverInstalled;
|
||||
@@ -88,25 +85,16 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
uri = new Uri(Url);
|
||||
}
|
||||
|
||||
#if VS2010
|
||||
_server = HasCredentials ?
|
||||
new TfsTeamProjectCollection(uri, GetCredential(), new UICredentialsProvider()) :
|
||||
new TfsTeamProjectCollection(uri, new UICredentialsProvider());
|
||||
#else
|
||||
_server = new TfsTeamProjectCollection(uri, GetTfsCredential());
|
||||
#endif
|
||||
_server = GetTfsCredential(uri);
|
||||
|
||||
_server.EnsureAuthenticated();
|
||||
}
|
||||
}
|
||||
|
||||
#if !VS2010
|
||||
protected TfsClientCredentials GetTfsCredential()
|
||||
{
|
||||
var basicAuthCredential = new BasicAuthCredential(GetCredential());
|
||||
return new TfsClientCredentials(basicAuthCredential) {AllowInteractive = !HasCredentials};
|
||||
}
|
||||
#endif
|
||||
protected abstract TfsTeamProjectCollection GetTfsCredential(Uri uri);
|
||||
|
||||
public abstract IIdentity GetIdentity(string username);
|
||||
|
||||
protected NetworkCredential GetCredential()
|
||||
{
|
||||
if (!HasCredentials)
|
||||
@@ -165,18 +153,6 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
Trace.WriteLine("get [C" + e.Version + "]" + e.ServerItem);
|
||||
}
|
||||
|
||||
#if VS2010
|
||||
private IGroupSecurityService GroupSecurityService
|
||||
{
|
||||
get { return GetService<IGroupSecurityService>(); }
|
||||
}
|
||||
#else
|
||||
private IIdentityManagementService GroupSecurityService
|
||||
{
|
||||
get { return GetService<IIdentityManagementService>(); }
|
||||
}
|
||||
#endif
|
||||
|
||||
private ILinking _linking;
|
||||
private ILinking Linking
|
||||
{
|
||||
@@ -1078,15 +1054,6 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
return _bridge.Wrap<WrapperForShelveset, Shelveset>(shelveset);
|
||||
}
|
||||
|
||||
public IIdentity GetIdentity(string username)
|
||||
{
|
||||
#if VS2010
|
||||
return _bridge.Wrap<WrapperForIdentity, Identity>(Retry.Do(() => GroupSecurityService.ReadIdentity(SearchFactor.AccountName, username, QueryMembership.None)));
|
||||
#else
|
||||
return _bridge.Wrap<WrapperForIdentity, TeamFoundationIdentity>(Retry.Do(() => GroupSecurityService.ReadIdentity(IdentitySearchFactor.AccountName, username, MembershipQuery.None, ReadIdentityOptions.None)));
|
||||
#endif
|
||||
}
|
||||
|
||||
public Changeset GetLatestChangeset(IGitTfsRemote remote, bool includeChanges)
|
||||
{
|
||||
var history = VersionControl.QueryHistory(remote.TfsRepositoryPath, VersionSpec.Latest, 0,
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.TeamFoundation.Client;
|
||||
using Microsoft.TeamFoundation.Framework.Client;
|
||||
using Microsoft.TeamFoundation.Framework.Common;
|
||||
using Microsoft.TeamFoundation.VersionControl.Client;
|
||||
using Sep.Git.Tfs.Core;
|
||||
using StructureMap;
|
||||
using Sep.Git.Tfs.Core.TfsInterop;
|
||||
|
||||
namespace Sep.Git.Tfs.VsCommon
|
||||
{
|
||||
@@ -28,5 +32,21 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
}
|
||||
return vsInstallDir;
|
||||
}
|
||||
|
||||
private IIdentityManagementService GroupSecurityService
|
||||
{
|
||||
get { return GetService<IIdentityManagementService>(); }
|
||||
}
|
||||
|
||||
public override IIdentity GetIdentity(string username)
|
||||
{
|
||||
return _bridge.Wrap<WrapperForIdentity, TeamFoundationIdentity>(Retry.Do(() => GroupSecurityService.ReadIdentity(IdentitySearchFactor.AccountName, username, MembershipQuery.None, ReadIdentityOptions.None)));
|
||||
}
|
||||
|
||||
protected override TfsTeamProjectCollection GetTfsCredential(Uri uri)
|
||||
{
|
||||
var basicAuthCredential = new BasicAuthCredential(GetCredential());
|
||||
return new TfsTeamProjectCollection(uri, new TfsClientCredentials(basicAuthCredential) { AllowInteractive = !HasCredentials });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user