Example #1
0
        /// <summary>
        /// Serializes a connectivity request.
        /// </summary>
        /// <param name="type">Operation type.</param>
        /// <param name="userName">User name.</param>
        /// <param name="password">Password for service.</param>
        /// <param name="expiration">Date when this service access expires.</param>
        /// <returns>A Serialized connectivity request.</returns>
        internal static string SerializeRdpConnectivityRequest(UserChangeRequestOperationType type, string userName, string password, DateTimeOffset expiration)
        {
            if (userName.IsNull())
            {
                userName = string.Empty;
            }
            if (password.IsNull())
            {
                password = string.Empty;
            }
            dynamic dynaXml = DynaXmlBuilder.Create(false, Formatting.None);

            dynaXml.xmlns(May2013)
            .xmlns.a(System)
            .RdpUserChangeRequest
            .b
            .Operation(type.ToString())
            .Username(userName)
            .Password(password)
            .ExpirationDate
            .b
            .xmlns.a.DateTime(expiration.DateTime.ToString("o", CultureInfo.InvariantCulture))
            .xmlns.a.OffsetMinutes(expiration.Offset.TotalMinutes)
            .d
            .d
            .End();

            return(dynaXml.ToString());
        }
Example #2
0
        /// <inheritdoc />
        public PayloadResponse <UserChangeRequestStatus> DeserializeConnectivityStatus(string payload)
        {
            XmlDocument doc = new XmlDocument();

            using (var stream = payload.ToUtf8Stream())
                using (var reader = XmlReader.Create(stream))
                {
                    doc.Load(reader);
                }
            var manager = new DynaXmlNamespaceTable(doc);
            PayloadResponse <UserChangeRequestStatus> result = new PayloadResponse <UserChangeRequestStatus>();
            var node = doc.SelectSingleNode("/def:PassthroughResponse/def:Data", manager.NamespaceManager);

            if (node.IsNotNull())
            {
                result.Data = new UserChangeRequestStatus();
                var data = node;
                node = data.SelectSingleNode("def:State", manager.NamespaceManager);
                UserChangeRequestOperationStatus status;
                if (node.IsNull() || !UserChangeRequestOperationStatus.TryParse(node.InnerText, out status))
                {
                    throw new SerializationException("Unable to deserialize the server response.");
                }
                result.Data.State = status;

                node = data.SelectSingleNode("def:UserType", manager.NamespaceManager);
                UserChangeRequestUserType userType;
                if (node.IsNull() || !UserChangeRequestUserType.TryParse(node.InnerText, out userType))
                {
                    throw new SerializationException("Unable to deserialize the server response.");
                }
                result.Data.UserType = userType;

                node = data.SelectSingleNode("def:OperationType", manager.NamespaceManager);
                UserChangeRequestOperationType operationType;
                if (node.IsNull() || !UserChangeRequestOperationType.TryParse(node.InnerText, out operationType))
                {
                    throw new SerializationException("Unable to deserialize the server response.");
                }
                result.Data.OperationType = operationType;

                node = data.SelectSingleNode("def:RequestIssueDate", manager.NamespaceManager);
                DateTime requestTime;
                if (node.IsNull() || !DateTime.TryParse(node.InnerText, out requestTime))
                {
                    throw new SerializationException("Unable to deserialize the server response.");
                }
                result.Data.RequestIssueDate = requestTime.ToUniversalTime();

                node = data.SelectSingleNode("def:Error", manager.NamespaceManager);
                result.Data.ErrorDetails = this.GetErrorDetails(node, manager.NamespaceManager);
            }
            node = doc.SelectSingleNode("/def:PassthroughResponse/def:Error", manager.NamespaceManager);
            result.ErrorDetails = this.GetErrorDetails(node, manager.NamespaceManager);

            return(result);
        }
 public Task <Guid> EnableDisableProtocol(
     UserChangeRequestUserType protocol,
     UserChangeRequestOperationType operation,
     string dnsName,
     string location,
     string userName,
     string password,
     DateTimeOffset expiration)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public Task <Guid> EnableDisableProtocol(
     UserChangeRequestUserType protocol,
     UserChangeRequestOperationType operation,
     string dnsName,
     string location,
     string userName,
     string password,
     DateTimeOffset expiration)
 {
     return(underlying.EnableDisableProtocol(protocol, operation, dnsName, location, userName, password, expiration));
 }
        // This method is used by the NonPublic SDK.  Be aware of braking changes to that project when you alter it.
        private static async Task <Guid> EnableDisableUserPocoCall(IHDInsightSubscriptionAbstractionContext context,
                                                                   UserChangeRequestUserType requestType,
                                                                   UserChangeRequestOperationType operation,
                                                                   string dnsName,
                                                                   string location,
                                                                   string userName,
                                                                   string password,
                                                                   DateTimeOffset expiration)
        {
            var client      = ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>().Create(context.Credentials, context, false);
            var operationId = await client.EnableDisableProtocol(requestType, operation, dnsName, location, userName, password, expiration);

            return(operationId);
        }
        // This method is used by the NonPublic SDK.  Be aware of breaking changes to that project when you alter it.
        internal static async Task EnableDisableUser(IHDInsightSubscriptionAbstractionContext context,
                                                     UserChangeRequestUserType requestType,
                                                     UserChangeRequestOperationType operation,
                                                     string dnsName,
                                                     string location,
                                                     string userName,
                                                     string password,
                                                     DateTimeOffset expiration)
        {
            var  client      = ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>().Create(context.Credentials, context, false);
            Guid operationId = await EnableDisableUserPocoCall(context, requestType, operation, dnsName, location, userName, password, expiration);

            await client.WaitForOperationCompleteOrError(dnsName, location, operationId, TimeSpan.FromHours(1), context.CancellationToken);
        }
Example #7
0
        internal static string SerializeHttpConnectivityRequest(UserChangeRequestOperationType type, string username, string password, DateTimeOffset experation)
        {
            Help.DoNothing(experation);
            if (username.IsNull())
            {
                username = string.Empty;
            }
            if (password.IsNull())
            {
                password = string.Empty;
            }
            dynamic dynaXml = DynaXmlBuilder.Create(false, Formatting.None);

            dynaXml.xmlns(May2013)
            .HttpUserChangeRequest
            .b
            .Operation(type.ToString())
            .Username(username)
            .Password(password)
            .d
            .End();

            return(dynaXml.ToString());
        }
        public async Task <Guid> EnableDisableProtocol(UserChangeRequestUserType requestType, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration)
        {
            var overrideHandlers = ServiceLocator.Instance.Locate <IHDInsightClusterOverrideManager>().GetHandlers(this.credentials, this.Context, this.ignoreSslErrors);
            var manager          = ServiceLocator.Instance.Locate <IUserChangeRequestManager>();
            var handler          = manager.LocateUserChangeRequestHandler(this.credentials.GetType(), requestType);
            var payload          = handler.Item2(operation, userName, password, expiration);
            var client           = ServiceLocator.Instance.Locate <IHDInsightManagementRestClientFactory>().Create(this.credentials, this.Context, this.ignoreSslErrors);
            var response         = await client.EnableDisableUserChangeRequest(dnsName, location, requestType, payload);

            var resultId   = overrideHandlers.PayloadConverter.DeserializeConnectivityResponse(response.Content);
            var pocoHelper = new HDInsightManagementPocoHelper();

            pocoHelper.ValidateResponse(resultId);
            return(resultId.Data);
        }
 public Task<Guid> EnableDisableProtocol(
     UserChangeRequestUserType protocol,
     UserChangeRequestOperationType operation,
     string dnsName,
     string location,
     string userName,
     string password,
     DateTimeOffset expiration)
 {
     return underlying.EnableDisableProtocol(protocol, operation, dnsName, location, userName, password, expiration);
 }
Example #10
0
        internal static string SerializeConnectivityRequest(UserChangeRequestOperationType type, string username, string password, DateTimeOffset experation)
        {
            Help.DoNothing(experation);
            if (username.IsNull())
            {
                username = string.Empty;
            }
            if (password.IsNull())
            {
                password = string.Empty;
            }
            dynamic dynaXml = DynaXmlBuilder.Create(false, Formatting.None);

            dynaXml.xmlns(May2013)
                   .HttpUserChangeRequest
                   .b
                     .Operation(type.ToString())
                     .Username(username)
                     .Password(password)
                   .d
                   .End();

            return dynaXml.ToString();
        }
        /// <summary>
        /// Serializes a connectivity request.
        /// </summary>
        /// <param name="type">Operation type.</param>
        /// <param name="userName">User name.</param>
        /// <param name="password">Password for service.</param>
        /// <param name="expiration">Date when this service access expires.</param>
        /// <returns>A Serialized connectivity request.</returns>
        internal static string SerializeRdpConnectivityRequest(UserChangeRequestOperationType type, string userName, string password, DateTimeOffset expiration)
        {
            if (userName.IsNull())
            {
                userName = string.Empty;
            }
            if (password.IsNull())
            {
                password = string.Empty;
            }
            dynamic dynaXml = DynaXmlBuilder.Create(false, Formatting.None);

            dynaXml.xmlns(May2013)
                   .xmlns.a(System)
                   .RdpUserChangeRequest
                   .b
                     .Operation(type.ToString())
                     .Username(userName)
                     .Password(password)
                     .ExpirationDate
                     .b
                       .xmlns.a.DateTime(expiration.DateTime.ToString("o", CultureInfo.InvariantCulture))
                       .xmlns.a.OffsetMinutes(expiration.Offset.TotalMinutes)
                     .d
                   .d
                   .End();

            return dynaXml.ToString();
        }
 public async Task<Guid> EnableDisableProtocol(UserChangeRequestUserType requestType, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration)
 {
     var overrideHandlers = ServiceLocator.Instance.Locate<IHDInsightClusterOverrideManager>().GetHandlers(this.credentials, this.Context, this.ignoreSslErrors);
     var manager = ServiceLocator.Instance.Locate<IUserChangeRequestManager>();
     var handler = manager.LocateUserChangeRequestHandler(this.credentials.GetType(), requestType);
     var payload = handler.Item2(operation, userName, password, expiration);
     var client = ServiceLocator.Instance.Locate<IHDInsightManagementRestClientFactory>().Create(this.credentials, this.Context, this.ignoreSslErrors);
     var response = await client.EnableDisableUserChangeRequest(dnsName, location, requestType, payload);
     var resultId = overrideHandlers.PayloadConverter.DeserializeConnectivityResponse(response.Content);
     var pocoHelper = new HDInsightManagementPocoHelper();
     pocoHelper.ValidateResponse(resultId);
     return resultId.Data;
 }
Example #13
0
 /// <inheritdoc />
 public async Task <Guid> EnableDisableProtocol(UserChangeRequestUserType protocol, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration)
 {
     throw new NotSupportedException(UnSupportedOperationMessage);
 }
 // This method is used by the NonPublic SDK.  Be aware of braking changes to that project when you alter it.
 private static async Task<Guid> EnableDisableUserPocoCall(IHDInsightSubscriptionAbstractionContext context,
                                                           UserChangeRequestUserType requestType,
                                                           UserChangeRequestOperationType operation,
                                                           string dnsName,
                                                           string location,
                                                           string userName,
                                                           string password,
                                                           DateTimeOffset expiration)
 {
     var client = ServiceLocator.Instance.Locate<IHDInsightManagementPocoClientFactory>().Create(context.Credentials, context, false);
     var operationId = await client.EnableDisableProtocol(requestType, operation, dnsName, location, userName, password, expiration);
     return operationId;
 }
 // This method is used by the NonPublic SDK.  Be aware of breaking changes to that project when you alter it.
 internal static async Task EnableDisableUser(IHDInsightSubscriptionAbstractionContext context,
                                              UserChangeRequestUserType requestType,
                                              UserChangeRequestOperationType operation,
                                              string dnsName,
                                              string location,
                                              string userName,
                                              string password,
                                              DateTimeOffset expiration)
 {
     var client = ServiceLocator.Instance.Locate<IHDInsightManagementPocoClientFactory>().Create(context.Credentials, context, false);
     Guid operationId = await EnableDisableUserPocoCall(context, requestType, operation, dnsName, location, userName, password, expiration);
     await client.WaitForOperationCompleteOrError(dnsName, location, operationId, TimeSpan.FromHours(1), context.CancellationToken);
 }