Skip to content

Commit

Permalink
Renamed APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Aug 28, 2024
1 parent 5619ce6 commit c2004ce
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public AbstractEuCtpPullRequestBuilder ()
signingParams ().setAlgorithmC14N (ECryptoAlgorithmC14N.C14N_EXCL_OMIT_COMMENTS);
// Use the BST value type "#X509PKIPathv1"
signingParams ().setUseSingleCertificate (false);

}
catch (final Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

import org.apache.hc.core5.http.message.StatusLine;

Expand All @@ -39,12 +39,12 @@
* @param <T>
* The response type
*/
@Immutable
@NotThreadSafe
public class AS4ClientSentMessage <T>
{
private final AS4ClientBuiltMessage m_aBuiltMsg;
private final StatusLine m_aResponseStatusLine;
private HttpHeaderMap m_aResponseHeaders;
private final HttpHeaderMap m_aResponseHeaders;
private final T m_aResponseContent;
private final OffsetDateTime m_aSentDateTime;

Expand Down Expand Up @@ -159,7 +159,7 @@ public final HttpHeaderMap getResponseHeaders ()
* @return The response payload. May be <code>null</code>.
*/
@Nullable
public final T getResponse ()
public final T getResponseContent ()
{
return m_aResponseContent;
}
Expand All @@ -168,7 +168,7 @@ public final T getResponse ()
* @return <code>true</code> if a response payload is present,
* <code>false</code> if not.
*/
public final boolean hasResponse ()
public final boolean hasResponseContent ()
{
return m_aResponseContent != null;
}
Expand All @@ -189,7 +189,7 @@ public String toString ()
return new ToStringGenerator (this).append ("BuiltMsg", m_aBuiltMsg)
.append ("ResponseStatusLine", m_aResponseStatusLine)
.append ("ResponseHeaders", m_aResponseHeaders)
.append ("Response", m_aResponseContent)
.append ("ResponseContent", m_aResponseContent)
.append ("SentDateTime", m_aSentDateTime)
.getToString ();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,6 @@ public final IAS4CryptoFactory getAS4CryptoFactorySign ()
return m_aCryptoFactorySign;
}

/**
* @return The currently set crypto factory for crypting. <code>null</code> by
* default.
* @since 2.2.0
*/
@Nullable
public final IAS4CryptoFactory getAS4CryptoFactoryCrypt ()
{
return m_aCryptoFactoryCrypt;
}

/**
* Set all the crypto properties at once.
*
* @param aCryptoFactory
* The crypto factory to be used. May be <code>null</code>.
* @return this for chaining
*/
@Nonnull
public final IMPLTYPE setAS4CryptoFactory (@Nullable final IAS4CryptoFactory aCryptoFactory)
{
return setAS4CryptoFactorySign (aCryptoFactory).setAS4CryptoFactoryCrypt (aCryptoFactory);
}

/**
* Set the crypto factory to be used for signing.
*
Expand All @@ -180,6 +156,17 @@ public final IMPLTYPE setAS4CryptoFactorySign (@Nullable final IAS4CryptoFactory
return thisAsT ();
}

/**
* @return The currently set crypto factory for crypting. <code>null</code> by
* default.
* @since 2.2.0
*/
@Nullable
public final IAS4CryptoFactory getAS4CryptoFactoryCrypt ()
{
return m_aCryptoFactoryCrypt;
}

/**
* Set the crypto factory to be used for crypting.
*
Expand All @@ -196,6 +183,19 @@ public final IMPLTYPE setAS4CryptoFactoryCrypt (@Nullable final IAS4CryptoFactor
return thisAsT ();
}

/**
* Set all the crypto properties at once.
*
* @param aCryptoFactory
* The crypto factory to be used. May be <code>null</code>.
* @return this for chaining
*/
@Nonnull
public final IMPLTYPE setAS4CryptoFactory (@Nullable final IAS4CryptoFactory aCryptoFactory)
{
return setAS4CryptoFactorySign (aCryptoFactory).setAS4CryptoFactoryCrypt (aCryptoFactory);
}

/**
* @return The signing algorithm to use. Never <code>null</code>.
* @since 0.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void handleResponse (@Nonnull final AS4ClientSentMessage <byte []> aRespo
{
final boolean bUseStatusLine = isHandleStatusLine () && aResponseEntity.hasResponseStatusLine ();
final boolean bUseHttpHeaders = isHandleHttpHeaders () && aResponseEntity.getResponseHeaders ().isNotEmpty ();
final boolean bUseBody = aResponseEntity.hasResponse () && aResponseEntity.getResponse ().length > 0;
final boolean bUseBody = aResponseEntity.hasResponseContent () && aResponseEntity.getResponseContent ().length > 0;

if (bUseStatusLine || bUseHttpHeaders || bUseBody)
{
Expand Down Expand Up @@ -208,7 +208,7 @@ public void handleResponse (@Nonnull final AS4ClientSentMessage <byte []> aRespo
if (bUseBody)
{
// Write the main content
aOS.write (aResponseEntity.getResponse ());
aOS.write (aResponseEntity.getResponseContent ());
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ private static void _dumpSoap (@Nonnull final IAS4IncomingMessageMetadata aMessa
{
// Write formatted SOAP
{
final Document aSoapDoc = aState.hasDecryptedSoapDocument () ? aState.getDecryptedSoapDocument () : aState
.getOriginalSoapDocument ();
final Document aSoapDoc = aState.getEffectiveDecryptedSoapDocument ();
if (aSoapDoc == null)
throw new IllegalStateException ("No SOAP Document present");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ private static void _send (@Nonnull final IAS4CryptoFactory aCF, final Path aSen
aSW.stopAndGetMillis () +
" ms");

if (aResponseEntity.hasResponse ())
if (aResponseEntity.hasResponseContent ())
{
final String sMessageID = aResponseEntity.getMessageID ();
final String sFilename = FilenameHelper.getAsSecureValidASCIIFilename (sMessageID) + "-response.xml";
final File aResponseFile = aIncomingDir.resolve (sFilename).toFile ();
if (SimpleFileIO.writeFile (aResponseFile, aResponseEntity.getResponse ()).isSuccess ())
if (SimpleFileIO.writeFile (aResponseFile, aResponseEntity.getResponseContent ()).isSuccess ())
LOGGER.info ("Response file was written to '" + aResponseFile.getAbsolutePath () + "'");
else
LOGGER.error ("Error writing response file to '" + aResponseFile.getAbsolutePath () + "'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ private static void _dumpSoap (@Nonnull final IAS4IncomingMessageMetadata aMessa
// Write formatted SOAP
{
final File aFile = StorageHelper.getStorageFile (aMessageMetadata, ".soap");
final Document aSoapDoc = aState.hasDecryptedSoapDocument () ? aState.getDecryptedSoapDocument ()
: aState.getOriginalSoapDocument ();
final Document aSoapDoc = aState.getEffectiveDecryptedSoapDocument ();
final byte [] aBytes = XMLWriter.getNodeAsBytes (aSoapDoc,
new XMLWriterSettings ().setNamespaceContext (Ebms3NamespaceHandler.getInstance ())
.setIndent (EXMLSerializeIndent.INDENT_AND_ALIGN));
Expand Down Expand Up @@ -113,8 +112,7 @@ public AS4MessageProcessorResult processAS4UserMessage (@Nonnull final IAS4Incom
{
final File aFile = StorageHelper.getStorageFile (aMessageMetadata, "-" + nIndex + ".payload");
if (StreamHelper.copyInputStreamToOutputStream (aIncomingAttachment.getSourceStream (),
FileHelper.getOutputStream (aFile))
.isFailure ())
FileHelper.getOutputStream (aFile)).isFailure ())
{
LOGGER.error ("Failed to write incoming attachment [" + nIndex + "] to '" + aFile.getAbsolutePath () + "'");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public IMicroDocument sendMessageAndGetMicroDocument (@Nonnull final String sURL
new ResponseHandlerMicroDom (),
aCallback,
aOutgoingDumper,
aRetryCallback).getResponse ();
aRetryCallback).getResponseContent ();
AS4HttpDebug.debug ( () -> "SEND-RESPONSE received: " +
MicroWriter.getNodeAsString (ret, AS4HttpDebug.getDebugXMLWriterSettings ()));

Expand Down

0 comments on commit c2004ce

Please sign in to comment.