Inheritance: Amazon.Runtime.AmazonWebServiceResponse
 public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) 
 {   
     GetPasswordDataResponse response = new GetPasswordDataResponse();
     
     int targetDepth = 2;
     while (context.Read())
     {
         if (context.IsStartElement || context.IsAttribute)
         {
             
             if (context.TestExpression("instanceId", targetDepth))
             {
                 response.InstanceId = StringUnmarshaller.GetInstance().Unmarshall(context);
                     
                 continue;
             }
             if (context.TestExpression("timestamp", targetDepth))
             {
                 response.Timestamp = DateTimeUnmarshaller.GetInstance().Unmarshall(context);
                     
                 continue;
             }
             if (context.TestExpression("passwordData", targetDepth))
             {
                 response.PasswordData = StringUnmarshaller.GetInstance().Unmarshall(context);
                     
                 continue;
             }
         }
     }
          
                 
     return response;
 }
示例#2
0
        public void TestMissingLeadingZeroIssue()
        {
            string encryptedPassword = "******";
            string privateKey = "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAmOMJ9AIxkXBhPK+0dU0CfgqP+uMUnwPa8TwnY9+pl49s2+BGrGVIl+qccYl+\nZ0mu7MDd0MZsQBH2ZNDl+7464sqpA5PlWkl4a3/Mgc/OC00kU2o4aslLGoHUgFfIRtiA40bXEif8\nnHWQR4AWJCGS3w1oLlW4qvUwDzvLZ5dJ6n/erThZAFJa1XEPZgh3vjdLQEkxb1pkgo831niNPC5B\nZYVpr+MfBFgdVt4LdY3B7o6jkA1h7QxeZp9Au84Ag7nE3RELU7ll4U3Z9WK+8NZ+5/mJQ5LrSN47\n2KRR3Z+KBM2GYLo4U1LutL/ajUbZe1IJeTgdZMb1DMvyLu2283uiOwIDAQABAoIBAQCFzn9RjfHw\nBlk0Edtwplu+EGR/Aet0WJ1wcGNRJ9l4ClEOBzYTf/mO7AjL3bhBkd2E3C/Gn0LyuEXbanE+aPmE\nsDZIKVKcOJ0qCInmOwdsILHgR6Dk5RPUOTjQswNX7fiv8bod691M2h/SVCoMqU2v5j39/4xGI51S\nV9Tn7yMEFk5/Lmu9NNA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PRIVATE KEY-----";

            GetPasswordDataResponse response = new GetPasswordDataResponse { PasswordData = encryptedPassword };
            string decryptedPassword = response.GetDecryptedPassword(privateKey);
            Assert.IsNotNull(decryptedPassword);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>  
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            GetPasswordDataResponse response = new GetPasswordDataResponse();

            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("instanceId", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.InstanceId = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("passwordData", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.PasswordData = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("timestamp", targetDepth))
                    {
                        var unmarshaller = DateTimeUnmarshaller.Instance;
                        response.Timestamp = unmarshaller.Unmarshall(context);
                        continue;
                    }
                } 
            }

            return response;
        }