示例#1
0
        private SIF_ZoneStatus createZoneStatus()
        {
            SIF_ZoneStatus zoneStatus = new SIF_ZoneStatus();
            SIF_Providers  providers  = new SIF_Providers();

            zoneStatus.SIF_Providers = providers;

            SIF_Provider provider = new SIF_Provider();

            provider.SourceId       = "SPProvider";
            provider.SIF_ObjectList = new SIF_ObjectList(new SIF_Object("StudentPersonal"));
            providers.Add(provider);


            provider          = new SIF_Provider();
            provider.SourceId = "AcmeAgent";
            SIF_ObjectList objects = new SIF_ObjectList();

            objects.Add(new SIF_Object("Authentication"));
            objects.Add(new SIF_Object("SchoolInfo"));
            objects.Add(new SIF_Object("Acme"));
            objects.Add(new SIF_Object("SIF_AgentACL"));
            provider.SIF_ObjectList = objects;
            providers.Add(provider);

            return(zoneStatus);
        }
示例#2
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="zoneId">
 ///         The identifier for this Zone.
 ///         It is the same as the SIF_SourceId that the ZIS would place in any SIF_Header that it creates.
 ///       </param>
 ///<param name="sifProviders">Encompasses all of the providers registered with the ZIS</param>
 ///<param name="sifSubscribers">Encompasses all of the subscribers registered with the ZIS</param>
 ///<param name="sifsifNodes">Encompasses all of the nodes attached to this ZIS</param>
 ///<param name="sifSupportedAuthentication">Enumerates the various authentication protocols that the ZIS supports</param>
 ///<param name="sifSupportedProtocols">Enumerates the various communication transport protocols that the ZIS supports</param>
 ///<param name="sifSupportedVersions">Enumerates the versions of the SIF Specification that the ZIS can use when communicating with the SIF_SIFNode</param>
 ///
 public SIF_ZoneStatus( string zoneId, SIF_Providers sifProviders, SIF_Subscribers sifSubscribers, SIF_SIFNodes sifsifNodes, SIF_SupportedAuthentication sifSupportedAuthentication, SIF_SupportedProtocols sifSupportedProtocols, SIF_SupportedVersions sifSupportedVersions )
     : base(Adk.SifVersion, InfraDTD.SIF_ZONESTATUS)
 {
     this.ZoneId = zoneId;
     this.SIF_Providers = sifProviders;
     this.SIF_Subscribers = sifSubscribers;
     this.SIF_SIFNodes = sifsifNodes;
     this.SIF_SupportedAuthentication = sifSupportedAuthentication;
     this.SIF_SupportedProtocols = sifSupportedProtocols;
     this.SIF_SupportedVersions = sifSupportedVersions;
 }
示例#3
0
        private void _processSIF_ZoneStatus(SIF_ZoneStatus zoneStatus, IZone zone)
        {
            if (zoneStatus == null)
            {
                return;
            }

            bool      sync       = getChameleonProperty(zone, "sync", false);
            bool      events     = getChameleonProperty(zone, "logEvents", true);
            bool      logEntry   = getChameleonProperty(zone, "sifLogEntrySupport", false);
            ArrayList objectDefs = new ArrayList();

            SIF_Providers providers = zoneStatus.SIF_Providers;

            if (providers != null)
            {
                foreach (SIF_Provider p in providers)
                {
                    foreach (SIF_Object obj in p.SIF_ObjectList)
                    {
                        // Lookup the topic for each provided object in the zone
                        IElementDef def = Adk.Dtd.LookupElementDef(obj.ObjectName);
                        if (def != null)
                        {
                            objectDefs.Add(def);
                            ITopic topic = TopicFactory.GetInstance(def);
                            if (topic.GetSubscriber() == null)
                            {
                                if (events)
                                {
                                    topic.SetSubscriber(fLogger, new SubscriptionOptions());
                                }
                                if (sync)
                                {
                                    topic.SetQueryResults(fLogger);
                                }
                            }
                        }
                    }
                }
            }

            if (logEntry)
            {
                ITopic sifLogEntryTopic = TopicFactory.GetInstance(InfraDTD.SIF_LOGENTRY);
                sifLogEntryTopic.SetSubscriber(fLogger, new SubscriptionOptions());
            }

            foreach (ITopic topic in TopicFactory.GetAllTopics(SifContext.DEFAULT))
            {
                try
                {
                    // Join the topic to each zone ( causes the agent to subscribe to the joined objects )
                    // TODO: Add an "isJoinedTo()" API to topic so that it doesn't throw an exception
                    if (topic.ObjectType != InfraDTD.SIF_ZONESTATUS.Name)
                    {
                        topic.Join(zone);
                    }
                }
                catch (Exception ex)
                {
                    zone.Log.Error(ex.Message, ex);
                }
            }

            if (sync)
            {
                if (objectDefs.Count == 0)
                {
                    zone.ServerLog.Log
                        (LogLevel.WARNING, "No objects are being provided in this zone", null,
                        "1001");
                }
                string syncObjects = zone.Properties.GetProperty("chameleon.syncObjects");
                foreach (IElementDef def in objectDefs)
                {
                    if (def.IsSupported(Adk.SifVersion))
                    {
                        if (syncObjects == null ||
                            (syncObjects.Length > 0 && syncObjects.IndexOf(def.Name) > -1))
                        {
                            Query q = new Query(def);

                            // Query by specific parameters
                            string condition =
                                zone.Properties.GetProperty
                                    ("chameleon.syncConditions." + def.Name);
                            if (condition != null && condition.Length > 0)
                            {
                                // The condition should be in the format "path=value" e.g "@RefId=123412341...1234|@Name=asdfasdf"
                                String[] queryConditions = condition.Split('|');
                                foreach (String cond in queryConditions)
                                {
                                    string[] conds = cond.Split('=');
                                    if (conds.Length == 2)
                                    {
                                        q.AddCondition(conds[0], "EQ", conds[1]);
                                    }
                                }
                            }

                            if (logEntry)
                            {
                                zone.ServerLog.Log
                                    (LogLevel.INFO,
                                    "Requesting " + q.ObjectType.Name + " from the zone",
                                    q.ToXml(Adk.SifVersion), "1002");
                            }

                            zone.Query(q);
                        }
                    }
                    else
                    {
                        String debug = "Will not request " + def.Name +
                                       " because it is not supported in " +
                                       Adk.SifVersion.ToString();
                        Console.WriteLine(debug);
                        zone.ServerLog.Log(LogLevel.WARNING, debug, null, "1001");
                    }
                }
            }
        }
        private SIF_ZoneStatus createZoneStatus()
        {
            SIF_ZoneStatus zoneStatus = new SIF_ZoneStatus();
            SIF_Providers providers = new SIF_Providers();
            zoneStatus.SIF_Providers = providers;

            SIF_Provider provider = new SIF_Provider();
            provider.SourceId = "SPProvider";
            provider.SIF_ObjectList = new SIF_ObjectList(new SIF_Object("StudentPersonal"));
            providers.Add(provider);

            provider = new SIF_Provider();
            provider.SourceId = "AcmeAgent";
            SIF_ObjectList objects = new SIF_ObjectList();
            objects.Add(new SIF_Object("Authentication"));
            objects.Add(new SIF_Object("SchoolInfo"));
            objects.Add(new SIF_Object("Acme"));
            objects.Add(new SIF_Object("SIF_AgentACL"));
            provider.SIF_ObjectList = objects;
            providers.Add(provider);

            return zoneStatus;
        }