Skip to content

Commit

Permalink
Readme, AppsView and AppsViewTest fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Finevman committed Sep 27, 2023
1 parent 66578c3 commit daa4de4
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 153 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ java -jar target/privacydashboard-1.0-SNAPSHOT.jar

You can also run the program by typing in the IDE terminal the `mvn` command.

Once the application is running, it can be found at the url `localhost:8080`.

## Project structure

- `MainLayout.java` in `src/main/java` contains the navigation setup (i.e., the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,79 +87,75 @@ public class AppsView extends Div implements AfterNavigationObserver, BeforeEnte
private IoTApp priorityApp;


private List<IoTApp> getJsonAppsFromUrl(){
private List<IoTApp> getJsonAppsFromUrl() throws NullPointerException {

TrustManager[] dummyTrustManager = new TrustManager[] { new X509TrustManager() {
TrustManager[] dummyTrustManager = new TrustManager[] { new X509TrustManager() {

public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}

public void checkClientTrusted(X509Certificate[] certs, String authType) {
}

public void checkServerTrusted(X509Certificate[] certs, String authType) {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}

public void checkClientTrusted(X509Certificate[] certs, String authType) {
}

public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}
}

};
};

String responseString = "";

try{
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, dummyTrustManager, new java.security.SecureRandom());
URL url = new URL("https://yggio.sifis-home.eu:3000/dht-insecure/topic_name/SIFIS:container_list");
String responseString = "";
try{
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, dummyTrustManager, new java.security.SecureRandom());
URL url = new URL("https://yggio.sifis-home.eu:3000/dht-insecure/topic_name/SIFIS:container_list");

HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();

if(responseCode == HttpsURLConnection.HTTP_OK){
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();

if(responseCode == HttpsURLConnection.HTTP_OK){
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();

while((inputLine = in.readLine()) != null){
response.append(inputLine);
}
in.close();
while((inputLine = in.readLine()) != null){
response.append(inputLine);
}
in.close();

responseString = response.toString().substring(response.toString().indexOf("[")+1, response.toString().lastIndexOf("]"));
responseString = response.toString().substring(response.toString().indexOf("[")+1, response.toString().lastIndexOf("]"));

}
else{
System.out.println("GET Request failed");
}
}
else{
System.out.println("GET Request failed");
}


JsonNode json = new ObjectMapper().readTree(new StringReader(responseString));
json = json.get("value");
int size = json.get("containers").size();
IoTApp[] appArray = new IoTApp[size];

for(int i = 0; i < size; i++){
IoTApp app = new IoTApp();
app.setName(json.get("containers").elements().next().asText());
app.setId(new UUID(0, app.getName().hashCode()));
appArray[i] = app;

JsonNode json = new ObjectMapper().readTree(new StringReader(responseString));
json = json.get("value");
int size = json.get("containers").size();
IoTApp[] appArray = new IoTApp[size];

for(int i = 0; i < size; i++){
IoTApp app = new IoTApp();
app.setName(json.get("containers").elements().next().asText());
app.setId(new UUID(0, app.getName().hashCode()));
appArray[i] = app;
}

List<IoTApp> apps = List.of(appArray);
return apps;
}
/*
IoTApp app = new IoTApp();
app.setName("TestApp");
appArray[size] = app;
*/
List<IoTApp> apps = List.of(appArray);
return apps;
catch(Exception e){
System.out.println("JsonFromUrl Exception: "+e.getMessage());
throw new NullPointerException(e.getMessage());
}
}
catch(Exception e){
System.out.println("JsonFromUrl Exception: "+e.getMessage());
}
return null;
}

private String cleanAppName(String name){
String newName = name.split("3pa-")[1].split("-")[0];
Expand All @@ -185,13 +181,18 @@ public AppsView(DataBaseService dataBaseService, AuthenticatedUser authenticated
initializeSearchText();
initializeGrid();

VerticalLayout appLayout = new VerticalLayout();
List<IoTApp> apps = getJsonAppsFromUrl();
for (IoTApp app : apps) {
appLayout.add(createApp(app));
try{
VerticalLayout appLayout = new VerticalLayout();
List<IoTApp> apps = getJsonAppsFromUrl();
for (IoTApp app : apps) {
appLayout.add(createApp(app));
}

add(summaryEvaluation, searchText, appLayout, grid);
}
catch(Exception e){
add(summaryEvaluation, searchText, grid);
}

add(summaryEvaluation, searchText, appLayout, grid);
}

private void initilizeInfrastuctureEvaluation(){
Expand Down
Loading

0 comments on commit daa4de4

Please sign in to comment.