예제 #1
0
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (name == null || name.Length == 0)
            {
                name = "SDBProfileProvider";
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            accessKey = GetConfigValue(config["accessKey"], "");
            secretKey = GetConfigValue(config["secretKey"], "");
            domain    = GetConfigValue(config["domain"], "Profiles");

            client = new AmazonSimpleDBClient(accessKey, secretKey);

            // Make sure the domain for user profiles exists
            CreateDomainRequest cdRequest = new CreateDomainRequest();

            cdRequest.DomainName = domain;
            client.CreateDomain(cdRequest);
        }
예제 #2
0
        public override void CreateDomain(string Domain)
        {
            Domain = SetDomain(Domain);
            CreateDomainRequest request = new CreateDomainRequest().WithDomainName(Domain);

            client.CreateDomain(request);
        }
예제 #3
0
        public void sendAmazonSimpleDbIndex(String XML)
        {
            AmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            try
            {
                String domainName = "";

                CreateDomainRequest createDomain2 = (new CreateDomainRequest()).WithDomainName("index");
                sdb.CreateDomain(createDomain2);

                domainName = "index";
                String itemNameTwo = "1";
                PutAttributesRequest        putAttributesActionTwo = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameTwo);
                List <ReplaceableAttribute> attributesTwo          = putAttributesActionTwo.Attribute;
                attributesTwo.Add(new ReplaceableAttribute().WithName("indexID").WithValue(indexID));
                attributesTwo.Add(new ReplaceableAttribute().WithName("compID").WithValue(machineName));
                attributesTwo.Add(new ReplaceableAttribute().WithName("XML_Profile").WithValue(XML));

                sdb.PutAttributes(putAttributesActionTwo);
            }
            catch (AmazonSimpleDBException ex)
            {
                failCount++;
                log("Caught Exception: " + ex.Message);
                log("Response Status Code: " + ex.StatusCode);
                log("Error Code: " + ex.ErrorCode);
                log("Error Type: " + ex.ErrorType);
                log("Request ID: " + ex.RequestId);
                log("XML: " + ex.XML);
            }

            //Console.WriteLine("Press Enter to continue...");
            //Console.Read();
        }
예제 #4
0
        public override void Initialize(string name, NameValueCollection config)
        {
            base.Initialize(name, config);

            accessKey = config["accessKey"];
            secretKey = config["secretKey"];
            if (string.IsNullOrEmpty(accessKey))
            {
                throw new ConfigurationErrorsException("AWS Access Key is required.");
            }
            if (string.IsNullOrEmpty(secretKey))
            {
                throw new ConfigurationErrorsException("AWS Secret Key is required.");
            }

            // Set any domain prefix
            if (!string.IsNullOrEmpty(config["domainPrefix"]))
            {
                domainPrefix = config["domainPrefix"];
            }

            client = new AmazonSimpleDBClient(accessKey, secretKey);

            if (config["domains"] != null)
            {
                // Make sure domains exist
                string[] domains = config["domains"].ToString().Split(new char[] { ',' });
                foreach (string domain in domains)
                {
                    string _domain = SetDomain(domain);
                    CreateDomainRequest request = new CreateDomainRequest().WithDomainName(_domain);
                    client.CreateDomain(request);
                }
            }
        }
예제 #5
0
        //Amazon
        public void sendAmazonSimpleMachineName()
        {
            AmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            try
            {
                String domainName = "";

                CreateDomainRequest createDomain = (new CreateDomainRequest()).WithDomainName("Computer");
                sdb.CreateDomain(createDomain);

                // Putting data into a domain
                domainName = "Computer";

                String itemNameOne = "1";
                PutAttributesRequest        putAttributesActionOne = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameOne);
                List <ReplaceableAttribute> attributesOne          = putAttributesActionOne.Attribute;
                attributesOne.Add(new ReplaceableAttribute().WithName("compID").WithValue(machineName));
                attributesOne.Add(new ReplaceableAttribute().WithName("compName").WithValue(machineName));
                sdb.PutAttributes(putAttributesActionOne);
            }
            catch (AmazonSimpleDBException ex)
            {
                log(".........AmazonSimpleDBException.........");
                log("Caught Exception: " + ex.Message);
                log("Response Status Code: " + ex.StatusCode);
                log("Error Code: " + ex.ErrorCode);
                log("Error Type: " + ex.ErrorType);
                log("Request ID: " + ex.RequestId);
                log("XML: " + ex.XML);
            }
        }
예제 #6
0
 void Init()
 {
     client = new AmazonSimpleDBClient(accessKey, secretKey);
     foreach (string domain in domains)
     {
         string _domain = SetDomain(domain);
         CreateDomainRequest request = new CreateDomainRequest().WithDomainName(_domain);
         client.CreateDomain(request);
     }
 }
예제 #7
0
        /// <summary>
        /// Creates the domain for the given type
        /// </summary>
        public void CreateDomain()
        {
            if (Logger.IsInfoEnabled)
            {
                Logger.Info("Sending request to create domain '{0}' to ensure it exists".StringFormat(_domainName));
            }

            var request = _domainRequestFactory.Create(this.DomainName);

            _simpleDB.CreateDomain(request);
        }
예제 #8
0
        public static void CheckForDomain(string domainName, AmazonSimpleDB sdbClient)
        {
            VerifyKeys();

            ListDomainsRequest listDomainsRequest = new ListDomainsRequest();
            ListDomainsResponse listDomainsResponse = sdbClient.ListDomains(listDomainsRequest);
            if (!listDomainsResponse.ListDomainsResult.DomainName.Contains(domainName))
            {
                CreateDomainRequest createDomainRequest = new CreateDomainRequest().WithDomainName(domainName);
                sdbClient.CreateDomain(createDomainRequest);
            }
        }
예제 #9
0
        public override void Initialize(string name, NameValueCollection config)
        {
            //
            // Initialize values from web.config.
            //

            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (name == null || name.Length == 0)
            {
                name = "SDBRoleProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Amazon Simple DB Role provider");
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            accessKey = GetConfigValue(config["accessKey"], "");
            secretKey = GetConfigValue(config["secretKey"], "");
            domain    = GetConfigValue(config["domain"], "Roles");

            if (config["writeExceptionsToEventLog"] != null)
            {
                if (config["writeExceptionsToEventLog"].ToUpper() == "TRUE")
                {
                    pWriteExceptionsToEventLog = true;
                }
            }

            //
            // Initialize the SimpleDB Client.
            //

            client = new AmazonSimpleDBClient(accessKey, secretKey);

            // Make sure the domain for users exists
            CreateDomainRequest cdRequest = new CreateDomainRequest();

            cdRequest.DomainName = domain;
            client.CreateDomain(cdRequest);
        }
        private void EnsureDomain(string domain)
        {
            var listDomainsRequest  = new ListDomainsRequest();
            var listDomainsResponse = _client.ListDomains(listDomainsRequest);

            if (listDomainsResponse.ListDomainsResult.DomainName.Contains(domain))
            {
                return;
            }

            var createDomainRequest = new CreateDomainRequest {
                DomainName = domain
            };

            _client.CreateDomain(createDomainRequest);
        }
예제 #11
0
        public bool sendAmazonSimpleDbImage(String filename, String partNo, String part)
        {
            AmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            try
            {
                String domainName = "";

                CreateDomainRequest createDomain3 = (new CreateDomainRequest()).WithDomainName("Images");
                sdb.CreateDomain(createDomain3);

                domainName = "Images";
                String itemNameThree = itemNo.ToString();
                PutAttributesRequest        putAttributesActionThree = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameThree);
                List <ReplaceableAttribute> attributesThree          = putAttributesActionThree.Attribute;
                attributesThree.Add(new ReplaceableAttribute().WithName("ImgID").WithValue("TestImage01"));
                attributesThree.Add(new ReplaceableAttribute().WithName("indexID").WithValue("1"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Extension").WithValue("jpg"));
                attributesThree.Add(new ReplaceableAttribute().WithName("location").WithValue(filename));
                attributesThree.Add(new ReplaceableAttribute().WithName("imgPart").WithValue(partNo.ToString()));
                attributesThree.Add(new ReplaceableAttribute().WithName("raw").WithValue(part));
                sdb.PutAttributes(putAttributesActionThree);
            }
            catch (AmazonSimpleDBException ex)
            {
                failCount++;
                log("Caught Exception: " + ex.Message);
                log("Response Status Code: " + ex.StatusCode);
                log("Error Code: " + ex.ErrorCode);
                log("Error Type: " + ex.ErrorType);
                log("Request ID: " + ex.RequestId);
                log("XML: " + ex.XML);

                return(false);
            }
            itemNo++;
            return(true);
        }
예제 #12
0
        /// <summary>
        /// Put the user's reco into the ZigMeRecos domain in SimpleDB
        /// </summary>
        /// <returns></returns>
        private bool SaveRecoToSimpleDB(string myFBId)
        {
            AmazonSimpleDB sdb = GetSDB();

            // Creating a domain
            String domainName = "ZigMeRecos";
            CreateDomainRequest createDomain = (new CreateDomainRequest()).WithDomainName(domainName);

            sdb.CreateDomain(createDomain);

            // Check to see how many recos this FB user id has stored in our domain
            String         selectExpression    = "Select * From ZigMeRecos Where FBId = '" + myFBId + "'";
            SelectRequest  selectRequestAction = new SelectRequest().WithSelectExpression(selectExpression);
            SelectResponse selectResponse      = sdb.Select(selectRequestAction);

            int cRecos = 0;

            // Now store the actual recommendation item
            if (selectResponse.IsSetSelectResult())
            {
                SelectResult selectResult = selectResponse.SelectResult;
                cRecos = selectResult.Item.Count;
            }
            cRecos++;
            String recoItem = "Reco_" + myFBId + "_" + cRecos;
            PutAttributesRequest        putAttributesRecoItem = new PutAttributesRequest().WithDomainName(domainName).WithItemName(recoItem);
            List <ReplaceableAttribute> attributesRecoItem    = putAttributesRecoItem.Attribute;

            attributesRecoItem.Add(new ReplaceableAttribute().WithName("FBId").WithValue(myFBId));
            attributesRecoItem.Add(new ReplaceableAttribute().WithName("Name").WithValue(RecoName.Text));
            attributesRecoItem.Add(new ReplaceableAttribute().WithName("Email").WithValue(ContactEmail.Text));
            attributesRecoItem.Add(new ReplaceableAttribute().WithName("City").WithValue(RecoCity.Text));
            attributesRecoItem.Add(new ReplaceableAttribute().WithName("Service").WithValue(RecoService.SelectedValue));
            PutAttributesResponse putAttributesResponse = sdb.PutAttributes(putAttributesRecoItem);

            return(putAttributesResponse.IsSetResponseMetadata());
        }
예제 #13
0
        public override void Initialize(string name, NameValueCollection config)
        {
            //
            // Initialize values from web.config.
            //

            if (config == null)
                throw new ArgumentNullException("config");

            if (name == null || name.Length == 0)
                name = "SDBRoleProvider";

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Amazon Simple DB Role provider");
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            accessKey = GetConfigValue(config["accessKey"], "");
            secretKey = GetConfigValue(config["secretKey"], "");
            domain = GetConfigValue(config["domain"], "Roles");

            if (config["writeExceptionsToEventLog"] != null)
            {
                if (config["writeExceptionsToEventLog"].ToUpper() == "TRUE")
                {
                    pWriteExceptionsToEventLog = true;
                }
            }

            //
            // Initialize the SimpleDB Client.
            //

            client = new AmazonSimpleDBClient(accessKey, secretKey);

            // Make sure the domain for users exists
            CreateDomainRequest cdRequest = new CreateDomainRequest();
            cdRequest.DomainName = domain;
            client.CreateDomain(cdRequest);
        }
예제 #14
0
        private void EnsureDomain(string storeIdentifier)
        {
            var createDomainRequest = new CreateDomainRequest().WithDomainName(storeIdentifier);

            _simpleDb.CreateDomain(createDomainRequest);
        }
예제 #15
0
 void Init()
 {
     client = new AmazonSimpleDBClient(accessKey, secretKey);
     foreach (string domain in domains)
     {
         string _domain = SetDomain(domain);
         CreateDomainRequest request = new CreateDomainRequest().WithDomainName(_domain);
         client.CreateDomain(request);
     }
 }
예제 #16
0
        //
        // System.Configuration.Provider.ProviderBase.Initialize Method
        //

        public override void Initialize(string name, NameValueCollection config)
        {
            //
            // Initialize values from web.config.
            //

            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (name == null || name.Length == 0)
            {
                name = "SDBMembershipProvider";
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            accessKey = GetConfigValue(config["accessKey"], "");
            secretKey = GetConfigValue(config["secretKey"], "");
            domain    = GetConfigValue(config["domain"], "Users");
            pWriteExceptionsToEventLog = Convert.ToBoolean(GetConfigValue(config["writeExceptionsToEventLog"], "true"));

            string temp_format = config["passwordFormat"];

            if (temp_format == null)
            {
                temp_format = "Hashed";
            }

            switch (temp_format)
            {
            case "Hashed":
                pPasswordFormat = MembershipPasswordFormat.Hashed;
                break;

            case "Encrypted":
                pPasswordFormat = MembershipPasswordFormat.Encrypted;
                break;

            case "Clear":
                pPasswordFormat = MembershipPasswordFormat.Clear;
                break;

            default:
                throw new ProviderException("Password format not supported.");
            }

            //
            // Initialize the SimpleDB Client.
            //

            client = new AmazonSimpleDBClient(accessKey, secretKey);

            // Make sure the domain for users exists
            CreateDomainRequest cdRequest = new CreateDomainRequest();

            cdRequest.DomainName = domain;
            client.CreateDomain(cdRequest);

            // Get encryption and decryption key information from the configuration.
            Configuration cfg =
                WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);

            machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");

            if (machineKey.ValidationKey.Contains("AutoGenerate"))
            {
                if (PasswordFormat != MembershipPasswordFormat.Clear)
                {
                    throw new ProviderException("Hashed or Encrypted passwords " +
                                                "are not supported with auto-generated keys.");
                }
            }
        }
예제 #17
0
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            if (name == null || name.Length == 0)
                name = "SDBProfileProvider";

            // Initialize the abstract base class.
            base.Initialize(name, config);

            accessKey = GetConfigValue(config["accessKey"], "");
            secretKey = GetConfigValue(config["secretKey"], "");
            domain = GetConfigValue(config["domain"], "Profiles");

            client = new AmazonSimpleDBClient(accessKey, secretKey);

            // Make sure the domain for user profiles exists
            CreateDomainRequest cdRequest = new CreateDomainRequest();
            cdRequest.DomainName = domain;
            client.CreateDomain(cdRequest);
        }
예제 #18
0
        public override void Initialize(string name, NameValueCollection config)
        {
            base.Initialize(name, config);

            accessKey = config["accessKey"];
            secretKey = config["secretKey"];
            if (string.IsNullOrEmpty(accessKey)) throw new ConfigurationErrorsException("AWS Access Key is required.");
            if (string.IsNullOrEmpty(secretKey)) throw new ConfigurationErrorsException("AWS Secret Key is required.");

            // Set any domain prefix
            if (!string.IsNullOrEmpty(config["domainPrefix"])) domainPrefix = config["domainPrefix"];

            client = new AmazonSimpleDBClient(accessKey, secretKey);

            if (config["domains"] != null)
            {
                // Make sure domains exist
                string[] domains = config["domains"].ToString().Split(new char[] { ',' });
                foreach (string domain in domains)
                {
                    string _domain = SetDomain(domain);
                    CreateDomainRequest request = new CreateDomainRequest().WithDomainName(_domain);
                    client.CreateDomain(request);
                }
            }
        }
예제 #19
0
        //
        // System.Configuration.Provider.ProviderBase.Initialize Method
        //
        public override void Initialize(string name, NameValueCollection config)
        {
            //
            // Initialize values from web.config.
            //

            if (config == null)
                throw new ArgumentNullException("config");

            if (name == null || name.Length == 0)
                name = "SDBMembershipProvider";

            // Initialize the abstract base class.
            base.Initialize(name, config);

            accessKey = GetConfigValue(config["accessKey"], "");
            secretKey = GetConfigValue(config["secretKey"], "");
            domain = GetConfigValue(config["domain"], "Users");
            pWriteExceptionsToEventLog = Convert.ToBoolean(GetConfigValue(config["writeExceptionsToEventLog"], "true"));

            string temp_format = config["passwordFormat"];
            if (temp_format == null)
            {
                temp_format = "Hashed";
            }

            switch (temp_format)
            {
                case "Hashed":
                    pPasswordFormat = MembershipPasswordFormat.Hashed;
                    break;
                case "Encrypted":
                    pPasswordFormat = MembershipPasswordFormat.Encrypted;
                    break;
                case "Clear":
                    pPasswordFormat = MembershipPasswordFormat.Clear;
                    break;
                default:
                    throw new ProviderException("Password format not supported.");
            }

            //
            // Initialize the SimpleDB Client.
            //

            client = new AmazonSimpleDBClient(accessKey, secretKey);

            // Make sure the domain for users exists
            CreateDomainRequest cdRequest = new CreateDomainRequest();
            cdRequest.DomainName = domain;
            client.CreateDomain(cdRequest);

            // Get encryption and decryption key information from the configuration.
            Configuration cfg =
              WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");

            if (machineKey.ValidationKey.Contains("AutoGenerate"))
                if (PasswordFormat != MembershipPasswordFormat.Clear)
                    throw new ProviderException("Hashed or Encrypted passwords " +
                                                "are not supported with auto-generated keys.");
        }