Exemple #1
0
 internal virtual void  DoGet(System.Collections.BitArray a, OpenBitSet b)
 {
     int max = a.Count;
     for (int i = 0; i < max; i++)
     {
         Assert.AreEqual(a.Get(i) != b.Get(i), "mismatch: BitSet=[" + i + "]=" + a.Get(i));
     }
 }
Exemple #2
0
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
                throw new ArgumentNullException("config");
            if (String.IsNullOrEmpty(name))
                name = "TalkACDProvider";
            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Talk ACD Provider");
            }
            base.Initialize(name, config);
            _applicationName = config["applicationName"];

            if (String.IsNullOrEmpty(_applicationName))
                _applicationName = "/";
            config.Remove("applicationName");

            if (config.Count > 0)
            {
                string attr = config.Get(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException("Unrecognized attribute: " + attr);
            }
        }
 public static Dictionary<string, string> ProcessEncryptedForm(System.Collections.Specialized.NameValueCollection FormContextObject, string PrivateKey)
 {
     try
     {
         /// rsa strategy
         RSAContext context = new RSAContext();
         /// sort strategy we are using that is the bus
         context.SetStrategy(new RSAInterface());
         /// we create the collection based on a dictionary
         Dictionary<string, string> Collection = new Dictionary<string, string>();
         /// we loop now the collection
         for (int i = 0; i < FormContextObject.Count; i++)
         {
             /// get the key for the object that is the key only
             string key = FormContextObject.GetKey(i);
             /// get the for object and decrypt it
             string value = context.Decrypt(FormContextObject.Get(i), "base64", PrivateKey);
             /// we add the value for it
             Collection.Add(key, value);
         }
         /// we return the collection
         return Collection;
     }
     catch
     {
         /// we return the null entity
         return null;
     }
 }
 /// <summary>
 /// Convert a <see cref="System.Collections.Specialized.NameValueCollection"/> into the corresponding 
 /// common logging equivalent <see cref="Common.Logging.Configuration.NameValueCollection"/>
 /// </summary>
 /// <param name="properties">The properties.</param>
 /// <returns></returns>
 public static NameValueCollection ToCommonLoggingCollection(System.Collections.Specialized.NameValueCollection properties)
 {
     var result = new NameValueCollection();
     foreach (var key in properties.AllKeys)
         result.Add(key, properties.Get(key));
     return result;
 }
            public async Task ReactsToCurrentServerChange()
            {
                //mocking current time to avoid test breaking precisely on midnight
                using (var scope = TimeStub.CreateStubbedScope())
                {
                    scope.OverrideNow(new DateTime(2015, 10, 06, 03, 10, 30));

                    var subscriber =
                        new Subscriber <CharacterDirectoriesChanged>(Fixture.WurmApiManager.InternalEventAggregator);
                    var serverChangeAwaiter = new EventAwaiter <PotentialServerChangeEventArgs>();

                    var playerdir = ClientMock.AddPlayer("Jack");
                    playerdir.SetConfigName("default");

                    // have to immediatelly create file, because during log monitor creation, existing file contents will not trigger events.
                    playerdir.Logs.CreateEventLogFile();
                    // have to wait until wurmapi picks up this folder
                    subscriber.WaitMessages(1);

                    var character = System.Get("Jack");
                    character.LogInOrCurrentServerPotentiallyChanged += serverChangeAwaiter.GetEventHandler();

                    Trace.WriteLine("writing first event");
                    playerdir.Logs.WriteEventLog("5 other players are online. You are on Exodus (50 totally in Wurm).");

                    serverChangeAwaiter.WaitUntilMatch(
                        list =>
                        list.Any(args => args.ServerName == new ServerName("Exodus")));

                    var server = await character.TryGetCurrentServerAsync();

                    Expect(server.ServerName, EqualTo(new ServerName("Exodus")));

                    Trace.WriteLine(
                        "writing second event");
                    playerdir.Logs.WriteEventLog(
                        "5 other players are online. You are on Deliverance (50 totally in Wurm).");

                    serverChangeAwaiter.WaitUntilMatch(
                        list =>
                        list.Any(args => args.ServerName == new ServerName("Deliverance")));

                    server = await character.TryGetCurrentServerAsync();

                    Expect(server.ServerName, EqualTo(new ServerName("Deliverance")));

                    Trace.WriteLine("writing third event");
                    playerdir.Logs.WriteEventLog(
                        "5 other players are online. You are on Deliverance (50 totally in Wurm).");

                    serverChangeAwaiter.WaitUntilMatch(
                        list =>
                        list.Any(args => args.ServerName == new ServerName("Deliverance")));

                    server = await character.TryGetCurrentServerAsync();

                    Expect(server.ServerName, EqualTo(new ServerName("Deliverance")));
                }
            }
Exemple #6
0
 public static List <string> Get()
 {
     return(new List <string> {
     }.Concat(UI.Get())
            .Concat(Editor.Get())
            .Concat(Input.Get())
            .Concat(System.Get())
            .Where(s => !string.IsNullOrEmpty(s)).Distinct().ToList());
 }
 /// <summary>
 /// Returns the next un-set bit at or after index, or -1 if no such bit exists.
 /// </summary>
 /// <param name="bitArray"></param>
 /// <param name="index">the index of bit array at which to start checking</param>
 /// <returns>the next set bit or -1</returns>
 public static int NextClearBit(System.Collections.BitArray bitArray, int index)
 {
     while (index < bitArray.Length)
     {
         // if index bit is not set, return it
         // otherwise check next index bit
         if (!bitArray.Get(index))
             return index;
         else
             index++;
     }
     // if no bits are set at or after index, return -1
     return -1;
 }
		/// <summary> Creates a set of protected properties from a set of normal ones.
		/// 
		/// </summary>
		/// <param name="props">the properties to be stored and protected.
		/// </param>
		//UPGRADE_ISSUE: Class hierarchy differences between 'java.util.Properties' and 'System.Collections.Specialized.NameValueCollection' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
		public ProtectedProperties(System.Collections.Specialized.NameValueCollection props)
		{
			
			System.Collections.IEnumerator propEnum = props.Keys.GetEnumerator();
			//UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
			while (propEnum.MoveNext())
			{
				//UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
				System.String propName = (System.String) propEnum.Current;
				System.String propValue = props.Get(propName);
				//UPGRADE_TODO: Method 'java.util.Properties.setProperty' was converted to 'System.Collections.Specialized.NameValueCollection.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilPropertiessetProperty_javalangString_javalangString'"
				base[propName] = propValue;
			}
			closed = true; // no modifications allowed from now on
		}
 /// <summary> Returns the value of the specified servlet context initialization parameter.
 /// 
 /// </summary>
 /// <param name="param">the parameter to return
 /// </param>
 /// <param name="properties">the <code>Properties</code> for the Java system
 /// </param>
 /// <param name="arguments">optionally takes the arguments passed into the main to 
 /// use as the migration system name
 /// </param>
 /// <returns> the value of the specified system initialization parameter
 /// </returns>
 /// <throws>  IllegalArgumentException if the parameter does not exist </throws>
 //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.Properties' and 'System.Collections.Specialized.NameValueCollection' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
 private static System.String getRequiredParam(System.String param, System.Collections.Specialized.NameValueCollection properties, System.String[] arguments)
 {
     System.String value_Renamed = properties.Get(param);
     if (value_Renamed == null)
     {
         if ((arguments != null) && (arguments.Length > 0))
         {
             value_Renamed = arguments[0].Trim();
         }
         else
         {
             throw new System.ArgumentException("'" + param + "' is a required " + "initialization parameter.  Aborting.");
         }
     }
     return value_Renamed;
 }
		/// <summary> Configure the launcher from the provided properties, system name
		/// 
		/// </summary>
		/// <param name="launcher">The launcher to configure
		/// </param>
		/// <param name="systemName">The name of the system we're configuring
		/// </param>
		/// <param name="props">The Properties object with our configuration information
		/// </param>
		/// <throws>  IllegalArgumentException if a required parameter is missing </throws>
		/// <throws>  MigrationException if there is problem setting the context into the launcher </throws>
		
		private void  configureFromMigrationProperties(AdoMigrationLauncher launcher, System.String systemName, System.Collections.Specialized.NameValueCollection props)
		{
            //TODO: change to use MigrationConfigurationManager
            launcher.PatchPath = null;//getRequiredParam(props, systemName + ".patch.path");
			launcher.PostPatchPath = props.Get(systemName + ".postpatch.path");
			
			// Set up the data source
			/*NonPooledDataSource dataSource = new NonPooledDataSource();
			dataSource.DriverClass = getRequiredParam(props, systemName + ".ado.driver");
			dataSource.DatabaseUrl = getRequiredParam(props, systemName + ".ado.url");
			dataSource.Username = getRequiredParam(props, systemName + ".ado.username");
			dataSource.Password = getRequiredParam(props, systemName + ".ado.password");*/
			
			// Set up the ADO migration context; accepts one of two property names
			DataSourceMigrationContext context = DataSourceMigrationContext;
            //TODO: change to use MigrationConfigurationManager
            System.String databaseType = null;// getRequiredParam(props, systemName + ".ado.database.type", systemName + ".ado.dialect");
			context.DatabaseType = new DatabaseType(databaseType);
			
			// Finish setting up the context
			context.SystemName = systemName;
			
			//context.DataSource = dataSource;
			
			// done reading in config, set launcher's context
			launcher.AddContext(context);
		}
        public void Get()
        {
            var obj1 = new {
                valueTypeProperty1 = 45245,
                valueTypeProperty2 = 45245L,
                valueTypeProperty3 = 134134.54252,
                valueTypeProperty4 = 134134.54252F,
                valueTypeProperty5 = 134134.54252M,
                valueTypeProperty6 = DateTime.Now,
                referenceProperty1 = new object(),
                referenceProperty2 = new object[0]
            };

            // Get existed properties
            Assert.AreEqual(obj1.valueTypeProperty1, obj1.Get("valueTypeProperty1"));
            Assert.AreEqual(obj1.valueTypeProperty2, obj1.Get("valueTypeProperty2"));
            Assert.AreEqual(obj1.valueTypeProperty3, obj1.Get("valueTypeProperty3"));
            Assert.AreEqual(obj1.valueTypeProperty4, obj1.Get("valueTypeProperty4"));
            Assert.AreEqual(obj1.valueTypeProperty5, obj1.Get("valueTypeProperty5"));
            Assert.AreEqual(obj1.valueTypeProperty6, obj1.Get("valueTypeProperty6"));

            Assert.AreEqual(obj1.referenceProperty1, obj1.Get("referenceProperty1"));
            Assert.AreEqual(obj1.referenceProperty2, obj1.Get("referenceProperty2"));

            // Get bad property names
            Assert.AreEqual(null, obj1.Get("NotExisted"));
            Assert.AreEqual(null, obj1.Get(string.Empty));
            Assert.AreEqual(null, obj1.Get(null));

            // Get with specified type right
            Assert.AreEqual(obj1.valueTypeProperty1, obj1.Get<int>("valueTypeProperty1"));
            Assert.AreEqual(obj1.valueTypeProperty1, obj1.Get<long>("valueTypeProperty1"));

            // Get with specified wrong type
            Assert.AreNotEqual(obj1.valueTypeProperty1, obj1.Get<DateTime>("valueTypeProperty1"));
            Assert.AreEqual(default(DateTime), obj1.Get<DateTime>("valueTypeProperty1"));
        }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
                throw new ArgumentNullException("config");
            if (String.IsNullOrEmpty(name))
                name = "TalkAuthenticationProvider";
            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Talk Authentication Provider");
            }
            base.Initialize(name, config);
            _applicationName = config["applicationName"];

            if (String.IsNullOrEmpty(_applicationName))
                _applicationName = "/";
            config.Remove("applicationName");

            try
            {
                _tokenExpiration = int.Parse(config["tokenExpiration"]);
            }
            catch (Exception e)
            {
                log.Error("Unable to parse tokenExpiration attribute: " + e.Message);
                _tokenExpiration = 20;
            }

            if (_tokenExpiration <= 0)
            {
                _tokenExpiration = 20;
            }
            config.Remove("tokenExpiration");

            if (config.Count > 0)
            {
                string attr = config.Get(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException("Unrecognized attribute: " + attr);
            }
        }
        public void handleHttpResponseHeaders(System.Net.WebHeaderCollection headers)
        {
            log.enteredMethod();


            String wwwAuthenticate = headers.Get("WWW-Authenticate");


            if (null != wwwAuthenticate) 
            {

                log.warn(wwwAuthenticate);

                WwwAuthenticate authenticateResponseHeader = WwwAuthenticate.buildFromString(wwwAuthenticate);

                String serverRealm = authenticateResponseHeader.realm;
                Subject server = _securityConfiguration.getServer(serverRealm);

                if (null == server)
                {
                    log.warnFormat("null == _subject; serverRealm = '{0}'", serverRealm);
                    _authorization = null;
                    _ha1 = null;
                    return;
                }

                _ha1 = server.getHa1();

                _authorization = new Authorization();
                _authorization.nc = 1;
                _authorization.cnonce = SecurityUtilities.generateNonce();
                _authorization.nonce = authenticateResponseHeader.nonce;
                _authorization.opaque = authenticateResponseHeader.opaque;
                _authorization.qop = authenticateResponseHeader.qop;
                _authorization.realm = server.Realm;
                _authorization.username = server.Username;

                return; // our work here is done
            }

            String authenticationInfo = headers.Get("Authentication-Info");

            if (null != authenticationInfo)
            {

                AuthenticationInfo authenticationInfoHeader = AuthenticationInfo.buildFromString( authenticationInfo );

                long nc = _authorization.nc + 1;
                _authorization.nc = nc;
                _authorization.nonce = authenticationInfoHeader.nextnonce;

                return; // our work here is done

            }

            log.warn("did not find a 'WWW-Authenticate' or a 'Authentication-Info'");
            
        }
Exemple #14
0
 public static string BitArrayToString(System.Collections.BitArray b)
 {
     StringBuilder sb = new StringBuilder();
     for (int i = 0; i < b.Length; i++)
     {
         sb.Append(b.Get(i) ? "1" : "0");
     }
     return sb.ToString();
 }
Exemple #15
0
    private bool HasPermission(System.Collections.Specialized.NameValueCollection permissions, string sfindPermission, ref ArrayList sPermIndex)
    {
        bool bReturn = false;
        string[] sFind;
        string[] sInclusive;

        sPermIndex = new ArrayList();
        sFind = sfindPermission.Split(';');

        for (int i = 0; i < sFind.Length; i++)
        {
        if (sFind[i].Contains("|"))
        {
            sInclusive = sFind[i].Split('|');

            for (int j = 0; j < sInclusive.Length; j++)
            {
                if (permissions.Get(sInclusive[j]) == null)
                {
                    bReturn = false;
                    break;
                }
                else if (permissions.Get(sInclusive[j]) != "true")
                {
                    bReturn = false;
                    sPermIndex.Add(sInclusive[j]);
                    break;
                }
                else
                    bReturn = true;
            }

            if (bReturn)
                break;
        }
        else
        {
            if (permissions.Get(sFind[i]) != null && (permissions.Get(sFind[i]) == "true"))
            {
                bReturn = true;
                break;
            }
        }
        }

        if (bReturn)
        sPermIndex.Clear();

        return bReturn;
    }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
                throw new ArgumentNullException("config");
            if (String.IsNullOrEmpty(name))
                name = "LdapAuthenticationProvider";
            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "LDAP Authentication Provider");
            }
            base.Initialize(name, config);
            _applicationName = config["applicationName"];

            if (String.IsNullOrEmpty(_applicationName))
                _applicationName = "/";
            config.Remove("applicationName");

            this.ldapServer = config["ldapServer"];

            if (String.IsNullOrEmpty(this.ldapServer))
                throw new ProviderException("ldapServer attribute is required");
            config.Remove("ldapServer");

            this.authenticationMode = config["authMode"];

            if (String.IsNullOrEmpty(this.authenticationMode))
                throw new ProviderException("authMode attribute is required");
            config.Remove("authMode");

            this.ldapUser = config["ldapUser"];

            if (String.IsNullOrEmpty(this.ldapUser))
                throw new ProviderException("ldapUser attribute is required");
            config.Remove("ldapUser");

            this.ldapUserPassword = config["ldapUserPassword"];

            if (String.IsNullOrEmpty(this.ldapUserPassword))
                throw new ProviderException("ldapUserPassword attribute is required");
            config.Remove("ldapUserPassword");

            this.ldapFilter = config["ldapFilter"];

            if (String.IsNullOrEmpty(this.ldapFilter))
                throw new ProviderException("ldapFilter attribute is required");
            config.Remove("ldapFilter");

            this.userIdAttribute = config["useridAttribute"];

            if (String.IsNullOrEmpty(this.userIdAttribute))
                throw new ProviderException("useridAttribute attribute is required");
            config.Remove("useridAttribute");

            this.telephoneAttribute = config["telephoneAttribute"];

            if (String.IsNullOrEmpty(this.telephoneAttribute))
                throw new ProviderException("telephoneAttribute attribute is required");
            config.Remove("telephoneAttribute");

            this.baseOU = config["baseOU"];

            if (String.IsNullOrEmpty(this.baseOU))
                throw new ProviderException("baseOU attribute is required");
            config.Remove("baseOU");


            try
            {
                _tokenExpiration = int.Parse(config["tokenExpiration"]);
            }
            catch (Exception e)
            {
                log.Error("Unable to parse tokenExpiration attribute: " + e.Message);
                _tokenExpiration = 20;
            }

            if (_tokenExpiration <= 0)
            {
                _tokenExpiration = 20;
            }
            config.Remove("tokenExpiration");

            if (config.Count > 0)
            {
                string attr = config.Get(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException("Unrecognized attribute: " + attr);
            }
        }
Exemple #17
0
        public static bool[] BitArrayToBoolArray(System.Collections.BitArray b)
        {
            // TODO: When we switch to .net 3,5..
            if (b == null)
                return new bool[] { };

            bool[] tmp = new bool[b.Count - 1];
            for (int i = 0; i < b.Length; i++)
            {
                tmp[i] = b.Get(i);
            }
            return tmp;
        }
		private void  CheckExpecteds(System.Collections.BitArray expecteds)
		{
			IndexReader r = IndexReader.Open(dir);
			
			//Perhaps not the most efficient approach but meets our needs here.
			for (int i = 0; i < r.MaxDoc(); i++)
			{
				if (!r.IsDeleted(i))
				{
					System.String sval = r.Document(i).Get(FIELD_RECORD_ID);
					if (sval != null)
                    {
                        int val = System.Int32.Parse(sval);
                        Assert.IsTrue(expecteds.Get(val), "Did not expect document #" + val);
                        expecteds.Set(val, false); 
                    }
				}
			}
			r.Close();
			Assert.AreEqual(0, Support.BitSetSupport.Cardinality(expecteds), "Should have 0 docs remaining ");
		}
Exemple #19
0
 private void AddUpdateRight(ref System.Collections.Specialized.NameValueCollection security, string sRight, AccessControlType controlType, FileSystemRights ruleRights, FileSystemRights constRights)
 {
     if (DotNetBitwiseAnd(ruleRights, constRights))
     {
         if ((security.Get(sRight) != null) && (security.Get(sRight) != "false"))
         {
             security.Remove(sRight);
             security.Add(sRight, controlType == AccessControlType.Allow ? "true" : "false");
         }
         else
         {
             security.Add(sRight, controlType == AccessControlType.Allow ? "true" : "false");
         }
     }
     else
     {
         if (security.Get(sRight) == null)
             security.Add(sRight, "notSpecified");
     }
 }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
                throw new ArgumentNullException("config");
            if (String.IsNullOrEmpty(name))
                name = "CiscoPrivacyProvider";
            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Cisco Privacy Provider");
            }
            base.Initialize(name, config);
            _applicationName = config["applicationName"];

            if (String.IsNullOrEmpty(_applicationName))
                _applicationName = "/";
            config.Remove("applicationName");

            string save = config["saveInCache"];
            config.Remove("saveInCache");

            if (String.IsNullOrEmpty(save))
            {
                _saveInCache = true;
            }
            else
            {
                _saveInCache = bool.Parse(save);
            }

            if (config.Count > 0)
            {
                string attr = config.Get(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException("Unrecognized atrtibute: " + attr);
            }
        }
 public override void Setup()
 {
     base.Setup();
     wurmCharacter = System.Get(new CharacterName("Testguy"));
 }
        /// <summary> Configure the launcher from the provided properties, system name
        /// 
        /// </summary>
        /// <param name="launcher">The launcher to configure
        /// </param>
        /// <param name="systemName">The name of the system we're configuring
        /// </param>
        /// <param name="props">The Properties object with our configuration information
        /// </param>
        /// <throws>  IllegalArgumentException if a required parameter is missing </throws>
        /// <throws>  MigrationException if there is problem setting the context into the launcher </throws>
        //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.Properties' and 'System.Collections.Specialized.NameValueCollection' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
        private void configureFromMigrationProperties(DistributedAdoMigrationLauncher launcher, System.String systemName, System.Collections.Specialized.NameValueCollection props)
        {
            // Get the name of the context to use for our patch information
            System.String patchStoreContextName = null;//getRequiredParam(props, systemName + ".context");

            // Set up the data source
            /* TODO
            dataSource.DriverClass = getRequiredParam(props, patchStoreContextName + ".ado.driver");
            dataSource.DatabaseUrl = getRequiredParam(props, patchStoreContextName + ".ado.url");
            dataSource.Username = getRequiredParam(props, patchStoreContextName + ".ado.username");
            dataSource.Password = getRequiredParam(props, patchStoreContextName + ".ado.password");
            */
            // Get any post-patch task paths
            launcher.PostPatchPath = props.Get(patchStoreContextName + ".postpatch.path");

            // Set up the ADO migration context; accepts one of two property names
            DataSourceMigrationContext context = DataSourceMigrationContext;
            System.String databaseType = null;// getRequiredParam(props, patchStoreContextName + ".ado.database.type", patchStoreContextName + ".ado.dialect");
            context.DatabaseType = new DatabaseType(databaseType);

            // Finish setting up the context
            context.SystemName = systemName;
            //context.DataSource = dataSource;

            // done reading in config, set launcher's context
            launcher.AddContext(context);

            // Get our controlled systems, and instantiate their launchers
            //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
            System.Collections.Hashtable controlledSystems = new System.Collections.Hashtable();
            System.String[] controlledSystemNames = null;// getRequiredParam(props, systemName + ".controlled.systems").split(",");
            for (int i = 0; i < controlledSystemNames.Length; i++)
            {
                log.Info("Creating controlled migration launcher for system " + controlledSystemNames[i]);
                AdoMigrationLauncherFactory factory = AdoMigrationLauncherFactoryLoader.createFactory();
                AdoMigrationLauncher subLauncher = factory.createMigrationLauncher(controlledSystemNames[i]);
                controlledSystems[controlledSystemNames[i]] = subLauncher;

                // Make sure the controlled migration process gets migration events
                //launcher.MigrationProcess.addListener(subLauncher);
                launcher.MigrationProcess.MigrationStarted += new MigrationProcess.MigrationStatusEventHandler(subLauncher.MigrationStarted);
                launcher.MigrationProcess.MigrationSuccessful += new MigrationProcess.MigrationStatusEventHandler(subLauncher.MigrationSuccessful);
                launcher.MigrationProcess.MigrationFailed += new MigrationProcess.MigrationStatusEventHandler(subLauncher.MigrationFailed);
            }

            // communicate our new-found controlled systems to the migration process
            // TODO ((DistributedMigrationProcess)launcher.MigrationProcess).ControlledSystems = null;// controlledSystems;
        }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
                throw new ArgumentNullException("config");
            if (String.IsNullOrEmpty(name))
                name = "CiscoExtensionMobilityProvider";
            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Cisco Extension Mobility Provider");
            }
            base.Initialize(name, config);
            _applicationName = config["applicationName"];

            if (String.IsNullOrEmpty(_applicationName))
                _applicationName = "/";
            config.Remove("applicationName");

            try
            {
                _emserver = config["emserver"];
            }
            catch (Exception e)
            {
                log.Error("Unable to parse emserver attribute: " + e.Message);
            }

            
            config.Remove("emserver");

            try
            {
                _emuser = config["emuser"];
            }
            catch (Exception e)
            {
                log.Error("Unable to parse emuser attribute: " + e.Message);
            }


            config.Remove("emuser");

            try
            {
                _empassword = config["empassword"];
            }
            catch (Exception e)
            {
                log.Error("Unable to parse empassword attribute: " + e.Message);
            }


            config.Remove("empassword");

            try
            {
                _sharedLinePartition = config["sharedlinepartition"];
            }
            catch (Exception e)
            {
                log.Error("Unable to parse sharedlinepartition attribute: " + e.Message);
            }

            
            config.Remove("sharedlinepartition");

            _emapi.empassword = _empassword;
            _emapi.emserver = _emserver;
            _emapi.emuser = _emuser;

            if (config.Count > 0)
            {
                string attr = config.Get(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException("Unrecognized attribute: " + attr);
            }
        }
Exemple #24
0
            public static string UploadFileEx(string uploadfile, string url,
               string fileFormName, string contenttype, System.Collections.Specialized.NameValueCollection querystring,
               CookieContainer cookies)
            {
                if ((fileFormName == null) ||
                    (fileFormName.Length == 0))
                {
                    fileFormName = "file";
                }

                if ((contenttype == null) ||
                    (contenttype.Length == 0))
                {
                    contenttype = "application/octet-stream";
                }

                string postdata;
                postdata = "?";
                if (querystring != null)
                {
                    foreach (string key in querystring.Keys)
                    {
                        postdata += key + "=" + querystring.Get(key) + "&";
                    }
                }
                Uri uri = new Uri(url + postdata);

                string boundary = "----------" + DateTime.Now.Ticks.ToString("x");
                HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(uri);
                webrequest.CookieContainer = cookies;
                webrequest.ContentType = "multipart/form-data; boundary=" + boundary;
                webrequest.Method = "POST";

                StringBuilder sb = new StringBuilder();
                sb.Append("--");
                sb.Append(boundary);
                sb.Append("\r\n");
                sb.Append("Content-Disposition: form-data; name=\"");
                sb.Append(fileFormName);
                sb.Append("\"; filename=\"");
                sb.Append(Path.GetFileName(uploadfile));
                sb.Append("\"");
                sb.Append("\r\n");
                sb.Append("Content-Type: ");
                sb.Append(contenttype);
                sb.Append("\r\n");
                sb.Append("\r\n");

                string postHeader = sb.ToString();
                byte[] postHeaderBytes = Encoding.UTF8.GetBytes(postHeader);

                byte[] boundaryBytes =
                       Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");

                FileStream fileStream = new FileStream(uploadfile,
                                            FileMode.Open, FileAccess.Read);
                long length = postHeaderBytes.Length + fileStream.Length +
                                                       boundaryBytes.Length;
                webrequest.ContentLength = length;

                Stream requestStream = webrequest.GetRequestStream();

                requestStream.Write(postHeaderBytes, 0, postHeaderBytes.Length);

                byte[] buffer = new Byte[checked((uint)Math.Min(40,(int)fileStream.Length))];
                int bytesRead = 0;
                while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
                    requestStream.Write(buffer, 0, bytesRead);

                requestStream.Write(boundaryBytes, 0, boundaryBytes.Length);
                WebResponse responce = webrequest.GetResponse();
                Stream s = responce.GetResponseStream();
                StreamReader sr = new StreamReader(s);

                return sr.ReadToEnd();
            }