-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a custom
IMICMatchingHandler
interface to AS2SenderModule
and
`AS2MDNReceiverHandler`; #59
- Loading branch information
Showing
5 changed files
with
146 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
as2-lib/src/main/java/com/helger/as2lib/crypto/IMICMatchingHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.helger.as2lib.crypto; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
import com.helger.as2lib.exception.OpenAS2Exception; | ||
import com.helger.as2lib.message.IMessage; | ||
|
||
/** | ||
* A special handler if MIC is not matched. | ||
* | ||
* @author Philip Helger | ||
* @since 4.4.0 | ||
*/ | ||
public interface IMICMatchingHandler extends Serializable | ||
{ | ||
/** | ||
* Invoked upon MIC match | ||
* | ||
* @param aMsg | ||
* The message it is all about. Never null | ||
* @param sMIC | ||
* The MIC calculated and received. May not be <code>null</code>. | ||
* @throws OpenAS2Exception | ||
* In case of error | ||
*/ | ||
void onMICMatch (@Nonnull IMessage aMsg, @Nonnull String sMIC) throws OpenAS2Exception; | ||
|
||
/** | ||
* Invoked upon MIC mismatch | ||
* | ||
* @param aMsg | ||
* The message it is all about. Never null | ||
* @param sOriginalMIC | ||
* The MIC calculated here. May be <code>null</code>. | ||
* @param sReceivedMIC | ||
* The MIC received from the other side. May be <code>null</code>. | ||
* @throws OpenAS2Exception | ||
* In case of error | ||
*/ | ||
void onMICMismatch (@Nonnull IMessage aMsg, | ||
@Nullable String sOriginalMIC, | ||
@Nullable String sReceivedMIC) throws OpenAS2Exception; | ||
} |
35 changes: 35 additions & 0 deletions
35
as2-lib/src/main/java/com/helger/as2lib/crypto/LoggingMICMatchingHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.helger.as2lib.crypto; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.helger.as2lib.message.IMessage; | ||
|
||
/** | ||
* Logging implementation of {@link IMICMatchingHandler} | ||
* | ||
* @author Philip Helger | ||
* @since 4.40 | ||
*/ | ||
public class LoggingMICMatchingHandler implements IMICMatchingHandler | ||
{ | ||
private static final Logger LOGGER = LoggerFactory.getLogger (LoggingMICMatchingHandler.class); | ||
|
||
public void onMICMatch (@Nonnull final IMessage aMsg, @Nonnull final String sMIC) | ||
{ | ||
if (LOGGER.isInfoEnabled ()) | ||
LOGGER.info ("MIC is matched, MIC: " + sMIC + aMsg.getLoggingText ()); | ||
} | ||
|
||
public void onMICMismatch (final IMessage aMsg, final String sOriginalMIC, final String sReceivedMIC) | ||
{ | ||
if (LOGGER.isInfoEnabled ()) | ||
LOGGER.info ("MIC IS NOT MATCHED; original MIC: " + | ||
sOriginalMIC + | ||
" received MIC: " + | ||
sReceivedMIC + | ||
aMsg.getLoggingText ()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters