コード例 #1
0
ファイル: imgTransport.cs プロジェクト: tcwolf/imageTransport
        //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);
            }
        }
コード例 #2
0
ファイル: imgTransport.cs プロジェクト: tcwolf/imageTransport
        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();
        }
コード例 #3
0
ファイル: SDBProvider.cs プロジェクト: kouweizhong/multicore
        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);
                }
            }
        }
コード例 #4
0
ファイル: Profile.cs プロジェクト: kouweizhong/multicore
        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);
        }
コード例 #5
0
        protected override void OnSetup()
        {
            var settings = (IDictionary<string, object>) Settings;

            object providedClient;

            if (settings.TryGetValue("Client", out providedClient))
            {
                this.client = (AmazonSimpleDB) providedClient;

                return;
            }
            
            object accessKey;
            object secret;

            if (!settings.TryGetValue("AccessKey", out accessKey) || 
                !settings.TryGetValue("Secret", out secret))
            {
                throw new InvalidOperationException(
                    "The SimpleDB adapter requires the AccessKey and Secret properties to be set.");
            }
            
            var config = new AmazonSimpleDBConfig();
            object serviceUrl;

            if (settings.TryGetValue("ServiceUrl", out serviceUrl))
            {
                config.WithServiceURL(serviceUrl.ToString());
            }

            client = Amazon.AWSClientFactory.CreateAmazonSimpleDBClient(accessKey.ToString(), secret.ToString(), config);
        }
コード例 #6
0
ファイル: StandAlone.cs プロジェクト: kouweizhong/multicore
 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
        private void SetSimpleDBClient()
        {
            if (this.aSimpleDBClient != null)
            {
                this.aSimpleDBClient.Dispose();
                this.aSimpleDBClient = null;
            }

            this.aSimpleDBClient = AWSClientFactory.CreateAmazonSimpleDBClient(this.aAWSAccessKey, this.aAWSSecretAccessKey);
        }
コード例 #8
0
        /// <summary>
        /// Get a reference to an instance of AmazonSimpleDB
        /// </summary>
        /// <returns></returns>
        private AmazonSimpleDB GetSDB()
        {
            NameValueCollection appConfig = ConfigurationManager.AppSettings;
            AmazonSimpleDB      sdb       = AWSClientFactory.CreateAmazonSimpleDBClient(
                appConfig["AWSAccessKey"],
                appConfig["AWSSecretKey"]
                );

            return(sdb);
        }
コード例 #9
0
        /// <summary>
        /// Constructor with only the Amazon credentials
        /// </summary>
        /// <param name="amazonAccessKey"></param>
        /// <param name="amazonSecretKey"></param>
        public SimpleDBProvider(string amazonAccessKey, string amazonSecretKey) : this()
        {
            var entityMapper = new EntityMapper();

            _deleteFactory        = new BatchDeleteAttributeRequestFactory(new DeleteableItemAdapter());
            _putFactory           = new BatchPutAttributeRequestFactory(new ReplaceableItemAdapter(entityMapper));
            _selectRequestFactory = new SelectRequestFactory();
            _itemAdapter          = new ItemAdapter(entityMapper);
            _domainRequestFactory = new DomainRequestFactory();
            _simpleDB             = new AmazonSimpleDBClient(amazonAccessKey, amazonSecretKey);
        }
コード例 #10
0
        public static bool DoesDomainExist(string domainName, AmazonSimpleDB sdbClient)
        {
            ListDomainsRequest listDomainsRequest = new ListDomainsRequest();
            ListDomainsResult result = sdbClient.ListDomains(listDomainsRequest).ListDomainsResult;
            if (result != null)
            {
                return result.DomainName.Contains(domainName);
            }

            return false;
        }
コード例 #11
0
        public SimpleDBAdapter()
        {
            // initialize Amazon SimpleDBClient
            AmazonSimpleDBConfig simpleDBConfig = new AmazonSimpleDBConfig();
            simpleDBConfig.ServiceURL = ConfigurationManager.AppSettings["SimpleDBServiceURL"];
            m_simpleDBClient = AWSClientFactory.CreateAmazonSimpleDBClient(simpleDBConfig);

            m_BroadcastMessagesDomain = ConfigurationManager.AppSettings["BroadcastMessagesSDBDomain"];
            m_GroupMessagesDomain = ConfigurationManager.AppSettings["GroupMessagesSDBDomain"];
            m_PrivateMessagesDomain = ConfigurationManager.AppSettings["PrivateMessagesSDBDomain"];
            m_UserStateDomain = ConfigurationManager.AppSettings["UserStateSDBDomain"];
        }
コード例 #12
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);
            }
        }
コード例 #13
0
 /// <summary>
 /// Constructor with all dependencies injected
 /// </summary>
 /// <param name="deleteFactory">Factory for creating delete requests</param>
 /// <param name="putFactory">Factory for creating put requests</param>
 /// <param name="selectRequestFactory">Factory for creating select requests</param>
 /// <param name="itemAdapter">Factory for converting select response items to the given POCO of type T</param>
 /// <param name="simpleDb">Amazon SimpleDB instance</param>
 /// <param name="domainRequestFactory">Factory for domain requests</param>
 public SimpleDBProvider(BatchDeleteAttributeRequestFactory deleteFactory,
                         BatchPutAttributeRequestFactory putFactory,
                         SelectRequestFactory selectRequestFactory,
                         ItemAdapter itemAdapter,
                         AmazonSimpleDB simpleDb,
                         DomainRequestFactory domainRequestFactory) : this()
 {
     _deleteFactory        = deleteFactory;
     _putFactory           = putFactory;
     _selectRequestFactory = selectRequestFactory;
     _itemAdapter          = itemAdapter;
     _simpleDB             = simpleDb;
     _domainRequestFactory = domainRequestFactory;
 }
コード例 #14
0
ファイル: Role.cs プロジェクト: kouweizhong/multicore
        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);
        }
コード例 #15
0
        public void setup()
        {
            var streamReader = new StreamReader(@"C:\SpecialSuperSecret\[email protected]");

            var dictionary = new Dictionary<string, string>();
            while (!streamReader.EndOfStream)
            {
                var line = streamReader.ReadLine();
                var keyValue = line.Split(':');
                dictionary.Add(keyValue[0], keyValue[1]);
            }
            _key = dictionary["UserName"];
            _secret = dictionary["Password"];
            _client = Amazon.AWSClientFactory.CreateAmazonSimpleDBClient(_key, _secret);
            _manager = new UserManager(new AuthenticationServiceConfig() {StoreName = "TEST_AUTHENTICATION"}, _client);
        }
        private void GivenAFeatureUsageService()
        {
            _simpleDbClient = MockRepository.GenerateStub<AmazonSimpleDB>();
            _simpleDbClient
                .Stub(s => s.PutAttributes(Arg<PutAttributesRequest>.Is.Anything))
                .Return(null);

            _exceptionToThrow = new Exception("Something really bad happened");
            _simpleDbClient
                .Stub(s => s.CreateDomain(Arg<CreateDomainRequest>.Is.Anything))
                .Throw(_exceptionToThrow);
            
            _domainName = "My Domain";
            Action<Exception> exceptionAction = exception => _exceptions.Add(exception);

            _service = new SimpleDbFeatureUsageService(exceptionAction, _domainName, _simpleDbClient);
        }
コード例 #17
0
ファイル: imgTransport.cs プロジェクト: tcwolf/imageTransport
        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);
        }
コード例 #18
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());
        }
コード例 #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder(1024);
            using (StringWriter sr = new StringWriter(sb))
            {
                try
                {
                    ec2 = AWSClientFactory.CreateAmazonEC2Client(RegionEndpoint.USWest2);
                    this.WriteEC2Info();
                }
                catch (AmazonEC2Exception ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon EC2.");
                        sr.WriteLine("<br />");
                        sr.WriteLine("You can sign up for Amazon EC2 at http://aws.amazon.com/ec2");
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("<br />");
                        sr.WriteLine("XML: " + ex.XML);
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    this.ec2Placeholder.Text = sr.ToString();
                }
            }

            sb = new StringBuilder(1024);
            using (StringWriter sr = new StringWriter(sb))
            {
                try
                {
                    s3 = AWSClientFactory.CreateAmazonS3Client(RegionEndpoint.USWest2);
                    this.WriteS3Info();
                }
                catch (AmazonS3Exception ex)
                {
                    if (ex.ErrorCode != null && (ex.ErrorCode.Equals("InvalidAccessKeyId") ||
                        ex.ErrorCode.Equals("InvalidSecurity")))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon S3");
                        sr.WriteLine("<br />");
                        sr.WriteLine("You can sign up for Amazon S3 at http://aws.amazon.com/s3");
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("<br />");
                        sr.WriteLine("XML: " + ex.XML);
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    this.s3Placeholder.Text = sr.ToString();
                }
            }

            sb = new StringBuilder(1024);
            using (StringWriter sr = new StringWriter(sb))
            {
                try
                {
                    sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);
                    this.WriteSimpleDBInfo();
                }
                catch (AmazonSimpleDBException ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("InvalidClientTokenId"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon SimpleDB.");
                        sr.WriteLine("<br />");
                        sr.WriteLine("You can sign up for Amazon SimpleDB at http://aws.amazon.com/simpledb");
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    else
                    {
                        sr.WriteLine("Exception Message: " + ex.Message);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("<br />");
                        sr.WriteLine("XML: " + ex.XML);
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    this.sdbPlaceholder.Text = sr.ToString();
                }
            }
        }
コード例 #20
0
ファイル: Membership.cs プロジェクト: kouweizhong/multicore
        //
        // 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.");
                }
            }
        }
コード例 #21
0
ファイル: Profile.cs プロジェクト: typemismatch/multicore
        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);
        }
コード例 #22
0
 public WorkItemFactoryAWS(string awsAccessKey, string awsSecretKey)
 {
     sdb = AWSClientFactory.CreateAmazonSimpleDBClient(awsAccessKey, awsSecretKey);
 }
コード例 #23
0
ファイル: Membership.cs プロジェクト: typemismatch/multicore
        //
        // 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.");
        }
コード例 #24
0
 public UserManager(AuthenticationServiceConfig config, AmazonSimpleDB client)
 {
     _config = config;
     _client = client;
     EnsureDomain();
 }
コード例 #25
0
ファイル: Program.cs プロジェクト: melnx/Bermuda
        public static string GetServiceOutput()
        {
            StringBuilder sb = new StringBuilder(1024);

            using (StringWriter sr = new StringWriter(sb))
            {
                sr.WriteLine("===========================================");
                sr.WriteLine("Welcome to the AWS .NET SDK!");
                sr.WriteLine("===========================================");

                // Print the number of Amazon EC2 instances.
                AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client();
                DescribeInstancesRequest ec2Request = new DescribeInstancesRequest();

                try
                {
                    DescribeInstancesResponse ec2Response = ec2.DescribeInstances(ec2Request);
                    int numInstances = 0;
                    numInstances = ec2Response.DescribeInstancesResult.Reservation.Count;
                    sr.WriteLine("You have " + numInstances + " Amazon EC2 instance(s) running in the US-East (Northern Virginia) region.");
                }
                catch (AmazonEC2Exception ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon EC2.");
                        sr.WriteLine("You can sign up for Amazon EC2 at http://aws.amazon.com/ec2");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("XML: " + ex.XML);
                    }
                }
                sr.WriteLine();

                // Print the number of Amazon SimpleDB domains.
                AmazonSimpleDB     sdb        = AWSClientFactory.CreateAmazonSimpleDBClient();
                ListDomainsRequest sdbRequest = new ListDomainsRequest();

                try
                {
                    ListDomainsResponse sdbResponse = sdb.ListDomains(sdbRequest);

                    if (sdbResponse.IsSetListDomainsResult())
                    {
                        int numDomains = 0;
                        numDomains = sdbResponse.ListDomainsResult.DomainName.Count;
                        sr.WriteLine("You have " + numDomains + " Amazon SimpleDB domain(s) in the US-East (Northern Virginia) region.");
                    }
                }
                catch (AmazonSimpleDBException ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon SimpleDB.");
                        sr.WriteLine("You can sign up for Amazon SimpleDB at http://aws.amazon.com/simpledb");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("XML: " + ex.XML);
                    }
                }
                sr.WriteLine();

                // Print the number of Amazon S3 Buckets.
                AmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client();

                try
                {
                    ListBucketsResponse response = s3Client.ListBuckets();
                    int numBuckets = 0;
                    if (response.Buckets != null &&
                        response.Buckets.Count > 0)
                    {
                        numBuckets = response.Buckets.Count;
                    }
                    sr.WriteLine("You have " + numBuckets + " Amazon S3 bucket(s) in the US Standard region.");
                }
                catch (AmazonS3Exception ex)
                {
                    if (ex.ErrorCode != null && (ex.ErrorCode.Equals("InvalidAccessKeyId") ||
                                                 ex.ErrorCode.Equals("InvalidSecurity")))
                    {
                        sr.WriteLine("Please check the provided AWS Credentials.");
                        sr.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("XML: " + ex.XML);
                    }
                }
                sr.WriteLine("Press any key to continue...");
            }
            return(sb.ToString());
        }
コード例 #26
0
 public static Database OpenSimpleDb(this IDatabaseOpener opener, AmazonSimpleDB client)
 {
     return opener.Open("SimpleDb", new {Client = client});
 }
コード例 #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                CheckIfFacebookAppIsSetupCorrectly();

                var auth = new CanvasAuthorizer {
                    Permissions = new[] { "user_about_me" }
                };

                if (auth.Authorize())
                {
                    ShowFacebookContent();
                }
            }
            else
            {
                AmazonSimpleDB sdb = GetSDB();

                // Should I clean out the AWS domain state?
                if (Page.Request.Params["delaws"] == "1")
                {
                    //Deleting a domain
                    DeleteDomainRequest deleteDomainAction = new DeleteDomainRequest().WithDomainName("ZigMeRecos");
                    sdb.DeleteDomain(deleteDomainAction);
                }

                // Now read from the AWS domain and populate the dropdown list

                // First check to see if a domain contain service types exists. if not then create it and populate it
                // Listing domains

                /*ListDomainsResponse sdbListDomainsResponse = sdb.ListDomains(new ListDomainsRequest());
                 * if (sdbListDomainsResponse.IsSetListDomainsResult())
                 * {
                 *  ListDomainsResult listDomainsResult = sdbListDomainsResponse.ListDomainsResult;
                 *
                 *  if (!listDomainsResult.DomainName.Contains("ZigMeServiceTypes"))
                 *  {
                 *  }
                 *  else
                 *  {
                 *      String selectExpression = "Select * From ZigMeServiceTypes";
                 *      SelectRequest selectRequestAction = new SelectRequest().WithSelectExpression(selectExpression);
                 *      SelectResponse selectResponse = sdb.Select(selectRequestAction);
                 *      if (selectResponse.IsSetSelectResult())
                 *      {
                 *          SelectResult selectResult = selectResponse.SelectResult;
                 *          foreach (Item item in selectResult.Item)
                 *          {
                 *              foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attribute)
                 *              {
                 *                  if (attribute.IsSetName() && attribute.IsSetValue())
                 *                  {
                 *                  }
                 *              }
                 *          }
                 *      }
                 *  }
                 * }*/
            }
        }
コード例 #28
0
 public SimpleDBDataStore()
 {
     _simpleDb = AwsFacade.GetSimpleDBClient();
 }
コード例 #29
0
 public SimpleDBHelper(AmazonSimpleDB amazonSimpleDBClient)
 {
     Client = amazonSimpleDBClient;
 }
コード例 #30
0
 public SimpleDBQueryProvider(AmazonSimpleDB service, string domainName, SetterDelegate setter)
 {
     m_service    = service;
     m_domainName = domainName;
     m_setter     = setter;
 }
コード例 #31
0
        private void UploadEvent(LoggingEvent loggingEvent, AmazonSimpleDB client)
        {
            var request = new PutAttributesRequest();
            request.Attribute.Add(
                new ReplaceableAttribute
                    {
                        Name = "UserName",
                        Replace = true,
                        Value = loggingEvent.UserName
                    });
            request.Attribute.Add(
                new ReplaceableAttribute
                    {
                        Value = loggingEvent.TimeStamp.ToString(CultureInfo.InvariantCulture),
                        Name = "TimeStamp",
                        Replace = true
                    });
            request.Attribute.Add(
                new ReplaceableAttribute
                    {
                        Value = loggingEvent.ThreadName,
                        Name = "ThreadName",
                        Replace = true
                    });
            request.Attribute.Add(
                new ReplaceableAttribute
                    {
                        Value = loggingEvent.RenderedMessage,
                        Name = "Message",
                        Replace = true
                    });
            request.Attribute.Add(
                new ReplaceableAttribute
                    {
                        Value = loggingEvent.LoggerName,
                        Name = "LoggerName",
                        Replace = true
                    });
            request.Attribute.Add(
                new ReplaceableAttribute
                    {
                        Value = loggingEvent.Level.ToString(),
                        Name = "Level",
                        Replace = true
                    });
            request.Attribute.Add(
                new ReplaceableAttribute
                    {
                        Value = loggingEvent.Identity,
                        Name = "Identity",
                        Replace = true
                    });
            request.Attribute.Add(
                new ReplaceableAttribute
                    {
                        Value = loggingEvent.Domain,
                        Name = "Domain",
                        Replace = true
                    });
            request.Attribute.Add(
                new ReplaceableAttribute
                    {
                        Value = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture),
                        Name = "CreatedOn",
                        Replace = true
                    });
            request.DomainName = _dbName;
            request.ItemName = Guid.NewGuid().ToString();

            client.PutAttributes(request);
        }
コード例 #32
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder(1024);

            using (StringWriter sr = new StringWriter(sb))
            {
                try
                {
                    ec2 = AWSClientFactory.CreateAmazonEC2Client();
                    this.WriteEC2Info();
                }
                catch (AmazonEC2Exception ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon EC2.");
                        sr.WriteLine("<br />");
                        sr.WriteLine("You can sign up for Amazon EC2 at http://aws.amazon.com/ec2");
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("<br />");
                        sr.WriteLine("XML: " + ex.XML);
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    this.ec2Placeholder.Text = sr.ToString();
                }
            }

            sb = new StringBuilder(1024);
            using (StringWriter sr = new StringWriter(sb))
            {
                try
                {
                    s3 = AWSClientFactory.CreateAmazonS3Client();
                    this.WriteS3Info();
                }
                catch (AmazonS3Exception ex)
                {
                    if (ex.ErrorCode != null && (ex.ErrorCode.Equals("InvalidAccessKeyId") ||
                                                 ex.ErrorCode.Equals("InvalidSecurity")))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon S3");
                        sr.WriteLine("<br />");
                        sr.WriteLine("You can sign up for Amazon S3 at http://aws.amazon.com/s3");
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("<br />");
                        sr.WriteLine("XML: " + ex.XML);
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    this.s3Placeholder.Text = sr.ToString();
                }
            }

            sb = new StringBuilder(1024);
            using (StringWriter sr = new StringWriter(sb))
            {
                try
                {
                    sdb = AWSClientFactory.CreateAmazonSimpleDBClient();
                    this.WriteSimpleDBInfo();
                }
                catch (AmazonSimpleDBException ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("InvalidClientTokenId"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon SimpleDB.");
                        sr.WriteLine("<br />");
                        sr.WriteLine("You can sign up for Amazon SimpleDB at http://aws.amazon.com/simpledb");
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    else
                    {
                        sr.WriteLine("Exception Message: " + ex.Message);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("<br />");
                        sr.WriteLine("XML: " + ex.XML);
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    this.sdbPlaceholder.Text = sr.ToString();
                }
            }
        }
コード例 #33
0
 public SimpleDBQueryProvider(AmazonSimpleDB service, string domainName, SetterDelegate setter) {
     m_service = service;
     m_domainName = domainName;
     m_setter = setter;
 }
コード例 #34
0
ファイル: StandAlone.cs プロジェクト: typemismatch/multicore
 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);
     }
 }
コード例 #35
0
 public SimpleDBWorkStepRepository(string domain, string accessKey, string secretKey)
 {
     _domain = domain;
     _client = AWSClientFactory.CreateAmazonSimpleDBClient(accessKey, secretKey);
     EnsureDomain(_domain);
 }
コード例 #36
0
 public SimpleDBDataStore()
 {
     _simpleDb = AwsFacade.GetSimpleDBClient();
 }
コード例 #37
0
 public SimpleDBWorkStepRepository(string domain, string accessKey, string secretKey)
 {
     _domain = domain;
     _client = AWSClientFactory.CreateAmazonSimpleDBClient(accessKey, secretKey);
     EnsureDomain(_domain);
 }
コード例 #38
0
 public SimpleDBHelper(AmazonSimpleDB amazonSimpleDBClient)
 {
     Client = amazonSimpleDBClient;
 }
コード例 #39
0
 public SimpleDbDomainConfiguration(ISimpleDbConfiguration config)
 {
     _config = config;
     _service = AWSClientFactory.CreateAmazonSimpleDBClient
         (config.SimpleDbAccessKey, config.SimpleDbSecretKey, config.AmazonSimpleDbConfig);
 }
コード例 #40
0
        public void SetUp()
        {
            _client = AWSClientFactory.CreateAmazonSimpleDBClient(Access_Key_ID, Secret_Access_Key);

            //A pre-requisite for testing SimpleDB Objects. Ensure that we create one Domain to test the Objects.
            //Create the Domain.
            bool hasCallbackArrived = false;

            SimpleDBResponseEventHandler<object, ResponseEventArgs> handler = null;
            handler = delegate(object sender, ResponseEventArgs args)
            {
                //Unhook from event.
                _client.OnSimpleDBResponse -= handler;
                hasCallbackArrived = true;
            };
            _client.OnSimpleDBResponse += handler;

            _client.BeginCreateDomain(new Amazon.SimpleDB.Model.CreateDomainRequest { DomainName = _domainName_UnitTesting });

            EnqueueConditional(() => hasCallbackArrived);
            EnqueueTestComplete();
        }
コード例 #41
0
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 /// <param name="onFailure">What to do in the catch clause when an exception occurs in the NotifyFeatureUsageSafe method</param>
 /// <param name="domainName">Domain to log feature usage to</param>
 /// <param name="simpleDbClient">SimpleDb client to use for persistence</param>
 public SimpleDbFeatureSubscriptionService(Action<Exception> onFailure, string domainName, AmazonSimpleDB simpleDbClient)
 {
     _onFailure = onFailure;
     _domainName = domainName;
     _simpleDbClient = simpleDbClient;
 }
コード例 #42
0
ファイル: SDBProvider.cs プロジェクト: typemismatch/multicore
        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);
                }
            }
        }
コード例 #43
0
 protected override void SafeManagedResourcesDisposing()
 {
     m_simpleDBClient.Dispose();
     m_simpleDBClient = null;
 }
コード例 #44
0
ファイル: Role.cs プロジェクト: typemismatch/multicore
        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);
        }
コード例 #45
0
ファイル: Program.cs プロジェクト: bernardoleary/MyBigBro
        // Change the accessKeyID and the secretAccessKeyID to your credentials in the App.config file.
        // See http://aws.amazon.com/credentials  for more details.
        //
        // This sample adds 50 items in a domain using the synchronized API and then
        // the asynchronized API.
        static void Main(string[] args)
        {
            sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            addDataSynchronized();

            addDataAsynchronized();

            Console.WriteLine("Press Enter to continue...");
            Console.Read();
        }
コード例 #46
0
 public SimpleDbProxy()
 {
     _simpleDbClient = AWSClientFactory.CreateAmazonSimpleDBClient(new AmazonSimpleDBConfig());
 }