Ejemplo n.º 1
0
        public JObject FunctionHandler(JObject input)
        {
            LambdaLogger.Log(JObject.FromObject(input).ToString());
            string accountId = input.SelectToken("CreateAccountStatus.CreateAccountStatus.AccountId").ToString();

            var credentials = AssumeIdentity.AssumeRole(accountId).Credentials;

            string accessKey    = credentials.AccessKeyId;
            string secretkey    = credentials.SecretAccessKey;
            string sessionToken = credentials.SessionToken;

            AmazonIdentityManagementServiceClient client = new AmazonIdentityManagementServiceClient(accessKey, secretkey, sessionToken);

            CreateSAMLProviderRequest request = new CreateSAMLProviderRequest()
            {
                Name = "ADFS",
                SAMLMetadataDocument = MetadataXML()
            };

            CreateSAMLProviderResponse response = client.CreateSAMLProviderAsync(request).Result;

            JObject outputObject = new JObject();

            outputObject.Add("CreateSAMLProviderResponse", JObject.FromObject(response));
            outputObject.Add("CreateAccountResponse", input.SelectToken("CreateAccountStatus"));
            outputObject.Add("EventData", input.SelectToken("EventData"));

            return(outputObject);
        }
Ejemplo n.º 2
0
        private static void CreateSAMLProvider(String Name, String MetadataFile)
        {
            if (String.IsNullOrEmpty(Token))
            {
                stsClient = new AmazonIdentityManagementServiceClient(AccessKeyId, SecretKey, iamconfig);
            }
            else
            {
                stsClient = new AmazonIdentityManagementServiceClient(AccessKeyId, SecretKey, Token, iamconfig);
            }

            try
            {
                CreateSAMLProviderRequest Req = new CreateSAMLProviderRequest();
                if (File.Exists(MetadataFile))
                {
                    String Metadata = File.ReadAllText(MetadataFile);
                    Req.SAMLMetadataDocument = Metadata;
                    Req.Name = Name;

                    CreateSAMLProviderResponse response = stsClient.CreateSAMLProvider(Req);
                    Console.WriteLine("Saml Provider Created successfully.");
                }
                else
                {
                    Console.WriteLine("Metadata file missing");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occured while creating user. " + ex.ToString());
            }
        }
        /// <summary>
        /// 创建SAML身份提供商
        /// </summary>
        /// <param name="req">参考<see cref="CreateSAMLProviderRequest"/></param>
        /// <returns>参考<see cref="CreateSAMLProviderResponse"/>实例</returns>
        public async Task <CreateSAMLProviderResponse> CreateSAMLProvider(CreateSAMLProviderRequest req)
        {
            JsonResponseModel <CreateSAMLProviderResponse> rsp = null;

            try
            {
                var strResp = await this.InternalRequest(req, "CreateSAMLProvider");

                rsp = JsonConvert.DeserializeObject <JsonResponseModel <CreateSAMLProviderResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
 public Task <CreateSAMLProviderResponse> CreateSAMLProviderAsync(CreateSAMLProviderRequest request,
                                                                  CancellationToken cancellationToken = new CancellationToken())
 {
     throw new System.NotImplementedException();
 }