public IRaspRequest PrepareRequest(OiosiMessage message, UddiType uddiType) { // First we need to find out what type of object we are sending DocumentTypeConfigSearcher typeSearcher = new DocumentTypeConfigSearcher(); DocumentTypeConfig docTypeConfig = typeSearcher.FindUniqueDocumentType(message.MessageXml); // 1. Lookup the endpoint address and certificate using UDDI UddiLookupResponse uddiResponse = this.Uddi(message, docTypeConfig); // 2. Download the server certificate using LDAP X509Certificate2 serverCert = this.Ldap(uddiResponse.CertificateSubjectSerialNumber); // 3. Check the validity status of the certificate using OCSP this.Revocation(serverCert); // 4. Let the user configure the client certificate Console.WriteLine("\nPlease configure the certificate used for sending\n----------------------------------------------------"); X509Certificate2 clientCert = this.GetCertificate(uddiType); Credentials credentials = new Credentials(new OcesX509Certificate(clientCert), new OcesX509Certificate(serverCert)); // Create request RaspRequest raspRequest = new RaspRequest(new Request(uddiResponse.EndpointAddress.GetAsUri(), credentials)); return(raspRequest); }
/// <summary> /// Performs a lookup in the UDDI and validates the response. /// </summary> /// <returns>Returns the UDDI response</returns> protected UddiLookupResponse PerformUddiLookup(LookupParameters uddiLookupParameters) { RegistryLookupClientFactory uddiClientFactory = new RegistryLookupClientFactory(); IUddiLookupClient uddiClient = uddiClientFactory.CreateUddiLookupClient(); List <UddiLookupResponse> uddiResponses = uddiClient.Lookup(uddiLookupParameters); Assert.AreEqual(1, uddiResponses.Count, "Unexcpected number of uddi results."); UddiLookupResponse selectedUddiResponse = uddiResponses[0]; return(selectedUddiResponse); }
public void LookOioXmlWithoutProfile() { LookupParameters lookupParameters = new LookupParameters(eanIdentifier, this.oioxmlInvoiceServiceId, acceptHttpProtocol); List <UddiLookupResponse> lookupResponses = this.GetEndpointsWithProfileFromUddi(lookupParameters); Assert.AreEqual(1, lookupResponses.Count, "Exactly 1 endpoint expected."); UddiLookupResponse response = lookupResponses[0]; this.AssertReponsePropertiesAreSetCorrectly(response, "OIOXML elektronisk handel BuyerParty"); this.AssertReponsePropertiesAreSetCorrectlyProfile(response, "IOXML elektronisk handel - læs ind BuyerParty", false); }
static UddiLookupResponse Uddi(OiosiMessage message, DocumentTypeConfig docTypeConfig) { UddiConfig uddiConfig = ConfigurationHandler.GetConfigurationSection <UddiConfig>(); Console.WriteLine("1. UDDI services"); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(" Using UDDI/NemHandel register(s):"); foreach (Registry registry in uddiConfig.LookupRegistryFallbackConfig.PrioritizedRegistryList) { foreach (string endpoint in registry.Endpoints) { Console.WriteLine(" " + endpoint); } } // Create a uddi client RegistryLookupClientFactory uddiClientFactory = new RegistryLookupClientFactory(); uddiClient = uddiClientFactory.CreateUddiLookupClient(); // Get the UDDI parameters with which to call the UDDI server LookupParameters parameters = GetUddiParameters(message, docTypeConfig); Console.WriteLine(" Lookup Parameters"); Console.WriteLine(" EndPoint : " + parameters.Identifier.ToString()); Console.WriteLine(" EndPoint type : " + parameters.Identifier.KeyTypeCode); Console.WriteLine(" Profile : " + GetProfileName(message, docTypeConfig)); // Perform the actual UDDI lookup UddiLookupResponse uddiResponse = PerformUddiLookup(parameters); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" Got UDDI reply:"); Console.ForegroundColor = ConsoleColor.Yellow; if (uddiResponse == null) { Console.WriteLine(" The endpoint is no registrated in UDDI!"); } else { Console.WriteLine(" " + uddiResponse.EndpointAddress.GetKeyAsString()); } Console.ForegroundColor = ConsoleColor.White; return(uddiResponse); }
private UddiLookupResponse PerformUddiLookup(LookupParameters uddiLookupParameters, IUddiLookupClient uddiClient) { UddiLookupResponse selectedUddiResponse = null; // Do the actual UDDI call List <UddiLookupResponse> uddiResponses = uddiClient.Lookup(uddiLookupParameters); // Pick the first response gotten if (uddiResponses.Count == 0) { // No endpoint found in the uddi(s). throw new Exception("Endpoint does not exixt. " + uddiLookupParameters.Identifier.KeyTypeCode.ToString() + ": " + uddiLookupParameters.Identifier + ". "); } else if (uddiResponses.Count == 1) { selectedUddiResponse = uddiResponses[0]; // Make sure the UDDI call returned the reference to a certificate and an endpoint address if (selectedUddiResponse.CertificateSubjectSerialNumber == null) { throw new Exception("The UDDI call didn't return a certificate serial number"); } if (selectedUddiResponse.EndpointAddress == null) { throw new Exception("The UDDI call didn't return any endpoint"); } } else { // more the one - not good Console.WriteLine("To many endpoints found (" + uddiResponses.Count + "), for " + uddiLookupParameters.Identifier.KeyTypeCode.ToString() + ": " + uddiLookupParameters.Identifier + ". Using the first one."); selectedUddiResponse = uddiResponses[0]; // Make sure the UDDI call returned the reference to a certificate and an endpoint address if (selectedUddiResponse.CertificateSubjectSerialNumber == null) { throw new Exception("The UDDI call didn't return a certificate serial number"); } if (selectedUddiResponse.EndpointAddress == null) { throw new Exception("The UDDI call didn't return any endpoint"); } } return(selectedUddiResponse); }
//static IUddiLookupClient uddiClient; private UddiLookupResponse Uddi(OiosiMessage message, DocumentTypeConfig docTypeConfig) { // Create a uddi client RegistryLookupClientFactory uddiClientFactory = new RegistryLookupClientFactory(); IUddiLookupClient uddiClient = uddiClientFactory.CreateUddiLookupClient(); // Get the UDDI parameters with which to call the UDDI server LookupParameters parameters = this.GetUddiParameters(message, docTypeConfig); // Perform the actual UDDI lookup UddiLookupResponse uddiResponse = this.PerformUddiLookup(parameters, uddiClient); // Print out info Console.Write("\n 1. Got UDDI reply\n "); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(uddiResponse.EndpointAddress.GetKeyAsString()); Console.ForegroundColor = ConsoleColor.White; return(uddiResponse); }
protected RaspRequest GetRaspRequest(OiosiMessage oiosiMessage) { DocumentTypeConfigSearcher documentTypeConfigSearcher = new DocumentTypeConfigSearcher(); DocumentTypeConfig documentTypeConfig = documentTypeConfigSearcher.FindUniqueDocumentType(oiosiMessage.MessageXml); LookupParameters messageParameters = this.GetMessageParameters(oiosiMessage, documentTypeConfig); UddiLookupResponse uddiResponse = this.PerformUddiLookup(messageParameters); Uri endpointAddressUri = uddiResponse.EndpointAddress.GetAsUri(); OcesX509Certificate endpointCertificate = this.GetEndpointCertificateFromLdap(uddiResponse.CertificateSubjectSerialNumber); this.ValidateEndpointCertificate(endpointCertificate); //X509Certificate2 clientCertificate = CertificateUtil.InstallAndGetFunctionCertificateFromCertificateStore(); X509Certificate2 clientCertificate = this.ClientCertificate; Credentials credentials = new Credentials(new OcesX509Certificate(clientCertificate), endpointCertificate); Request request = new Request(endpointAddressUri, credentials); RaspRequest raspRequest = new RaspRequest(request); return(raspRequest); }
public List <UddiLookupResponse> Lookup(LookupParameters parameters) { if (ErroneousEndpoints.Contains(_address)) { Console.WriteLine("Dummy UDDI throwing on register " + _address); throw new UddiException(); } if (NonExistingRegistrations.ContainsKey(_address) && NonExistingRegistrations[_address].Contains(parameters.Identifier)) { Console.WriteLine("Dummy UDDI returning empty from register " + _address); return(new List <UddiLookupResponse>()); } Console.WriteLine("Dummy UDDI returning " + parameters.Identifier.GetAsString() + " from " + _address); UddiLookupResponse response = new UddiLookupResponse(); response.EndpointAddress = new EndpointAddressHttp(_address); return(new List <UddiLookupResponse> { response }); }