com.helger.phase4.profile.cef.AS4CEFProfileRegistarSPI Maven / Gradle / Ivy
/*
* Copyright (C) 2015-2024 Philip Helger (www.helger.com)
* 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.phase4.profile.cef;
import javax.annotation.Nonnull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.helger.commons.annotation.IsSPIImplementation;
import com.helger.phase4.model.pmode.IPModeIDProvider;
import com.helger.phase4.profile.AS4Profile;
import com.helger.phase4.profile.IAS4ProfilePModeProvider;
import com.helger.phase4.profile.IAS4ProfileRegistrar;
import com.helger.phase4.profile.IAS4ProfileRegistrarSPI;
/**
* Library specific implementation of {@link IAS4ProfileRegistrarSPI}.
*
* @author Philip Helger
*/
@IsSPIImplementation
public final class AS4CEFProfileRegistarSPI implements IAS4ProfileRegistrarSPI
{
public static final String AS4_PROFILE_ID_FOUR_CORNER = "cef";
public static final String AS4_PROFILE_NAME_FOUR_CORNER = "CEF (four corner)";
public static final String AS4_PROFILE_ID_TWO_CORNER = "cef-two-corner";
public static final String AS4_PROFILE_NAME_TWO_CORNER = "CEF (two corner)";
public static final IPModeIDProvider PMODE_ID_PROVIDER = IPModeIDProvider.DEFAULT_DYNAMIC;
private static final Logger LOGGER = LoggerFactory.getLogger (AS4CEFProfileRegistarSPI.class);
public void registerAS4Profile (@Nonnull final IAS4ProfileRegistrar aRegistrar)
{
final IAS4ProfilePModeProvider aDefaultPModeProvider = (i, r, a) -> CEFPMode.createCEFPMode (i,
r,
a,
PMODE_ID_PROVIDER,
true);
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Registering phase4 profile '" + AS4_PROFILE_ID_FOUR_CORNER + "'");
final AS4Profile aProfileFourCorner = new AS4Profile (AS4_PROFILE_ID_FOUR_CORNER,
AS4_PROFILE_NAME_FOUR_CORNER,
() -> new CEFCompatibilityValidator ().setExpectFourCornerModel (true),
aDefaultPModeProvider,
PMODE_ID_PROVIDER,
false,
false);
aRegistrar.registerProfile (aProfileFourCorner);
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Registering phase4 profile '" + AS4_PROFILE_ID_TWO_CORNER + "'");
final AS4Profile aProfileTwoCorner = new AS4Profile (AS4_PROFILE_ID_TWO_CORNER,
AS4_PROFILE_NAME_TWO_CORNER,
() -> new CEFCompatibilityValidator ().setExpectFourCornerModel (false),
aDefaultPModeProvider,
PMODE_ID_PROVIDER,
false,
false);
aRegistrar.registerProfile (aProfileTwoCorner);
// The four corner profile is the default
aRegistrar.setDefaultProfile (aProfileFourCorner);
}
}