Search in sources :

Example 11 with ETriState

use of com.helger.commons.state.ETriState in project phase4 by phax.

the class PModeLegSecurityMicroTypeConverter method convertToNative.

@Nonnull
public PModeLegSecurity convertToNative(@Nonnull final IMicroElement aElement) {
    final String sWSSVersion = aElement.getAttributeValue(ATTR_WSS_VERSION);
    final EWSSVersion eWSSVersion = EWSSVersion.getFromVersionOrNull(sWSSVersion);
    if (eWSSVersion == null && sWSSVersion != null) {
        throw new IllegalStateException("Invalid WSS version '" + sWSSVersion + "'");
    }
    final ICommonsList<String> aX509SignElement = new CommonsArrayList<>();
    for (final IMicroElement aSignElement : aElement.getAllChildElements(ELEMENT_X509_SIGN_ELEMENT)) {
        aX509SignElement.add(aSignElement.getTextContentTrimmed());
    }
    final ICommonsList<String> aX509SignAttachment = new CommonsArrayList<>();
    for (final IMicroElement aSignElement : aElement.getAllChildElements(ELEMENT_X509_SIGN_ATTACHMENT)) {
        aX509SignAttachment.add(aSignElement.getTextContentTrimmed());
    }
    final String sX509SignatureCertificate = MicroHelper.getChildTextContentTrimmed(aElement, ELEMENT_X509_SIGNATURE_CERTIFICATE);
    final String sX509SignatureHashFunction = aElement.getAttributeValue(ATTR_X509_SIGNATURE_HASH_FUNCTION);
    final ECryptoAlgorithmSignDigest eX509SignatureHashFunction = ECryptoAlgorithmSignDigest.getFromIDOrNull(sX509SignatureHashFunction);
    if (eX509SignatureHashFunction == null && sX509SignatureHashFunction != null) {
        throw new IllegalStateException("Invalid signature hash function '" + sX509SignatureHashFunction + "'");
    }
    final String sX509SignatureAlgorithm = aElement.getAttributeValue(ATTR_X509_SIGNATURE_ALGORITHM);
    final ECryptoAlgorithmSign eX509SignatureAlgorithm = ECryptoAlgorithmSign.getFromIDOrNull(sX509SignatureAlgorithm);
    if (eX509SignatureAlgorithm == null && sX509SignatureAlgorithm != null) {
        throw new IllegalStateException("Invalid signature algorithm '" + sX509SignatureAlgorithm + "'");
    }
    final ICommonsList<String> aX509EncryptionEncryptElement = new CommonsArrayList<>();
    for (final IMicroElement aEncryptElement : aElement.getAllChildElements(ELEMENT_X509_ENCRYPTION_ENCRYPT_ELEMENT)) {
        aX509EncryptionEncryptElement.add(aEncryptElement.getTextContentTrimmed());
    }
    final ICommonsList<String> aX509EncryptionEncryptAttachment = new CommonsArrayList<>();
    for (final IMicroElement aEncryptElement : aElement.getAllChildElements(ELEMENT_X509_ENCRYPTION_ENCRYPT_ATTACHMENT)) {
        aX509EncryptionEncryptAttachment.add(aEncryptElement.getTextContentTrimmed());
    }
    final String sX509EncryptionCertificate = MicroHelper.getChildTextContentTrimmed(aElement, ELEMENT_X509_ENCRYPTION_CERTIFICATE);
    final String sX509EncryptionAlgorithm = aElement.getAttributeValue(ATTR_X509_ENCRYPTION_ALGORITHM);
    final ECryptoAlgorithmCrypt eX509EncryptionAlgorithm = ECryptoAlgorithmCrypt.getFromIDOrNull(sX509EncryptionAlgorithm);
    if (eX509EncryptionAlgorithm == null && sX509EncryptionAlgorithm != null) {
        throw new IllegalStateException("Invalid encrypt algorithm '" + sX509EncryptionAlgorithm + "'");
    }
    final Integer aX509EncryptionMinimumStrength = aElement.getAttributeValueWithConversion(ATTR_X509_ENCRYPTION_MINIMUM_STRENGTH, Integer.class);
    final String sUsernameTokenUsername = aElement.getAttributeValue(ATTR_USERNAME_TOKEN_USERNAME);
    final String sUsernameTokenPassword = aElement.getAttributeValue(ATTR_USERNAME_TOKEN_PASSWORD);
    final ETriState eUsernameTokenDigest = getTriState(aElement.getAttributeValue(ATTR_USERNAME_TOKEN_DIGEST), PModeLegSecurity.DEFAULT_USERNAME_TOKEN_DIGEST);
    final ETriState eUsernameTokenNonce = getTriState(aElement.getAttributeValue(ATTR_USERNAME_TOKEN_NONCE), PModeLegSecurity.DEFAULT_USERNAME_TOKEN_NONCE);
    final ETriState eUsernameTokenCreated = getTriState(aElement.getAttributeValue(ATTR_USERNAME_TOKEN_CREATED), PModeLegSecurity.DEFAULT_USERNAME_TOKEN_CREATED);
    final ETriState ePModeAuthorize = getTriState(aElement.getAttributeValue(ATTR_PMODE_AUTHORIZE), PModeLegSecurity.DEFAULT_PMODE_AUTHORIZE);
    final ETriState eSendReceipt = getTriState(aElement.getAttributeValue(ATTR_SEND_RECEIPT), PModeLegSecurity.DEFAULT_SEND_RECEIPT);
    final String sSendReceiptReplyPattern = aElement.getAttributeValue(ATTR_SEND_RECEIPT_REPLY_PATTERN);
    final EPModeSendReceiptReplyPattern eSendReceiptReplyPattern = EPModeSendReceiptReplyPattern.getFromIDOrNull(sSendReceiptReplyPattern);
    if (eSendReceiptReplyPattern == null && sSendReceiptReplyPattern != null) {
        throw new IllegalStateException("Invalid SendReceipt ReplyPattern version '" + sSendReceiptReplyPattern + "'");
    }
    final ETriState eSendReceiptNonRepudiation = getTriState(aElement.getAttributeValue(ATTR_SEND_RECEIPT_NON_REPUDIATION), PModeLegSecurity.DEFAULT_SEND_RECEIPT_NON_REPUDIATION);
    return new PModeLegSecurity(eWSSVersion, aX509SignElement, aX509SignAttachment, sX509SignatureCertificate, eX509SignatureHashFunction, eX509SignatureAlgorithm, aX509EncryptionEncryptElement, aX509EncryptionEncryptAttachment, sX509EncryptionCertificate, eX509EncryptionAlgorithm, aX509EncryptionMinimumStrength, sUsernameTokenUsername, sUsernameTokenPassword, eUsernameTokenDigest, eUsernameTokenNonce, eUsernameTokenCreated, ePModeAuthorize, eSendReceipt, eSendReceiptReplyPattern, eSendReceiptNonRepudiation);
}
Also used : ETriState(com.helger.commons.state.ETriState) ECryptoAlgorithmCrypt(com.helger.phase4.crypto.ECryptoAlgorithmCrypt) IMicroElement(com.helger.xml.microdom.IMicroElement) ECryptoAlgorithmSignDigest(com.helger.phase4.crypto.ECryptoAlgorithmSignDigest) EWSSVersion(com.helger.phase4.wss.EWSSVersion) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) ECryptoAlgorithmSign(com.helger.phase4.crypto.ECryptoAlgorithmSign) Nonnull(javax.annotation.Nonnull)

Example 12 with ETriState

use of com.helger.commons.state.ETriState in project phase4 by phax.

the class PModeLegErrorHandlingJsonConverter method convertToNative.

@Nonnull
public static PModeLegErrorHandling convertToNative(@Nonnull final IJsonObject aElement) {
    final IJsonArray aSender = aElement.getAsArray(REPORT_SENDER_ERRORS_TO);
    final PModeAddressList aSenderAddresses = aSender == null ? null : PModeAddressListJsonConverter.convertToNative(aSender);
    final IJsonArray aReceiver = aElement.getAsArray(REPORT_RECEIVER_ERRORS_TO);
    final PModeAddressList aReceiverAddresses = aReceiver == null ? null : PModeAddressListJsonConverter.convertToNative(aReceiver);
    final ETriState eReportAsResponse = AbstractPModeMicroTypeConverter.getTriState(aElement.getAsString(REPORT_AS_RESPONSE), PModeLegSecurity.DEFAULT_PMODE_AUTHORIZE);
    final ETriState eReportProcessErrorNotifyConsumer = AbstractPModeMicroTypeConverter.getTriState(aElement.getAsString(REPORT_PROCESS_ERROR_NOTFIY_CONSUMER), PModeLegSecurity.DEFAULT_USERNAME_TOKEN_CREATED);
    final ETriState eReportProcessErrorNotifyProducer = AbstractPModeMicroTypeConverter.getTriState(aElement.getAsString(REPORT_PROCESS_ERROR_NOTFIY_PRODUCER), PModeLegSecurity.DEFAULT_USERNAME_TOKEN_DIGEST);
    final ETriState eReportDeliveryFailuresNotifyProducer = AbstractPModeMicroTypeConverter.getTriState(aElement.getAsString(REPORT_DELIVERY_FAILURE_NOTFIY_PRODUCER), PModeLegSecurity.DEFAULT_SEND_RECEIPT);
    return new PModeLegErrorHandling(aSenderAddresses, aReceiverAddresses, eReportAsResponse, eReportProcessErrorNotifyConsumer, eReportProcessErrorNotifyProducer, eReportDeliveryFailuresNotifyProducer);
}
Also used : ETriState(com.helger.commons.state.ETriState) IJsonArray(com.helger.json.IJsonArray) Nonnull(javax.annotation.Nonnull)

Example 13 with ETriState

use of com.helger.commons.state.ETriState in project phase4 by phax.

the class PModeLegReliabilityMicroTypeConverter method convertToNative.

@Nonnull
public PModeLegReliability convertToNative(@Nonnull final IMicroElement aElement) {
    final ETriState eAtLeastOnceContract = getTriState(aElement.getAttributeValue(ATTR_AT_LEAST_ONCE_CONTRACT), PModeLegReliability.DEFAULT_AT_LEAST_ONCE_CONTRACT);
    final ETriState eAtLeastOnceAckOnDelivery = getTriState(aElement.getAttributeValue(ATTR_AT_LEAST_ONCE_ACK_ON_DELIVERY), PModeLegReliability.DEFAULT_AT_LEAST_ONCE_ACK_ON_DELIVERY);
    final String sAtLeastOnceContractAcksTo = aElement.getAttributeValue(ATTR_AT_LEAST_ONCE_CONTRACT_ACK_TO);
    final ETriState eAtLeastOnceContractAckResponse = getTriState(aElement.getAttributeValue(ATTR_AT_LEAST_ONCE_CONTRACT_ACK_RESPONSE), PModeLegReliability.DEFAULT_AT_LEAST_ONCE_CONTRACT_ACK_RESPONSE);
    final String sAtLeastOnceReplyPattern = aElement.getAttributeValue(ATTR_AT_LEAST_ONCE_REPLY_PATTERN);
    final ETriState eAtMostOnceContract = getTriState(aElement.getAttributeValue(ATTR_AT_MOST_ONCE_CONTRACT), PModeLegReliability.DEFAULT_AT_MOST_ONCE_CONTRACT);
    final ETriState eInOrderContract = getTriState(aElement.getAttributeValue(ATTR_IN_ORDER_CONTRACT), PModeLegReliability.DEFAULT_IN_ORDER_CONTACT);
    final ETriState eStartGroup = getTriState(aElement.getAttributeValue(ATTR_START_GROUP), PModeLegReliability.DEFAULT_START_GROUP);
    final ICommonsList<String> aCorrelationStrings = new CommonsArrayList<>();
    for (final IMicroElement aCorrelationElement : aElement.getAllChildElements(ELEMENT_CORRELATION)) {
        aCorrelationStrings.add(aCorrelationElement.getTextContentTrimmed());
    }
    final ETriState eTerminateGroup = getTriState(aElement.getAttributeValue(ATTR_TERMINATE_GROUP), PModeLegReliability.DEFAULT_TERMINATE_GROUP);
    return new PModeLegReliability(eAtLeastOnceContract, eAtLeastOnceAckOnDelivery, sAtLeastOnceContractAcksTo, eAtLeastOnceContractAckResponse, sAtLeastOnceReplyPattern, eAtMostOnceContract, eInOrderContract, eStartGroup, aCorrelationStrings, eTerminateGroup);
}
Also used : ETriState(com.helger.commons.state.ETriState) IMicroElement(com.helger.xml.microdom.IMicroElement) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Nonnull(javax.annotation.Nonnull)

Example 14 with ETriState

use of com.helger.commons.state.ETriState in project phase4 by phax.

the class PModeReceptionAwarenessJsonConverter method convertToNative.

@Nonnull
public static PModeReceptionAwareness convertToNative(final IJsonObject aElement) {
    final ETriState eReceptionAwareness = AbstractPModeMicroTypeConverter.getTriState(aElement.getAsString(RECEPTION_AWARENESS), PModeReceptionAwareness.DEFAULT_RECEPTION_AWARENESS);
    final ETriState eRetry = AbstractPModeMicroTypeConverter.getTriState(aElement.getAsString(RETRY), PModeReceptionAwareness.DEFAULT_RETRY);
    final int nMaxRetries = aElement.getAsInt(MAX_RETRIES, PModeReceptionAwareness.DEFAULT_MAX_RETRIES);
    final int nRetryIntervalMS = aElement.getAsInt(RETRY_INTERVAL_MS, PModeReceptionAwareness.DEFAULT_RETRY_INTERVAL_MS);
    final ETriState eDuplicateDetection = AbstractPModeMicroTypeConverter.getTriState(aElement.getAsString(DUPLICATE_DETECTION), PModeReceptionAwareness.DEFAULT_DUPLICATE_DETECTION);
    return new PModeReceptionAwareness(eReceptionAwareness, eRetry, nMaxRetries, nRetryIntervalMS, eDuplicateDetection);
}
Also used : ETriState(com.helger.commons.state.ETriState) Nonnull(javax.annotation.Nonnull)

Example 15 with ETriState

use of com.helger.commons.state.ETriState in project phase4 by phax.

the class PModeReceptionAwarenessMicroTypeConverter method convertToNative.

@Nonnull
public PModeReceptionAwareness convertToNative(final IMicroElement aElement) {
    final ETriState eReceptionAwareness = getTriState(aElement.getAttributeValue(ATTR_RECEPTION_AWARENESS), PModeReceptionAwareness.DEFAULT_RECEPTION_AWARENESS);
    final ETriState eRetry = getTriState(aElement.getAttributeValue(ATTR_RETRY), PModeReceptionAwareness.DEFAULT_RETRY);
    final int nMaxRetries = aElement.getAttributeValueAsInt(ATTR_MAX_RETRIES, PModeReceptionAwareness.DEFAULT_MAX_RETRIES);
    // Was a typo
    final int nRetryIntervalMS = aElement.getAttributeValueAsInt(ATTR_RETRY_INTERVAL_MS, aElement.getAttributeValueAsInt("MayRetries", PModeReceptionAwareness.DEFAULT_RETRY_INTERVAL_MS));
    final ETriState eDuplicateDetection = getTriState(aElement.getAttributeValue(ATTR_DUPLICATE_DETECTION), PModeReceptionAwareness.DEFAULT_DUPLICATE_DETECTION);
    return new PModeReceptionAwareness(eReceptionAwareness, eRetry, nMaxRetries, nRetryIntervalMS, eDuplicateDetection);
}
Also used : ETriState(com.helger.commons.state.ETriState) Nonnull(javax.annotation.Nonnull)

Aggregations

ETriState (com.helger.commons.state.ETriState)32 Nonnull (javax.annotation.Nonnull)24 Nullable (javax.annotation.Nullable)10 ValueEnforcer (com.helger.commons.ValueEnforcer)7 ErrorList (com.helger.commons.error.list.ErrorList)7 Consumer (java.util.function.Consumer)7 AmountType (un.unece.uncefact.data.standard.unqualifieddatatype._100.AmountType)7 CGlobal (com.helger.commons.CGlobal)6 CollectionHelper (com.helger.commons.collection.CollectionHelper)6 EqualsHelper (com.helger.commons.equals.EqualsHelper)6 IErrorList (com.helger.commons.error.list.IErrorList)6 MathHelper (com.helger.commons.math.MathHelper)6 StringHelper (com.helger.commons.string.StringHelper)6 Serializable (java.io.Serializable)6 BigDecimal (java.math.BigDecimal)6 LocalDate (java.time.LocalDate)6 CrossIndustryInvoiceType (un.unece.uncefact.data.standard.crossindustryinvoice._100.CrossIndustryInvoiceType)6 FormattedDateTimeType (un.unece.uncefact.data.standard.qualifieddatatype._100.FormattedDateTimeType)6 un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._100 (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._100)6 BinaryObjectType (un.unece.uncefact.data.standard.unqualifieddatatype._100.BinaryObjectType)6