Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Nov 19, 2023
1 parent c32035a commit a60f7c2
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private ESuccess _verifyAndDecrypt (@Nonnull final Document aSOAPDoc,
@Nonnull final ICommonsList <WSS4JAttachment> aAttachments,
@Nonnull final AS4MessageState aState,
@Nonnull final ErrorList aErrorList,
@Nonnull final Supplier <WSSConfig> aWSSConfigSupplier)
@Nonnull final Supplier <? extends WSSConfig> aWSSConfigSupplier)
{
// Default is Leg 1, gets overwritten when a reference to a message id
// exists and then uses leg2
Expand All @@ -126,7 +126,8 @@ private ESuccess _verifyAndDecrypt (@Nonnull final Document aSOAPDoc,
final WSS4JAttachmentCallbackHandler aAttachmentCallbackHandler = new WSS4JAttachmentCallbackHandler (aAttachments,
aState.getResourceHelper ());

// Resolve the WSS config here to ensure the context matches
// Resolve the WSS config here to ensure the context matches (either from
// an instance of globally)
final WSSConfig aWSSConfig = aWSSConfigSupplier.get ();

if (m_aDecryptParameterModifier != null)
Expand Down Expand Up @@ -364,21 +365,20 @@ public ESuccess processHeaderElement (@Nonnull final Document aSOAPDoc,
final Element aSignatureAlgorithm = XMLHelper.getFirstChildElementOfName (aSignedNode,
CAS4.DS_NS,
"SignatureMethod");

// Get Signing algorithm
String sAlgorithm = aSignatureAlgorithm == null ? null : aSignatureAlgorithm.getAttribute ("Algorithm");
final ECryptoAlgorithmSign eSignAlgo = ECryptoAlgorithmSign.getFromURIOrNull (sAlgorithm);
if (eSignAlgo == null)
{
LOGGER.error ("Error processing the Security Header, your signing algorithm '" +
sAlgorithm +
"' is incorrect. Expected one of the following '" +
Arrays.asList (ECryptoAlgorithmSign.values ()) +
Arrays.toString (ECryptoAlgorithmSign.values ()) +
"' algorithms");

aErrorList.add (EEbmsError.EBMS_FAILED_AUTHENTICATION.getAsError (aLocale));

return ESuccess.FAILURE;
}

if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Using signature algorithm " + eSignAlgo);

Expand All @@ -392,11 +392,10 @@ public ESuccess processHeaderElement (@Nonnull final Document aSOAPDoc,
LOGGER.error ("Error processing the Security Header, your signing digest algorithm is incorrect. Expected one of the following'" +
Arrays.toString (ECryptoAlgorithmSignDigest.values ()) +
"' algorithms");

aErrorList.add (EEbmsError.EBMS_FAILED_AUTHENTICATION.getAsError (aLocale));

return ESuccess.FAILURE;
}

if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Using signature digest algorithm " + eSignDigestAlgo);
}
Expand All @@ -409,13 +408,16 @@ public ESuccess processHeaderElement (@Nonnull final Document aSOAPDoc,
// Check if Attachment IDs are the same
for (int i = 0; i < aAttachments.size (); i++)
{
// Get "Content-ID" header
String sAttachmentID = aAttachments.get (i).getHeaders ().get (AttachmentUtils.MIME_HEADER_CONTENT_ID);
if (StringHelper.hasNoText (sAttachmentID))
{
LOGGER.error ("The provided attachment ID in the 'Content-ID' header may not be empty.");
aErrorList.add (EEbmsError.EBMS_VALUE_INCONSISTENT.getAsError (aLocale));
return ESuccess.FAILURE;
}

// Starts with "<attachment="?
if (!sAttachmentID.startsWith (WSS4JAttachment.CONTENT_ID_PREFIX))
{
LOGGER.error ("The provided attachment ID '" +
Expand All @@ -426,6 +428,8 @@ public ESuccess processHeaderElement (@Nonnull final Document aSOAPDoc,
aErrorList.add (EEbmsError.EBMS_VALUE_INCONSISTENT.getAsError (aLocale));
return ESuccess.FAILURE;
}

// Ends with ">"?
if (!sAttachmentID.endsWith (WSS4JAttachment.CONTENT_ID_SUFFIX))
{
LOGGER.error ("The provided attachment ID '" +
Expand All @@ -436,6 +440,7 @@ public ESuccess processHeaderElement (@Nonnull final Document aSOAPDoc,
aErrorList.add (EEbmsError.EBMS_VALUE_INCONSISTENT.getAsError (aLocale));
return ESuccess.FAILURE;
}

// Strip prefix and suffix
sAttachmentID = sAttachmentID.substring (WSS4JAttachment.CONTENT_ID_PREFIX.length (),
sAttachmentID.length () -
Expand Down

0 comments on commit a60f7c2

Please sign in to comment.