コード例 #1
0
        public override void AwakeFromNib ()
        {
            base.AwakeFromNib ();

            ResetToolBarItems ();

            //Load SplitView
            splitViewController = new SplitViewMMCController ();
            splitViewController.MainOutlineView = new TreeView ();
            splitViewController.MainOutlineView.OutlineTableColumn = new NSTableColumn ();
            this.MainCustomView.AddSubview (splitViewController.View);
            var userController = new DefaultViewController ();
            this.DetailedCustomView.AddSubview (userController.View);

            AddToolbarItem.Activated += AddToolbarItem_Activated;
            DeleteToolbarItem.Activated += DeleteToolbarItem_Activated;
            PropertiesToolbarItem.Activated += PropertiesToolbarItem_Activated;
            RefreshToolbarItem.Activated += RefreshToolbarItem_Activated;
            TokenWizardToolbarItem.Activated += TokenWizardToolbarItem_Activated;
            ADToolbarItem.Activated += ADToolbarItem_Activated;
            ComputerToolbarItem.Activated += ComputerToolbarItem_Activated;
            HttptransportToolbarItem.Activated += HttpTransportToolbarItem_Activated;
            (NSApplication.SharedApplication.Delegate as AppDelegate).OpenConnectionMenuItem.Hidden = true;


            //Notifications for OutlineView and Tableview to reload
            NSNotificationCenter.DefaultCenter.AddObserver ((NSString)"ReloadOutlineView", ReloadOutlineView);
            NSNotificationCenter.DefaultCenter.AddObserver ((NSString)"ReloadTableView", ReloadTableView);
            NSNotificationCenter.DefaultCenter.AddObserver ((NSString)"RefreshTableView", RefreshTableView);
            NSNotificationCenter.DefaultCenter.AddObserver ((NSString)"LoggedInSessionExpired", LoggedInSessionExpired);
            NSNotificationCenter.DefaultCenter.AddObserver ((NSString)"RefreshToken", RefreshToken);
        }
コード例 #2
0
            public override void SelectionDidChange (NSNotification notification)
			{
				ActionHelper.Execute (delegate() {
					var row = (int)ob.splitViewController.MainTableView.SelectedRow;
					AppKit.NSViewController controller = null;
					if (row >= 0) {
						ActionHelper.Execute (delegate() {
							if (ob.CurrentSelectedNode is UsersNode) {
								var node = ob.CurrentSelectedNode as UsersNode;
								var tenant = node.GetTenant ();
								var user = ((UsersDataSource)ob.splitViewController.MainTableView.DataSource).Entries [row];
								var groups = new List<GroupDto>();
								try
								{
									var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken (ob._serverDto.ServerName);
									groups = SnapInContext.Instance.ServiceGateway.User.GetUserGroups (ob._serverDto, tenant, user, auth.Token);
									user.ActAsUsers = groups != null && groups.Exists (x => x.GroupName == "ActAsUsers" && x.GroupDomain == user.Domain);
									user.IsIdpAdmin = groups != null && groups.Exists (x => x.GroupName == "IdpProvisioningAdmin" && x.GroupDomain == user.Domain);
									var isAdmin = groups != null && groups.Exists (x => x.GroupName == "Administrators" && x.GroupDomain == user.Domain);
									var isUser = groups != null && groups.Exists (x => x.GroupName == "Users" && x.GroupDomain == user.Domain);
									user.Role = isAdmin ? UserRole.Administrator : isUser ? UserRole.RegularUser : UserRole.GuestUser;
								}
								catch(Exception exc)
								{
									user.ActAsUsers = false;
									user.IsIdpAdmin = false;
									user.Role = UserRole.GuestUser;
								}
								controller = new UserDetailsViewController () {
									UserDtoOriginal = user,
									GroupsOriginal = groups,
									ServerDto = ob._serverDto,
									TenantName = tenant,
									IsSystemDomain = node.IsSystemDomain
								};

							} else if (ob.CurrentSelectedNode is SolutionUsersNode) {
								var node = ob.CurrentSelectedNode as SolutionUsersNode;
								var tenant = node.GetTenant ();
								var user = ((SolutionUsersDataSource)ob.splitViewController.MainTableView.DataSource).Entries [row];
								controller = new SolutionUserDetailsViewController () {
									SolutionUserDtoOriginal = user,
									ServerDto = ob._serverDto,
									TenantName = tenant,
									IsSystemDomain = node.IsSystemDomain
								};
							} else if (ob.CurrentSelectedNode is GroupsNode) {
								var node = ob.CurrentSelectedNode as GroupsNode;
								var tenant = node.GetTenant ();
								var user = ((GroupsDataSource)ob.splitViewController.MainTableView.DataSource).Entries [row];
								var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken (ob._serverDto.ServerName);
								//var groupMembership = SnapInContext.Instance.ServiceGateway.Group.GetMembers (ob._serverDto, tenant, user, Vmware.Tools.RestSsoAdminSnapIn.Service.Group.GroupMemberType.ALL, auth.Token);
								var memberInfo = new GroupMembershipDto ();
								var userInfo = SnapInContext.Instance.ServiceGateway.Group.GetMembers (ob._serverDto, tenant, user, GroupMemberType.USER, auth.Token);
								memberInfo.Users = userInfo.Users == null ? new List<UserDto> () : new List<UserDto> (userInfo.Users);
								if (node.IsSystemDomain) {
									userInfo = SnapInContext.Instance.ServiceGateway.Group.GetMembers (ob._serverDto, tenant, user, GroupMemberType.SOLUTIONUSER, auth.Token);
									memberInfo.SolutionUsers = userInfo.SolutionUsers == null ? new List<SolutionUserDto> () : new List<SolutionUserDto> (userInfo.SolutionUsers);
								}
								userInfo = SnapInContext.Instance.ServiceGateway.Group.GetMembers (ob._serverDto, tenant, user, GroupMemberType.GROUP, auth.Token);
								memberInfo.Groups = userInfo.Groups == null ? new List<GroupDto> () : new List<GroupDto> (userInfo.Groups);

								controller = new GroupDetailsViewController () {
									GroupDtoOriginal = user,
									GroupsMembershipDtoOriginal = memberInfo,
									ServerDto = ob._serverDto,
									TenantName = tenant,
									IsSystemDomain = node.IsSystemDomain
								};
							} else if (ob.CurrentSelectedNode is TrustedCertificateNode) {
								var certificate = ((TrustedCertificatesDataSource)ob.splitViewController.MainTableView.DataSource).Entries [row];
								controller = new CertificateDetailsViewController () {
									CertificateDto = certificate
								};
							} else if (ob.CurrentSelectedNode is RelyingPartyNode) {
								var node = ob.CurrentSelectedNode as RelyingPartyNode;
								var tenant = node.GetTenant ();
								var rp = ((RelyingPartyDataSource)ob.splitViewController.MainTableView.DataSource).Entries [row];
								controller = new RelyingPartyDetailsViewController () { 
									RelyingPartyDtoOriginal = rp, 
									ServerDto = ob._serverDto,
									TenantName = tenant
								};
							} else if (ob.CurrentSelectedNode is OidcClientNode) {
								var node = ob.CurrentSelectedNode as OidcClientNode;
								var rp = ((OidcClientDataSource)ob.splitViewController.MainTableView.DataSource).Entries [row];
								var tenant = node.GetTenant ();
								controller = new OidcClientDetailsViewController () {
									OidcClientDtoOriginal = rp,
									ServerDto = ob._serverDto,
									TenantName = tenant
								};
							} else if (ob.CurrentSelectedNode is IdentityProvidersNode) {
								var node = ob.CurrentSelectedNode as IdentityProvidersNode;
								var rp = ((IdentityProvidersDataSource)ob.splitViewController.MainTableView.DataSource).Entries [row];
								var rpLatest = node.GetIdentityProvider (rp);
								controller = new ExtenalIdpDetailsViewController () {
									ExternalIdentityProviderDto = rpLatest
								};
							} else {
								controller = new DefaultViewController ();
							}
						});
						if (controller == null)
							controller = new DefaultViewController ();

						AppKit.NSView oldView = null;
						if (ob.DetailedCustomView.Subviews.Count () > 0) {
							oldView = ob.DetailedCustomView.Subviews [0];
						}
						if (oldView != null)
							ob.DetailedCustomView.ReplaceSubviewWith (oldView, controller.View);
						else
							ob.DetailedCustomView.AddSubview (controller.View);
					
					}
				});
			}
コード例 #3
0
 void SetDefaultView ()
 {
     AppKit.NSView oldView = null;
     var controller = new DefaultViewController ();
     if (DetailedCustomView.Subviews.Count () > 0) {
         oldView = DetailedCustomView.Subviews [0];
     }
     if (oldView != null)
         DetailedCustomView.ReplaceSubviewWith (oldView, controller.View);
     else
         DetailedCustomView.AddSubview (controller.View);
 }