Skip to content

Commit

Permalink
Merge pull request #8 from dropbox/jack/4.2
Browse files Browse the repository at this point in the history
Jack 4 5
  • Loading branch information
jackb-dropbox authored Nov 15, 2016
2 parents dd73a86 + f13f4c2 commit 8216d1d
Show file tree
Hide file tree
Showing 32 changed files with 545 additions and 247 deletions.
Binary file modified Installer/DBAdminToolkit.Setup.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions Source/DBAdminToolkit.Setup/DBAdminToolkit.Setup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Dropbox Business Admin Toolkit"
"ProductCode" = "8:{E45FF5F2-727B-4B69-B555-247B6A8C959D}"
"ProductCode" = "8:{9FD4D23E-457C-4206-86DA-6CAF1D08C192}"
"PackageCode" = "8:{4F507568-2104-402C-812B-BF0F65944546}"
"UpgradeCode" = "8:{F6F4214B-C1CB-4F20-B1B3-35E1B7262F93}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:4.2.0"
"ProductVersion" = "8:4.5.0"
"Manufacturer" = "8:Dropbox Enterprise Services"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand Down
2 changes: 2 additions & 0 deletions Source/DfBAdminToolkit.Common/DfBAdminToolkit.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Security" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down Expand Up @@ -73,6 +74,7 @@
</Compile>
<Compile Include="Component\Win32.cs" />
<Compile Include="DataExchange\DataUpdatedEventArgs.cs" />
<Compile Include="Extensions\StringExtension.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\DataResponse.cs" />
<Compile Include="Services\IData.cs" />
Expand Down
42 changes: 42 additions & 0 deletions Source/DfBAdminToolkit.Common/Extensions/StringExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Text;
using System.Security.Cryptography;

namespace DfBAdminToolkit.Common.Extensions
{
public static class StringExtension
{
public static string Encrypt(
this string clearText,
string optionalEntropy = null,
DataProtectionScope scope = DataProtectionScope.LocalMachine)
{
if (clearText == null)
throw new ArgumentNullException("Clear text is null");
byte[] clearBytes = Encoding.UTF8.GetBytes(clearText);
byte[] entropyBytes = string.IsNullOrEmpty(optionalEntropy)
? null
: Encoding.UTF8.GetBytes(optionalEntropy);
byte[] encryptedBytes = ProtectedData.Protect(clearBytes, entropyBytes, scope);
string encryptedString = "encrypted-" + Convert.ToBase64String(encryptedBytes);
return encryptedString;
}

public static string Decrypt(
this string encryptedText,
string optionalEntropy = null,
DataProtectionScope scope = DataProtectionScope.LocalMachine)
{
if (encryptedText == null)
throw new ArgumentNullException("Encrypted text is null");
//remove encrypted- tag from beginning
encryptedText = encryptedText.Remove(0, 10);
byte[] encryptedBytes = Convert.FromBase64String(encryptedText);
byte[] entropyBytes = string.IsNullOrEmpty(optionalEntropy)
? null
: Encoding.UTF8.GetBytes(optionalEntropy);
byte[] clearBytes = ProtectedData.Unprotect(encryptedBytes, entropyBytes, scope);
return Encoding.UTF8.GetString(clearBytes);
}
}
}
4 changes: 2 additions & 2 deletions Source/DfBAdminToolkit.Common/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.2.0.0")]
[assembly: AssemblyFileVersion("4.2.0.0")]
[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("4.5.0.0")]
2 changes: 2 additions & 0 deletions Source/DfBAdminToolkit.Common/Services/IMemberData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public interface IMemberData

string NewExternalId { get; set; }

string ProvisionStatus { get; set; }

#endregion Provision

#region Groups
Expand Down
6 changes: 5 additions & 1 deletion Source/DfBAdminToolkit.Common/Services/IMemberServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public interface IMemberServices {

string ArchiveTeamFolderUrl { get; set; }

string SyncSettingTeamFolderUrl { get; set; }

string CreateTeamFolderUrl { get; set; }

string ListTeamFolderUrl { get; set; }
Expand Down Expand Up @@ -89,8 +91,10 @@ public interface IMemberServices {

IDataResponse ListTeamFolders(string authToken);

IServiceResponse CreateTeamFolder(string teamFolderName, bool syncSetting, string authToken);
IServiceResponse CreateTeamFolder(string teamFolderName, string authToken);

IServiceResponse SetFolderStatus(string teamFolderId, bool activeSetting, string authToken);

IServiceResponse SetFolderSyncSetting(string teamFolderId, string syncSetting, string authToken);
}
}
2 changes: 2 additions & 0 deletions Source/DfBAdminToolkit.Common/Services/MemberData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class MemberData

public string NewExternalId { get; set; }

public string ProvisionStatus { get; set; }

#endregion Provision

#region Search Text
Expand Down
55 changes: 45 additions & 10 deletions Source/DfBAdminToolkit.Common/Services/MemberServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class MemberServices

public string ArchiveTeamFolderUrl { get; set; }

public string SyncSettingTeamFolderUrl { get; set; }

public string CreateTeamFolderUrl { get; set; }

public string ListTeamFolderUrl { get; set; }
Expand Down Expand Up @@ -104,7 +106,7 @@ public IServiceResponse AddMember(IMemberData data, string authToken)
request.RequestFormat = DataFormat.Json;
client.UserAgent = UserAgentVersion;
IRestResponse response = client.Execute(request);
serviceResponse = new ServiceResponse(response.StatusCode, response.ErrorMessage);
serviceResponse = new ServiceResponse(response.StatusCode, response.Content);
}
else
{
Expand Down Expand Up @@ -728,14 +730,9 @@ public IDataResponse ListTeamFolders(string authToken)
return dataResponse;
}

public IServiceResponse CreateTeamFolder(string teamFolderName, bool syncSetting, string authToken)
public IServiceResponse CreateTeamFolder(string teamFolderName, string authToken)
{
IServiceResponse serviceResponse = null;
string syncStringSetting = "sync";
if (!syncSetting)
{
syncStringSetting = "no_sync";
}
try
{
if (!string.IsNullOrEmpty(CreateTeamFolderUrl))
Expand All @@ -746,8 +743,7 @@ public IServiceResponse CreateTeamFolder(string teamFolderName, bool syncSetting
request.AddHeader("Content-Type", "application/json");

JObject json = new JObject(
new JProperty("name", teamFolderName),
new JProperty("default_sync_setting", syncStringSetting)
new JProperty("name", teamFolderName)
);

request.AddParameter("application/json", json, ParameterType.RequestBody);
Expand Down Expand Up @@ -821,14 +817,53 @@ public IServiceResponse SetFolderStatus(string teamFolderId, bool activeSetting,
return serviceResponse;
}

public IServiceResponse SetFolderSyncSetting(string teamFolderId, string syncSetting, string authToken)
{
IServiceResponse serviceResponse = null;
try
{
if (!string.IsNullOrEmpty(SyncSettingTeamFolderUrl))
{
RestClient client = new RestClient(string.Format("{0}/{1}/", _baseUrl, _apiVersion));
RestRequest request = new RestRequest(SyncSettingTeamFolderUrl, Method.POST);
request.AddHeader("Authorization", Convert.ToString("Bearer ") + authToken);
request.AddHeader("Content-Type", "application/json");

JObject json = new JObject(
new JProperty("team_folder_id", teamFolderId),
new JProperty("default_sync_setting", syncSetting)
);
request.AddParameter("application/json", json, ParameterType.RequestBody);

request.RequestFormat = DataFormat.Json;
client.UserAgent = UserAgentVersion;
IRestResponse response = client.Execute(request);
serviceResponse = new ServiceResponse(response.StatusCode, response.ErrorMessage);
}
else
{
throw new ArgumentNullException("Missing service url");
}
}
catch (Exception e)
{
serviceResponse = new ServiceResponse(HttpStatusCode.InternalServerError, e.Message);
}
return serviceResponse;
}

public IDataResponse DumpFile(IMemberData data, string outputFolder, string authToken)
{
IDataResponse dataResponse = null;
try
{
if (!string.IsNullOrEmpty(FileDumpUrl))
{
string pathString = string.Concat(@"{""path"":""", data.Path, @"""}");
//added this to be able to get files with ASCII characters in them.
Byte[] encodedBytes = System.Text.Encoding.ASCII.GetBytes(data.Path);
string newPath = System.Text.Encoding.ASCII.GetString(encodedBytes);

string pathString = string.Concat(@"{""path"":""", newPath, @"""}");
string url = string.Format("{0}/{1}/", _baseUrl, _apiVersion);
RestClient client = new RestClient(url);
RestRequest request = new RestRequest(FileDumpUrl, Method.GET);
Expand Down
2 changes: 1 addition & 1 deletion Source/DfBAdminToolkit/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<add key="ActionArchiveTeamFolder" value="team/team_folder/archive" />
<add key="ActionCreateTeamFolder" value="team/team_folder/create" />
<add key="ActionListTeamFolder" value="team/team_folder/list" />
<add key="ActionUpdateMembersTeamFolder" value="team/team_folder/update_members" />
<add key="ActionUpdateDefaultSyncSettingTeamFolder" value="team/team_folder/update_default_sync_setting" />

<!-- registry handling -->
<add key="RegistryEntryPoint" value="SOFTWARE\Dropbox Business Toolkit" />
Expand Down
26 changes: 24 additions & 2 deletions Source/DfBAdminToolkit/ApplicationResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Configuration;
using System.Threading;
using DfBAdminToolkit.Common.Extensions;

public static class ApplicationResource {

Expand Down Expand Up @@ -119,6 +120,11 @@ public static string ActionArchiveTeamFolder
get { return ConfigurationManager.AppSettings.Get("ActionArchiveTeamFolder"); }
}

public static string ActionUpdateDefaultSyncSettingTeamFolder
{
get { return ConfigurationManager.AppSettings.Get("ActionUpdateDefaultSyncSettingTeamFolder"); }
}

public static string ActionCreateTeamFolder
{
get { return ConfigurationManager.AppSettings.Get("ActionCreateTeamFolder"); }
Expand Down Expand Up @@ -168,11 +174,27 @@ public static string RegistryKey {
}

public static string DefaultAccessToken {
get { return ConfigurationManager.AppSettings.Get("DefaultAccessToken"); }
get
{
string defaultToken = ConfigurationManager.AppSettings.Get("DefaultAccessToken");
if (defaultToken.StartsWith("encrypted-"))
{
defaultToken = defaultToken.Decrypt();
}
return defaultToken;
}
}

public static string DefaultProvisionToken {
get { return ConfigurationManager.AppSettings.Get("DefaultProvisionToken"); }
get
{
string defaultProvisionToken = ConfigurationManager.AppSettings.Get("DefaultProvisionToken");
if (defaultProvisionToken.StartsWith("encrypted-"))
{
defaultProvisionToken = defaultProvisionToken.Decrypt();
}
return defaultProvisionToken;
}
}

public static string DefaultOutputReportFilePrefix {
Expand Down
1 change: 1 addition & 0 deletions Source/DfBAdminToolkit/DfBAdminToolkit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<add key="ActionCreateTeamFolder" value="team/team_folder/create" />
<add key="ActionListTeamFolder" value="team/team_folder/list" />
<add key="ActionUpdateMembersTeamFolder" value="team/team_folder/update_members" />
<add key="ActionUpdateDefaultSyncSettingTeamFolder" value="team/team_folder/update_default_sync_setting" />

<!-- registry handling -->
<add key="RegistryEntryPoint" value="SOFTWARE\Dropbox Business Toolkit" />
Expand Down
2 changes: 2 additions & 0 deletions Source/DfBAdminToolkit/Model/IProvisioningModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public interface IProvisioningModel

string NewExternalId { get; set; }

string ProvisionStatus { get; set; }

List<MemberListViewItemModel> Members { get; set; }
}
}
11 changes: 11 additions & 0 deletions Source/DfBAdminToolkit/Model/MemberListViewItemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class MemberListViewItemModel
private decimal _usage;
private string _newEmail;
private string _newExternalId;
private string _provisionStatus;
private bool _isChecked;

public string Email {
Expand Down Expand Up @@ -102,6 +103,16 @@ public string NewExternalId
}
}

public string ProvisionStatus
{
get { return _provisionStatus; }
set
{
_provisionStatus = value;
OnPropertyChanged("ProvisionStatus");
}
}

public bool IsChecked {
get { return _isChecked; }
set {
Expand Down
5 changes: 4 additions & 1 deletion Source/DfBAdminToolkit/Model/ProvisioningModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class ProvisioningModel

public string NewExternalId { get; set; }

public string ProvisionStatus { get; set; }

public List<MemberListViewItemModel> Members { get; set; }

public ProvisioningModel() {
Expand All @@ -29,7 +31,8 @@ public void Initialize() {
AccessToken = ApplicationResource.DefaultProvisionToken;
SelectedRole = string.Empty;
SendWelcomeEmail = true;
KeepAccount = true;
ProvisionStatus = string.Empty;
KeepAccount = false;
}

public void CleanUp() {
Expand Down
22 changes: 12 additions & 10 deletions Source/DfBAdminToolkit/Model/TeamFoldersListViewItemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class TeamFoldersListViewItemModel
: INotifyPropertyChanged, IModel {
private string _teamFolderName;
private string _teamFolderId;
private string _defaultSyncSetting;
//private string _defaultSyncSetting;
private string _status;
private bool _isChecked;

Expand All @@ -26,15 +26,17 @@ public string TeamFolderId {
}
}

public string DefaultSyncSetting {
get { return _defaultSyncSetting; }
set {
_defaultSyncSetting = value;
OnPropertyChanged("DefaultSyncSetting");
}
}

public string Status {
//public string DefaultSyncSetting
//{
// get { return _defaultSyncSetting; }
// set
// {
// _defaultSyncSetting = value;
// OnPropertyChanged("DefaultSyncSetting");
// }
//}

public string Status {
get { return _status; }
set {
_status = value;
Expand Down
Loading

0 comments on commit 8216d1d

Please sign in to comment.