com.helger.smpclient.url.IPeppolURLProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of peppol-smp-client Show documentation
Show all versions of peppol-smp-client Show documentation
Peppol and OASIS BDXR SMP client
The newest version!
/*
* Copyright (C) 2015-2024 Philip Helger
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.smpclient.url;
import java.net.URI;
import java.net.URISyntaxException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.helger.commons.ValueEnforcer;
import com.helger.peppol.sml.ISMLInfo;
import com.helger.peppolid.IParticipantIdentifier;
/**
* Base interface for a customizable URL provider so that different URL encoding
* schemes can be used.
*
* @author Philip Helger
*/
public interface IPeppolURLProvider extends ISMPURLProvider
{
/**
* Get DNS record from ParticipantIdentifier.
* Example PEPPOL PI iso6523-actorid-upis::0010:1234
using BDX
* scheme would result in
* B-<hash over PI-Value>.<PI-Scheme>.<sml-zone-name>
* . This method ensures that the hash value is created from the UTF-8 lower
* case value of the identifier. The result string never ends with a dot!
*
* @param aParticipantIdentifier
* Participant identifier. May not be null
.
* @param sSMLZoneName
* e.g. sml.peppolcentral.org.
. May be empty. If it is not
* empty, it must end with a dot!
* @return DNS record. It does not contain any prefix like
* http://
or any path suffix. It is the plain DNS host
* name. Since version 1.1.4 this method returns the DNS name without
* the trailing dot!
* @throws SMPDNSResolutionException
* If the URL resolution failed.
* @throws IllegalArgumentException
* In case one argument is invalid
*/
@Nonnull
String getDNSNameOfParticipant (@Nonnull IParticipantIdentifier aParticipantIdentifier,
@Nullable String sSMLZoneName) throws SMPDNSResolutionException;
/**
* Get DNS record from ParticipantIdentifier.
* Example PEPPOL PI iso6523-actorid-upis::0010:1234
using BDX
* scheme would result in
* B-<hash over PI-Value>.<PI-Scheme>.<sml-zone-name>
* . This method ensures that the hash value is created from the UTF-8 lower
* case value of the identifier. The result string never ends with a dot!
*
* @param aParticipantIdentifier
* Participant identifier. May not be null
.
* @param aSMLInfo
* The SML information object to be used. May not be null
.
* @return DNS record
* @throws SMPDNSResolutionException
* If the URL resolution failed.
*/
@Nonnull
default String getDNSNameOfParticipant (@Nonnull final IParticipantIdentifier aParticipantIdentifier,
@Nonnull final ISMLInfo aSMLInfo) throws SMPDNSResolutionException
{
ValueEnforcer.notNull (aParticipantIdentifier, "ParticipantIdentifier");
ValueEnforcer.notNull (aSMLInfo, "SMLInfo");
return getDNSNameOfParticipant (aParticipantIdentifier, aSMLInfo.getDNSZone ());
}
@Nonnull
default URI getSMPURIOfParticipant (@Nonnull final IParticipantIdentifier aParticipantIdentifier,
@Nullable final String sSMLZoneName) throws SMPDNSResolutionException
{
ValueEnforcer.notNull (aParticipantIdentifier, "ParticipantIdentifier");
// MUST always be http, port 80 and the root path
final String sURIString = "http://" + getDNSNameOfParticipant (aParticipantIdentifier, sSMLZoneName);
try
{
return new URI (sURIString);
}
catch (final URISyntaxException ex)
{
throw new SMPDNSResolutionException ("Error building SMP URI from string '" + sURIString + "'", ex);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy