public static void resetService() { try { Endpoint endpoint = Endpoint.of( TransportProfile.of("busdox-transport-dummy"), URI.create("http://localhost/"), CertificateMock.withCN("APP_00000042")); Mockito.reset(lookupService); Mockito.when(lookupService.lookup(Mockito.any(Header.class))).thenReturn(endpoint); Mockito.when(lookupService.lookup(Mockito.any(Header.class), Mockito.any(Span.class))).thenReturn(endpoint); } catch (OxalisTransmissionException e) { // No action } }
public Endpoint getEndpoint(ServiceMetadata serviceMetadata, ProcessIdentifier processIdentifier, TransportProfile... transportProfiles) throws PeppolSecurityException, EndpointNotFoundException { Endpoint endpoint = serviceMetadata.getEndpoint(processIdentifier, transportProfiles); validator.validate(Service.AP, endpoint.getCertificate()); return endpoint; }
/** * {@inheritDoc} */ @Override default TransportProfile getProtocol() { return getEndpoint().getTransportProfile(); }
transmissionRequest.getEndpoint().getTransportProfile()); span.setTag("endpoint url", transmissionRequest.getEndpoint().getAddress().toString()); HttpPost httpPost = new HttpPost(transmissionRequest.getEndpoint().getAddress()); httpPost.addHeader(As2Header.AS2_FROM, fromIdentifier); httpPost.setHeader(As2Header.AS2_TO, CertificateUtils.extractCommonName( transmissionRequest.getEndpoint().getCertificate())); httpPost.addHeader(As2Header.DISPOSITION_NOTIFICATION_TO, notificationAddress); httpPost.addHeader(As2Header.DISPOSITION_NOTIFICATION_OPTIONS,
if (transmissionRequest.getEndpoint().getCertificate() != null) { String accessPointIdentifierValue = CertificateUtils .extractCommonName(transmissionRequest.getEndpoint().getCertificate()); builder.channel(new ChannelId(accessPointIdentifierValue)); } else { String protocolName = transmissionRequest.getEndpoint().getTransportProfile().getIdentifier(); builder.channel(new ChannelId(protocolName));
response.getStatusLine().getStatusCode(), transmissionRequest.getEndpoint().getAddress()); transmissionRequest.getEndpoint().getAddress()); message.validate(transmissionRequest.getEndpoint().getCertificate()); } catch (OxalisAs2Exception e) { throw new OxalisTransmissionException("Unable to parse received MDN.", e);
@Override public TransmissionResponse send(TransmissionRequest transmissionRequest) throws OxalisTransmissionException { TransmissionIdentifier transmissionIdentifier = TransmissionIdentifier.generateUUID(); // For use in testing when no receiver is configured. if (config.hasPath("oxalis.asd.sender.skip") && config.getBoolean("oxalis.asd.sender.skip")) { return new AsdTransmissionResponse(transmissionRequest, transmissionIdentifier); } HttpPost httpPost = new HttpPost(transmissionRequest.getEndpoint().getAddress()); httpPost.setHeader(AsdHeaders.TRANSMISSION_ID, transmissionIdentifier.getIdentifier()); httpPost.setEntity(new InputStreamEntity(transmissionRequest.getPayload())); try (CloseableHttpResponse response = httpClient.execute(httpPost)) { String status = response.getFirstHeader(AsdHeaders.STATUS).getValue(); if (!"OK".equals(status)) throw new OxalisTransmissionException(status); return new AsdTransmissionResponse(transmissionRequest, transmissionIdentifier); } catch (OxalisTransmissionException e) { throw e; } catch (Exception e) { throw new OxalisTransmissionException("Unable to send message.", e); } } }
public static Endpoint of(TransportProfile transportProfile, URI address, X509Certificate certificate) { return new Endpoint(transportProfile, address, certificate, null); }
Endpoint endpoint = lookupService.lookup(effectiveStandardBusinessHeader.toVefa(), null); if (isEndpointSuppliedByCaller() && !this.endpoint.equals(endpoint)) { throw new IllegalStateException("You are not allowed to override the EndpointAddress from SMP.");
transmissionRequest.getEndpoint().getTransportProfile()); span.setTag("endpoint url", transmissionRequest.getEndpoint().getAddress().toString()); HttpPost httpPost = new HttpPost(transmissionRequest.getEndpoint().getAddress()); httpPost.addHeader(As2Header.AS2_FROM, fromIdentifier); httpPost.setHeader(As2Header.AS2_TO, CertificateUtils.extractCommonName( transmissionRequest.getEndpoint().getCertificate())); httpPost.addHeader(As2Header.DISPOSITION_NOTIFICATION_TO, notificationAddress); httpPost.addHeader(As2Header.DISPOSITION_NOTIFICATION_OPTIONS,
if (transmissionRequest.getEndpoint().getCertificate() != null) { String accessPointIdentifierValue = CertificateUtils .extractCommonName(transmissionRequest.getEndpoint().getCertificate()); builder.channel(new ChannelId(accessPointIdentifierValue)); } else { String protocolName = transmissionRequest.getEndpoint().getTransportProfile().getIdentifier(); builder.channel(new ChannelId(protocolName));
response.getStatusLine().getStatusCode(), transmissionRequest.getEndpoint().getAddress()); transmissionRequest.getEndpoint().getAddress()); message.validate(transmissionRequest.getEndpoint().getCertificate()); } catch (OxalisAs2Exception e) { throw new OxalisTransmissionException("Unable to parse received MDN.", e);
@Override public TransmissionResponse send(TransmissionRequest transmissionRequest) throws OxalisTransmissionException { TransmissionIdentifier transmissionIdentifier = TransmissionIdentifier.generateUUID(); // For use in testing when no receiver is configured. if (config.hasPath("oxalis.asd.sender.skip") && config.getBoolean("oxalis.asd.sender.skip")) { return new AsdTransmissionResponse(transmissionRequest, transmissionIdentifier); } HttpPost httpPost = new HttpPost(transmissionRequest.getEndpoint().getAddress()); httpPost.setHeader(AsdHeaders.TRANSMISSION_ID, transmissionIdentifier.getIdentifier()); httpPost.setEntity(new InputStreamEntity(transmissionRequest.getPayload())); try (CloseableHttpResponse response = httpClient.execute(httpPost)) { String status = response.getFirstHeader(AsdHeaders.STATUS).getValue(); if (!"OK".equals(status)) throw new OxalisTransmissionException(status); return new AsdTransmissionResponse(transmissionRequest, transmissionIdentifier); } catch (OxalisTransmissionException e) { throw e; } catch (Exception e) { throw new OxalisTransmissionException("Unable to send message.", e); } } }
public static Endpoint of(TransportProfile transportProfile, URI address, X509Certificate certificate, Period period) { return new Endpoint(transportProfile, address, certificate, period); }
public static void resetService() { try { Endpoint endpoint = Endpoint.of( TransportProfile.of("bdx-transport-asd"), URI.create("http://localhost/"), CertificateMock.withCN("APP_00000042")); Mockito.reset(lookupService); Mockito.when(lookupService.lookup(Mockito.any(Header.class))).thenReturn(endpoint); Mockito.when(lookupService.lookup(Mockito.any(Header.class), Mockito.any(Span.class))).thenReturn(endpoint); } catch (OxalisTransmissionException e) { // No action } }
if (transmissionRequest.getEndpoint().getCertificate() == null) throw new OxalisTransmissionException("Certificate of receiving access point is not provided."); certificateValidator.validate(Service.AP, transmissionRequest.getEndpoint().getCertificate(), root); } else { try { endpoint = lookupService.lookup(transmissionMessage.getHeader(), span); span.setTag("transport profile", endpoint.getTransportProfile().getIdentifier()); transmissionRequest = new DefaultTransmissionRequest(transmissionMessage, endpoint); } catch (OxalisTransmissionException e) { TransmissionResponse transmissionResponse; try { TransportProfile transportProfile = transmissionRequest.getEndpoint().getTransportProfile(); MessageSender messageSender = messageSenderFactory.getMessageSender(transportProfile); transmissionResponse = messageSender.send(transmissionRequest, span);
protected TransmissionResponse sendHttpRequest(HttpPost httpPost) throws OxalisTransmissionException { Span span = tracer.buildSpan("execute").asChildOf(root).start(); try (CloseableHttpClient httpClient = httpClientProvider.get()) { BasicHttpContext basicHttpContext = new BasicHttpContext(); basicHttpContext.setAttribute(Constants.PARENT_CONTEXT, span.context()); CloseableHttpResponse response = httpClient.execute(httpPost, basicHttpContext); span.finish(); return handleResponse(response); } catch (HttpHostConnectException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Receiving server does not seem to be running.", transmissionRequest.getEndpoint().getAddress(), e); } catch (SSLHandshakeException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Possible invalid SSL Certificate at the other end.", transmissionRequest.getEndpoint().getAddress(), e); } catch (IOException e) { span.setTag("exception", String.valueOf(e.getMessage())); throw new OxalisTransmissionException(transmissionRequest.getEndpoint().getAddress(), e); } finally { span.finish(); } }
/** * {@inheritDoc} */ @Override default TransportProfile getProtocol() { return getEndpoint().getTransportProfile(); }
public static void resetService() { try { Endpoint endpoint = Endpoint.of( TransportProfile.of("bdx-transport-asd"), URI.create("http://localhost/"), CertificateMock.withCN("APP_00000042")); Mockito.reset(lookupService); Mockito.when(lookupService.lookup(Mockito.any(Header.class))).thenReturn(endpoint); Mockito.when(lookupService.lookup(Mockito.any(Header.class), Mockito.any(Span.class))).thenReturn(endpoint); } catch (OxalisTransmissionException e) { // No action } }
protected TransmissionResponse sendHttpRequest(HttpPost httpPost) throws OxalisTransmissionException { Span span = tracer.buildSpan("execute").asChildOf(root).start(); try (CloseableHttpClient httpClient = httpClientProvider.get()) { BasicHttpContext basicHttpContext = new BasicHttpContext(); basicHttpContext.setAttribute(Constants.PARENT_CONTEXT, span.context()); CloseableHttpResponse response = httpClient.execute(httpPost, basicHttpContext); span.finish(); return handleResponse(response); } catch (SocketTimeoutException e) { span.setTag("exception", String.valueOf(e.getMessage())); throw new OxalisTransmissionException("Receiving server has not sent anything back within SOCKET_TIMEOUT", transmissionRequest.getEndpoint().getAddress(), e); } catch (HttpHostConnectException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Receiving server does not seem to be running.", transmissionRequest.getEndpoint().getAddress(), e); } catch (SSLHandshakeException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Possible invalid SSL Certificate at the other end.", transmissionRequest.getEndpoint().getAddress(), e); } catch (IOException e) { span.setTag("exception", String.valueOf(e.getMessage())); throw new OxalisTransmissionException(transmissionRequest.getEndpoint().getAddress(), e); } finally { span.finish(); } }