public static CloudConnection CreateAndImplersonateUser(string username, string password) { string target = ConfigurationManager.AppSettings["target"]; string adminUser = ConfigurationManager.AppSettings["adminUsername"].ToString(); string adminPassword = ConfigurationManager.AppSettings["adminPassword"].ToString(); CloudCredentialsEncryption encryptor = new CloudCredentialsEncryption(); SecureString encryptedPassword = CloudCredentialsEncryption.GetSecureString(adminPassword); Uhuru.CloudFoundry.Connection.CloudClient cloudClient = new Connection.CloudClient(); try { cloudClient.CreateUser(adminUser, adminPassword, @"http://"+ target); } catch (Uhuru.CloudFoundry.Connection.CloudClientException) { } CloudManager cloudManager = CloudManager.Instance(); CloudTarget cloudTarget = new CloudTarget(adminUser, encryptedPassword, new Uri(@"http://" + target)); CloudConnection cloudConnection = cloudManager.GetConnection(cloudTarget); cloudConnection.CreateUser(username, password); SecureString newPassword = CloudCredentialsEncryption.GetSecureString(password); cloudTarget = new CloudTarget(username, newPassword, new Uri(@"http://" + target)); cloudConnection = cloudManager.GetConnection(cloudTarget); return cloudConnection; }
public static CloudConnection CreateAndImplersonateUser(string username, string password) { string target = ConfigurationManager.AppSettings["target"]; string adminUser = ConfigurationManager.AppSettings["adminUsername"].ToString(); string adminPassword = ConfigurationManager.AppSettings["adminPassword"].ToString(); CloudCredentialsEncryption encryptor = new CloudCredentialsEncryption(); SecureString encryptedPassword = CloudCredentialsEncryption.GetSecureString(adminPassword); Uhuru.CloudFoundry.Connection.CloudClient cloudClient = new Connection.CloudClient(); try { cloudClient.CreateUser(adminUser, adminPassword, @"http://" + target); } catch (Uhuru.CloudFoundry.Connection.CloudClientException) { } CloudManager cloudManager = CloudManager.Instance(); CloudTarget cloudTarget = new CloudTarget(adminUser, encryptedPassword, new Uri(@"http://" + target)); CloudConnection cloudConnection = cloudManager.GetConnection(cloudTarget); cloudConnection.CreateUser(username, password); SecureString newPassword = CloudCredentialsEncryption.GetSecureString(password); cloudTarget = new CloudTarget(username, newPassword, new Uri(@"http://" + target)); cloudConnection = cloudManager.GetConnection(cloudTarget); return(cloudConnection); }
private async void BtnFinish_Click(object sender, RoutedEventArgs e) { this.InfoSpinner.Visibility = System.Windows.Visibility.Visible; this.InfoMessage.Text = "Checking cloud connectivity..."; var targetUrl = this.tbUrl.Text; var errorResource = this.DataContext as ErrorResource; if (errorResource == null) { throw new InvalidOperationException("Invalid DataContext"); } try { var client = new CloudFoundryClient(new Uri(targetUrl), new CancellationToken(), null, (bool)cbIgnoreSSK.IsChecked); CloudCredentials creds = new CloudCredentials(); creds.User = this.tbUsername.Text; creds.Password = this.pbPassword.Password; var authContext = await client.Login(creds); var info = await client.Info.GetInfo(); this.version = info.ApiVersion; this.cloudTarget = CloudTarget.CreateV2Target( new Uri(this.tbUrl.Text), this.tbDescription.Text, this.tbUsername.Text, (bool)this.cbIgnoreSSK.IsChecked, this.version); this.credentials = creds; this.DialogResult = true; this.Close(); } catch (Exception ex) { this.InfoSpinner.Visibility = System.Windows.Visibility.Hidden; this.InfoMessage.Text = string.Empty; var errorMessages = new List <string>(); ErrorFormatter.FormatExceptionMessage(ex, errorMessages); errorResource.ErrorMessage = string.Join(Environment.NewLine, errorMessages.ToArray()); errorResource.HasErrors = true; } }
public static void DeleteUser(string username, List <string> directoriesCreated) { string target = ConfigurationManager.AppSettings["target"]; CloudCredentialsEncryption encryptor = new CloudCredentialsEncryption(); string adminPassword = ConfigurationManager.AppSettings["adminPassword"].ToString(); SecureString encryptedPassword = CloudCredentialsEncryption.GetSecureString(adminPassword); CloudManager cloudManager = CloudManager.Instance(); CloudTarget cloudTarget = new CloudTarget(ConfigurationManager.AppSettings["adminUsername"].ToString(), encryptedPassword, new Uri("http://" + target)); CloudConnection cloudConnection = cloudManager.GetConnection(cloudTarget); User tempUser = cloudConnection.Users.First(usr => usr.Email == username); tempUser.Delete(); foreach (string str in directoriesCreated) { Directory.Delete(str, true); } }
public CloudFoundryTarget(CloudTarget target) : base(CloudItemType.Target) { this.target = target; }
public static void DeleteUser(string username, List<string> directoriesCreated) { string target = ConfigurationManager.AppSettings["target"]; CloudCredentialsEncryption encryptor = new CloudCredentialsEncryption(); string adminPassword = ConfigurationManager.AppSettings["adminPassword"].ToString(); SecureString encryptedPassword = CloudCredentialsEncryption.GetSecureString(adminPassword); CloudManager cloudManager = CloudManager.Instance(); CloudTarget cloudTarget = new CloudTarget(ConfigurationManager.AppSettings["adminUsername"].ToString(), encryptedPassword, new Uri("http://"+target)); CloudConnection cloudConnection = cloudManager.GetConnection(cloudTarget); User tempUser = cloudConnection.Users.First(usr => usr.Email == username); tempUser.Delete(); foreach (string str in directoriesCreated) { Directory.Delete(str, true); } }