Skip to content

Commit

Permalink
Merge pull request #10 from OpenAS2/dev
Browse files Browse the repository at this point in the history
Major rework of sending  message and receiving MDN responses
  • Loading branch information
pete-gilchrist committed Nov 27, 2015
2 parents 7a352af + b318d4b commit 80e1679
Show file tree
Hide file tree
Showing 33 changed files with 1,649 additions and 1,187 deletions.
22 changes: 12 additions & 10 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
OpenAS2 Server
Version 1.3.5
Version 1.3.6
RELEASE NOTES

The OpenAS2 project is pleased to announce the release of OpenAS2 1.3.5
The OpenAS2 project is pleased to announce the release of OpenAS2 1.3.6

The release download file is: OpenAS2Server-1.3.5.zip
The release download file is: OpenAS2Server-1.3.6.zip
The zip file contains a PDF document providing information on installing and using the application.

This release is an enahncement and bugfix release:
- fix handling of file streams to ensure file handle is always closed
- fix async MDN functionality
- fix calculation of MIC when content is signed and compressed
- improved logic handling sending of MDN errors and HTTP responses
- add compiler option to build file to ensure java 1.5 compatibility
- add ability to control number of resend attempts
UPGRADE Instructions:
1. As of version 1.3.6, a new "errordir" parameter is required on the processor element to specify where files that fail resend attempts are stored.
It defaults to a sub-directory named "error" off the directory pointed to by the "pendingMDN" parameter.

This release is an enhancement and bugfix release:
1. Fix handling creating a unique file name for storing message info for ASYNC MDN
2. Rationalise the handling of received MDN so that there is a common handler for Async and Sync MDN
3. Fix moving pending messages that fail after retries to the error folder.
4. Enhance logging to pass MEssage object to log manager to facilitate finer grained and more targeted logging

Java 1.5 or later is required.

Expand Down
8 changes: 3 additions & 5 deletions Server/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@

<processor classname="org.openas2.processor.DefaultProcessor"
pendingMDN="%home%/../data/pendingMDN3"
pendingMDNinfo="%home%/../data/pendinginfoMDN3"
resend_max_retries="10">


pendingMDNinfo="%home%/../data/pendinginfoMDN3"
>
<module classname="org.openas2.processor.sender.AS2SenderModule">
</module>

Expand Down Expand Up @@ -117,7 +115,7 @@

<module classname="org.openas2.processor.resender.DirectoryResenderModule"
resenddir="%home%/../data/resend"
errordir="%home%/resend/error"
errordir="%home%/../data/resend/error"
resenddelay="60"/>
</processor>
</openas2>
6 changes: 4 additions & 2 deletions Server/config/partnerships.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<attribute name="compression_type" value="ZLIB"/>
<attribute name="subject" value="From OpenAS2A to OpenAS2B"/>
<attribute name="as2_url" value="http://localhost:10080"/>
<attribute name="as2_mdn_to" value="http://localhost:10081"/>
<attribute name="as2_mdn_to" value="[email protected]"/>
<!-- <attribute name="as2_receipt_option" value="http://localhost:10080"/> ...for async MDN-->
<attribute name="as2_mdn_options" value="signed-receipt-protocol=optional, pkcs7-signature; signed-receipt-micalg=optional, SHA1"/>
<attribute name="encrypt" value="3DES"/>
<attribute name="sign" value="MD5"/>
Expand All @@ -30,7 +31,8 @@
<attribute name="content_transfer_encoding" value="binary"/>
<attribute name="subject" value="From OpenAS2B to OpenAS2A"/>
<attribute name="as2_url" value="http://localhost:10080"/>
<attribute name="as2_mdn_to" value="http://localhost:10081"/>
<attribute name="as2_mdn_to" value="[email protected]"/>
<!-- <attribute name="as2_receipt_option" value="http://localhost:10080"/> ...for async MDN-->
<attribute name="as2_mdn_options" value="signed-receipt-protocol=optional, pkcs7-signature; signed-receipt-micalg=optional, SHA1"/>
<attribute name="encrypt" value="3DES"/>
<attribute name="sign" value="SHA1"/>
Expand Down
Binary file not shown.
Binary file modified Server/lib/openas2-server.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion Server/src/org/openas2/OpenAS2Exception.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ public void terminate() {
}

protected void log(boolean terminated) {
logger.error("Error occurred:: " + this.getMessage() + "\n Sources: "+ this.getSources(), this);
logger.error("Error occurred:: " + org.openas2.logging.Log.getExceptionMsg(this) + "\n Sources: "+ this.getSources(), this);
}
}
2 changes: 1 addition & 1 deletion Server/src/org/openas2/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
public interface Session {
/** Official OpenAS2 release version */
public static final String VERSION = "1.3.5";
public static final String VERSION = "1.3.6";

/** Official OpenAS2 title */
public static final String TITLE = "OpenAS2 v" + VERSION;
Expand Down
4 changes: 2 additions & 2 deletions Server/src/org/openas2/lib/helper/BCCryptoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public MimeBodyPart verify(MimeBodyPart part, Certificate cert)
throw new SignatureException("Verification failed");
}
} catch (Exception e) {
if (logger.isWarnEnabled()) logger.warn("Signer verification failed:: " + e.getMessage());
if (logger.isWarnEnabled()) logger.warn("Signer verification failed: " + org.openas2.logging.Log.getExceptionMsg(e), e);
throw new SignatureException("Verification failed");
}
}
Expand Down Expand Up @@ -524,4 +524,4 @@ public KeyStore loadKeyStore(String filename, char[] password) throws Exception
fIn.close();
}
}
}
}
4 changes: 2 additions & 2 deletions Server/src/org/openas2/logging/ConsoleLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


public class ConsoleLogger extends BaseLogger {
public void doLog(Level level, String msgText, Message message) {
public void doLog(Level level, String msgText, Message as2Msg) {
if (System.out != null) {
getFormatter().format(level, msgText, System.out);
getFormatter().format(level, msgText + (as2Msg == null?"":as2Msg.getLogMsgID()), System.out);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Server/src/org/openas2/logging/EmailLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class EmailLogger extends BaseLogger {
public static final String PARAM_BODY = "body";
public static final String PARAM_BODYTEMPLATE = "bodytemplate";

public void doLog(Level level, String msgText, Message message) {
public void doLog(Level level, String msgText, Message as2Msg) {

if (level != Level.ERROR)
{
Expand All @@ -47,7 +47,7 @@ public void doLog(Level level, String msgText, Message message) {
subject = getSubject(level, msgText);
}

sendMessage(subject, getFormatter().format(level, msgText));
sendMessage(subject, getFormatter().format(level, msgText + (as2Msg == null?"":as2Msg.getLogMsgID())));
} catch (InvalidParameterException ipe) {
ipe.printStackTrace();
}
Expand Down
4 changes: 2 additions & 2 deletions Server/src/org/openas2/logging/FileLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public void init(Session session, Map<String, String> parameters) throws OpenAS2
getLogFile();
}

public void doLog(Level level, String msgText, Message message) {
appendToFile(getFormatter().format(level, msgText));
public void doLog(Level level, String msgText, Message as2Msg) {
appendToFile(getFormatter().format(level, msgText + (as2Msg == null?"":as2Msg.getLogMsgID())));
}

protected String getShowDefaults() {
Expand Down
73 changes: 32 additions & 41 deletions Server/src/org/openas2/logging/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,79 +147,61 @@ protected boolean isLevelEnabled(int logLevel) {
* @see org.apache.commons.logging.Log#trace(java.lang.Object)
*/
public void trace(Object message) {
if (isLevelEnabled(LOG_LEVEL_TRACE))
lm.log(Level.FINEST, clazzname+": "+message.toString());
trace(message, null);
}

/* (non-Javadoc)
* @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable)
*/
public void trace(Object message, Throwable t) {
if (isLevelEnabled(LOG_LEVEL_TRACE))
{
lm.log(Level.FINEST, clazzname+": "+message.toString());
lm.log(t, false);
lm.log(Level.FINEST, clazzname, message);
if (t != null) lm.log(t, false);
}
}

/* (non-Javadoc)
* @see org.apache.commons.logging.Log#debug(java.lang.Object)
*/
public void debug(Object message) {
if (isLevelEnabled(LOG_LEVEL_DEBUG))
lm.log(Level.FINER, clazzname+": "+message.toString());

debug(message, null);
}

/* (non-Javadoc)
* @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable)
*/
public void debug(Object message, Throwable t) {
if (isLevelEnabled(LOG_LEVEL_DEBUG))
{
lm.log(Level.FINER, clazzname+": "+message.toString());
lm.log(t, false);
lm.log(Level.FINER, clazzname, message);
if (t != null) lm.log(t, false);
}

}

/* (non-Javadoc)
* @see org.apache.commons.logging.Log#info(java.lang.Object)
*/
public void info(Object message) {
if (isLevelEnabled(LOG_LEVEL_INFO))
lm.log(Level.FINE, clazzname+": "+message.toString());
info(message, null);

}

/* (non-Javadoc)
* @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable)
*/
public void info(Object message, Throwable t) {
if (isLevelEnabled(LOG_LEVEL_INFO))
{
lm.log(Level.FINE, clazzname+": "+message.toString());
lm.log(t, false);
lm.log(Level.FINE, clazzname, message);
if (t != null) lm.log(t, false);
}
}

/* (non-Javadoc)
* @see org.apache.commons.logging.Log#warn(java.lang.Object)
*/
public void warn(Object message) {
if (isLevelEnabled(LOG_LEVEL_WARN))
lm.log(Level.WARNING, clazzname+": "+message.toString());
warn(message, null);

}

/* (non-Javadoc)
* @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable)
*/
public void warn(Object message, Throwable t) {
if (isLevelEnabled(LOG_LEVEL_WARN))
{
lm.log(Level.WARNING, clazzname+": "+message.toString());
lm.log(t, false);
lm.log(Level.WARNING, clazzname, message);
if (t != null) lm.log(t, false);
}
}

Expand All @@ -228,8 +210,7 @@ public void warn(Object message, Throwable t) {
* @see org.apache.commons.logging.Log#error(java.lang.Object)
*/
public void error(Object message) {
if (isLevelEnabled(LOG_LEVEL_ERROR))
lm.log(Level.ERROR, clazzname+": "+message.toString());
error(message, null);

}

Expand All @@ -239,8 +220,8 @@ public void error(Object message) {
public void error(Object message, Throwable t) {
if (isLevelEnabled(LOG_LEVEL_ERROR))
{
lm.log(Level.ERROR, clazzname+": "+message.toString());
lm.log(t, false);
lm.log(Level.ERROR, clazzname, message);
if (t != null) lm.log(t, false);
}

}
Expand All @@ -249,19 +230,15 @@ public void error(Object message, Throwable t) {
* @see org.apache.commons.logging.Log#fatal(java.lang.Object)
*/
public void fatal(Object message) {
if (isLevelEnabled(LOG_LEVEL_FATAL))
lm.log(Level.ERROR, clazzname+": "+message.toString());
fatal(message, null);

}

/* (non-Javadoc)
* @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable)
*/
public void fatal(Object message, Throwable t) {
if (isLevelEnabled(LOG_LEVEL_FATAL))
{
lm.log(Level.ERROR, clazzname+": "+message.toString());
lm.log(t, true);
lm.log(Level.ERROR, clazzname, message);
if (t != null) lm.log(t, true);
}
}

Expand Down Expand Up @@ -310,4 +287,18 @@ public boolean isWarnEnabled() {
private static InputStream getResourceAsStream(final String name) {
return ClassLoader.getSystemResourceAsStream(name);
}

public static String getExceptionMsg(Throwable e)
{
String msg = null;
if (e.getCause() != null)
msg = e.getCause().getMessage();
if (msg == null || msg.length() == 0)
{
msg = e.getMessage();
if (msg == null || msg.length() == 0)
msg = e.toString();
}
return msg;
}
}
13 changes: 9 additions & 4 deletions Server/src/org/openas2/logging/LogManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Iterator;
import java.util.List;

import org.openas2.message.Message;


public class LogManager {
private static LogManager defaultManager;
Expand Down Expand Up @@ -49,20 +51,23 @@ public void log(Throwable e, boolean terminated) {
}
}


/**
* @param level
* @param msg
* @param clazzName - the name of the class that the log was generated in
* @param message - the logging object to create the message from
*/
public void log(Level level, String msg) {
public void log(Level level, String clazzName, Object msg) {
Iterator<?> loggerIt = getLoggers().iterator();

if (loggerIt.hasNext()) {
while (loggerIt.hasNext()) {
Logger logger = (Logger) loggerIt.next();
logger.log(level, msg, null);
if (msg instanceof Message) logger.log(level, clazzName + ": " + ((Message)msg).getLogMsg(), (Message) msg);
else logger.log(level, clazzName + ": " + msg.toString(), null);
}
} else {
System.out.println(level.getName() + " " + msg);
System.out.println(level.getName() + " " + msg.toString());
}
}

Expand Down
4 changes: 2 additions & 2 deletions Server/src/org/openas2/logging/SocketLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void init(Session session, Map<String, String> parameters) throws OpenAS2

}

public void doLog(Level level, String msgText, Message message) {
sendToSocket(getFormatter().format(level, msgText));
public void doLog(Level level, String msgText, Message as2Msg) {
sendToSocket(getFormatter().format(level, msgText + (as2Msg == null?"":as2Msg.getLogMsgID())));
}

public void sendToSocket(String msgText) {
Expand Down
9 changes: 2 additions & 7 deletions Server/src/org/openas2/message/AS2Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public String getProtocol() {
return PROTOCOL_AS2;
}

public String generateMessageID() {
public String generateMessageID() throws InvalidParameterException {
CompositeParameters params =
new CompositeParameters(false).
add("date", new DateParameters()).
Expand All @@ -34,12 +34,7 @@ public String generateMessageID() {
}
StringBuffer messageId = new StringBuffer();
messageId.append("<");
try {
messageId.append(ParameterParser.parse(idFormat, params));
}
catch (InvalidParameterException e) {
messageId.append(idFormat); // useless, but what to do?
}
messageId.append(ParameterParser.parse(idFormat, params));
messageId.append(">");
return messageId.toString();
}
Expand Down
Loading

0 comments on commit 80e1679

Please sign in to comment.