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 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); } }
public static AttributedElectronicAddressType createElectronicAddressType(ParticipantIdentifier participant) { AttributedElectronicAddressType o = new AttributedElectronicAddressType(); o.setValue(participant.getIdentifier()); o.setScheme(participant.getScheme().getIdentifier()); return o; }
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; }