コード例 #1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            AssumeRoleWithSAMLResponse response = new AssumeRoleWithSAMLResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("AssumeRoleWithSAMLResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }
コード例 #2
0
        public static AssumeRoleWithSAMLResponse Unmarshall(UnmarshallerContext context)
        {
            AssumeRoleWithSAMLResponse assumeRoleWithSAMLResponse = new AssumeRoleWithSAMLResponse();

            assumeRoleWithSAMLResponse.HttpResponse = context.HttpResponse;
            assumeRoleWithSAMLResponse.RequestId    = context.StringValue("AssumeRoleWithSAML.RequestId");

            AssumeRoleWithSAMLResponse.AssumeRoleWithSAML_Credentials credentials = new AssumeRoleWithSAMLResponse.AssumeRoleWithSAML_Credentials();
            credentials.SecurityToken              = context.StringValue("AssumeRoleWithSAML.Credentials.SecurityToken");
            credentials.AccessKeySecret            = context.StringValue("AssumeRoleWithSAML.Credentials.AccessKeySecret");
            credentials.AccessKeyId                = context.StringValue("AssumeRoleWithSAML.Credentials.AccessKeyId");
            credentials.Expiration                 = context.StringValue("AssumeRoleWithSAML.Credentials.Expiration");
            assumeRoleWithSAMLResponse.Credentials = credentials;

            AssumeRoleWithSAMLResponse.AssumeRoleWithSAML_AssumedRoleUser assumedRoleUser = new AssumeRoleWithSAMLResponse.AssumeRoleWithSAML_AssumedRoleUser();
            assumedRoleUser.Arn           = context.StringValue("AssumeRoleWithSAML.AssumedRoleUser.Arn");
            assumedRoleUser.AssumedRoleId = context.StringValue("AssumeRoleWithSAML.AssumedRoleUser.AssumedRoleId");
            assumeRoleWithSAMLResponse.AssumedRoleUser = assumedRoleUser;

            AssumeRoleWithSAMLResponse.AssumeRoleWithSAML_SAMLAssertionInfo sAMLAssertionInfo = new AssumeRoleWithSAMLResponse.AssumeRoleWithSAML_SAMLAssertionInfo();
            sAMLAssertionInfo.SubjectType = context.StringValue("AssumeRoleWithSAML.SAMLAssertionInfo.SubjectType");
            sAMLAssertionInfo.Subject     = context.StringValue("AssumeRoleWithSAML.SAMLAssertionInfo.Subject");
            sAMLAssertionInfo.Recipient   = context.StringValue("AssumeRoleWithSAML.SAMLAssertionInfo.Recipient");
            sAMLAssertionInfo.Issuer      = context.StringValue("AssumeRoleWithSAML.SAMLAssertionInfo.Issuer");
            assumeRoleWithSAMLResponse.SAMLAssertionInfo = sAMLAssertionInfo;

            return(assumeRoleWithSAMLResponse);
        }
コード例 #3
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, AssumeRoleWithSAMLResponse response)
        {
            int currentDepth = context.get_CurrentDepth();
            int num          = currentDepth + 1;

            if (context.get_IsStartOfDocument())
            {
                num += 2;
            }
            while (context.ReadAtDepth(currentDepth))
            {
                if (context.get_IsStartElement() || context.get_IsAttribute())
                {
                    if (context.TestExpression("AssumedRoleUser", num))
                    {
                        AssumedRoleUserUnmarshaller instance = AssumedRoleUserUnmarshaller.Instance;
                        response.AssumedRoleUser = instance.Unmarshall(context);
                    }
                    else if (context.TestExpression("Audience", num))
                    {
                        StringUnmarshaller instance2 = StringUnmarshaller.get_Instance();
                        response.Audience = instance2.Unmarshall(context);
                    }
                    else if (context.TestExpression("Credentials", num))
                    {
                        CredentialsUnmarshaller instance3 = CredentialsUnmarshaller.Instance;
                        response.Credentials = instance3.Unmarshall(context);
                    }
                    else if (context.TestExpression("Issuer", num))
                    {
                        StringUnmarshaller instance4 = StringUnmarshaller.get_Instance();
                        response.Issuer = instance4.Unmarshall(context);
                    }
                    else if (context.TestExpression("NameQualifier", num))
                    {
                        StringUnmarshaller instance5 = StringUnmarshaller.get_Instance();
                        response.NameQualifier = instance5.Unmarshall(context);
                    }
                    else if (context.TestExpression("PackedPolicySize", num))
                    {
                        IntUnmarshaller instance6 = IntUnmarshaller.get_Instance();
                        response.PackedPolicySize = instance6.Unmarshall(context);
                    }
                    else if (context.TestExpression("Subject", num))
                    {
                        StringUnmarshaller instance7 = StringUnmarshaller.get_Instance();
                        response.Subject = instance7.Unmarshall(context);
                    }
                    else if (context.TestExpression("SubjectType", num))
                    {
                        StringUnmarshaller instance8 = StringUnmarshaller.get_Instance();
                        response.SubjectType = instance8.Unmarshall(context);
                    }
                }
            }
        }
コード例 #4
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, AssumeRoleWithSAMLResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Credentials", targetDepth))
                    {
                        response.Credentials = CredentialsUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("AssumedRoleUser", targetDepth))
                    {
                        response.AssumedRoleUser = AssumedRoleUserUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("PackedPolicySize", targetDepth))
                    {
                        response.PackedPolicySize = IntUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }



            return;
        }
コード例 #5
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            AssumeRoleWithSAMLResponse assumeRoleWithSAMLResponse = new AssumeRoleWithSAMLResponse();

            context.Read();
            int currentDepth = context.get_CurrentDepth();

            while (context.ReadAtDepth(currentDepth))
            {
                if (context.get_IsStartElement())
                {
                    if (context.TestExpression("AssumeRoleWithSAMLResult", 2))
                    {
                        UnmarshallResult(context, assumeRoleWithSAMLResponse);
                    }
                    else if (context.TestExpression("ResponseMetadata", 2))
                    {
                        assumeRoleWithSAMLResponse.set_ResponseMetadata(ResponseMetadataUnmarshaller.get_Instance().Unmarshall(context));
                    }
                }
            }
            return(assumeRoleWithSAMLResponse);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: n0kn0k/cortx-s3server
        private static void AssumeRoleWithSaml(String PrincipalARN, String RoleARN, String SAMLAssertionFile)
        {
            AmazonSecurityTokenServiceClient stsClient = new AmazonSecurityTokenServiceClient("", "", stsconfig);
            AssumeRoleWithSAMLRequest        Req       = new AssumeRoleWithSAMLRequest();

            if (File.Exists(SAMLAssertionFile))
            {
                String Assertion = File.ReadAllText(SAMLAssertionFile);
                Req.PrincipalArn  = PrincipalARN;
                Req.RoleArn       = RoleARN;
                Req.SAMLAssertion = Assertion;

                AssumeRoleWithSAMLResponse response = stsClient.AssumeRoleWithSAML(Req);
                Console.WriteLine("acess key id: {0}", response.Credentials.AccessKeyId);
                Console.WriteLine("secret key: {0}", response.Credentials.SecretAccessKey);
                Console.WriteLine("session token: {0}", response.Credentials.SessionToken);
                Console.WriteLine("Expiration: {0}", response.Credentials.Expiration);
                Console.WriteLine("AssumeRoleWithSAML was successful");
            }
            else
            {
                Console.WriteLine("Assertion file missing");
            }
        }
コード例 #7
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, AssumeRoleWithSAMLResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("AssumedRoleUser", targetDepth))
                    {
                        var unmarshaller = AssumedRoleUserUnmarshaller.Instance;
                        response.AssumedRoleUser = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("Audience", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.Audience = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("Credentials", targetDepth))
                    {
                        var unmarshaller = CredentialsUnmarshaller.Instance;
                        response.Credentials = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("Issuer", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.Issuer = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("NameQualifier", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.NameQualifier = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("PackedPolicySize", targetDepth))
                    {
                        var unmarshaller = IntUnmarshaller.Instance;
                        response.PackedPolicySize = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("Subject", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.Subject = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("SubjectType", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.SubjectType = unmarshaller.Unmarshall(context);
                        continue;
                    }
                }
            }

            return;
        }