public static BaseClientService.Initializer ForMtlsEndpoint(
            ICredential credential,
            IDeviceEnrollment enrollment,
            string baseUri)
        {
            var initializer = new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = Globals.UserAgent.ToApplicationName()
            };

            if (enrollment?.Certificate != null &&
                HttpClientHandlerExtensions.IsClientCertificateSupported)
            {
                TraceSources.IapDesktop.TraceInformation(
                    "Enabling MTLS for {0}",
                    baseUri);

                // Switch to mTLS endpoint.
                initializer.BaseUri = baseUri;

                // Add client certificate.
                initializer.HttpClientFactory = new MtlsHttpClientFactory(enrollment.Certificate);
            }

            return(initializer);
        }
Esempio n. 2
0
        public AuditLogAdapter(
            ICredential credential,
            IDeviceEnrollment deviceEnrollment)
        {
            this.service = new LoggingService(
                ClientServiceFactory.ForMtlsEndpoint(
                    credential,
                    deviceEnrollment,
                    MtlsBaseUri));

            Debug.Assert(
                (deviceEnrollment?.Certificate != null &&
                 HttpClientHandlerExtensions.IsClientCertificateSupported)
                == IsDeviceCertiticateAuthenticationEnabled);
        }
Esempio n. 3
0
        private IAuthorizationAdapter CreateAuthorizationAdapter(
            ICredential credential,
            IDeviceEnrollment enrollment)
        {
            var authz = new Mock <IAuthorization>();

            authz.SetupGet(a => a.Credential).Returns(credential);

            var adapter = new Mock <IAuthorizationAdapter>();

            adapter.SetupGet(a => a.Authorization).Returns(authz.Object);
            adapter.SetupGet(a => a.DeviceEnrollment).Returns(enrollment);

            return(adapter.Object);
        }
Esempio n. 4
0
        public DeviceFlyoutViewModel(
            IWin32Window window,
            IDeviceEnrollment enrollment)
        {
            this.View       = window;
            this.enrollment = enrollment;

            switch (enrollment.State)
            {
            case DeviceEnrollmentState.Disabled:
                this.EnrollmentStateDescription =
                    $"{ProductName} is not available on this computer";
                this.IsDeviceEnrolledIconVisible    = false;
                this.IsDeviceNotEnrolledIconVisible = true;
                this.IsDetailsLinkVisible           = true;
                this.DetailsLinkCaption             = "More information";
                break;

            case DeviceEnrollmentState.NotEnrolled:
                this.EnrollmentStateDescription =
                    $"This computer is currently not enrolled in {ProductName}";
                this.IsDeviceEnrolledIconVisible    = false;
                this.IsDeviceNotEnrolledIconVisible = true;
                this.IsDetailsLinkVisible           = true;
                this.DetailsLinkCaption             = "More information";
                break;

            case DeviceEnrollmentState.Enrolled:
                this.EnrollmentStateDescription =
                    $"Computer is enrolled in {ProductName} and uses " +
                    "device certificate authentication";
                this.IsDeviceEnrolledIconVisible    = true;
                this.IsDeviceNotEnrolledIconVisible = false;
                this.IsDetailsLinkVisible           = true;
                this.DetailsLinkCaption             = "View device certificate";
                break;
            }
        }