Example #1
0
        public bool AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
        {
            string url  = string.Empty;
            string name = string.Empty;

            reason = string.Empty;

            UUID uid = new UUID(AgentID);

            if (IsLocal(GroupID, out url, out name))
            {
                if (m_UserManagement.IsLocalGridUser(uid)) // local user
                {
                    // normal case: local group, local user
                    return(m_LocalGroupsConnector.AddAgentToGroup(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID, RoleID, token, out reason));
                }
                else // local group, foreign user
                {
                    // the user is accepting the  invitation, or joining, where the group resides
                    token = UUID.Random().ToString();
                    bool success = m_LocalGroupsConnector.AddAgentToGroup(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID, RoleID, token, out reason);

                    if (success)
                    {
                        // Here we always return true. The user has been added to the local group,
                        // independent of whether the remote operation succeeds or not
                        url = m_UserManagement.GetUserServerURL(uid, "GroupsServerURI");
                        if (url == string.Empty)
                        {
                            reason = "You don't have an accessible groups server in your home world. You membership to this group in only within this grid.";
                            return(true);
                        }

                        GroupsServiceHGConnector c = GetConnector(url);
                        if (c != null)
                        {
                            c.CreateProxy(AgentUUI(RequestingAgentID), AgentID, token, GroupID, m_LocalGroupsServiceLocation, name, out reason);
                        }
                        return(true);
                    }
                    return(false);
                }
            }
            else if (m_UserManagement.IsLocalGridUser(uid)) // local user
            {
                // foreign group, local user. She's been added already by the HG service.
                // Let's just check
                if (m_LocalGroupsConnector.GetAgentGroupMembership(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID) != null)
                {
                    return(true);
                }
            }

            reason = "Operation not allowed outside this group's origin world";
            return(false);
        }
        public ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string GroupName)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
            }


            string url  = string.Empty;
            string name = string.Empty;

            if (IsLocal(GroupID, out url, out name))
            {
                return(m_LocalGroupsConnector.GetGroupRecord(AgentUUI(RequestingAgentID), GroupID, GroupName));
            }
            else if (url != string.Empty)
            {
                ExtendedGroupMembershipData membership = m_LocalGroupsConnector.GetAgentGroupMembership(RequestingAgentID, RequestingAgentID, GroupID);
                string accessToken = string.Empty;
                if (membership != null)
                {
                    accessToken = membership.AccessToken;
                }
                else
                {
                    return(null);
                }

                GroupsServiceHGConnector c = GetConnector(url);
                if (c != null)
                {
                    ExtendedGroupRecord grec = m_CacheWrapper.GetGroupRecord(RequestingAgentID, GroupID, GroupName, delegate
                    {
                        return(c.GetGroupRecord(AgentUUIForOutside(RequestingAgentID), GroupID, GroupName, accessToken));
                    });

                    if (grec != null)
                    {
                        ImportForeigner(grec.FounderUUI);
                    }
                    return(grec);
                }
            }

            return(null);
        }
Example #3
0
        public ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string GroupName)
        {
            string url  = string.Empty;
            string name = string.Empty;

            if (IsLocal(GroupID, out url, out name))
            {
                return(m_LocalGroupsConnector.GetGroupRecord(AgentUUI(RequestingAgentID), GroupID, GroupName));
            }
            else if (url != string.Empty)
            {
                ExtendedGroupMembershipData membership = m_LocalGroupsConnector.GetAgentGroupMembership(RequestingAgentID, RequestingAgentID, GroupID);
                string accessToken = string.Empty;
                if (membership != null)
                {
                    accessToken = membership.AccessToken;
                }
                else
                {
                    return(null);
                }

                GroupsServiceHGConnector c = GetConnector(url);
                if (c != null)
                {
                    ExtendedGroupRecord grec = m_CacheWrapper.GetGroupRecord(RequestingAgentID, GroupID, GroupName, delegate
                    {
                        return(c.GetGroupRecord(AgentUUIForOutside(RequestingAgentID), GroupID, GroupName, accessToken));
                    });

                    if (grec != null)
                    {
                        ImportForeigner(grec.FounderUUI);
                    }
                    return(grec);
                }
            }

            return(null);
        }