-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b17317
commit 9424530
Showing
4 changed files
with
45 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM adoptopenjdk/maven-openjdk11 | ||
|
||
ENV MAVEN_OPTS -Xms64m -Xmx128m | ||
|
||
RUN mkdir -p /usr/local/src/mvnapp | ||
WORKDIR /usr/local/src/mvnapp | ||
ADD . /usr/local/src/mvnapp | ||
|
||
RUN mvn --settings settings.xml -Dmaven.test.skip=true clean install dependency:copy-dependencies | ||
|
||
WORKDIR /usr/local/src/mvnapp | ||
RUN chmod +x run.sh | ||
|
||
|
||
CMD ./run.sh it.unimore.dipi.openness.consumer.SimpleConsumerTester | ||
|
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,10 @@ | ||
#!/bin/bash | ||
|
||
# Build Classpath | ||
export CLASSPATH="./target/classes" | ||
for file in `ls target/*.jar` ; do export CLASSPATH=$CLASSPATH':'./target/$file; done | ||
for file in `ls target/dependency` ; do export CLASSPATH=$CLASSPATH':'./target/dependency/$file; done | ||
|
||
# Pass all arguments to java run | ||
java -classpath $CLASSPATH "$@" | ||
|
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 |
---|---|---|
|
@@ -9,13 +9,15 @@ | |
import it.unimore.dipi.iot.openness.exception.EdgeApplicationConnectorException; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.methods.CloseableHttpResponse; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.client.HttpClients; | ||
import org.apache.http.util.EntityUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.FileInputStream; | ||
import java.util.Optional; | ||
import java.util.Properties; | ||
|
||
/** | ||
* @author Marco Picone, Ph.D. - [email protected] | ||
|
@@ -26,12 +28,6 @@ public class SimpleConsumerTester { | |
|
||
public static final Logger logger = LoggerFactory.getLogger(SimpleConsumerTester.class); | ||
|
||
private static final String OPENNESS_CONTROLLER_BASE_AUTH_URL = "http://eaa.openness:7080/"; | ||
|
||
private static final String OPENNESS_CONTROLLER_BASE_APP_URL = "https://eaa.openness:7443/"; | ||
|
||
private static final String OPENNESS_CONTROLLER_BASE_APP_WS_URL = "wss://eaa.openness:7443/"; | ||
|
||
private static final String APPLICATION_ID = "opennessConsumerDemo"; | ||
|
||
private static final String NAME_SPACE = "consumerdemo"; | ||
|
@@ -42,16 +38,24 @@ public static void main(String[] args) { | |
|
||
try { | ||
|
||
final String rootPath = Thread.currentThread().getContextClassLoader().getResource("").getPath(); | ||
final String appConfigPath = rootPath + "urls.properties"; | ||
final Properties appProps = new Properties(); | ||
appProps.load(new FileInputStream(appConfigPath)); | ||
final String authUrl = appProps.getProperty("myAuth"); | ||
final String apiUrl = appProps.getProperty("myApi"); | ||
final String wsUrl = appProps.getProperty("myWs"); | ||
|
||
logger.info("Starting Simple Openness Consumer Tester ..."); | ||
|
||
AuthorizedApplicationConfiguration authorizedApplicationConfiguration = handleAuth(); | ||
AuthorizedApplicationConfiguration authorizedApplicationConfiguration = handleAuth(authUrl); | ||
|
||
logger.info("Application Correctly Authenticated ! AppId: {}", authorizedApplicationConfiguration.getApplicationId()); | ||
|
||
EdgeApplicationConnector edgeApplicationConnector = new EdgeApplicationConnector( | ||
OPENNESS_CONTROLLER_BASE_APP_URL, | ||
apiUrl, | ||
authorizedApplicationConfiguration, | ||
OPENNESS_CONTROLLER_BASE_APP_WS_URL); | ||
wsUrl); | ||
|
||
//Activate Notification Channel | ||
ConsumerNotificationsHandler myNotificationsHandler = new ConsumerNotificationsHandler(); | ||
|
@@ -103,11 +107,11 @@ private static void getEvents(final String endpoint) throws EdgeApplicationConne | |
} | ||
} | ||
|
||
private static AuthorizedApplicationConfiguration handleAuth() throws EdgeApplicationAuthenticatorException { | ||
private static AuthorizedApplicationConfiguration handleAuth(final String authUrl) throws EdgeApplicationAuthenticatorException { | ||
|
||
final AuthorizedApplicationConfiguration authorizedApplicationConfiguration; | ||
|
||
final EdgeApplicationAuthenticator edgeApplicationAuthenticator = new EdgeApplicationAuthenticator(OPENNESS_CONTROLLER_BASE_AUTH_URL); | ||
final EdgeApplicationAuthenticator edgeApplicationAuthenticator = new EdgeApplicationAuthenticator(authUrl); | ||
|
||
final Optional<AuthorizedApplicationConfiguration> storedConfiguration = edgeApplicationAuthenticator.loadExistingAuthorizedApplicationConfiguration(APPLICATION_ID, ORG_NAME); | ||
|
||
|
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,3 @@ | ||
myAuth=http://eaa.openness:7080/ | ||
myApi=https://eaa.openness:7443/ | ||
myWs=wss://eaa.openness:7443/ |