Skip to content

Commit

Permalink
Bouncycastle upgrade rx filename default (#158)
Browse files Browse the repository at this point in the history
* Support a fallback file name for when sender does not send file name

* Set the fallback filename for receiver when filename not sent in
content-disposition

* Updated documentation for release

* BouncyCastle upgrade
  • Loading branch information
uhurusurfa authored Sep 5, 2019
1 parent ff5c8db commit df4d72b
Show file tree
Hide file tree
Showing 12 changed files with 715 additions and 676 deletions.
2 changes: 1 addition & 1 deletion Bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.sf.openas2</groupId>
<artifactId>OpenAS2</artifactId>
<version>2.9.2</version>
<version>2.9.3</version>
</parent>

<artifactId>openas2-osgi</artifactId>
Expand Down
19 changes: 8 additions & 11 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# OpenAS2 Server
# Version 2.9.2
# Version 2.9.3
# RELEASE NOTES
-----
The OpenAS2 project is pleased to announce the release of OpenAS2 2.9.2
The OpenAS2 project is pleased to announce the release of OpenAS2 2.9.3

The release download file is: OpenAS2Server-2.9.2.zip
The release download file is: OpenAS2Server-2.9.3.zip

The zip file contains a PDF document (OpenAS2HowTo.pdf) providing information on installing and using the application.

Version 2.9.2 - 2019-08-16
This is a an enhancement and bugfix release:
Version 2.9.3 - 2019-09-05
This is a minior enhancement release:
**IMPORTANT NOTE**: Please review upgrade notes if you are upgrading

1. Fixed error where DB tracking module was not logging fields to database.
2. Added a script to connect to the H2 database from the command line.
3. Simplified the default config.xml for changing ports by using properties.
4. Added support for location of the config.xml using an environment variable in the start-openas2.sh file
5. Document stored_sent_filename and stored_error_filename as well as provide more examples for setting errordir and sentdir using extended dynamic variables

1. Allowed defining a custom fallback file name for received fiels where partner does not send file name. See section 6.3 of the OpenAS2HowTo and the as2_receive_message_filename_fallback attribute.
2. Upgraded BouncyCastle libraries to 1.62 to support Java 12

##Upgrade Notes
See the openAS2HowTo appendix for the general process on upgrading OpenAS2.
Below are some specific things to focus on depending on which version you are upgrading from.
Expand Down
2 changes: 1 addition & 1 deletion Remote/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>net.sf.openas2</groupId>
<artifactId>OpenAS2</artifactId>
<version>2.9.2</version>
<version>2.9.3</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion Server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- DO NOT CHANGE THIS "groupId" WITHOUT CHANGING XMLSession.getManifestAttributes.MANIFEST_VENDOR_ID_ATTRIB -->
<groupId>net.sf.openas2</groupId>
<artifactId>OpenAS2</artifactId>
<version>2.9.2</version>
<version>2.9.3</version>
</parent>

<artifactId>openas2-server</artifactId>
Expand Down
1 change: 1 addition & 0 deletions Server/src/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
sql_timestamp_format="yyyy-MM-dd HH:mm:ss.SSS"
as2_message_id_format="OPENAS2-$date.ddMMyyyyHHmmssZ$-$rand.UUID$@$msg.sender.as2_id$_$msg.receiver.as2_id$"
as2_async_mdn_url="http://localhost:10081"
as2_receive_message_filename_fallback="$rand.shortUUID$"
/>
<certificates classname="org.openas2.cert.PKCS12CertificateFactory"
filename="%home%/as2_certs.p12"
Expand Down
157 changes: 81 additions & 76 deletions Server/src/main/java/org/openas2/params/MessageParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,90 +7,95 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openas2.message.Message;

import org.openas2.util.Properties;

public class MessageParameters extends ParameterParser {
public static final String KEY_SENDER = "sender";
public static final String KEY_RECEIVER = "receiver";
public static final String KEY_ATTRIBUTES = "attributes";
public static final String KEY_HEADERS = "headers";
public static final String KEY_CONTENT_FILENAME = "content-disposition";
private Message target;

private Log logger = LogFactory.getLog(MessageParameters.class.getSimpleName());

public MessageParameters(Message target) {
super();
this.target = target;
}
public static final String KEY_SENDER = "sender";
public static final String KEY_RECEIVER = "receiver";
public static final String KEY_ATTRIBUTES = "attributes";
public static final String KEY_HEADERS = "headers";
public static final String KEY_CONTENT_FILENAME = "content-disposition";
private Message target;

private Log logger = LogFactory.getLog(MessageParameters.class.getSimpleName());

public MessageParameters(Message target) {
super();
this.target = target;
}

public void setParameter(String key, String value)
throws InvalidParameterException {
StringTokenizer keyParts = new StringTokenizer(key, ".", false);

if (keyParts.countTokens() != 2) {
throw new InvalidParameterException("Invalid key format", this, key, null);
}

String area = keyParts.nextToken();
String areaID = keyParts.nextToken();

if (area.equals(KEY_SENDER)) {
getTarget().getPartnership().setSenderID(areaID, value);
} else if (area.equals(KEY_RECEIVER)) {
getTarget().getPartnership().setReceiverID(areaID, value);
} else if (area.equals(KEY_ATTRIBUTES)) {
getTarget().setAttribute(areaID, value);
} else if (area.equals(KEY_HEADERS)) {
getTarget().setHeader(areaID, value);
} else {
throw new InvalidParameterException("Invalid area in key", this, key, null);
}
public void setParameter(String key, String value) throws InvalidParameterException {
StringTokenizer keyParts = new StringTokenizer(key, ".", false);

if (keyParts.countTokens() != 2) {
throw new InvalidParameterException("Invalid key format", this, key, null);
}

public String getParameter(String key) throws InvalidParameterException {
StringTokenizer keyParts = new StringTokenizer(key, ".", false);

if (keyParts.countTokens() != 2) {
throw new InvalidParameterException("Invalid key format", this, key, null);
}

String area = keyParts.nextToken();
String areaID = keyParts.nextToken();

if (area.equals(KEY_SENDER)) {
return getTarget().getPartnership().getSenderID(areaID);
} else if (area.equals(KEY_RECEIVER)) {
return getTarget().getPartnership().getReceiverID(areaID);
} else if (area.equals(KEY_ATTRIBUTES)) {
return getTarget().getAttribute(areaID);
} else if (area.equals(KEY_HEADERS)) {
return getTarget().getHeader(areaID);
} else if (area.equals(KEY_CONTENT_FILENAME) && areaID.equals("filename")) {
String filename = "noContentDispositionFilename";
String s = null;
try
{
s = getTarget().extractPayloadFilename();
} catch (ParseException e)
{
logger.warn("Failed to extract filename from content-disposition: " + org.openas2.logging.Log.getExceptionMsg(e), e);
}
if (s == null || s.length() < 1)
s = getTarget().getPayloadFilename();
if (s != null && s.length() > 0)
return s;
return filename;
} else {
throw new InvalidParameterException("Invalid area in key", this, key, null);
}
String area = keyParts.nextToken();
String areaID = keyParts.nextToken();

if (area.equals(KEY_SENDER)) {
getTarget().getPartnership().setSenderID(areaID, value);
} else if (area.equals(KEY_RECEIVER)) {
getTarget().getPartnership().setReceiverID(areaID, value);
} else if (area.equals(KEY_ATTRIBUTES)) {
getTarget().setAttribute(areaID, value);
} else if (area.equals(KEY_HEADERS)) {
getTarget().setHeader(areaID, value);
} else {
throw new InvalidParameterException("Invalid area in key", this, key, null);
}
}

public String getParameter(String key) throws InvalidParameterException {
StringTokenizer keyParts = new StringTokenizer(key, ".", false);

public void setTarget(Message message) {
target = message;
if (keyParts.countTokens() != 2) {
throw new InvalidParameterException("Invalid key format", this, key, null);
}

public Message getTarget() {
return target;
String area = keyParts.nextToken();
String areaID = keyParts.nextToken();

if (area.equals(KEY_SENDER)) {
return getTarget().getPartnership().getSenderID(areaID);
} else if (area.equals(KEY_RECEIVER)) {
return getTarget().getPartnership().getReceiverID(areaID);
} else if (area.equals(KEY_ATTRIBUTES)) {
return getTarget().getAttribute(areaID);
} else if (area.equals(KEY_HEADERS)) {
return getTarget().getHeader(areaID);
} else if (area.equals(KEY_CONTENT_FILENAME) && areaID.equals("filename")) {
String s = null;
try {
s = getTarget().extractPayloadFilename();
} catch (ParseException e) {
logger.warn("Failed to extract filename from content-disposition: "
+ org.openas2.logging.Log.getExceptionMsg(e), e);
}
if (s == null || s.length() < 1)
s = getTarget().getPayloadFilename();
if (s != null && s.length() > 0)
return s;
// If it gets to here then the sender did not send a filename so...
String filename = Properties.getProperty(Properties.AS2_RX_MESSAGE_FILENAME_FALLBACK, null);
if (filename == null)
return getTarget().getMessageID();
else {
CompositeParameters parser = new CompositeParameters(false).add("date", new DateParameters())
.add("msg", new MessageParameters(getTarget())).add("rand", new RandomParameters());
return ParameterParser.parse(filename, parser);
}
} else {
throw new InvalidParameterException("Invalid area in key", this, key, null);
}
}

public void setTarget(Message message) {
target = message;
}

public Message getTarget() {
return target;
}
}
Loading

0 comments on commit df4d72b

Please sign in to comment.