public NSObject ObjectValueForTableColumn (NSTableView table, NSTableColumn col, int row)
		{
			var value = (NSString)string.Empty;
			ActionHelper.Execute (delegate() {
				if (Entries != null) {
					var obj = (this.Entries [row]) as CertificateDto;
					X509Certificate2 cert;
					switch (col.Identifier) {
					case "Name":
						value = (NSString)obj.Chain;
						break;
					case "Status": 
						value = (NSString)(obj.IsSigner ? "ACTIVE" : "IN-ACTIVE");
						break;
					case "IssuedBy": 
						cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
						value = (NSString)cert.Issuer;
						break;
					case "IssuedOn": 
						cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
						value = (NSString)cert.NotBefore.ToShortDateString ();
						break;
					case "Expiration": 
						cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
						value = (NSString)cert.NotAfter.ToShortDateString ();
						break;
					case "Purpose": 
						cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
						value = (NSString)cert.ToKeyUsage ();
						break;
					case "SubjectDn": 
						cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
						value = (NSString)cert.Subject;
						break;
					case "Fingerprint": 
						cert = new X509Certificate2 (Encoding.ASCII.GetBytes (obj.Encoded));
						value = (NSString)cert.GetFormattedThumbPrint ();
						break;
					default:
						break;
					}
				}
			});
			return value;
		}
		public override void AwakeFromNib ()
		{
			base.AwakeFromNib ();
			_certificates = new List<CertificateDto> ();
			_currentStep = WizardSteps.One;
			SetWizardStep ();
			ReloadCertificates ();

			//Events
			this.BtnTestConnection.Activated += TestConnection;
			this.BtnNext.Activated += OnClickNextButton;
			this.BtnBack.Activated += OnClickBackButton;
			this.BtnAddCertificate.Activated +=	(object sender, EventArgs e) => {
				var openPanel = new NSOpenPanel();
				openPanel.ReleasedWhenClosed = true;
				openPanel.Prompt = "Select file";

				var result = openPanel.RunModal();
				if (result == 1)
				{
					var filePath = openPanel.Url.AbsoluteString.Replace("file://",string.Empty);
					var cert = new X509Certificate2 ();
					ActionHelper.Execute (delegate() {
						cert.Import (filePath);
						var certfificateDto = new CertificateDto { Encoded = cert.ToPem(), Chain = cert.GetFormattedThumbPrint()};
						_certificates.Add(certfificateDto);
						ReloadCertificates();
					});
				}
			};

			this.RdoIdentitySource.Activated += (object sender, EventArgs e) => 
			{
				SetSpnControls();
			};
			this.RdoDomainController.Activated += (object sender, EventArgs e) => 
			{
				var anyDc = RdoDomainController.SelectedTag == 1;
				if(anyDc)
				{
					SetConnectionString();
				}
				else
				{
					TxtLdapConnection.StringValue = (NSString) string.Empty;
				}
				ChkProtect.Enabled = anyDc;
				EnableDisableConnectionString(!anyDc);
			};
			this.BtnRemoveCertificate.Activated += (object sender, EventArgs e) => {
				if (LstCertificates.SelectedRows.Count > 0) {
					foreach (var row in LstCertificates.SelectedRows) {
						_certificates.RemoveAt ((int)row);
					}
					ReloadCertificates();
				}
			};
			this.BtnPrimaryImport.Activated += (object sender, EventArgs e) => {
				
			};

			this.BtnSecondaryImport.Activated += (object sender, EventArgs e) => {

			};
			this.TxtDomainName.Changed += (object sender, EventArgs e) => {
				SetConnectionString();
			};

			this.ChkProtect.Activated += (object sender, EventArgs e) => {
				SetConnectionString();
			};
			this.RdoSpn.Activated += (object sender, EventArgs e) => {
				SetSpnControls();
			};
			BtnPrimaryImport.Enabled = false;
			BtnSecondaryImport.Enabled = false;
			this.TxtPrimaryUrl.Activated += (object sender, EventArgs e) => 
			{
				BtnPrimaryImport.Enabled = this.TxtPrimaryUrl.StringValue!= null && this.TxtPrimaryUrl.StringValue.StartsWith("ldaps://");
			};
			this.TxtSecondaryConnection.Activated += (object sender, EventArgs e) => 
			{
				BtnSecondaryImport.Enabled = this.TxtSecondaryConnection.StringValue!= null && this.TxtSecondaryConnection.StringValue.StartsWith("ldaps://");
			};
			BtnPrimaryImport.Activated += (object sender, EventArgs e) => 
			{
				ImportCertificates(TxtPrimaryUrl.StringValue);
			};
			BtnSecondaryImport.Activated += (object sender, EventArgs e) => 
			{
				ImportCertificates(TxtSecondaryConnection.StringValue);
			};
			if (IdentityProviderDto != null)
				DtoToView ();
			else
				IdentityProviderDto = new IdentityProviderDto ();
			this.BtnAdvanced.Activated += (object sender, EventArgs e) => 
			{
				var form = new ExternalDomainAdvancedSettingsController ()
				{
					IdentityProviderDto = new IdentityProviderDto
					{
						Schema = IdentityProviderDto.Schema == null ? new Dictionary<string, SchemaObjectMappingDto>() :new Dictionary<string, SchemaObjectMappingDto>(IdentityProviderDto.Schema),
						AttributesMap = IdentityProviderDto.AttributesMap == null ?  new Dictionary<string, string>() : new Dictionary<string, string>(IdentityProviderDto.AttributesMap),
						BaseDnForNestedGroupsEnabled = IdentityProviderDto.BaseDnForNestedGroupsEnabled,
						MatchingRuleInChainEnabled = IdentityProviderDto.MatchingRuleInChainEnabled,
						DirectGroupsSearchEnabled = IdentityProviderDto.DirectGroupsSearchEnabled
					}
				};
				var result = NSApplication.SharedApplication.RunModalForWindow (form.Window);

				if(result == 1)
				{
					IdentityProviderDto.Schema = GetSchema(form.IdentityProviderDto.Schema);
					IdentityProviderDto.AttributesMap = new Dictionary<string, string>(form.IdentityProviderDto.AttributesMap);
					IdentityProviderDto.BaseDnForNestedGroupsEnabled = form.IdentityProviderDto.BaseDnForNestedGroupsEnabled;
					IdentityProviderDto.MatchingRuleInChainEnabled = form.IdentityProviderDto.MatchingRuleInChainEnabled;
					IdentityProviderDto.DirectGroupsSearchEnabled = form.IdentityProviderDto.DirectGroupsSearchEnabled;
				}
			};
			SetSpnControls ();
		}
		void ImportCertificates(string connection)
		{
			try
			{
				var xcert = LdapSecureConnectionCertificateFetcher.FetchServerCertificate(connection);
				var cert = new X509Certificate2(xcert);
				var thumbprint = cert.GetFormattedThumbPrint();
				var certfificateDto = new CertificateDto { Encoded = cert.ToPem(),Chain = thumbprint };

				var exists = _certificates.Exists(x=>x.Chain == thumbprint);
				if(exists)
				{
					UIErrorHelper.ShowAlert("Certificate with the same fingerprint already exists", "Error");
					return;
				}
				_certificates.Add(certfificateDto);
				ReloadCertificates ();
				UIErrorHelper.ShowAlert(string.Format("Certificate with subject {0} imported successfully", cert.Subject), "Information");
			}
			catch (Exception exception)
			{
				UIErrorHelper.ShowAlert (exception.Message, "Error");
			}
		}