Example #1
0
        public IcmWorkItemManagment(Config.InstanceConfig instanceConfig)
        {
            Logger.InfoFormat("Creating IcM work item manager...");
            ValidateConfig(instanceConfig);
            config           = instanceConfig;
            incidentDefaults = config.IncidentDefaults;

            X509Certificate certificate = RetrieveCertificate(CertThumbprint);

            dataServiceClient = new DataServiceODataClient(
                new Uri(config.IcmClientConfig.OdataServiceBaseUri),
                config,
                certificate);

            connectorClient = ConnectToIcmInstance();
            if (connectorClient == null)
            {
                Logger.ErrorFormat("Cannot initialize IcM Webservice.");
                throw new Exception("Cannot initialize IcM Webservice.");
            }

            InitWorkItemsCache();

            nameResolver = InitNameResolver();
            dateHolder   = DateTime.UtcNow;
            Logger.InfoFormat("Completed creating IcM work item manager.");
        }
Example #2
0
        private static ConnectorIncidentManagerClient CreateConnectorClient(string icmWebServiceBaseUrl)
        {
            WS2007HttpBinding binding = new WS2007HttpBinding(SecurityMode.Transport)
            {
                Name = "IcmBindingConfigCert",
                MaxBufferPoolSize      = 4194304,
                MaxReceivedMessageSize = 16777216
            };

            binding.Security.Transport.Realm = string.Empty;
            binding.Security.Transport.ProxyCredentialType      = HttpProxyCredentialType.None;
            binding.Security.Transport.ClientCredentialType     = HttpClientCredentialType.Certificate;
            binding.Security.Message.EstablishSecurityContext   = false;
            binding.Security.Message.NegotiateServiceCredential = true;
            binding.Security.Message.AlgorithmSuite             = SecurityAlgorithmSuite.Default;
            binding.Security.Message.ClientCredentialType       = MessageCredentialType.Certificate;

            EndpointAddress remoteAddress = new EndpointAddress(icmWebServiceBaseUrl);

            ConnectorIncidentManagerClient client = new ConnectorIncidentManagerClient(binding, remoteAddress);

            if (client.ClientCredentials != null)
            {
                client.ClientCredentials.ClientCertificate.SetCertificate(
                    StoreLocation.LocalMachine,
                    StoreName.My,
                    X509FindType.FindByThumbprint,
                    CertThumbprint);
            }

            return(client);
        }
        public long CreateWorkItem(Dictionary <string, string> values, Dictionary <string, string> overrides)
        {
            AlertSourceIncident incident = CreateIncidentWithDefaults(values);

            if (connectorClient == null)
            {
                connectorClient = ConnectToIcmInstance();
            }

            ApplyOverrides(ref incident, overrides);

            long incidentId = 0;
            IncidentAddUpdateResult result = connectorClient.AddOrUpdateIncident2(
                config.IcmClientConfig.ConnectorId,
                incident,
                RoutingOptions.None);

            if (result?.IncidentId != null)
            {
                incidentId = result.IncidentId.Value;
                WorkItemsCache.Add(values["ConverstionID"], incidentId);
                DateTime createDateTime = result.UpdateProcessTime ?? DateTime.UtcNow;
                InsertRecord(config.IcmClientConfig.RoutingId, values["ConverstionID"], incidentId, createDateTime);
            }
            return(incidentId);
        }
Example #4
0
        /// <summary>
        /// Creates the specified ic m connector authentication cert thumbprint.
        /// For this fucntion, we need to add the reference to namespace System.ServiceModel.
        /// </summary>
        /// <param name="icMConnectorAuthCertThumbprint">The ic m connector authentication cert thumbprint.</param>
        /// <returns>IConnectorIncidentManager.</returns>
        public static IConnectorIncidentManager CreateIncidentManager(string icMConnectorAuthCertThumbprint)
        {
            // ppe https://icm.ad.msoppe.msft.net/Connector3/ConnectorIncidentManager.svc
            string icmAlertEndpoint = "https://icm.ad.msft.net/Connector3/ConnectorIncidentManager.svc";

            ConnectorIncidentManagerClient client;
            WS2007HttpBinding binding;
            EndpointAddress   remoteAddress;

            binding = new WS2007HttpBinding(SecurityMode.Transport)
            {
                Name = "IcmBindingConfigCert",
                MaxBufferPoolSize      = 4194304,
                MaxReceivedMessageSize = 16777216,
                SendTimeout            = TimeSpan.FromMinutes(2)
            };

            binding.Security.Transport.Realm = string.Empty;
            binding.Security.Transport.ProxyCredentialType  = HttpProxyCredentialType.None;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

            binding.ReaderQuotas.MaxArrayLength         = 16384;
            binding.ReaderQuotas.MaxBytesPerRead        = 1048576;
            binding.ReaderQuotas.MaxStringContentLength = 1048576;

            binding.Security.Message.EstablishSecurityContext   = false;
            binding.Security.Message.NegotiateServiceCredential = true;
            binding.Security.Message.AlgorithmSuite             = SecurityAlgorithmSuite.Default;
            binding.Security.Message.ClientCredentialType       = MessageCredentialType.Certificate;

            remoteAddress = new EndpointAddress(icmAlertEndpoint);
            client        = new ConnectorIncidentManagerClient(binding, remoteAddress);

            if (client.ClientCredentials != null)
            {
                client.ClientCredentials.ClientCertificate.SetCertificate(
                    StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, icMConnectorAuthCertThumbprint);
            }

            return(client);
        }
Example #5
0
        public long CreateWorkItem(Dictionary <string, string> values)
        {
            AlertSourceIncident incident = this.CreateIncidentWithDefaults(values);

            if (connectorClient == null)
            {
                connectorClient = ConnectToIcmInstance();
            }

            long incidentId = 0;
            IncidentAddUpdateResult result = connectorClient.AddOrUpdateIncident2(
                config.IcmClientConfig.ConnectorId,
                incident,
                RoutingOptions.None);

            if (result != null && result.IncidentId.HasValue)
            {
                incidentId = result.IncidentId.Value;
                WorkItemsCache.Add(values["ConverstionID"], incidentId);
            }
            return(incidentId);
        }