Bugfixes + Security fixes #72

Merged
Maece97 merged 5 commits from dev into main 2021-11-17 17:29:38 +00:00
3 changed files with 22 additions and 9 deletions
Showing only changes of commit 01b5056671 - Show all commits

View File

@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.ConfigurableEnvironment;
import java.net.URI;
import java.util.List;
@ -23,20 +24,19 @@ import java.util.List;
public class TapasAuctionHouseApplication {
private static final Logger LOGGER = LogManager.getLogger(TapasAuctionHouseApplication.class);
@Autowired
private ConfigProperties config;
public static String RESOURCE_DIRECTORY = "https://api.interactions.ics.unisg.ch/auction-houses/";
public static String MQTT_BROKER = "tcp://broker.hivemq.com:1883";
public static String DEFAULT_MQTT_BROKER = "tcp://broker.hivemq.com:1883";
private static ConfigurableEnvironment ENVIRONMENT;
public static void main(String[] args) {
SpringApplication tapasAuctioneerApp = new SpringApplication(TapasAuctionHouseApplication.class);
ENVIRONMENT = tapasAuctioneerApp.run(args).getEnvironment();
// TODO Set start up of message services with config
// We will use these bootstrap methods in Week 6:
bootstrapMarketplaceWithWebSub();
// bootstrapMarketplaceWithWebSub();
bootstrapMarketplaceWithMqtt();
tapasAuctioneerApp.run(args);
}
/**
* Discovers auction houses and subscribes to WebSub notifications
@ -57,8 +57,16 @@ public class TapasAuctionHouseApplication {
*/
private static void bootstrapMarketplaceWithMqtt() {
try {
String broker = ENVIRONMENT.getProperty("mqtt.broker.uri");
if (broker == null) {
broker = DEFAULT_MQTT_BROKER;
LOGGER.info("No MQTT broker was set in application.propreties, going with default: "
+ DEFAULT_MQTT_BROKER);
}
AuctionEventsMqttDispatcher dispatcher = new AuctionEventsMqttDispatcher();
TapasMqttClient client = TapasMqttClient.getInstance(MQTT_BROKER, dispatcher);
TapasMqttClient client = TapasMqttClient.getInstance(broker, dispatcher);
client.startReceivingMessages();
} catch (MqttException e) {
LOGGER.error(e.getMessage(), e);

View File

@ -38,6 +38,7 @@ public class ExternalAuctionStartedEventListenerMqttAdapter extends AuctionEvent
// representation that makes sense in the context of your application.
JsonNode data = new ObjectMapper().readTree(payload);
// TODO Sanitize URIs
String auctionId = data.get("auctionId").asText();
String auctionHouseUri = data.get("auctionHouseUri").asText();
String taskUri = data.get("taskUri").asText();
@ -72,8 +73,12 @@ public class ExternalAuctionStartedEventListenerMqttAdapter extends AuctionEvent
LOGGER.error(e.getMessage(), e);
return false;
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
e.printStackTrace();
} catch (InterruptedException e) {
LOGGER.error(e.getMessage(), e);
e.printStackTrace();
} catch (Exception e){
LOGGER.error(e.getMessage(), e);

View File

@ -10,4 +10,4 @@ tasks.list.uri=http://localhost:8081
application.environment=development
auctionhouse.uri=http://localhost:8086
websub.hub.uri=http://localhost:3000
mqtt.broker.uri=tcp://localhost:1883
mqtt.broker.uri=tcp://broker.hivemq.com:1883