public String generate(ParticipantIdentifier participantIdentifier) throws LookupException { String receiverHash; try { // Create digest based on participant identifier. MessageDigest md = MessageDigest.getInstance(digestAlgorithm, BouncyCastleProvider.PROVIDER_NAME); byte[] digest = md.digest(participantIdentifier.getIdentifier().getBytes(StandardCharsets.UTF_8)); // Create hex of digest. receiverHash = encoding.encode(digest).toLowerCase(); } catch (Exception e) { throw new LookupException(e.getMessage(), e); } return String.format("%s%s.%s.%s", prefix, receiverHash, participantIdentifier.getScheme().getIdentifier(), hostname); } }
public static ParticipantIdentifier of(String value) { return of(value, DEFAULT_SCHEME); }
public static ParticipantIdentifier of(String value, Scheme scheme) { return new ParticipantIdentifier(value, scheme); }
@Override public void verify(Header header, Direction direction) { log.info("Direction: {} | Sender/Receiver: {}/{} | Instance identifier: {}", direction, header.getSender().getIdentifier(), header.getReceiver().getIdentifier(), header.getIdentifier()); } }
return false; if (timestamp != null ? !timestamp.equals(evidence.timestamp) : evidence.timestamp != null) return false; if (sender != null ? !sender.equals(evidence.sender) : evidence.sender != null) return false; if (receiver != null ? !receiver.equals(evidence.receiver) : evidence.receiver != null) return false; if (documentTypeIdentifier != null ? !documentTypeIdentifier.equals(evidence.documentTypeIdentifier) : evidence.documentTypeIdentifier != null)
/** * Computes the Path for a directory into which your file artifacts associated with * the supplied header may be written. Any intermediate directories are created for you. * * @param baseFolder the root folder to use as the basis for appending additional folders. * @param header meta data to be used as input for computation. * @return a path to a directory into which you may store your artifacts. * @throws IOException */ public static Path createArtifactFolders(Path baseFolder, Header header) throws IOException { Path folder = baseFolder.resolve(Paths.get( FileUtils.filterString(header.getReceiver().getIdentifier()), FileUtils.filterString(header.getSender().getIdentifier()))); Files.createDirectories(folder); return folder; } }
/** * Returns a list of "restricted" header names that will be overridden when calling #createEffectiveHeader * The restricted header names are SenderId, RecipientId, DocumentTypeIdentifier and ProfileTypeIdentifier * Compares values that exist both as parsed and supplied headers. * Ignores values that only exists in one of them (that allows for sending new and unknown document types) */ protected List<String> findRestricedHeadersThatWillBeOverridden(final PeppolStandardBusinessHeader parsed, final PeppolStandardBusinessHeader supplied) { List<String> headers = new ArrayList<>(); if ((parsed.getSenderId() != null) && (supplied.getSenderId() != null) && (!supplied.getSenderId().equals(parsed.getSenderId()))) headers.add("SenderId"); if ((parsed.getRecipientId() != null) && (supplied.getRecipientId() != null) && (!supplied.getRecipientId().equals(parsed.getRecipientId()))) headers.add("RecipientId"); if ((parsed.getDocumentTypeIdentifier() != null) && (supplied.getDocumentTypeIdentifier() != null) && (!supplied.getDocumentTypeIdentifier().equals(parsed.getDocumentTypeIdentifier()))) headers.add("DocumentTypeIdentifier"); if ((parsed.getProfileTypeIdentifier() != null) && (supplied.getProfileTypeIdentifier() != null) && (!supplied.getProfileTypeIdentifier().equals(parsed.getProfileTypeIdentifier()))) headers.add("ProfileTypeIdentifier"); return headers; }
public ParticipantIdentifier toVefa() { return ParticipantIdentifier.of(value, ParticipantIdentifier.DEFAULT_SCHEME); } }
public IcdIdentifier parse(ParticipantIdentifier participantIdentifier) throws PeppolParsingException { try { String[] parts = participantIdentifier.getIdentifier().split(":", 2); return IcdIdentifier.of(findBySchemeAndCode(participantIdentifier.getScheme(), parts[0]), parts[1]); } catch (IllegalArgumentException e) { throw new PeppolParsingException(e.getMessage(), e); } }
/** * Computes the Path for a directory into which your file artifacts associated with * the supplied header may be written. Any intermediate directories are created for you. * * @param baseFolder the root folder to use as the basis for appending additional folders. * @param header meta data to be used as input for computation. * @return a path to a directory into which you may store your artifacts. * @throws IOException */ public static Path createArtifactFolders(Path baseFolder, Header header) throws IOException { Path folder = baseFolder.resolve(Paths.get( FileUtils.filterString(header.getReceiver().getIdentifier()), FileUtils.filterString(header.getSender().getIdentifier()))); Files.createDirectories(folder); return folder; } }
@Override public URI lookup(String identifier) throws LookupException { return lookup(ParticipantIdentifier.of(identifier)); } }
public static AttributedElectronicAddressType createElectronicAddressType(ParticipantIdentifier participant) { AttributedElectronicAddressType o = new AttributedElectronicAddressType(); o.setValue(participant.getIdentifier()); o.setScheme(participant.getScheme().getIdentifier()); return o; }
@Override public URI lookup(ParticipantIdentifier participantIdentifier) throws LookupException { // Create hostname for participant identifier. String hostname = hostnameGenerator.generate(participantIdentifier); try { if (new Lookup(hostname).run() == null) throw new LookupException( String.format("Identifier '%s' is not registered in SML.", participantIdentifier.getIdentifier())); } catch (TextParseException e) { throw new LookupException(e.getMessage(), e); } return URI.create(String.format("http://%s", hostname)); } }
public static ParticipantIdentifier parse(String str) throws PeppolParsingException { String[] parts = str.split("::", 2); if (parts.length != 2) throw new PeppolParsingException(String.format("Unable to parse participant identifier '%s'.", str)); return of(parts[1], Scheme.of(parts[0])); }
static Partner createPartner(ParticipantIdentifier participant) { PartnerIdentification partnerIdentification = new PartnerIdentification(); partnerIdentification.setAuthority(participant.getScheme().getIdentifier()); partnerIdentification.setValue(participant.getIdentifier()); Partner partner = new Partner(); partner.setIdentifier(partnerIdentification); return partner; }
ps.setTimestamp(2, new Timestamp(rawStatistics.getDate().getTime())); ps.setString(3, rawStatistics.getDirection().toString()); ps.setString(4, rawStatistics.getSender().getIdentifier()); ps.setString(5, rawStatistics.getReceiver().getIdentifier()); ps.setString(6, rawStatistics.getDocumentTypeIdentifier().toString()); ps.setString(7, rawStatistics.getProcessIdentifier().toString());
public ParticipantIdentifier toParticipantIdentifier() { return ParticipantIdentifier.of(String.format("%s:%s", icd.getCode(), identifier), icd.getScheme()); }
ps.setTimestamp(2, new Timestamp(rawStatistics.getDate().getTime())); ps.setString(3, rawStatistics.getDirection().toString()); ps.setString(4, rawStatistics.getSender().getIdentifier()); ps.setString(5, rawStatistics.getReceiver().getIdentifier()); ps.setString(6, rawStatistics.getDocumentTypeIdentifier().toString()); ps.setString(7, rawStatistics.getProcessIdentifier().toString());
public static ParticipantIdentifier readElectronicAddressType(AttributedElectronicAddressType o) { return ParticipantIdentifier.of(o.getValue(), Scheme.of(o.getScheme())); }
ps.setTimestamp(2, new Timestamp(rawStatistics.getDate().getTime())); ps.setString(3, rawStatistics.getDirection().toString()); ps.setString(4, rawStatistics.getSender().getIdentifier()); ps.setString(5, rawStatistics.getReceiver().getIdentifier()); ps.setString(6, rawStatistics.getDocumentTypeIdentifier().toString()); ps.setString(7, rawStatistics.getProcessIdentifier().toString());