Skip to content

Commit

Permalink
release: v5.0.0 (#296)
Browse files Browse the repository at this point in the history
* feat: throw exception and log error if no private key for alias found (#264)

* feat: throw exception and log error if no private key for alias found

* refactor: add used keyalias to printed logs

* feat: check incoming payload for valid json and securityProfile attr (#266)

* feat: check incoming payload for valid json and securityProfile attr

* docs: update changelog

* feat: enable or disable infomodel compatibility check (#267)

* feat: enable or disable infomodel compatibility check via application properties

* chore: fix checkstyle error

* refactor: logs message reason formats (#269)

* build(deps): bump infomodel-artifacts from 4.2.0 to 4.2.1 (#270)

* build(deps): bump infomodel-artifacts from 4.2.0 to 4.2.1

* docs: update readme

* chore: minor javadoc refactoring

* docs: add missing throws to IDSBrokerService javadoc

* refactor: minor log adjustments

* docs: prepare release v4.3.0

* docs: add remaining missing throws and javadoc

* build: pom set version to 4.3.1

* build(deps): bump checkstyle from 8.45.1 to 9.0 (#275)

* build(deps): bump checkstyle from 8.45.1 to 9.0

Bumps [checkstyle](https://github.com/checkstyle/checkstyle) from 8.45.1 to 9.0.
- [Release notes](https://github.com/checkstyle/checkstyle/releases)
- [Commits](checkstyle/checkstyle@checkstyle-8.45.1...checkstyle-9.0)

---
updated-dependencies:
- dependency-name: com.puppycrawl.tools:checkstyle
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* docs: update changelog

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tim Berthold <[email protected]>

* Add new Clearinghouse Endpoint for registering PIDs (#276)

* [CLEARINGHOUSE] #FEAT 'file:ClearingHouseService' {Create method specification for registering PIDs at clearinghouse}

* [CLEARINGHOUSE] #CHORE 'file:ClearingHouseService' {Remove sendlogtoclrearinghouse with random pid generation}

* [CLEARINGHOUSE] #FEAT 'file:ClearingHouseService' {Implement method for sending pid request}

* [CLEARINGHOUSE] #FIX 'file:ClearingHouseService' {Add PID to path, create RequestMessage Template}

* [MESSAGING] #FIX 'file:RequestTemplateProvider' {Fix Checkstyle}

* [CLEARINGHOUSE] #FIX 'file:ClearingHouseService' {Fix Checkstyle}

* [CLEARINGHOUSE] #FEAT 'file:ClearingHouseService' {Make pid registering connectorIDs varargs, allow for arbitrary numbner of connectors sharing a pid}

* refactor: code adjustments

* build: set new version in pom

* docs: update changelog

Co-authored-by: Tim Berthold <[email protected]>
Co-authored-by: Tim Berthold <[email protected]>

* docs: update changelog

* fix: new clearinghouse process endpoint setting

* fix: response codes outside 200-299 provoke IOExceptions (#278)

* fix: response codes outside 200-299 provoke IOExceptions

* docs: update changelog, add links

* refactor: remove not yet supported useIDSCP and useLDP (#279)

* build(deps): bump maven-javadoc-plugin from 3.3.0 to 3.3.1 (#281)

* build(deps): bump maven-javadoc-plugin from 3.3.0 to 3.3.1

Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.3.0 to 3.3.1.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](apache/maven-javadoc-plugin@maven-javadoc-plugin-3.3.0...maven-javadoc-plugin-3.3.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* docs: update changelog

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tim Berthold <[email protected]>

* chore: update infomodel artifacts 4.2.1 -> 4.2.3 (#289)

* chore: update infomodel artifacts 4.2.1 -> 4.2.3

* docs: update changelog

* docs: update readme

* feat: log-debug outgoing messages (#286)

* feat: log-debug outgoing messages

* chore: fix checkstyle

* chore: fix javadoc

* docs: update changelog

* feat: check if keystore-location is null on init (#291)

* feat: check if keystore-location is null on init

* chore: refactor javadoc

* feat: validity check for proxy hostname (#285)

* feat: Proxy-Config, if no hostname set, issue warn message and try sending without proxy

* docs: update changelog

* chore: add check for proxy port

* test: fix ConfigProducerTest testProvider

* chore: update test comment

Co-authored-by: eakker <[email protected]>

* chore: update org.junit.jupiter dependencies (#295)

* chore: update org.junit.jupiter dependencies

* chore: update changelog

* docs: prepare release v5.0.0

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: vdakker <[email protected]>
Co-authored-by: eakker <[email protected]>
  • Loading branch information
4 people authored Sep 14, 2021
1 parent f7fd83d commit 52d2054
Show file tree
Hide file tree
Showing 31 changed files with 257 additions and 357 deletions.
33 changes: 28 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,42 @@
# Changelog
All notable changes to this project will be documented in this file.

## Version [5.0.0] 2021-09-14

### Major Change: ClearingHouse Module - New Endpoint
- The ClearingHouse has a new endpoint, which allows the registration of a freely selectable PID that has not been assigned, whereby the PID access-authorized Connectors (Owners) must be specified as with their IDs in the body. As a result the previous existing functionality of the ClearingHouse module to log a message at the ClearingHouse, where the Messaging-Services randomly generated the PID, was removed (ClearingHouseService sendLogToClearingHouse). The new method is the ClearingHouseService.registerPidAtClearingHouse, which expects as parameters the desired PID and the IDs of the Connectors, which should all be set as Owners for the PID (can also be exactly 1 Connector-Id). ([Issue 259](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/issues/259))

### Patch Change: Enhancements
- For incoming responses to sent requests, an IOException is now no longer thrown for response codes outside 200-299. These responses may also be valid IDS-messages, for example a RejectionMessage with the status BAD_REQUEST. ([Issue 277](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/issues/277))
- If the connector's proxy configuration contains an incorrect empty hostname or proxy, a warning message is now logged and an attempt is made to send the message without this proxy instead of throwing an IllegalArgumentException. ([Issue 285](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/pull/285))
- Due to an incorrect or missing connector configuration it could happen that the location of the KeyStore is null. This is now handled in the form of a KeyStoreManagerInitializationException and log message at KeyStoreManager init. ([Issue 290](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/issues/290))
- Outgoing messages can now be logged in loglevel:debug (requires loglevel-config:debug for IDS-Messaging-Services e.g.: `<Loggername="de.fraunhofer.ids.messaging" level="debug"/>`) . ([Issue 284](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/issues/284))
- Other minor enhancements to existing Javadoc.

### Patch Change: Infomodel Maintenance
- Used Dependency Version: 4.2.3 ([Issue 288](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/issues/288))
- Used Artifacts: java, infomodel-serializer, interaction

### Patch Change: Dependency Maintenance
- Upgrade: com.puppycrawl.tools:checkstyle 8.45.1 -> 9.0 ([PR 275](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/pull/275))
- Upgrade: org.apache.maven.plugins:maven-javadoc-plugin 3.3.0 -> 3.3.1 ([PR 281](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/pull/281))
- Upgrade: org.junit.jupiter:junit-jupiter 5.7.2 -> 5.8.0 ([PR 295](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/pull/295))
- Upgrade: org.junit.jupiter:junit-jupiter-api 5.7.2 -> 5.8.0 ([PR 295](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/pull/295))
- Upgrade: org.junit.jupiter:junit-jupiter-engine 5.7.2 -> 5.8.0 ([PR 295](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/pull/295))

## Version [4.3.0] 2021-08-31

### Minor Change: Incoming message infomodel compatibility check
- The check whether an incoming message is compatible with its ModelVersion to the inbound ModelVersions of the Connector can be switched on or off via application.properties (infomodel.compatibility.validation=true/false). The default value if not set is true (switched on).
- The check whether an incoming message is compatible with its ModelVersion to the inbound ModelVersions of the Connector can be switched on or off via application.properties (infomodel.compatibility.validation=true/false). The default value if not set is true (switched on). ([PR 267](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/pull/267))

### Patch Change: Infomodel Maintenance
- Used Dependency Version: 4.2.1 (released 2021-08-30)
- Used Dependency Version: 4.2.1 (released 2021-08-30) ([Issue 268](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/issues/268))
- Used Artifacts: java, infomodel-serializer, interaction

### Patch Change: Enhancements
- If no private key can be found for a given alias within a keystore, a KeyStoreException is now thrown and an error is logged, preventing an otherwise possible NullpointerException (KeystoreManager getPrivateKeyFromKeyStore).
- The payload of incoming messages is now first validated for valid JSON and whether the securityProfile attribute is present, if not, this check is skipped instead of issuing an error message in the logs (IdsHttpService checkDatFromResponse).
- For log error messages and others important logs with dynamic content, the e.g. exception reason is now highlighted to distinguish it from the rest of the log message. Format: [exception=(...)].
- If no private key can be found for a given alias within a keystore, a KeyStoreException is now thrown and an error is logged, preventing an otherwise possible NullpointerException (KeystoreManager getPrivateKeyFromKeyStore). ([Issue 263](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/issues/263))
- The payload of incoming messages is now first validated for valid JSON and whether the securityProfile attribute is present, if not, this check is skipped instead of issuing an error message in the logs (IdsHttpService checkDatFromResponse). ([PR 266](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/pull/266))
- For log error messages and others important logs with dynamic content, the e.g. exception reason is now highlighted to distinguish it from the rest of the log message. Format: [exception=(...)]. ([PR 269](https://github.com/International-Data-Spaces-Association/IDS-Messaging-Services/pull/269))

### Patch Change: Miscellaneous
- Other minor enhancements to existing Javadoc and log messages.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ The following IDS-Infomodel-Artifacts are used as dependencies.

| Group | Artifact | Version |
| ------ | ------ | ------ |
| de.fraunhofer.iais.eis.ids.infomodel | java | 4.2.1 |
| de.fraunhofer.iais.eis.ids | infomodel-serializer | 4.2.1 |
| de.fraunhofer.iais.eis.ids | interaction | 4.2.1 |
| de.fraunhofer.iais.eis.ids.infomodel | java | 4.2.3 |
| de.fraunhofer.iais.eis.ids | infomodel-serializer | 4.2.3 |
| de.fraunhofer.iais.eis.ids | interaction | 4.2.3 |

## Overview: Supported IDS-Message protocols

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.SecureRandom;
import java.util.Objects;

import de.fraunhofer.iais.eis.Message;
Expand Down Expand Up @@ -48,6 +47,8 @@
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

Expand All @@ -64,11 +65,6 @@ public class ClearingHouseService extends InfrastructureService
*/
private final Serializer serializer = new Serializer();

/**
* SecureRandom function.
*/
private final SecureRandom secureRandom = new SecureRandom();

/**
* The MultipartResponseConverter.
*/
Expand Down Expand Up @@ -108,6 +104,12 @@ public class ClearingHouseService extends InfrastructureService
@Value("${clearinghouse.log.endpoint:/messages/log}")
private String logEndpoint;

/**
* The CH endpoint for creating PIDs.
*/
@Value("${clearinghouse.process.endpoint:/process}")
private String processEndpoint;

/**
* Constructor for the ClearingHouseService.
*
Expand All @@ -132,27 +134,6 @@ public ClearingHouseService(final ConfigContainer container,
this.requestTemplateProvider = requestTemplateProvider;
}

/**
* {@inheritDoc}
*/
@Override
public MessageProcessedNotificationMAP sendLogToClearingHouse(final Message messageToLog)
throws DapsTokenManagerException,
ClaimsException,
MultipartParseException,
URISyntaxException,
IOException,
UnknownResponseException,
DeserializeException,
UnexpectedResponseException,
ShaclValidatorException,
SerializeException {
//log message under some random processId
final var pid = Math.abs(secureRandom.nextInt());

return sendLogToClearingHouse(messageToLog, String.valueOf(pid));
}

/**
* {@inheritDoc}
*/
Expand All @@ -178,7 +159,7 @@ public MessageProcessedNotificationMAP sendLogToClearingHouse(final Message mess
serializer.serialize(messageToLog),
MediaType.parse("application/json"));

//set some random id for message
//set given id for message
final var response = idsHttpService
.sendAndCheckDat(body, new URI(clearingHouseUrl + logEndpoint + "/" + pid));
final var map = multipartResponseConverter.convertResponse(response);
Expand Down Expand Up @@ -236,6 +217,41 @@ public ResultMAP queryClearingHouse(final String pid,

}

/**
* {@inheritDoc}
*/
@Override
public MessageProcessedNotificationMAP registerPidAtClearingHouse(final String pid,
final String... connectorIDs)
throws DapsTokenManagerException,
URISyntaxException,
ClaimsException,
MultipartParseException,
IOException,
UnknownResponseException,
DeserializeException,
UnexpectedResponseException,
ShaclValidatorException,
SerializeException {
//Build request json
final var payload = new JSONObject();
payload.put("owners", new JSONArray(connectorIDs));

//Build IDS Multipart Message
final var body = buildMultipartWithInternalHeaders(
requestTemplateProvider
.requestMessageTemplate().buildMessage(),
payload.toString(),
MediaType.parse("application/json"));

//send message to clearinghouse
final var response = idsHttpService
.sendAndCheckDat(body, new URI(clearingHouseUrl + processEndpoint + "/" + pid));
final var map = multipartResponseConverter.convertResponse(response);

return expectMapOfTypeT(map, MessageProcessedNotificationMAP.class);
}

/**
* @param headerMessage IDS Message used as Header
* @param payloadContent Payload String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,50 +37,11 @@
*/
public interface IDSClearingHouseService {

/**
* Send a LogMessage with some random pid to ClearingHouse.
*
* @param messageToLog Infomodel Message that should be Logged.
* @return Response from ClearingHouse.
* @throws DapsTokenManagerException If no DAT for sending the message could be received.
* @throws URISyntaxException If Clearing House URI can not be parsed from String.
* Check Application Properties!
* @throws IOException If message could not be sent or Serializer could not parse RDF
* to Java Object.
* @throws ClaimsException If DAT of incoming message could not be validated.
* @throws MultipartParseException If response could not be parsed to header and payload.
* @throws ClaimsException Exception while validating the DAT from the Broker Response.
* @throws UnknownResponseException Thrown during converting IDS-Response into a
* corresponding Object if no possible cast found.
* @throws DeserializeException Exception that is thrown if deserializing a message
* threw an IOException
* @throws UnexpectedResponseException Exception that is thrown if the received response-type
* is not expected as a response to the request send.
* @throws SerializeException Exception is thrown if serializing a message threw an IOException.
* @throws ShaclValidatorException SHACL-Validation, received message
* header does not conform to IDS-Infomodel and did not pass SHACL-Validation.
* @throws MessageBuilderException Exception that is thrown if building an IDS-Message with
* the given information threw a RuntimeException.
*/
MessageProcessedNotificationMAP sendLogToClearingHouse(Message messageToLog)
throws
DapsTokenManagerException,
ClaimsException,
MultipartParseException,
URISyntaxException,
IOException,
UnknownResponseException,
DeserializeException,
UnexpectedResponseException,
ShaclValidatorException,
SerializeException,
MessageBuilderException;

/**
* Send a LogMessage with given pid to ClearingHouse.
*
* @param messageToLog Infomodel Message that should be Logged.
* @param pid process id under which the message will be logged.
* @param pid Process id under which the message will be logged.
* @return Response from ClearingHouse.
* @throws DapsTokenManagerException If no DAT for sending the message could be received.
* @throws URISyntaxException If Clearing House URI can not be parsed from String.
Expand Down Expand Up @@ -162,6 +123,48 @@ ResultMAP queryClearingHouse(String pid,
UnknownResponseException,
DeserializeException,
UnexpectedResponseException,
ShaclValidatorException, SerializeException,
ShaclValidatorException,
SerializeException,
MessageBuilderException;

/**
* Register a pid at the clearinghouse for logging usage.
*
* @param pid Pid to register.
* @param connectorIDs IDs the pid is registered for.
* @return Response from clearing house.
* @throws DapsTokenManagerException If no DAT for sending the message could be received.
* @throws URISyntaxException If Clearing House URI can not be parsed from String.
* Check Application Properties!
* @throws IOException If message could not be sent or Serializer could not parse
* RDF to Java Object.
* @throws ClaimsException If DAT of incoming message could not be validated.
* @throws MultipartParseException If response could not be parsed to header and payload.
* @throws ClaimsException Exception while validating the DAT from the Broker Response.
* @throws UnknownResponseException Thrown during converting IDS-Response into a
* corresponding Object if no possible cast found.
* @throws DeserializeException Exception that is thrown if deserializing a message
* threw an IOException.
* @throws UnexpectedResponseException Exception that is thrown if the received
* response-type is not expected as a response to the request send.
* @throws SerializeException Exception is thrown if serializing a message threw an IOException.
* @throws ShaclValidatorException SHACL-Validation, received message header does not
* conform to IDS-Infomodel and did not pass SHACL-Validation.
* @throws MessageBuilderException Exception that is thrown if building an IDS-Message with
* the given information threw a RuntimeException.
*/
MessageProcessedNotificationMAP registerPidAtClearingHouse(String pid,
String... connectorIDs)
throws
DapsTokenManagerException,
URISyntaxException,
ClaimsException,
MultipartParseException,
IOException,
UnknownResponseException,
DeserializeException,
UnexpectedResponseException,
ShaclValidatorException,
SerializeException,
MessageBuilderException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void testSendLogToClearingHouse() throws Exception {
.thenReturn(map);
Mockito.when(multipartResponseConverter.convertResponse(any(Map.class)))
.thenReturn(new MessageProcessedNotificationMAP(message));
final var result = idsClearingHouseService.sendLogToClearingHouse(message);
final var result = idsClearingHouseService.sendLogToClearingHouse(message, "id");
assertNotNull(result.getMessage(), "Method should return a message");
assertEquals(MessageProcessedNotificationMAP.class, result.getClass(), "Method should return MessageProcessedNotificationMessage");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,24 @@ public List<Proxy> select(final URI uri) {
if (log.isDebugEnabled()) {
log.debug("Address: [host=({})], Port: [port=({})]", proxyHost, proxyPort);
}
proxyList.add(new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(proxyHost, proxyPort)));

if (proxyHost == null || proxyHost.trim().equals("")) {
if (log.isWarnEnabled()) {
log.warn("Proxy hostname invalid! Trying to skip using this proxy!"
+ " Please check configuration! [hostname=({})]", proxyHost);
}
proxyList.add(Proxy.NO_PROXY);
} else if (proxyPort == -1) {
if (log.isWarnEnabled()) {
log.warn("Proxy port invalid! Trying to skip using this proxy!"
+ " Please check configuration! [port=({})]", proxyPort);
}
proxyList.add(Proxy.NO_PROXY);
} else {
proxyList.add(new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(proxyHost, proxyPort)));
}

}
return proxyList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ private KeyStore loadKeyStore(final char[] pw, final URI location, final String
NoSuchAlgorithmException,
IOException,
KeyStoreManagerInitializationException {

validateLocation(location, keyStoreType);

if (log.isDebugEnabled()) {
log.debug("Searching for keystore file. [location=({})]", location.toString());
}
Expand Down Expand Up @@ -320,6 +323,26 @@ private KeyStore loadKeyStore(final char[] pw, final URI location, final String
return store;
}

/**
* Checks whether the keystore path specification is set in the connector configuration.
*
* @param location The keystore path.
* @param keyStoreType Indication whether it is keystore or truststore.
* @throws KeyStoreManagerInitializationException Thrown if location specification is not set.
*/
private void validateLocation(final URI location, final String keyStoreType)
throws KeyStoreManagerInitializationException {
if (location == null) {
if (log.isErrorEnabled()) {
log.error("Location input for keystore-path from connector configuration"
+ " is not valid!"
+ " [type=({}), location=(null)]", keyStoreType);
}
throw new KeyStoreManagerInitializationException(
"Location input for keystore-path is null! Type: " + keyStoreType);
}
}

@Nullable
private KeyStore getKeyStoreInstance() {
KeyStore store = null;
Expand Down
Loading

0 comments on commit 52d2054

Please sign in to comment.