From ac4544b422531098a072f45c6b1592c6cb294307 Mon Sep 17 00:00:00 2001 From: Nomcabango <137044128+Nomcabango@users.noreply.github.com> Date: Tue, 27 Jun 2023 07:20:56 +0000 Subject: [PATCH 01/32] change on login label --- src/main/webapp/login.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/login.xhtml b/src/main/webapp/login.xhtml index b6ec4b7..2732892 100644 --- a/src/main/webapp/login.xhtml +++ b/src/main/webapp/login.xhtml @@ -35,7 +35,7 @@
- Username ID + login Password From 564584a37e7623db292bb786614300840ee89776 Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Fri, 7 Jul 2023 15:24:02 +1200 Subject: [PATCH 02/32] fixes to code format added TOC to readme improves readibility --- README.md | 20 +++- src/main/java/bean/AttendanceRegister.java | 23 +++-- src/main/java/bean/Main.java | 33 +++---- src/main/java/bean/MainMenu.java | 1 - src/main/java/bean/UserBean.java | 21 ++-- src/main/webapp/login.xhtml | 110 ++++++++++----------- 6 files changed, 111 insertions(+), 97 deletions(-) diff --git a/README.md b/README.md index ba0f356..7ac018d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ +- [Attendance WebApp](#attendance-webapp) + - [Introduction](#introduction) + - [Attendance WebApp Architecture (re-architected)](#attendance-webapp-architecture-re-architected) + - [2018-Attendance WebApp high level Architecture](#2018-attendance-webapp-high-level-architecture) + - [Attendance WebApp UI](#attendance-webapp-ui) + - [Refer to the Wiki for details on the project](#refer-to-the-wiki-for-details-on-the-project) +- [Project general guidelines](#project-general-guidelines) +- [Build and Test](#build-and-test) + - [Maven](#maven) + - [Run the maven build Locally](#run-the-maven-build-locally) + - [Build using maven docker container](#build-using-maven-docker-container) + - [GitHub Vulnerability report](#github-vulnerability-report) + # Attendance WebApp -# Introduction +## Introduction Attendance WebApp is a proof of concept to improve the way attendance is managed at AUT university. @@ -9,15 +22,14 @@ The idea is that you have a short timeframe to submit a random generated code by The application is a proof of concept for Service orientation and Service interoperability in the cloud -> ## Security Warning - +> Security Warning GitHub found 2 vulnerabilities on aleon1220/multi-cloud-WebApp-Attendance's default branch (2 moderate). To find out more, visit: [This project security report](https://github.com/aleon1220/multi-cloud-WebApp-Attendance/security) ## Attendance WebApp Architecture (re-architected) -since this is a 2018 project a lot of things need to change +2018 project with a lot of things to change * Simplification of used services * Streamline app to use 100% rest and deprecate SOAP and WSDL diff --git a/src/main/java/bean/AttendanceRegister.java b/src/main/java/bean/AttendanceRegister.java index c5ae78f..f53a98b 100644 --- a/src/main/java/bean/AttendanceRegister.java +++ b/src/main/java/bean/AttendanceRegister.java @@ -1,7 +1,7 @@ - /** - * Class AttendanceRegister - * sends invocation to webservice for confirmation of attendance. Includes prime faces UI functionality. - */ +/** + * Class AttendanceRegister + * sends invocation to webservice for confirmation of attendance. Includes prime faces UI functionality. + */ package bean; @@ -38,7 +38,8 @@ public String confirmAttendance() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); - WebResource webResource = client.resource(UriBuilder.fromUri("https://xgdeevdwh1.execute-api.us-east-1.amazonaws.com").path("addAttendance").build()); + WebResource webResource = client.resource(UriBuilder + .fromUri("https://xgdeevdwh1.execute-api.us-east-1.amazonaws.com").path("addAttendance").build()); // Passing parameters // {"studentId": "246810","paperId": "COMP101","status": "present"} @@ -52,11 +53,15 @@ public String confirmAttendance() { jsonPayLoad.addProperty("paperId", "COMP101"); jsonPayLoad.addProperty("status", "present"); - //ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).header("Authorization", token).post(ClientResponse.class, jsonPayLoad.toString()); - ClientResponse response = webResource.header("Authorization", token).post(ClientResponse.class, jsonPayLoad.toString()); - // + // ClientResponse response = + // webResource.accept(MediaType.APPLICATION_JSON).header("Authorization", + // token).post(ClientResponse.class, jsonPayLoad.toString()); + ClientResponse response = webResource.header("Authorization", token).post(ClientResponse.class, + jsonPayLoad.toString()); replyFromMS = response.getEntity(String.class); - //String replyFromMS = webResource.path("addAttendance").accept(MediaType.APPLICATION_JSON).header("Authorization", token).post(String.class, jsonPayLoad.toString()); + // String replyFromMS = + // webResource.path("addAttendance").accept(MediaType.APPLICATION_JSON).header("Authorization", + // token).post(String.class, jsonPayLoad.toString()); System.out.println("AttendanceRegisterResponse:" + response); diff --git a/src/main/java/bean/Main.java b/src/main/java/bean/Main.java index a4196b8..9b4379d 100644 --- a/src/main/java/bean/Main.java +++ b/src/main/java/bean/Main.java @@ -1,8 +1,8 @@ - /** - * Class Main connects to main.xhtml - * calls Web services to obtain data from random Free services online - * obtains IP and Random Bible Verse - */ +/** + * Class Main connects to main.xhtml + * calls Web services to obtain data from random Free services online + * obtains IP and Random Bible Verse + */ package bean; @@ -11,24 +11,24 @@ import javax.faces.bean.SessionScoped; import service.MainService; - + @ManagedBean(name = "main") @SessionScoped -public class Main{ - +public class Main { + private String bibleVerse; private String linkedPage; private String geoIpWS; - + @PostConstruct public void init() { - MainService invoker = new MainService(); - //invoke services + MainService invoker = new MainService(); + // invoke web services setGeoIpWS(invoker.invokeWSDLForIP()); setBibleVerse(invoker.invokeRestForBibleVerse()); } - + public String getGeoIpWS() { return geoIpWS; } @@ -48,15 +48,14 @@ public void setBibleVerse(String bibleVerse) { public void setLinkedPage(String linkedPage) { this.linkedPage = linkedPage; } - + public String getlinkedPage() { - if (linkedPage=="1") { - + if (linkedPage == "1") { linkedPage = "attendance"; - System.out.println("this block page is-->"+linkedPage); + System.out.println("this block page is-->" + linkedPage); } else { linkedPage = "registerAttendance"; - System.out.println("this else block page is-->"+linkedPage); + System.out.println("this else block page is-->" + linkedPage); } return linkedPage; } diff --git a/src/main/java/bean/MainMenu.java b/src/main/java/bean/MainMenu.java index 001e728..15234f1 100644 --- a/src/main/java/bean/MainMenu.java +++ b/src/main/java/bean/MainMenu.java @@ -20,7 +20,6 @@ public void setLinkedPage(String linkedPage) { public String getlinkedPage() { if (linkedPage=="1") { - linkedPage = "attendance"; System.out.println("this page is-->"+linkedPage); } else { diff --git a/src/main/java/bean/UserBean.java b/src/main/java/bean/UserBean.java index 9ac9a19..bfad57a 100644 --- a/src/main/java/bean/UserBean.java +++ b/src/main/java/bean/UserBean.java @@ -1,7 +1,7 @@ - /** - * Class UserBean performs specialized login - * contains attributes of user object and performs login calling service objects and functionalities - */ +/** + * Class UserBean performs specialized login + * contains attributes of user object and performs login calling service objects and functionalities + */ package bean; @@ -30,19 +30,18 @@ public class UserBean { private String idToken; private String refreshToken; private String tokenType; - + // Login Method public String login() { try { UserService userService = new UserService(); - //System.out.println("userBean: print the name to see if it got it: "+getId()); - + // System.out.println("userBean: print the name to see if it got it: "+getId()); String IdToken = userService.obtainIdToken(getId(), getPassword()); - //System.out.println("IdToken in UserBean: " + IdToken); - //System.out.println("UserBean checking value of response before if"); + // System.out.println("IdToken in UserBean: " + IdToken); + // System.out.println("UserBean checking value of response before if"); if (userService.createSession(IdToken).equals("ok")) { - + setAccessToken(userService.getAccessToken()); setExpiresIn(userService.getExpiresIn().toString()); setIdToken(userService.getIdToken()); @@ -62,7 +61,7 @@ public String login() { System.out.println("UserBean. inside exception catch."); return "loginError"; } - }// end of login method + }// end of login method public String getAccessToken() { return accessToken; diff --git a/src/main/webapp/login.xhtml b/src/main/webapp/login.xhtml index b6ec4b7..f0d2ead 100644 --- a/src/main/webapp/login.xhtml +++ b/src/main/webapp/login.xhtml @@ -1,63 +1,63 @@ - - + + Login Attendance System + - - - - - - - - - - - - - - - - - - Login -

Attendance System

- - AUT Attendance - -
- - Username ID - - Password - - -
- -
-
- -
-
-
-
-
-

- Info: - Enter Username and password -

-
-
-
- -
+ + + + + + + + + + + + + + + + + + Login +

Attendance System

+ AUT Attendance +
+ + Username ID + + Password + + +
+ +
+
+ +
+
+
+
+
+

+ Info: - Enter Username and password +

+
+
+
+ +
- + + \ No newline at end of file From 4f7757bc9fe63b6f81cd6b93e4fc5b13323cc2ea Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Mon, 10 Jul 2023 21:26:31 +1200 Subject: [PATCH 03/32] Java Formatted Code --- src/main/webapp/login.xhtml | 63 ++++++++++++++++ src/test/attendance/login/TestLogin.java | 6 +- .../student/StudentAuthenticationResult.java | 13 ++-- .../student/StudentAuthorization.java | 4 +- src/test/json/ConversionJson2Map.java | 5 +- src/test/json/JSON2Object.java | 4 - src/test/json/Json2Map.java | 1 - src/test/restclient/JerseyClient.java | 3 +- src/test/restclient/JerseyClientPost.java | 4 +- src/test/restclient/JerseyJsonResponse.java | 13 ++-- src/test/restclient/TestJSONResponse.java | 69 ++++++++--------- src/test/restclient/TestRestClient.java | 6 +- src/test/ux/AttendanceGenerateTest.java | 3 +- src/test/wsclient/GeoIP.java | 74 ++++++++++--------- src/test/wsclient/GeoIPService.java | 28 +++---- src/test/wsclient/GeoIPServiceSoap.java | 25 +++---- src/test/wsclient/GetGeoIP.java | 30 ++++---- .../wsclient/GetGeoIPContextResponse.java | 33 +++++---- src/test/wsclient/GetGeoIPResponse.java | 32 ++++---- src/test/wsclient/ObjectFactory.java | 33 +++++---- src/test/wsdl/ServiceInvokationTest.java | 14 ++-- 21 files changed, 261 insertions(+), 202 deletions(-) create mode 100644 src/main/webapp/login.xhtml diff --git a/src/main/webapp/login.xhtml b/src/main/webapp/login.xhtml new file mode 100644 index 0000000..d8b27b9 --- /dev/null +++ b/src/main/webapp/login.xhtml @@ -0,0 +1,63 @@ + + + + + Login Attendance System + + + + + + + + + + + + + + + + + + + + + + Login +

University Attendance System

+ + Attendance + +
+ + Username ID + + Passcode + + +
+ +
+
+ +
+
+
+
+
+

+ Info: - Enter Username - password +

+
+
+
+
+ + + \ No newline at end of file diff --git a/src/test/attendance/login/TestLogin.java b/src/test/attendance/login/TestLogin.java index 7fb1c58..d078644 100644 --- a/src/test/attendance/login/TestLogin.java +++ b/src/test/attendance/login/TestLogin.java @@ -10,7 +10,7 @@ public class TestLogin { @Test public void GetToken() { - //fail("Not yet implemented"); + // fail("Not yet implemented"); } @Test @@ -18,8 +18,8 @@ public void loginGeneralUser() { UserBean user = new UserBean(); user.setId("10295765"); user.setPassword("Value!12"); - //System.out.println("assert result"+user.login()); - assertTrue(user.login()=="main"); + // System.out.println("assert result"+user.login()); + assertTrue(user.login() == "main"); } public void loginGeneralUserNOK() { diff --git a/src/test/attendance/student/StudentAuthenticationResult.java b/src/test/attendance/student/StudentAuthenticationResult.java index 03b2f41..2a29d77 100644 --- a/src/test/attendance/student/StudentAuthenticationResult.java +++ b/src/test/attendance/student/StudentAuthenticationResult.java @@ -4,7 +4,8 @@ public class StudentAuthenticationResult { - public StudentAuthenticationResult(String accessToken, Integer expiresIn, String tokenType, String refreshToken, String idToken) { + public StudentAuthenticationResult(String accessToken, Integer expiresIn, String tokenType, String refreshToken, + String idToken) { this.accessToken = accessToken; this.expiresIn = expiresIn; this.tokenType = tokenType; @@ -14,19 +15,19 @@ public StudentAuthenticationResult(String accessToken, Integer expiresIn, String @SerializedName("AccessToken") private String accessToken; - + @SerializedName("ExpiresIn") private Integer expiresIn; - + @SerializedName("TokenType") private String tokenType; - + @SerializedName("RefreshToken") private String refreshToken; - + @SerializedName("IdToken") private String idToken; - + // Setters and getters public String getAccessToken() { diff --git a/src/test/attendance/student/StudentAuthorization.java b/src/test/attendance/student/StudentAuthorization.java index 01d3593..d4df42b 100644 --- a/src/test/attendance/student/StudentAuthorization.java +++ b/src/test/attendance/student/StudentAuthorization.java @@ -1,6 +1,4 @@ -/*---------------------------------- com.leo.json.Authorization.java ---------------------------------- */ - -package attendance.gson; +package test.student; import com.google.gson.annotations.SerializedName; diff --git a/src/test/json/ConversionJson2Map.java b/src/test/json/ConversionJson2Map.java index 106862d..e6f491d 100644 --- a/src/test/json/ConversionJson2Map.java +++ b/src/test/json/ConversionJson2Map.java @@ -22,8 +22,9 @@ public static void main(String[] args) { Map retMap = new Gson().fromJson(jsonFromMS, new TypeToken>() { }.getType()); - Map map = new Gson().fromJson(jsonFromMS, new TypeToken>() { - }.getType()); + Map map = new Gson().fromJson(jsonFromMS, + new TypeToken>() { + }.getType()); System.out.println("Printing Map object: " + authorizationMap.values().toString()); diff --git a/src/test/json/JSON2Object.java b/src/test/json/JSON2Object.java index 2b50e7e..9f46c05 100644 --- a/src/test/json/JSON2Object.java +++ b/src/test/json/JSON2Object.java @@ -5,12 +5,8 @@ public class JSON2Object { public static void main(String[] args) { - // TODO Auto-generated method stub - String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1MTc5MyIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.ZGB_kCYoU4vDREr6teZQyIyRT2MZkpmGyleAgsgzMRIauq7RpqgL_HUZukqSK6E5mtNxux6hihzl5CaP9jcY26u4zJTnYASBJwE4iqqggNqhp82PtFdxipf5ZvYAyF3uVTPCeiRGrxJSyoQpEWVUPDYaqj1ak1b2oTExH8sG1oOmYcaACAWY4mkjueFJCrgcWov3SyWDyMKCE7ZhaloJkcJ2uZypztB42XQ67z96bxTvRozzEVEVT4_4szpMjEj3Nmxy9kIv8H7kNMUrb5tE4vTfG-kzctCq7YxU2FfJhDTR_feoRohcjWZp-Zyl2BYFjNXl42ZZEk-TlLHov73izA\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NTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.gGcx2YYcjWzNvzlpPklry4Jt59GwDQuDRRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; - String jsonInString = "{'name' : 'martina perumal'}"; - Gson gson = new Gson(); // Restaurant restaurantObject = gson.fromJson(restaurantJson, diff --git a/src/test/json/Json2Map.java b/src/test/json/Json2Map.java index cf80674..edeade6 100644 --- a/src/test/json/Json2Map.java +++ b/src/test/json/Json2Map.java @@ -15,7 +15,6 @@ public static void main(String[] args) { Type authorization = new TypeToken>() { }.getType(); - // TODO Auto-generated method stub Map authorizationMap = gson.fromJson(jsonFromMS, authorization); diff --git a/src/test/restclient/JerseyClient.java b/src/test/restclient/JerseyClient.java index eb99c52..46fb03e 100644 --- a/src/test/restclient/JerseyClient.java +++ b/src/test/restclient/JerseyClient.java @@ -19,8 +19,7 @@ public class JerseyClient { public void obtainJSONResponse() throws ClientProtocolException, IOException { - // invoking REST service with GET Method - + // Invoke REST service with GET Method ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); diff --git a/src/test/restclient/JerseyClientPost.java b/src/test/restclient/JerseyClientPost.java index 8c36562..4b58e7f 100644 --- a/src/test/restclient/JerseyClientPost.java +++ b/src/test/restclient/JerseyClientPost.java @@ -9,10 +9,8 @@ public class JerseyClientPost { public static void main(String[] args) { try { - Client client = Client.create(); - WebResource webResource = client - .resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + WebResource webResource = client.resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); diff --git a/src/test/restclient/JerseyJsonResponse.java b/src/test/restclient/JerseyJsonResponse.java index f04a585..9521ae6 100644 --- a/src/test/restclient/JerseyJsonResponse.java +++ b/src/test/restclient/JerseyJsonResponse.java @@ -5,9 +5,8 @@ import com.sun.jersey.api.client.WebResource; public class JerseyJsonResponse { - - public static void main(String[] args) { + public static void main(String[] args) { try { String baseuri = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login/"; Client client = Client.create(); @@ -17,11 +16,12 @@ public static void main(String[] args) { String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; // POST method - ClientResponse response = webResource.accept("application/json").type("application/json").post(ClientResponse.class, input); + ClientResponse response = webResource.accept("application/json").type("type:application/json") + .post(ClientResponse.class, input); // check response status code if (response.getStatus() != 200) { - throw new RuntimeException("Failed : HTTP error code : "+ response.getStatus()); + throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } // display response @@ -32,8 +32,5 @@ public static void main(String[] args) { e.printStackTrace(); } - } - + } // main() } - - diff --git a/src/test/restclient/TestJSONResponse.java b/src/test/restclient/TestJSONResponse.java index 46de1f6..fec4be0 100644 --- a/src/test/restclient/TestJSONResponse.java +++ b/src/test/restclient/TestJSONResponse.java @@ -14,48 +14,49 @@ public class TestJSONResponse { public static void main(String[] args) throws MalformedURLException { - //URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); - //URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - - //try (InputStream is = url.openStream(); JsonParser parser = Json.createParser(is)) { + // URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); + // URL url = new + // URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + + // try (InputStream is = url.openStream(); JsonParser parser = + // Json.createParser(is)) { try { - URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - OutputStream os = conn.getOutputStream(); - // 1.The client sends their credentials (username and password) to the server. - os.write(input.getBytes()); - os.flush(); - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - JsonParser parser = (JsonParser) Json.createReader(br); - + URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + OutputStream os = conn.getOutputStream(); + // 1.The client sends their credentials (username and password) to the server. + os.write(input.getBytes()); + os.flush(); + + BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); + + JsonParser parser = (JsonParser) Json.createReader(br); + while (parser.hasNext()) { Event e = parser.next(); if (e == Event.KEY_NAME) { switch (parser.getString()) { - case "RefreshToken": - parser.next(); - System.out.print(parser.getString()); - System.out.print(": "); - break; - case "IdToken": - parser.next(); - System.out.println(parser.getString()); - System.out.println("---------"); - break; + case "RefreshToken": + parser.next(); + System.out.print(parser.getString()); + System.out.print(": "); + break; + case "IdToken": + parser.next(); + System.out.println(parser.getString()); + System.out.println("---------"); + break; } } } - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } } } diff --git a/src/test/restclient/TestRestClient.java b/src/test/restclient/TestRestClient.java index db047ad..342011d 100644 --- a/src/test/restclient/TestRestClient.java +++ b/src/test/restclient/TestRestClient.java @@ -5,9 +5,9 @@ import com.sun.jersey.api.client.WebResource; public class TestRestClient { - string AWS_URL="https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"; + string AWS_URL = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"; - public void cheackServerAvailable(){ + public void checkServiceAvailability() { } @@ -16,7 +16,7 @@ public void testAWSConnectAPI() { try { Client client = Client.create(); - WebResource webResource = client.resource(+ AWS_URL); + WebResource webResource = client.resource(+AWS_URL); String input = "{\"id\":\"10295765\",\"password\":\"TestPassword!12\"}"; ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); diff --git a/src/test/ux/AttendanceGenerateTest.java b/src/test/ux/AttendanceGenerateTest.java index 426478a..df73971 100644 --- a/src/test/ux/AttendanceGenerateTest.java +++ b/src/test/ux/AttendanceGenerateTest.java @@ -10,6 +10,5 @@ public class AttendanceGenerateTest { public void testRandomCode() { AttendanceBean at = new AttendanceBean(); assertNotNull("data", at.generateAttendanceCode()); - } - + } // testRandomCode() } diff --git a/src/test/wsclient/GeoIP.java b/src/test/wsclient/GeoIP.java index 0e9bf9a..1e66ceb 100644 --- a/src/test/wsclient/GeoIP.java +++ b/src/test/wsclient/GeoIP.java @@ -1,7 +1,7 @@ - /** - * Class GeoIP imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ +/** + * Class GeoIP imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ package wsclient; @@ -10,11 +10,13 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; - /** - *

Java class for GeoIP complex type. + *

+ * Java class for GeoIP complex type. * - *

The following schema fragment specifies the expected content contained within this class. + *

+ * The following schema fragment specifies the expected content contained within + * this class. * *

  * <complexType name="GeoIP">
@@ -36,11 +38,11 @@
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "GeoIP", propOrder = {
-    "returnCode",
-    "ip",
-    "returnCodeDetails",
-    "countryName",
-    "countryCode"
+        "returnCode",
+        "ip",
+        "returnCodeDetails",
+        "countryName",
+        "countryCode"
 })
 public class GeoIP {
 
@@ -75,9 +77,9 @@ public void setReturnCode(int value) {
      * Gets the value of the ip property.
      * 
      * @return
-     *     possible object is
-     *     {@link String }
-     *     
+     *         possible object is
+     *         {@link String }
+     * 
      */
     public String getIP() {
         return ip;
@@ -87,9 +89,9 @@ public String getIP() {
      * Sets the value of the ip property.
      * 
      * @param value
-     *     allowed object is
-     *     {@link String }
-     *     
+     *              allowed object is
+     *              {@link String }
+     * 
      */
     public void setIP(String value) {
         this.ip = value;
@@ -99,9 +101,9 @@ public void setIP(String value) {
      * Gets the value of the returnCodeDetails property.
      * 
      * @return
-     *     possible object is
-     *     {@link String }
-     *     
+     *         possible object is
+     *         {@link String }
+     * 
      */
     public String getReturnCodeDetails() {
         return returnCodeDetails;
@@ -111,9 +113,9 @@ public String getReturnCodeDetails() {
      * Sets the value of the returnCodeDetails property.
      * 
      * @param value
-     *     allowed object is
-     *     {@link String }
-     *     
+     *              allowed object is
+     *              {@link String }
+     * 
      */
     public void setReturnCodeDetails(String value) {
         this.returnCodeDetails = value;
@@ -123,9 +125,9 @@ public void setReturnCodeDetails(String value) {
      * Gets the value of the countryName property.
      * 
      * @return
-     *     possible object is
-     *     {@link String }
-     *     
+     *         possible object is
+     *         {@link String }
+     * 
      */
     public String getCountryName() {
         return countryName;
@@ -135,9 +137,9 @@ public String getCountryName() {
      * Sets the value of the countryName property.
      * 
      * @param value
-     *     allowed object is
-     *     {@link String }
-     *     
+     *              allowed object is
+     *              {@link String }
+     * 
      */
     public void setCountryName(String value) {
         this.countryName = value;
@@ -147,9 +149,9 @@ public void setCountryName(String value) {
      * Gets the value of the countryCode property.
      * 
      * @return
-     *     possible object is
-     *     {@link String }
-     *     
+     *         possible object is
+     *         {@link String }
+     * 
      */
     public String getCountryCode() {
         return countryCode;
@@ -159,9 +161,9 @@ public String getCountryCode() {
      * Sets the value of the countryCode property.
      * 
      * @param value
-     *     allowed object is
-     *     {@link String }
-     *     
+     *              allowed object is
+     *              {@link String }
+     * 
      */
     public void setCountryCode(String value) {
         this.countryCode = value;
diff --git a/src/test/wsclient/GeoIPService.java b/src/test/wsclient/GeoIPService.java
index b3eecd0..7771643 100644
--- a/src/test/wsclient/GeoIPService.java
+++ b/src/test/wsclient/GeoIPService.java
@@ -1,7 +1,7 @@
-   /**
-    * Class GeoIPService imported from WSDL with java tool 
-    * replicates WSDL to invoke External Web service
-    */
+/**
+ * Class GeoIPService imported from WSDL with java tool 
+ * replicates WSDL to invoke External Web service
+ */
 
 package wsclient;
 
@@ -14,7 +14,6 @@
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.WebServiceFeature;
 
-
 /**
  * This class was generated by the JAX-WS RI.
  * JAX-WS RI 2.2.9-b130926.1035
@@ -23,8 +22,7 @@
  */
 @WebServiceClient(name = "GeoIPService", targetNamespace = "http://www.webservicex.net/", wsdlLocation = "http://www.webservicex.net/geoipservice.asmx?WSDL")
 public class GeoIPService
-    extends Service
-{
+        extends Service {
 
     private final static URL GEOIPSERVICE_WSDL_LOCATION;
     private final static WebServiceException GEOIPSERVICE_EXCEPTION;
@@ -67,9 +65,8 @@ public GeoIPService(URL wsdlLocation, QName serviceName, WebServiceFeature... fe
     }
 
     /**
-     * 
      * @return
-     *     returns GeoIPServiceSoap
+     *         returns GeoIPServiceSoap
      */
     @WebEndpoint(name = "GeoIPServiceSoap")
     public GeoIPServiceSoap getGeoIPServiceSoap() {
@@ -79,20 +76,23 @@ public GeoIPServiceSoap getGeoIPServiceSoap() {
     /**
      * 
      * @param features
-     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the features parameter will have their default values.
+     *                 A list of {@link javax.xml.ws.WebServiceFeature} to configure
+     *                 on the proxy. Supported features not in the
+     *                 features parameter will have their default
+     *                 values.
      * @return
-     *     returns GeoIPServiceSoap
+     *         returns GeoIPServiceSoap
      */
     @WebEndpoint(name = "GeoIPServiceSoap")
     public GeoIPServiceSoap getGeoIPServiceSoap(WebServiceFeature... features) {
-        return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class, features);
+        return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class,
+                features);
     }
 
     private static URL __getWsdlLocation() {
-        if (GEOIPSERVICE_EXCEPTION!= null) {
+        if (GEOIPSERVICE_EXCEPTION != null) {
             throw GEOIPSERVICE_EXCEPTION;
         }
         return GEOIPSERVICE_WSDL_LOCATION;
     }
-
 }
diff --git a/src/test/wsclient/GeoIPServiceSoap.java b/src/test/wsclient/GeoIPServiceSoap.java
index af50614..22a84bb 100644
--- a/src/test/wsclient/GeoIPServiceSoap.java
+++ b/src/test/wsclient/GeoIPServiceSoap.java
@@ -1,7 +1,7 @@
-   /**
-    * Class GeoIPServiceSoap imported from WSDL with java tool 
-    * replicates WSDL to invoke External Web service
-    */
+/**
+ * Class GeoIPServiceSoap imported from WSDL with java tool 
+ * replicates WSDL to invoke External Web service
+ */
 
 package wsclient;
 
@@ -13,7 +13,6 @@
 import javax.xml.ws.RequestWrapper;
 import javax.xml.ws.ResponseWrapper;
 
-
 /**
  * This class was generated by the JAX-WS RI.
  * JAX-WS RI 2.2.9-b130926.1035
@@ -22,35 +21,35 @@
  */
 @WebService(name = "GeoIPServiceSoap", targetNamespace = "http://www.webservicex.net/")
 @XmlSeeAlso({
-    ObjectFactory.class
+        ObjectFactory.class
 })
 public interface GeoIPServiceSoap {
 
     /**
-     * GeoIPService - GetGeoIP enables you to easily look up countries by IP addresses
+     * GeoIPService - GetGeoIP enables you to easily look up countries by IP
+     * addresses
      * 
      * @param ipAddress
      * @return
-     *     returns wsclient.GeoIP
+     *         returns wsclient.GeoIP
      */
     @WebMethod(operationName = "GetGeoIP", action = "http://www.webservicex.net/GetGeoIP")
     @WebResult(name = "GetGeoIPResult", targetNamespace = "http://www.webservicex.net/")
     @RequestWrapper(localName = "GetGeoIP", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIP")
     @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPResponse")
     public GeoIP getGeoIP(
-        @WebParam(name = "IPAddress", targetNamespace = "http://www.webservicex.net/")
-        String ipAddress);
+            @WebParam(name = "IPAddress", targetNamespace = "http://www.webservicex.net/") String ipAddress);
 
     /**
-     * GeoIPService - GetGeoIPContext enables you to easily look up countries by Context
+     * GeoIPService - GetGeoIPContext enables you to easily look up countries by
+     * Context
      * 
      * @return
-     *     returns wsclient.GeoIP
+     *         returns wsclient.GeoIP
      */
     @WebMethod(operationName = "GetGeoIPContext", action = "http://www.webservicex.net/GetGeoIPContext")
     @WebResult(name = "GetGeoIPContextResult", targetNamespace = "http://www.webservicex.net/")
     @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContext")
     @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContextResponse")
     public GeoIP getGeoIPContext();
-
 }
diff --git a/src/test/wsclient/GetGeoIP.java b/src/test/wsclient/GetGeoIP.java
index fcb0571..ab3a42f 100644
--- a/src/test/wsclient/GetGeoIP.java
+++ b/src/test/wsclient/GetGeoIP.java
@@ -1,7 +1,7 @@
-   /**
-    * Class GetGeoIP imported from WSDL with java tool 
-    * replicates WSDL to invoke External Web service
-    */
+/**
+ * Class GetGeoIP imported from WSDL with java tool 
+ * replicates WSDL to invoke External Web service
+ */
 
 package wsclient;
 
@@ -11,11 +11,13 @@
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
-
 /**
- * 

Java class for anonymous complex type. + *

+ * Java class for anonymous complex type. * - *

The following schema fragment specifies the expected content contained within this class. + *

+ * The following schema fragment specifies the expected content contained within + * this class. * *

  * <complexType>
@@ -34,7 +36,7 @@
 
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "", propOrder = {
-    "ipAddress"
+        "ipAddress"
 })
 @XmlRootElement(name = "GetGeoIP")
 public class GetGeoIP {
@@ -46,9 +48,9 @@ public class GetGeoIP {
      * Gets the value of the ipAddress property.
      * 
      * @return
-     *     possible object is
-     *     {@link String }
-     *     
+     *         possible object is
+     *         {@link String }
+     * 
      */
     public String getIPAddress() {
         return ipAddress;
@@ -58,9 +60,9 @@ public String getIPAddress() {
      * Sets the value of the ipAddress property.
      * 
      * @param value
-     *     allowed object is
-     *     {@link String }
-     *     
+     *              allowed object is
+     *              {@link String }
+     * 
      */
     public void setIPAddress(String value) {
         this.ipAddress = value;
diff --git a/src/test/wsclient/GetGeoIPContextResponse.java b/src/test/wsclient/GetGeoIPContextResponse.java
index 0fbb17b..eabac05 100644
--- a/src/test/wsclient/GetGeoIPContextResponse.java
+++ b/src/test/wsclient/GetGeoIPContextResponse.java
@@ -1,7 +1,7 @@
-   /**
-    * Class getGeoIPContextResult imported from WSDL with java tool 
-    * replicates WSDL to invoke External Web service
-    */
+/**
+ * Class getGeoIPContextResult imported from WSDL with java tool 
+ * replicates WSDL to invoke External Web service
+ */
 
 package wsclient;
 
@@ -11,11 +11,13 @@
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
-
 /**
- * 

Java class for anonymous complex type. + *

+ * Java class for anonymous complex type. * - *

The following schema fragment specifies the expected content contained within this class. + *

+ * The following schema fragment specifies the expected content contained within + * this class. * *

  * <complexType>
@@ -28,12 +30,11 @@
  *   </complexContent>
  * </complexType>
  * 
- * - * */ + @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "getGeoIPContextResult" + "getGeoIPContextResult" }) @XmlRootElement(name = "GetGeoIPContextResponse") public class GetGeoIPContextResponse { @@ -45,9 +46,9 @@ public class GetGeoIPContextResponse { * Gets the value of the getGeoIPContextResult property. * * @return - * possible object is - * {@link GeoIP } - * + * possible object is + * {@link GeoIP } + * */ public GeoIP getGetGeoIPContextResult() { return getGeoIPContextResult; @@ -57,9 +58,9 @@ public GeoIP getGetGeoIPContextResult() { * Sets the value of the getGeoIPContextResult property. * * @param value - * allowed object is - * {@link GeoIP } - * + * allowed object is + * {@link GeoIP } + * */ public void setGetGeoIPContextResult(GeoIP value) { this.getGeoIPContextResult = value; diff --git a/src/test/wsclient/GetGeoIPResponse.java b/src/test/wsclient/GetGeoIPResponse.java index e5e621e..fa15f74 100644 --- a/src/test/wsclient/GetGeoIPResponse.java +++ b/src/test/wsclient/GetGeoIPResponse.java @@ -1,7 +1,7 @@ - /** - * Class getGeoIPResult imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ +/** + * Class getGeoIPResult imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ package wsclient; @@ -12,9 +12,12 @@ import javax.xml.bind.annotation.XmlType; /** - *

Java class for anonymous complex type. + *

+ * Java class for anonymous complex type. * - *

The following schema fragment specifies the expected content contained within this class. + *

+ * The following schema fragment specifies the expected content contained within + * this class. * *

  * <complexType>
@@ -32,7 +35,7 @@
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "", propOrder = {
-    "getGeoIPResult"
+        "getGeoIPResult"
 })
 @XmlRootElement(name = "GetGeoIPResponse")
 public class GetGeoIPResponse {
@@ -44,9 +47,9 @@ public class GetGeoIPResponse {
      * Gets the value of the getGeoIPResult property.
      * 
      * @return
-     *     possible object is
-     *     {@link GeoIP }
-     *     
+     *         possible object is
+     *         {@link GeoIP }
+     * 
      */
     public GeoIP getGetGeoIPResult() {
         return getGeoIPResult;
@@ -56,12 +59,11 @@ public GeoIP getGetGeoIPResult() {
      * Sets the value of the getGeoIPResult property.
      * 
      * @param value
-     *     allowed object is
-     *     {@link GeoIP }
-     *     
+     *              allowed object is
+     *              {@link GeoIP }
+     * 
      */
     public void setGetGeoIPResult(GeoIP value) {
         this.getGeoIPResult = value;
     }
-
-}
+}
\ No newline at end of file
diff --git a/src/test/wsclient/ObjectFactory.java b/src/test/wsclient/ObjectFactory.java
index 0c8da64..a81a6eb 100644
--- a/src/test/wsclient/ObjectFactory.java
+++ b/src/test/wsclient/ObjectFactory.java
@@ -1,7 +1,7 @@
-   /**
-    * Class ObjectFactory imported from WSDL with java tool 
-    * replicates WSDL to invoke External Web service
-    */
+/**
+ * Class ObjectFactory imported from WSDL with java tool 
+ * replicates WSDL to invoke External Web service
+ */
 
 package wsclient;
 
@@ -10,18 +10,18 @@
 import javax.xml.bind.annotation.XmlRegistry;
 import javax.xml.namespace.QName;
 
-
 /**
- * This object contains factory methods for each 
- * Java content interface and Java element interface 
- * generated in the wsclient package. 
- * 

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the wsclient package. + *

+ * An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. * */ @@ -31,7 +31,8 @@ public class ObjectFactory { private final static QName _GeoIP_QNAME = new QName("http://www.webservicex.net/", "GeoIP"); /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: wsclient + * Create a new ObjectFactory that can be used to create new instances of schema + * derived classes for package: wsclient * */ public ObjectFactory() { diff --git a/src/test/wsdl/ServiceInvokationTest.java b/src/test/wsdl/ServiceInvokationTest.java index ff82ba3..848ec17 100644 --- a/src/test/wsdl/ServiceInvokationTest.java +++ b/src/test/wsdl/ServiceInvokationTest.java @@ -9,20 +9,20 @@ import service.MainService; public class ServiceInvokationTest { - + MainService testService = new MainService(); AttendanceRegister attend = new AttendanceRegister(); @Test public void testWSDLSuccess() { - - assertTrue(testService.invokeWSDLForIP().length()>2); - //System.out.println(testService.invokeWSDLForIP()); + + assertTrue(testService.invokeWSDLForIP().length() > 2); + // System.out.println(testService.invokeWSDLForIP()); } - + @Test public void testRestBibleSuccess() { - assertTrue(testService.invokeRestForBibleVerse().length()>2); - //System.out.println(testService.invokeRestForBibleVerse()); + assertTrue(testService.invokeRestForBibleVerse().length() > 2); + // System.out.println(testService.invokeRestForBibleVerse()); } } From 8d693f03b1320605c5942a61f23d3e527fb3b3f0 Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Mon, 10 Jul 2023 21:40:47 +1200 Subject: [PATCH 04/32] instructions when using docker --- README.md | 78 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 7ac018d..f26881e 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,12 @@ - [Attendance WebApp UI](#attendance-webapp-ui) - [Refer to the Wiki for details on the project](#refer-to-the-wiki-for-details-on-the-project) - [Project general guidelines](#project-general-guidelines) -- [Build and Test](#build-and-test) - - [Maven](#maven) + - [Locally Build and Test](#locally-build-and-test) + - [Maven Stages](#maven-stages) - [Run the maven build Locally](#run-the-maven-build-locally) - - [Build using maven docker container](#build-using-maven-docker-container) + - [Docker](#docker) + - [Run and test the container webapp](#run-and-test-the-container-webapp) + - [Build using maven docker container](#build-using-maven-docker-container) - [GitHub Vulnerability report](#github-vulnerability-report) # Attendance WebApp @@ -59,64 +61,70 @@ To find out more, visit: 3. Latest releases by using git tags 4. API references. API docs -# Build and Test - +## Locally Build and Test +> Tested in Win11 with WSL +- Clone git repo ```bash git clone repo -# import in IDE Eclipse suggested or use online IDE -# execute some of the unit tests -# Generate the .WAR file -mvn package -# Deploy WebArchive file in tomcat. Docker apps info below -deploy .WAR in tomcat ``` -## Maven - -### Run the maven build Locally - -- build the project locally with a locally installed maven client - -> Tested in Win11 with WSL +- open in IDE Eclipse, IntelliJ (suggested) or use online IDE (Github codespaces) -```bash -mvn verify +- Pack the WebArchive file using maven. Generate the .WAR file +``` bash +mvn package ``` -- Use a docker tag to select a target JDK - -> 8-jdk8-corretto - +- Build the app image with Docker. Deploy .WAR file in Tomcat +refer to https://hub.docker.com/_/tomcat ```bash TOMCAT_DOCKER_TAG="8-jdk8-corretto" +docker build --tag aleon1220/soa:latest . ``` -- build the container to the latest version tag +- Run the tomcat server with the pre-built WAR web Archive file + Use the tag latest or a particular version e.g. aleon1220/soa:v2 or aleon1220/soa:latest ```bash -docker build --tag aleon1220/soa:latest . +docker run -itd --publish 8888:8080 aleon1220/soa:latest +``` +- get the name of the running container in port 8888 +``` bash +CONTAINER_NAME=$(docker container ls --all --filter publish=8888 --format "{{.Names}}") ``` -- Run the tomcat server with the pre-built WAR web Archive file - Use the tag latest or a particular version e.g. aleon1220/soa:v2 or aleon1220/soa:latest +- Access the Docker container via CLI ```bash -docker run -itd --publish 8888:8080 --name attendance_webapp_container aleon1220/soa:latest +docker container exec -it $CONTAINER_NAME /bin/bash ``` -refer to https://hub.docker.com/_/tomcat +- The URl is URL:8888/AttendanceWebApp [AttendanceWebApp](http://localhost:8888/AttendanceWebApp) -- Access container -```bash -docker container exec -it aleon1220/soa /bin/bash +- clean up docker container environment +``` bash +docker stop $(docker ps --quiet) +docker rm $(docker container ls --all --quiet) ``` +## Maven Stages -- The URl is localhost:8888/AttendanceWebApp | [AttendanceWebApp](http://localhost:8888/AttendanceWebApp) +### Run the maven build Locally +- build the project locally with a locally installed maven client + +```bash +mvn verify +``` --- -## Build using maven docker container +## Docker +### Run and test the container webapp +```bash +docker build --tag aleon1220/soa:latest . +docker run -itd --publish 8888:8080 --name attendance_webapp_container aleon1220/soa:latest +``` +### Build using maven docker container Refer to maven docker official image https://hub.docker.com/_/maven is best to have maven locally installed From 732303ecea0ac1e697d8eb882d2d7104a5a07d3f Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Wed, 12 Jul 2023 18:26:50 +1200 Subject: [PATCH 05/32] Implement Gradle for the build moves maven files to respective directory Readme is updated with instructions --- .gitignore | 18 +++++++++- Dockerfile | 7 ++-- README.md | 33 +++++++++++------ build.gradle.kts | 77 ++++++++++++++++++++++++++++++++++++++++ gradle.properties | 3 ++ maven/Dockerfile | 7 ++++ pom.xml => maven/pom.xml | 2 -- settings.gradle.kts | 7 ++++ 8 files changed, 137 insertions(+), 17 deletions(-) create mode 100644 build.gradle.kts create mode 100644 gradle.properties create mode 100644 maven/Dockerfile rename pom.xml => maven/pom.xml (99%) create mode 100644 settings.gradle.kts diff --git a/.gitignore b/.gitignore index 12924fc..7b16d59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,26 @@ +# Gradle +**/build/ +!src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Avoid ignore Gradle wrappper properties +!gradle-wrapper.properties + +# Cache of project +.gradletasknamecache + #.config file for eclipse projects .settings /.classpath /bin/ /.project -#target with generated objects +# Maven build files /target # Compiled class file diff --git a/Dockerfile b/Dockerfile index 629b2f7..f51d8c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM tomcat:8-jdk8-corretto # https://hub.docker.com/layers/library/tomcat/7.0.109-jdk8-openjdk/images/sha256-489823486120d076cb576640c5819c6fa54948f470b46c54f02b48f462eb2c23 LABEL org.nz.itlatinos.image.authors="aleonrangel@outlook.co.nz" -ADD conf/tomcat-users.xml /usr/local/tomcat/conf +LABEL maintainer="andres.nz" +ENV APP_WAR_FILE="AttendanceApp-0.0.1.war" -COPY target/AttendanceWebApp.war /usr/local/tomcat/webapps/ -LABEL maintainer="andres.nz" \ No newline at end of file +# Tomcat Custom settings +COPY "build/libs/$APP_WAR_FILE" /usr/local/tomcat/webapps/ \ No newline at end of file diff --git a/README.md b/README.md index f26881e..99feb37 100644 --- a/README.md +++ b/README.md @@ -56,35 +56,46 @@ To find out more, visit: # Project general guidelines -1. Installation process: project is Maven java project. Import in any IDE with the POM File. +1. Installation process: project a Java project JEE. Import in any IDE and build with gradle or maven. Build docker image and run 2. Software dependencies: dependencies are described in pom.xml file 3. Latest releases by using git tags 4. API references. API docs -## Locally Build and Test -> Tested in Win11 with WSL -- Clone git repo +## Setup +> Tested in Win11 with WSL, Github codespaces and Ubuntu22 + +- Clone repo ```bash git clone repo ``` -- open in IDE Eclipse, IntelliJ (suggested) or use online IDE (Github codespaces) +- open repo in chosen IDE +IDEs can be Eclipse, IntelliJ (suggested) or use online IDE (Github codespaces) -- Pack the WebArchive file using maven. Generate the .WAR file +## Build Web Package +- Pack the WebArchive file. Generate the .WAR file ``` bash -mvn package +gradle clean build --console plain --warning-mode all ``` +### Maven Build +> maven has been deprecated and moved to [maven](./maven) +if you still want to build with maven run `mvn package` + +## Docker Image Build - Build the app image with Docker. Deploy .WAR file in Tomcat refer to https://hub.docker.com/_/tomcat ```bash -TOMCAT_DOCKER_TAG="8-jdk8-corretto" docker build --tag aleon1220/soa:latest . ``` -- Run the tomcat server with the pre-built WAR web Archive file - Use the tag latest or a particular version e.g. aleon1220/soa:v2 or aleon1220/soa:latest +### Available Tomcat versions +Use the tag latest or a particular version e.g. aleon1220/soa:v2 or aleon1220/soa:latest +- 7.0.109 = `TOMCAT_VERSION_DOCKER_TAG="7.0.109-jdk8-openjdk"` +- 9.0.78 = `TOMCAT_VERSION_DOCKER_TAG="9.0.78-jre8"` +## Docker execution +Run the tomcat server with the pre-built WAR web Archive file ```bash docker run -itd --publish 8888:8080 aleon1220/soa:latest ``` @@ -99,7 +110,7 @@ CONTAINER_NAME=$(docker container ls --all --filter publish=8888 --format "{{.Na docker container exec -it $CONTAINER_NAME /bin/bash ``` -- The URl is URL:8888/AttendanceWebApp [AttendanceWebApp](http://localhost:8888/AttendanceWebApp) +- The URl is URL:8888/Attendance-0.0.1 [AttendanceWebApp](http://localhost:8888/Attendance-0.0.1) - clean up docker container environment diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..21b81ae --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,77 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.api.tasks.testing.logging.TestLogEvent + +/* + * This file was generated by the Gradle 'init' task. + * + * This project uses @Incubating APIs which are subject to change. + */ + +plugins { + java + id ("com.adarshr.test-logger") version "3.0.0" + // https://docs.gradle.org/7.3/dsl/org.gradle.api.tasks.bundling.War.html + war +} + +repositories { + mavenCentral() + mavenLocal() + maven { + url = uri("https://repository.primefaces.org") + } + // maven { // url = uri("https://repo.maven.apache.org/maven2/") // } +} + +dependencies { + implementation("org.primefaces.extensions:primefaces-extensions:6.0.0") + implementation("org.primefaces:primefaces:6.0") + implementation("com.sun.faces:jsf-api:2.2.12") + implementation("com.sun.faces:jsf-impl:2.2.12") + implementation("javax.json:javax.json-api:1.1") + implementation("javax.ws.rs:javax.ws.rs-api:2.1") + implementation("com.sun.jersey:jersey-client:1.19.4") + implementation("com.google.code.gson:gson:2.8.9") + implementation("org.apache.httpcomponents:httpclient:4.5.3") + implementation("org.glassfish.jersey.core:jersey-common:2.22.2") + implementation("javax.servlet:javax.servlet-api:3.1.0") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.3.1") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.3.1") + testImplementation("io.jsonwebtoken:jjwt:0.7.0") +} + +group = "soa.nz.aut" +version = "0.0.1" +description = "Class Attendance WebApp" +java.sourceCompatibility = JavaVersion.VERSION_1_8 + +tasks.war { + archiveBaseName.set("Attendance") + webAppDirectory.set(file("src/main/webapp")) + // from("src/rootContent") // adds a file-set to the root of the archive + // webInf { from("src/additionalWebInf") } // adds a file-set to the WEB-INF dir. + // classpath(fileTree("additionalLibs")) // adds a file-set to the WEB-INF/lib dir. + // classpath(moreLibs) // adds a configuration to the WEB-INF/lib dir. + // webXml = file("src/someWeb.xml") // copies a file to WEB-INF/web.xml +} + +tasks { + test { + useJUnitPlatform() + testLogging.events = setOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED) + } +} + +// task{ +// testlogger{ +// setTheme("mocha") +// showExceptions=true +// showStackTraces=true +// } +// } + +// afterEvaluate { +// tasks.getByName("run") { +// dependsOn("appRun") +// } +// } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..eca1768 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +log4j_version = 1.2.17 +jaxb_version = 2.3.1 +junit_version = 5.5.1 diff --git a/maven/Dockerfile b/maven/Dockerfile new file mode 100644 index 0000000..629b2f7 --- /dev/null +++ b/maven/Dockerfile @@ -0,0 +1,7 @@ +FROM tomcat:8-jdk8-corretto +# https://hub.docker.com/layers/library/tomcat/7.0.109-jdk8-openjdk/images/sha256-489823486120d076cb576640c5819c6fa54948f470b46c54f02b48f462eb2c23 +LABEL org.nz.itlatinos.image.authors="aleonrangel@outlook.co.nz" +ADD conf/tomcat-users.xml /usr/local/tomcat/conf + +COPY target/AttendanceWebApp.war /usr/local/tomcat/webapps/ +LABEL maintainer="andres.nz" \ No newline at end of file diff --git a/pom.xml b/maven/pom.xml similarity index 99% rename from pom.xml rename to maven/pom.xml index cce3041..209ca25 100644 --- a/pom.xml +++ b/maven/pom.xml @@ -86,7 +86,6 @@ gson 2.8.9 - org.apache.httpcomponents @@ -100,7 +99,6 @@ 2.22.2 compile - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..dbab213 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,7 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This project uses @Incubating APIs which are subject to change. + */ + +rootProject.name = "AttendWebApp" \ No newline at end of file From 96bf9585035ab77d92b1d3f6b4623d78ea384cb3 Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Mon, 31 Jul 2023 18:44:44 +1200 Subject: [PATCH 06/32] enable diagrams.net develop branch --- README.md | 12 ++- project-diagrams.drawio | 177 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 project-diagrams.drawio diff --git a/README.md b/README.md index 99feb37..40d722e 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,18 @@ - [Attendance WebApp UI](#attendance-webapp-ui) - [Refer to the Wiki for details on the project](#refer-to-the-wiki-for-details-on-the-project) - [Project general guidelines](#project-general-guidelines) - - [Locally Build and Test](#locally-build-and-test) + - [Setup](#setup) + - [Build Web Package](#build-web-package) + - [Maven Build](#maven-build) + - [Docker Image Build](#docker-image-build) + - [Available Tomcat versions](#available-tomcat-versions) + - [Docker execution](#docker-execution) - [Maven Stages](#maven-stages) - [Run the maven build Locally](#run-the-maven-build-locally) - [Docker](#docker) - [Run and test the container webapp](#run-and-test-the-container-webapp) - [Build using maven docker container](#build-using-maven-docker-container) + - [Editing project diagrams](#editing-project-diagrams) - [GitHub Vulnerability report](#github-vulnerability-report) # Attendance WebApp @@ -164,6 +170,10 @@ docker run -it --rm --name my-maven-project -v "$(pwd)":/usr/src/mymaven -w /usr docker run -it --name my-maven-project -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3.3-jdk-8 mvn clean install ``` +## Editing project diagrams +- go to [diagrams.net](https://app.diagrams.net/?src=about) +- open the file [project-diagrams.drawio](./project-diagrams.drawio) XML file with the diagrams +- Explore > export images to convinience and update this README ## GitHub Vulnerability report https://github.com/aleon1220/multi-cloud-WebApp-Attendance/security/dependabot diff --git a/project-diagrams.drawio b/project-diagrams.drawio new file mode 100644 index 0000000..21e212e --- /dev/null +++ b/project-diagrams.drawio @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 18ffaaadee9ddfd7712ef9a1b28368ec2f8b0a34 Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Tue, 1 Aug 2023 18:41:57 +1200 Subject: [PATCH 07/32] Sitemap & wireframes added --- project-diagrams.drawio | 153 ++++++++++++++++++++++++++++++++-------- 1 file changed, 124 insertions(+), 29 deletions(-) diff --git a/project-diagrams.drawio b/project-diagrams.drawio index 21e212e..98f894e 100644 --- a/project-diagrams.drawio +++ b/project-diagrams.drawio @@ -1,75 +1,81 @@ - + - + - + - + - + - + - - - - + - + - + - + - - + + - + - + - + - + - + - + - + - - - - + - + - + - + + + + + + + + + + + + + @@ -174,4 +180,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 0576fa42289ac2d10a029ffad2781a930082752f Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Tue, 1 Aug 2023 18:42:41 +1200 Subject: [PATCH 08/32] gradle wrapper --- gradle/wrapper/gradle-wrapper.properties | 5 + gradlew | 234 +++++++++++++++++++++++ gradlew.bat | 89 +++++++++ 3 files changed, 328 insertions(+) create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2e6e589 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega From b2e9c89a3247c22a44c355629b3e1afb4f3cf57f Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Thu, 3 Aug 2023 18:02:24 +1200 Subject: [PATCH 09/32] Redesigned app based on sitemap sitemap defines interaction flow in page Renamed files to have them in order for teaching purposes --- project-diagrams | 103 ----- project-diagrams.drawio | 435 +++++++++++++----- .../webapp/{login.xhtml => 01-login.xhtml} | 0 src/main/webapp/02-studentHome.xhtml | 106 +++++ ...tendanceOK.xhtml => 03-attendanceOK.xhtml} | 0 ...ceRegister.xhtml => 04-lecturerHome.xhtml} | 0 .../{main.xhtml => 05-universityStaff.xhtml} | 0 .../webapp/{sign.xhtml => 06-Reports.xhtml} | 0 ...test2.xhtml => 07-StudentManagement.xhtml} | 0 ...mponent.xhtml => 08-ClassManagement.xhtml} | 0 src/main/webapp/09-UserManagement.xhtml | 47 ++ src/main/webapp/10-CompositeServices.xhtml | 47 ++ src/main/webapp/404-attendanceError.xhtml | 108 +++++ ...{loginError.xhtml => 404-loginError.xhtml} | 0 src/main/webapp/UserCreated.xhtml | 37 -- src/main/webapp/WEB-INF/web.xml | 16 +- src/main/webapp/attendanceError.xhtml | 82 ---- src/main/webapp/attendanceGenerate.xhtml | 91 ---- src/main/webapp/attendanceNOK.xhtml | 38 -- src/main/webapp/dropdown.xhtml | 37 -- src/main/webapp/helloworld.xhtml | 23 - 21 files changed, 625 insertions(+), 545 deletions(-) delete mode 100644 project-diagrams rename src/main/webapp/{login.xhtml => 01-login.xhtml} (100%) create mode 100644 src/main/webapp/02-studentHome.xhtml rename src/main/webapp/{attendanceOK.xhtml => 03-attendanceOK.xhtml} (100%) rename src/main/webapp/{attendanceRegister.xhtml => 04-lecturerHome.xhtml} (100%) rename src/main/webapp/{main.xhtml => 05-universityStaff.xhtml} (100%) rename src/main/webapp/{sign.xhtml => 06-Reports.xhtml} (100%) rename src/main/webapp/{test2.xhtml => 07-StudentManagement.xhtml} (100%) rename src/main/webapp/{testComponent.xhtml => 08-ClassManagement.xhtml} (100%) create mode 100644 src/main/webapp/09-UserManagement.xhtml create mode 100644 src/main/webapp/10-CompositeServices.xhtml create mode 100644 src/main/webapp/404-attendanceError.xhtml rename src/main/webapp/{loginError.xhtml => 404-loginError.xhtml} (100%) delete mode 100644 src/main/webapp/UserCreated.xhtml delete mode 100644 src/main/webapp/attendanceError.xhtml delete mode 100644 src/main/webapp/attendanceGenerate.xhtml delete mode 100644 src/main/webapp/attendanceNOK.xhtml delete mode 100644 src/main/webapp/dropdown.xhtml delete mode 100644 src/main/webapp/helloworld.xhtml diff --git a/project-diagrams b/project-diagrams deleted file mode 100644 index 4c85eb3..0000000 --- a/project-diagrams +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project-diagrams.drawio b/project-diagrams.drawio index 98f894e..abac217 100644 --- a/project-diagrams.drawio +++ b/project-diagrams.drawio @@ -1,71 +1,62 @@ - + - - + + - + - - + + - - + + - - - - - + + - + - + - + - + - + - + - - - - - - - + - + - - + + @@ -73,14 +64,289 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -88,13 +354,13 @@ - + - + @@ -117,9 +383,6 @@ - - - @@ -129,14 +392,23 @@ + + + - + + + + + + + @@ -180,93 +452,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/webapp/login.xhtml b/src/main/webapp/01-login.xhtml similarity index 100% rename from src/main/webapp/login.xhtml rename to src/main/webapp/01-login.xhtml diff --git a/src/main/webapp/02-studentHome.xhtml b/src/main/webapp/02-studentHome.xhtml new file mode 100644 index 0000000..ec07e08 --- /dev/null +++ b/src/main/webapp/02-studentHome.xhtml @@ -0,0 +1,106 @@ + + + + Generate Attendance System + + + + + + + Generate Attendance Code + + +

Attendance System Date

+

Time and Date

+ + +
+
+
+ + + + + + + + +

+ Welcome + + to the session + + for Lecture. + + +
Generate a code to register attendance for this session. + Remember each student in the class has a time frame for 1 minute. +

+
+ + + + + + +
+ + + +
+ + + + + + + +
+ + + + +
+ +
+
+
+
+
+ +
+ +
+ + + + + diff --git a/src/main/webapp/attendanceOK.xhtml b/src/main/webapp/03-attendanceOK.xhtml similarity index 100% rename from src/main/webapp/attendanceOK.xhtml rename to src/main/webapp/03-attendanceOK.xhtml diff --git a/src/main/webapp/attendanceRegister.xhtml b/src/main/webapp/04-lecturerHome.xhtml similarity index 100% rename from src/main/webapp/attendanceRegister.xhtml rename to src/main/webapp/04-lecturerHome.xhtml diff --git a/src/main/webapp/main.xhtml b/src/main/webapp/05-universityStaff.xhtml similarity index 100% rename from src/main/webapp/main.xhtml rename to src/main/webapp/05-universityStaff.xhtml diff --git a/src/main/webapp/sign.xhtml b/src/main/webapp/06-Reports.xhtml similarity index 100% rename from src/main/webapp/sign.xhtml rename to src/main/webapp/06-Reports.xhtml diff --git a/src/main/webapp/test2.xhtml b/src/main/webapp/07-StudentManagement.xhtml similarity index 100% rename from src/main/webapp/test2.xhtml rename to src/main/webapp/07-StudentManagement.xhtml diff --git a/src/main/webapp/testComponent.xhtml b/src/main/webapp/08-ClassManagement.xhtml similarity index 100% rename from src/main/webapp/testComponent.xhtml rename to src/main/webapp/08-ClassManagement.xhtml diff --git a/src/main/webapp/09-UserManagement.xhtml b/src/main/webapp/09-UserManagement.xhtml new file mode 100644 index 0000000..953aaf8 --- /dev/null +++ b/src/main/webapp/09-UserManagement.xhtml @@ -0,0 +1,47 @@ + + + + Main Menu Attendance System + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/10-CompositeServices.xhtml b/src/main/webapp/10-CompositeServices.xhtml new file mode 100644 index 0000000..5b5862c --- /dev/null +++ b/src/main/webapp/10-CompositeServices.xhtml @@ -0,0 +1,47 @@ + + + + Composite Services Integration + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/404-attendanceError.xhtml b/src/main/webapp/404-attendanceError.xhtml new file mode 100644 index 0000000..b59f635 --- /dev/null +++ b/src/main/webapp/404-attendanceError.xhtml @@ -0,0 +1,108 @@ + + + + + + + Error registering attendance + + + + +
+ +
+ + + + +
+

+ Se ha presentado un Error al publicar el aviso. Contacte a soporte + IT. +

+

+
+
+

+ Suba el archivo en formato xlsx de los horarios de los abogados + para las distintas semanas. +

+
+
+ + + +
+
+ + +
+ + +
+
+ +
+ This template downloaded from + free website templates +
+
+ diff --git a/src/main/webapp/loginError.xhtml b/src/main/webapp/404-loginError.xhtml similarity index 100% rename from src/main/webapp/loginError.xhtml rename to src/main/webapp/404-loginError.xhtml diff --git a/src/main/webapp/UserCreated.xhtml b/src/main/webapp/UserCreated.xhtml deleted file mode 100644 index 9f4bea4..0000000 --- a/src/main/webapp/UserCreated.xhtml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - Main Menu Attendance System - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 7570a92..7b5a5ad 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,9 +1,9 @@ - + - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" + version="3.1"> + AttendanceWebApp login.xhtml @@ -15,11 +15,11 @@ 1 - + Faces Servlet *.xhtml - + State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2 javax.faces.STATE_SAVING_METHOD client @@ -30,5 +30,5 @@ com.sun.faces.config.ConfigureListener - + \ No newline at end of file diff --git a/src/main/webapp/attendanceError.xhtml b/src/main/webapp/attendanceError.xhtml deleted file mode 100644 index c4c8ddb..0000000 --- a/src/main/webapp/attendanceError.xhtml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - Error registering attendance - - - - -
- -
- - - - -
- -

- Se - ha presentado un Error al publicar el aviso. Contacte a soporte IT.

-

-
-
-

Suba el archivo en formato xlsx de los horarios de los - abogados para las distintas semanas.

-
-
- - -
-
- - -
- - -
-
- -
- This template downloaded from free - website templates -
- -
- \ No newline at end of file diff --git a/src/main/webapp/attendanceGenerate.xhtml b/src/main/webapp/attendanceGenerate.xhtml deleted file mode 100644 index 5250a45..0000000 --- a/src/main/webapp/attendanceGenerate.xhtml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - Generate Attendance System - - - - - - - - - - Generate Attendance Code - - -

Attendance System Date

-

Time and Date

- -
-
-
-
- - - - - - - - -

- Welcome - - to the session - - for Lecture. - - -
Generate a code to register attendance for this session. - Remember each student in the class has a time frame for 1 minute. -

-
- - - - - - -
- - - -
- - - - - - - -
- - - - -
- -
-
-
-
-
- -
- -
- -
- -
- -
- - - \ No newline at end of file diff --git a/src/main/webapp/attendanceNOK.xhtml b/src/main/webapp/attendanceNOK.xhtml deleted file mode 100644 index 95d0311..0000000 --- a/src/main/webapp/attendanceNOK.xhtml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Class Attendance error - - - - - - - - - - - - attendance Error - -
-
-
-
-
- -
- -
- -
-
-
- - - - \ No newline at end of file diff --git a/src/main/webapp/dropdown.xhtml b/src/main/webapp/dropdown.xhtml deleted file mode 100644 index 43711d9..0000000 --- a/src/main/webapp/dropdown.xhtml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - -Insert title here - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/webapp/helloworld.xhtml b/src/main/webapp/helloworld.xhtml deleted file mode 100644 index ea2dd4c..0000000 --- a/src/main/webapp/helloworld.xhtml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - Hello World - - - - - - - -

- -
-
- \ No newline at end of file From 971aea8c28ad046a0d2c85df94cdc92164cdda4c Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Mon, 25 Sep 2023 12:17:11 +1300 Subject: [PATCH 10/32] gradle automation setup documented primefaces custom repo setting --- .gitignore | 1 + README.md | 5 +++++ build.gradle.kts | 57 +++++++++++++++++++++++++++++++++--------------- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 7b16d59..23491a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Gradle +.gradle/ **/build/ !src/**/build/ diff --git a/README.md b/README.md index 40d722e..8e7bd57 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,11 @@ Attendance WebApp is a proof of concept to improve the way attendance is managed at AUT university. The application uses maven, J2EE, primefaces, gson. +```kotlin + maven { + url = uri("https://repository.primefaces.org") + } +``` The idea is that you have a short timeframe to submit a random generated code by the lecturer so that attendance can be registered in the system. The application is a proof of concept for Service orientation and Service interoperability in the cloud diff --git a/build.gradle.kts b/build.gradle.kts index 21b81ae..785e624 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,25 +2,21 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent /* - * This file was generated by the Gradle 'init' task. - * - * This project uses @Incubating APIs which are subject to change. + * This file was generated by the Gradle 'init' task + * This project uses @Incubating APIs which are subject to change */ plugins { java - id ("com.adarshr.test-logger") version "3.0.0" + // id ("com.adarshr.test-logger") version "3.0.0" // https://docs.gradle.org/7.3/dsl/org.gradle.api.tasks.bundling.War.html war + //wsdl + id("org.apache.cxf.cxf") version "1.0.0" } repositories { mavenCentral() - mavenLocal() - maven { - url = uri("https://repository.primefaces.org") - } - // maven { // url = uri("https://repo.maven.apache.org/maven2/") // } } dependencies { @@ -35,9 +31,15 @@ dependencies { implementation("org.apache.httpcomponents:httpclient:4.5.3") implementation("org.glassfish.jersey.core:jersey-common:2.22.2") implementation("javax.servlet:javax.servlet-api:3.1.0") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.3.1") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.3.1") + // https://mvnrepository.com/artifact/com.google.zxing/javase + implementation("com.google.zxing:javase:3.5.1") + // https://mvnrepository.com/artifact/com.google.zxing/core + implementation("com.google.zxing:core:3.5.1") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0") testImplementation("io.jsonwebtoken:jjwt:0.7.0") + implementation("org.apache.cxf:cxf-rt-frontend-jaxws:3.4.5") + } group = "soa.nz.aut" @@ -57,21 +59,40 @@ tasks.war { tasks { test { + reports { + html.isEnabled = true + junitXml.isEnabled = true + } useJUnitPlatform() testLogging.events = setOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED) } } -// task{ -// testlogger{ -// setTheme("mocha") -// showExceptions=true -// showStackTraces=true -// } -// } +tasks.register("singleTest") { + group = "Verification" + description = "Runs a test to create a local QR code" + filter { + includeTestsMatching("utilities.TestQRFunctions.createQRCodeLocally") + } +} +// task{ utilities +// testlogger{ +// setTheme("mocha") +// showExceptions=true +// showStackTraces=true +// } +// } // afterEvaluate { // tasks.getByName("run") { // dependsOn("appRun") // } // } +cxf { + wsdl2java { + // wsdl info about countries + wsdl = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL" + packageName = "org.example.countryinfo" + outputDir = file("src/main/java") + } +} \ No newline at end of file From 8023b6696f8a9e096ea9f3036f3453712399eff5 Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Mon, 25 Sep 2023 12:21:28 +1300 Subject: [PATCH 11/32] preparing test files new testing structure based on pluralsight courses --- .../login/TestAuthenticationResult.java | 72 ++++++++ src/test/java/attendance/login/TestLogin.java | 31 ++++ .../student/StudentAuthenticationResult.java | 72 ++++++++ .../student/StudentAuthorization.java | 31 ++++ .../java/attendance/student/TestStudent.java | 25 +++ .../restclient/JerseyClient.java | 41 +++++ .../restclient/JerseyClientPost.java | 33 ++++ .../restclient/JerseyGet.java | 37 ++++ .../restclient/JerseyJsonResponse.java | 36 ++++ .../restclient/JerseyJsonSimpler.java | 28 +++ .../restclient/JerseyPost.java | 36 ++++ .../restclient/JerseyPostHeader.java | 24 +++ .../restclient/JerseyTest.java | 36 ++++ .../restclient/NetClientPost.java | 56 ++++++ .../restclient/TestRestClient.java | 38 ++++ .../wsclient/GeoIP.java | 172 ++++++++++++++++++ .../wsclient/GeoIPService.java | 98 ++++++++++ .../wsclient/GeoIPServiceSoap.java | 55 ++++++ .../wsclient/GetGeoIP.java | 70 +++++++ .../wsclient/GetGeoIPContext.java | 37 ++++ .../wsclient/GetGeoIPContextResponse.java | 69 +++++++ .../wsclient/GetGeoIPResponse.java | 69 +++++++ .../wsclient/ObjectFactory.java | 90 +++++++++ .../wsclient/package-info.java | 6 + .../wsdlclient/MockCountryInfoService.java | 16 ++ .../wsdlclient/ServiceInvokationTest.java | 28 +++ .../PostAuthenticationToken.java | 85 +++++++++ src/test/java/json/ConversionJSON2Object.java | 30 +++ src/test/java/json/ConversionJson2Map.java | 39 ++++ src/test/java/json/JSON2Object.java | 24 +++ src/test/java/json/Json2Map.java | 39 ++++ src/test/java/json/TestJSONResponse.java | 62 +++++++ .../java/utilities/TestCodeGeneration.java | 15 ++ src/test/java/utilities/TestQRFunctions.java | 13 ++ 34 files changed, 1613 insertions(+) create mode 100644 src/test/java/attendance/login/TestAuthenticationResult.java create mode 100644 src/test/java/attendance/login/TestLogin.java create mode 100644 src/test/java/attendance/student/StudentAuthenticationResult.java create mode 100644 src/test/java/attendance/student/StudentAuthorization.java create mode 100644 src/test/java/attendance/student/TestStudent.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyClient.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyClientPost.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyGet.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyJsonResponse.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyJsonSimpler.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyPost.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyPostHeader.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyTest.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/NetClientPost.java create mode 100644 src/test/java/external/composite-app-mock-services/restclient/TestRestClient.java create mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GeoIP.java create mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GeoIPService.java create mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java create mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GetGeoIP.java create mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContext.java create mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContextResponse.java create mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPResponse.java create mode 100644 src/test/java/external/composite-app-mock-services/wsclient/ObjectFactory.java create mode 100644 src/test/java/external/composite-app-mock-services/wsclient/package-info.java create mode 100644 src/test/java/external/composite-app-mock-services/wsdlclient/MockCountryInfoService.java create mode 100644 src/test/java/external/composite-app-mock-services/wsdlclient/ServiceInvokationTest.java create mode 100644 src/test/java/external/tokenauthentication/PostAuthenticationToken.java create mode 100644 src/test/java/json/ConversionJSON2Object.java create mode 100644 src/test/java/json/ConversionJson2Map.java create mode 100644 src/test/java/json/JSON2Object.java create mode 100644 src/test/java/json/Json2Map.java create mode 100644 src/test/java/json/TestJSONResponse.java create mode 100644 src/test/java/utilities/TestCodeGeneration.java create mode 100644 src/test/java/utilities/TestQRFunctions.java diff --git a/src/test/java/attendance/login/TestAuthenticationResult.java b/src/test/java/attendance/login/TestAuthenticationResult.java new file mode 100644 index 0000000..85d629e --- /dev/null +++ b/src/test/java/attendance/login/TestAuthenticationResult.java @@ -0,0 +1,72 @@ +package attendance.login; + +import com.google.gson.annotations.SerializedName; + +public class TestAuthenticationResult { + + public TestAuthenticationResult(String accessToken, Integer expiresIn, String tokenType, String refreshToken, + String idToken) { + this.accessToken = accessToken; + this.expiresIn = expiresIn; + this.tokenType = tokenType; + this.refreshToken = refreshToken; + this.idToken = idToken; + } + + @SerializedName("AccessToken") + private String accessToken; + + @SerializedName("ExpiresIn") + private Integer expiresIn; + + @SerializedName("TokenType") + private String tokenType; + + @SerializedName("RefreshToken") + private String refreshToken; + + @SerializedName("IdToken") + private String idToken; + + // Setters and getters + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public Integer getExpiresIn() { + return expiresIn; + } + + public void setExpiresIn(Integer expiresIn) { + this.expiresIn = expiresIn; + } + + public String getTokenType() { + return tokenType; + } + + public void setTokenType(String tokenType) { + this.tokenType = tokenType; + } + + public String getRefreshToken() { + return refreshToken; + } + + public void setRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; + } + + public String getIdToken() { + return idToken; + } + + public void setIdToken(String idToken) { + this.idToken = idToken; + } +} \ No newline at end of file diff --git a/src/test/java/attendance/login/TestLogin.java b/src/test/java/attendance/login/TestLogin.java new file mode 100644 index 0000000..3eed44e --- /dev/null +++ b/src/test/java/attendance/login/TestLogin.java @@ -0,0 +1,31 @@ +package attendance.login; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +import bean.UserBean; + +public class TestLogin { + + @Test + public void GetToken() { + // fail("Not yet implemented"); + } + + @Test + public void loginGeneralUser() { + UserBean user = new UserBean(); + user.setId("10295765"); + user.setPassword("Value!12"); + // System.out.println("assert result"+user.login()); + assertTrue(user.login() == "main"); + } + + public void loginGeneralUserNOK() { + } + + public void loginLecturer() { + } + +} \ No newline at end of file diff --git a/src/test/java/attendance/student/StudentAuthenticationResult.java b/src/test/java/attendance/student/StudentAuthenticationResult.java new file mode 100644 index 0000000..2a29d77 --- /dev/null +++ b/src/test/java/attendance/student/StudentAuthenticationResult.java @@ -0,0 +1,72 @@ +package attendance.gson; + +import com.google.gson.annotations.SerializedName; + +public class StudentAuthenticationResult { + + public StudentAuthenticationResult(String accessToken, Integer expiresIn, String tokenType, String refreshToken, + String idToken) { + this.accessToken = accessToken; + this.expiresIn = expiresIn; + this.tokenType = tokenType; + this.refreshToken = refreshToken; + this.idToken = idToken; + } + + @SerializedName("AccessToken") + private String accessToken; + + @SerializedName("ExpiresIn") + private Integer expiresIn; + + @SerializedName("TokenType") + private String tokenType; + + @SerializedName("RefreshToken") + private String refreshToken; + + @SerializedName("IdToken") + private String idToken; + + // Setters and getters + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public Integer getExpiresIn() { + return expiresIn; + } + + public void setExpiresIn(Integer expiresIn) { + this.expiresIn = expiresIn; + } + + public String getTokenType() { + return tokenType; + } + + public void setTokenType(String tokenType) { + this.tokenType = tokenType; + } + + public String getRefreshToken() { + return refreshToken; + } + + public void setRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; + } + + public String getIdToken() { + return idToken; + } + + public void setIdToken(String idToken) { + this.idToken = idToken; + } +} diff --git a/src/test/java/attendance/student/StudentAuthorization.java b/src/test/java/attendance/student/StudentAuthorization.java new file mode 100644 index 0000000..d4df42b --- /dev/null +++ b/src/test/java/attendance/student/StudentAuthorization.java @@ -0,0 +1,31 @@ +package test.student; + +import com.google.gson.annotations.SerializedName; + +import entity.ChallengeParameters; + +public class StudentAuthorization { + + // names have to be the same from JSON to Java Object so that it works fine. + + private ChallengeParameters challengeParameters; + // @SerializedName("AuthenticationResult") + // @Expose + private StudentAuthenticationResult authenticationResult; + + public ChallengeParameters getChallengeParameters() { + return challengeParameters; + } + + public void setChallengeParameters(ChallengeParameters challengeParameters) { + this.challengeParameters = challengeParameters; + } + + public StudentAuthenticationResult getAuthenticationResult() { + return authenticationResult; + } + + public void setAuthenticationResult(StudentAuthenticationResult authenticationResult) { + this.authenticationResult = authenticationResult; + } +} \ No newline at end of file diff --git a/src/test/java/attendance/student/TestStudent.java b/src/test/java/attendance/student/TestStudent.java new file mode 100644 index 0000000..be1a249 --- /dev/null +++ b/src/test/java/attendance/student/TestStudent.java @@ -0,0 +1,25 @@ +package attendance.student; + +import javax.faces.bean.ManagedBean; + +@ManagedBean +public class TestStudent { + + private String name; + + public String sayHello() { + if (name != null && !name.trim().equals("")) { + return "Hello, " + name + "!"; + } else { + return null; + } + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyClient.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyClient.java new file mode 100644 index 0000000..27af2ad --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/JerseyClient.java @@ -0,0 +1,41 @@ +package external.services.restclient; + +import java.io.IOException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; +import org.apache.http.client.ClientProtocolException; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; + +public class JerseyClient { + + /** + * @param args + * @throws ClientProtocolException + * @throws IOException + */ + + public void obtainJSONResponse() throws ClientProtocolException, IOException { + + // Invoke REST service with GET Method + ClientConfig config = new DefaultClientConfig(); + Client client = Client.create(config); + + WebResource service = client + .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); + + // getting JSON data + System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( + "Authorization", + "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") + .get(String.class)); + } + + public void obtainXMLResponse() throws ClientProtocolException, IOException { + // getting XML data + // System.out.println("with + // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); + } +} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyClientPost.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyClientPost.java new file mode 100644 index 0000000..dfcb8d2 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/JerseyClientPost.java @@ -0,0 +1,33 @@ +package external.services.restclient; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; + +public class JerseyClientPost { + + public static void main(String[] args) { + + try { + Client client = Client.create(); + WebResource webResource = client + .resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); + + if (response.getStatus() != 201) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatus()); + } + + System.out.println("Output from Server .... \n"); + String output = response.getEntity(String.class); + System.out.println(output); + + } catch (Exception e) { + + e.printStackTrace(); + + } + } +} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyGet.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyGet.java new file mode 100644 index 0000000..7306244 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/JerseyGet.java @@ -0,0 +1,37 @@ +package external.services.restclient; + +import java.io.IOException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; +import org.apache.http.client.ClientProtocolException; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; + +public class JerseyGet { + + /** + * @param args + * @throws ClientProtocolException + * @throws IOException + */ + public static void main(String[] args) throws ClientProtocolException, IOException { + + ClientConfig config = new DefaultClientConfig(); + Client client = Client.create(config); + + WebResource service = client + .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); + + // getting JSON data + System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( + "Authorization", + "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") + .get(String.class)); + + // getting XML data + // System.out.println("with + // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); + } +} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonResponse.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonResponse.java new file mode 100644 index 0000000..d4e8bb9 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonResponse.java @@ -0,0 +1,36 @@ +package external.services.restclient; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; + +public class JerseyJsonResponse { + + public static void main(String[] args) { + try { + String baseuri = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login/"; + Client client = Client.create(); + + WebResource webResource = client.resource(baseuri); + + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + // POST method + ClientResponse response = webResource.accept("application/json").type("type:application/json") + .post(ClientResponse.class, input); + + // check response status code + if (response.getStatus() != 200) { + throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); + } + + // display response + String output = response.getEntity(String.class); + System.out.println("Output from Server .... "); + System.out.println(output + "\n"); + } catch (Exception e) { + e.printStackTrace(); + } + + } // main() +} diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonSimpler.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonSimpler.java new file mode 100644 index 0000000..ec56267 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonSimpler.java @@ -0,0 +1,28 @@ +package external.services.restclient; + +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.representation.Form; + +public class JerseyJsonSimpler { + + public static void main(String[] args) { + + try { + Client client = (Client) ClientBuilder.newClient(); + WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); + + Form form = new Form(); + form.add("id", "10295765"); + form.add("password", "Value!12"); + // ClientResponse response = + // WebResource.class.type(MediaType.TEXT_PLAIN).post(ClientResponse.class, + // form); + } catch (Exception e) { + e.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyPost.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyPost.java new file mode 100644 index 0000000..1cee7b6 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/JerseyPost.java @@ -0,0 +1,36 @@ +package external.services.restclient; + +import java.io.IOException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriBuilder; +import org.apache.http.client.ClientProtocolException; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class JerseyPost { + + public static void main(String[] args) throws ClientProtocolException, IOException { + + ClientConfig config = new DefaultClientConfig(); + + Client client = Client.create(config); + + WebResource webResource = client + .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/").build()); + + MultivaluedMap formData = new MultivaluedMapImpl(); + + formData.add("id", "10295765"); + formData.add("password", "Value!12"); + + ClientResponse response = webResource.path("dev").path("login").type(MediaType.APPLICATION_FORM_URLENCODED) + .post(ClientResponse.class, formData); + + System.out.println("Response " + response.getEntity(String.class)); + } +} diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyPostHeader.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyPostHeader.java new file mode 100644 index 0000000..e9c68c5 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/JerseyPostHeader.java @@ -0,0 +1,24 @@ +package external.services.restclient; + +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.representation.Form; + +public class JerseyPostHeader { + + Client client = (Client) ClientBuilder.newClient(); + WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); + + Form form = new Form(); + // form.param("x", "foo"); + // form.param("y", "bar"); + + // String bean = + // target.request(MediaType.APPLICATION_JSON_TYPE).post(MediaType.APPLICATION_FORM_URLENCODED_TYPE, + // String.class); +} diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyTest.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyTest.java new file mode 100644 index 0000000..6cee1e0 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/JerseyTest.java @@ -0,0 +1,36 @@ +package external.services.restclient; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Response; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; + +import util.AuthenticateToken; + +public class JerseyTest { + + public static void main(String[] args) { + testAttendanceRegister(); + // responseREST(); + } + + String responseREST() { + // Client client =(Client) ClientBuilder.newClient(); + Client client = Client.create(); + WebResource target = client.resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + Response response = ((WebTarget) target).request("application/json").post(Entity.json(input)); + // System.out.println(response.toString()); + + return response.toString(); + } + + static void testAttendanceRegister() { + AuthenticateToken att = new AuthenticateToken(); + att.confirmAttendance(); + } + +} diff --git a/src/test/java/external/composite-app-mock-services/restclient/NetClientPost.java b/src/test/java/external/composite-app-mock-services/restclient/NetClientPost.java new file mode 100644 index 0000000..1e71581 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/NetClientPost.java @@ -0,0 +1,56 @@ +package external.services.restclient; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +public class NetClientPost { + + // http://localhost:8080/RESTfulExample/json/product/post + public static void main(String[] args) { + + try { + URL url = new URL("https://fahze41owc.execute-api.us-east-1.amazonaws.com/dev/user"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + + String input = "{\r\n" + + " \"id\": \"102030\",\r\n" + + " \"firstName\": \"Julito\",\r\n" + + " \"lastName\": \"Schwartzenegger\",\r\n" + + " \"type\": \"administrator\"\r\n" + + "}"; + + OutputStream os = conn.getOutputStream(); + os.write(input.getBytes()); + os.flush(); + + if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { + throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); + } + + BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); + + String output; + System.out.println("Output from Server .... \n"); + while ((output = br.readLine()) != null) { + System.out.println(output); + } + + conn.disconnect(); + + } catch (MalformedURLException e) { + + e.printStackTrace(); + + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/TestRestClient.java b/src/test/java/external/composite-app-mock-services/restclient/TestRestClient.java new file mode 100644 index 0000000..8b4f929 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/restclient/TestRestClient.java @@ -0,0 +1,38 @@ +package external.services.restclient; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; + +public class TestRestClient { + string AWS_URL = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"; + + public void checkServiceAvailability() { + + } + + public void testAWSConnectAPI() { + + try { + + Client client = Client.create(); + WebResource webResource = client.resource(+AWS_URL); + String input = "{\"id\":\"10295765\",\"password\":\"TestPassword!12\"}"; + ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); + + if (response.getStatus() != 201) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatus()); + } + + System.out.println("Output from Server .... \n"); + String output = response.getEntity(String.class); + System.out.println(output); + + } catch (Exception e) { + + e.printStackTrace(); + + } + } +} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GeoIP.java b/src/test/java/external/composite-app-mock-services/wsclient/GeoIP.java new file mode 100644 index 0000000..8a58a95 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsclient/GeoIP.java @@ -0,0 +1,172 @@ +/** + * Class GeoIP imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package external.services.wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for GeoIP complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType name="GeoIP">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="ReturnCode" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="IP" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="ReturnCodeDetails" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="CountryName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="CountryCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "GeoIP", propOrder = { + "returnCode", + "ip", + "returnCodeDetails", + "countryName", + "countryCode" +}) +public class GeoIP { + + @XmlElement(name = "ReturnCode") + protected int returnCode; + @XmlElement(name = "IP") + protected String ip; + @XmlElement(name = "ReturnCodeDetails") + protected String returnCodeDetails; + @XmlElement(name = "CountryName") + protected String countryName; + @XmlElement(name = "CountryCode") + protected String countryCode; + + /** + * Gets the value of the returnCode property. + * + */ + public int getReturnCode() { + return returnCode; + } + + /** + * Sets the value of the returnCode property. + * + */ + public void setReturnCode(int value) { + this.returnCode = value; + } + + /** + * Gets the value of the ip property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIP() { + return ip; + } + + /** + * Sets the value of the ip property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIP(String value) { + this.ip = value; + } + + /** + * Gets the value of the returnCodeDetails property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getReturnCodeDetails() { + return returnCodeDetails; + } + + /** + * Sets the value of the returnCodeDetails property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReturnCodeDetails(String value) { + this.returnCodeDetails = value; + } + + /** + * Gets the value of the countryName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountryName() { + return countryName; + } + + /** + * Sets the value of the countryName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountryName(String value) { + this.countryName = value; + } + + /** + * Gets the value of the countryCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountryCode() { + return countryCode; + } + + /** + * Sets the value of the countryCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountryCode(String value) { + this.countryCode = value; + } + +} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GeoIPService.java b/src/test/java/external/composite-app-mock-services/wsclient/GeoIPService.java new file mode 100644 index 0000000..718e2c7 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsclient/GeoIPService.java @@ -0,0 +1,98 @@ +/** + * Class GeoIPService imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package external.services.wsclient; + +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.WebServiceFeature; + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebServiceClient(name = "GeoIPService", targetNamespace = "http://www.webservicex.net/", wsdlLocation = "http://www.webservicex.net/geoipservice.asmx?WSDL") +public class GeoIPService + extends Service { + + private final static URL GEOIPSERVICE_WSDL_LOCATION; + private final static WebServiceException GEOIPSERVICE_EXCEPTION; + private final static QName GEOIPSERVICE_QNAME = new QName("http://www.webservicex.net/", "GeoIPService"); + + static { + URL url = null; + WebServiceException e = null; + try { + url = new URL("http://www.webservicex.net/geoipservice.asmx?WSDL"); + } catch (MalformedURLException ex) { + e = new WebServiceException(ex); + } + GEOIPSERVICE_WSDL_LOCATION = url; + GEOIPSERVICE_EXCEPTION = e; + } + + public GeoIPService() { + super(__getWsdlLocation(), GEOIPSERVICE_QNAME); + } + + public GeoIPService(WebServiceFeature... features) { + super(__getWsdlLocation(), GEOIPSERVICE_QNAME, features); + } + + public GeoIPService(URL wsdlLocation) { + super(wsdlLocation, GEOIPSERVICE_QNAME); + } + + public GeoIPService(URL wsdlLocation, WebServiceFeature... features) { + super(wsdlLocation, GEOIPSERVICE_QNAME, features); + } + + public GeoIPService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public GeoIPService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * @return + * returns GeoIPServiceSoap + */ + @WebEndpoint(name = "GeoIPServiceSoap") + public GeoIPServiceSoap getGeoIPServiceSoap() { + return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure + * on the proxy. Supported features not in the + * features parameter will have their default + * values. + * @return + * returns GeoIPServiceSoap + */ + @WebEndpoint(name = "GeoIPServiceSoap") + public GeoIPServiceSoap getGeoIPServiceSoap(WebServiceFeature... features) { + return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class, + features); + } + + private static URL __getWsdlLocation() { + if (GEOIPSERVICE_EXCEPTION != null) { + throw GEOIPSERVICE_EXCEPTION; + } + return GEOIPSERVICE_WSDL_LOCATION; + } +} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java b/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java new file mode 100644 index 0000000..e51bfa8 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java @@ -0,0 +1,55 @@ +/** + * Class GeoIPServiceSoap imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package external.services.wsclient; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebService(name = "GeoIPServiceSoap", targetNamespace = "http://www.webservicex.net/") +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface GeoIPServiceSoap { + + /** + * GeoIPService - GetGeoIP enables you to easily look up countries by IP + * addresses + * + * @param ipAddress + * @return + * returns wsclient.GeoIP + */ + @WebMethod(operationName = "GetGeoIP", action = "http://www.webservicex.net/GetGeoIP") + @WebResult(name = "GetGeoIPResult", targetNamespace = "http://www.webservicex.net/") + @RequestWrapper(localName = "GetGeoIP", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIP") + @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPResponse") + public GeoIP getGeoIP( + @WebParam(name = "IPAddress", targetNamespace = "http://www.webservicex.net/") String ipAddress); + + /** + * GeoIPService - GetGeoIPContext enables you to easily look up countries by + * Context + * + * @return + * returns wsclient.GeoIP + */ + @WebMethod(operationName = "GetGeoIPContext", action = "http://www.webservicex.net/GetGeoIPContext") + @WebResult(name = "GetGeoIPContextResult", targetNamespace = "http://www.webservicex.net/") + @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContext") + @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContextResponse") + public GeoIP getGeoIPContext(); +} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIP.java b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIP.java new file mode 100644 index 0000000..821b804 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIP.java @@ -0,0 +1,70 @@ +/** + * Class GetGeoIP imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package external.services.wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for anonymous complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="IPAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "ipAddress" +}) +@XmlRootElement(name = "GetGeoIP") +public class GetGeoIP { + + @XmlElement(name = "IPAddress") + protected String ipAddress; + + /** + * Gets the value of the ipAddress property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIPAddress() { + return ipAddress; + } + + /** + * Sets the value of the ipAddress property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIPAddress(String value) { + this.ipAddress = value; + } +} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContext.java b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContext.java new file mode 100644 index 0000000..c1a2d5a --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContext.java @@ -0,0 +1,37 @@ +/** + * Class GetGeoIPContext imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package external.services.wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for anonymous complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "GetGeoIPContext") +public class GetGeoIPContext { + +} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContextResponse.java b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContextResponse.java new file mode 100644 index 0000000..7d94432 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContextResponse.java @@ -0,0 +1,69 @@ +/** + * Class getGeoIPContextResult imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package external.services.wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for anonymous complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetGeoIPContextResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getGeoIPContextResult" +}) +@XmlRootElement(name = "GetGeoIPContextResponse") +public class GetGeoIPContextResponse { + + @XmlElement(name = "GetGeoIPContextResult") + protected GeoIP getGeoIPContextResult; + + /** + * Gets the value of the getGeoIPContextResult property. + * + * @return + * possible object is + * {@link GeoIP } + * + */ + public GeoIP getGetGeoIPContextResult() { + return getGeoIPContextResult; + } + + /** + * Sets the value of the getGeoIPContextResult property. + * + * @param value + * allowed object is + * {@link GeoIP } + * + */ + public void setGetGeoIPContextResult(GeoIP value) { + this.getGeoIPContextResult = value; + } + +} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPResponse.java b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPResponse.java new file mode 100644 index 0000000..8ce29b2 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPResponse.java @@ -0,0 +1,69 @@ +/** + * Class getGeoIPResult imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package external.services.wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for anonymous complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetGeoIPResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getGeoIPResult" +}) +@XmlRootElement(name = "GetGeoIPResponse") +public class GetGeoIPResponse { + + @XmlElement(name = "GetGeoIPResult") + protected GeoIP getGeoIPResult; + + /** + * Gets the value of the getGeoIPResult property. + * + * @return + * possible object is + * {@link GeoIP } + * + */ + public GeoIP getGetGeoIPResult() { + return getGeoIPResult; + } + + /** + * Sets the value of the getGeoIPResult property. + * + * @param value + * allowed object is + * {@link GeoIP } + * + */ + public void setGetGeoIPResult(GeoIP value) { + this.getGeoIPResult = value; + } +} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/wsclient/ObjectFactory.java b/src/test/java/external/composite-app-mock-services/wsclient/ObjectFactory.java new file mode 100644 index 0000000..f94606f --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsclient/ObjectFactory.java @@ -0,0 +1,90 @@ +/** + * Class ObjectFactory imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package external.services.wsclient; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the wsclient package. + *

+ * An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _GeoIP_QNAME = new QName("http://www.webservicex.net/", "GeoIP"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema + * derived classes for package: wsclient + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link GeoIP } + * + */ + public GeoIP createGeoIP() { + return new GeoIP(); + } + + /** + * Create an instance of {@link GetGeoIP } + * + */ + public GetGeoIP createGetGeoIP() { + return new GetGeoIP(); + } + + /** + * Create an instance of {@link GetGeoIPResponse } + * + */ + public GetGeoIPResponse createGetGeoIPResponse() { + return new GetGeoIPResponse(); + } + + /** + * Create an instance of {@link GetGeoIPContextResponse } + * + */ + public GetGeoIPContextResponse createGetGeoIPContextResponse() { + return new GetGeoIPContextResponse(); + } + + /** + * Create an instance of {@link GetGeoIPContext } + * + */ + public GetGeoIPContext createGetGeoIPContext() { + return new GetGeoIPContext(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GeoIP }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.webservicex.net/", name = "GeoIP") + public JAXBElement createGeoIP(GeoIP value) { + return new JAXBElement(_GeoIP_QNAME, GeoIP.class, null, value); + } + +} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/package-info.java b/src/test/java/external/composite-app-mock-services/wsclient/package-info.java new file mode 100644 index 0000000..a7a776e --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsclient/package-info.java @@ -0,0 +1,6 @@ +/** + * injects annotation for java tool to work and invoke the WSDL + */ + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.webservicex.net/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package external.services.wsclient; diff --git a/src/test/java/external/composite-app-mock-services/wsdlclient/MockCountryInfoService.java b/src/test/java/external/composite-app-mock-services/wsdlclient/MockCountryInfoService.java new file mode 100644 index 0000000..a1f9c31 --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsdlclient/MockCountryInfoService.java @@ -0,0 +1,16 @@ +import org.apache.cxf.jaxws.JaxWsServerFactoryBean; +import org.example.countryinfo.CountryInfoService; + +public class MockCountryInfoService implements CountryInfoService { + // Implement the methods from the CountryInfoService interface here + + public static void main(String[] args) { + MockCountryInfoService mockService = new MockCountryInfoService(); + + JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); + factory.setServiceClass(CountryInfoService.class); + factory.setAddress("http://localhost:8080/"); + factory.setServiceBean(mockService); + factory.create(); + } +} diff --git a/src/test/java/external/composite-app-mock-services/wsdlclient/ServiceInvokationTest.java b/src/test/java/external/composite-app-mock-services/wsdlclient/ServiceInvokationTest.java new file mode 100644 index 0000000..fd7800b --- /dev/null +++ b/src/test/java/external/composite-app-mock-services/wsdlclient/ServiceInvokationTest.java @@ -0,0 +1,28 @@ +package external.services.wsdlclient; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import service.MainService; +import util.AuthenticateToken; + +public class ServiceInvokationTest { + + MainService testService = new MainService(); + AuthenticateToken attend = new AuthenticateToken(); + + @Test + public void testWSDLSuccess() { + + assertTrue(testService.invokeWSDLForIP().length() > 2); + // System.out.println(testService.invokeWSDLForIP()); + } + + @Test + public void testRestBibleSuccess() { + assertTrue(testService.invokeRestForBibleVerse().length() > 2); + // System.out.println(testService.invokeRestForBibleVerse()); + } +} diff --git a/src/test/java/external/tokenauthentication/PostAuthenticationToken.java b/src/test/java/external/tokenauthentication/PostAuthenticationToken.java new file mode 100644 index 0000000..8c93550 --- /dev/null +++ b/src/test/java/external/tokenauthentication/PostAuthenticationToken.java @@ -0,0 +1,85 @@ +package external.tokenauthentication; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonReader; + +public class PostAuthenticationToken { + + // authentication scheme based on tokens follow these steps, steps are numbered + public static void main(String[] args) { + + try { + + URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + OutputStream os = conn.getOutputStream(); + // 1.The client sends their credentials (username and password) to the server. + os.write(input.getBytes()); + os.flush(); + + if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { + throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); + } + + BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); + + String output; + // 2.The server authenticates the credentials and, if they are valid, generate a + // token for the user. + System.out.println("Output from Server .... \n"); + while ((output = br.readLine()) != null) { + JsonReader rdr = Json.createReader(br); + System.out.println("creates object"); + // rdr.readObject(); + System.out.println("obtain object" + rdr.toString()); + System.out.println("prints output " + br.readLine()); + + JsonObject obj = rdr.readObject(); + System.out.println("before reading object"); + + JsonArray results = obj.getJsonArray("AuthenticationResult"); + // obj.getJsonString(arg0) + System.out.print("value type: " + results.getValueType()); + + // for (JsonObject result : results.getValuesAs(JsonObject.class)) { + // System.out.print("value type: "+results.getValueType()); + // System.out.println("token"+ result.getString("IdToken")); + // } + + System.out.println(output); + } // end of while + + System.out.println("prints output 1" + br.readLine()); + + /// put object in hashmap somehow + + // disconnects + conn.disconnect(); + + } catch (MalformedURLException e) { + + e.printStackTrace(); + + } catch (IOException e) { + + e.printStackTrace(); + + } + } +} \ No newline at end of file diff --git a/src/test/java/json/ConversionJSON2Object.java b/src/test/java/json/ConversionJSON2Object.java new file mode 100644 index 0000000..d699a45 --- /dev/null +++ b/src/test/java/json/ConversionJSON2Object.java @@ -0,0 +1,30 @@ +package attendance.gson; + +import com.google.gson.Gson; + +import entity.LoginReply; + +public class ConversionJSON2Object { + + public static void main(String[] args) { + // TODO Auto-generated method stub: use a variable for the token + + String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaX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3hg\"}}"; + + String jsonInString = "{'name' : 'martina perumal'}"; + + Gson gson = new Gson(); + + // Restaurant restaurantObject = gson.fromJson(restaurantJson, + // Restaurant.class); + LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); + + // Object loginReplyObject = gson.fromJson(replyJson, Object.class); + + Girl girl = gson.fromJson(jsonInString, Girl.class); + + System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); + System.out.println("value of her name " + girl.getName()); + // System.out.println("obtain token "+ loginReplyObject.authenticationResult); + } +} diff --git a/src/test/java/json/ConversionJson2Map.java b/src/test/java/json/ConversionJson2Map.java new file mode 100644 index 0000000..e6f491d --- /dev/null +++ b/src/test/java/json/ConversionJson2Map.java @@ -0,0 +1,39 @@ +package attendance.gson; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; + +public class ConversionJson2Map { + + public static void main(String[] args) { + String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImp0aSI6ImI4MzY3ZjcwLTA5MDktNGI0Mi1hNDI2LWM2ZTYyY2M3ZTI0YSIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidX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YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTA4NTg2OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.N2vUTeKskoSGGnZNNQkoJrjqQSTwCRsAyoVzU8HoSESciE97PbHu_rsDBHdlIvExQgZOJUDH2fi2ZTVXL0qw_dw_1oy5PY0ss6iF9Ya8vNvwJ4QIg0nGLJEEWO6y9h81bUiy8WYOyC0uCy4FKPBzxu-VjO_ZkJwQZLlhkx56cPXhQI9JFbwQDeyxJDF9duOGiZkWYmiG842TeYpaNIiW46KtQ8kiZLGre9qUdPjQv9S-Ch9Cm8bDqVSunAVtTityUJMGJuxhM78hPAujGdeNfMX0qEx37MpKbQtkb_xJZaT1c0IXnu1tneqtGVxZtaZdQ4mUlBmdzamQaWhlSXvqyA\"}}"; + + Gson gson = new Gson(); + + Type authorization = new TypeToken>() { + }.getType(); + // TODO Auto-generated method stub + + Map authorizationMap = gson.fromJson(jsonFromMS, authorization); + + Map retMap = new Gson().fromJson(jsonFromMS, new TypeToken>() { + }.getType()); + + Map map = new Gson().fromJson(jsonFromMS, + new TypeToken>() { + }.getType()); + + System.out.println("Printing Map object: " + authorizationMap.values().toString()); + + authorizationMap.keySet().iterator().forEachRemaining(System.out::println); + + System.out.println("Printing ret Map object this is bringing the values: " + retMap.values().toString()); + + map.keySet().iterator().forEachRemaining(System.out::println); + + System.out.println(retMap.get("IdToken")); + } +} diff --git a/src/test/java/json/JSON2Object.java b/src/test/java/json/JSON2Object.java new file mode 100644 index 0000000..9f46c05 --- /dev/null +++ b/src/test/java/json/JSON2Object.java @@ -0,0 +1,24 @@ +package com.leo.json; + +import com.google.gson.Gson; + +public class JSON2Object { + + public static void main(String[] args) { + String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1MTc5MyIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.ZGB_kCYoU4vDREr6teZQyIyRT2MZkpmGyleAgsgzMRIauq7RpqgL_HUZukqSK6E5mtNxux6hihzl5CaP9jcY26u4zJTnYASBJwE4iqqggNqhp82PtFdxipf5ZvYAyF3uVTPCeiRGrxJSyoQpEWVUPDYaqj1ak1b2oTExH8sG1oOmYcaACAWY4mkjueFJCrgcWov3SyWDyMKCE7ZhaloJkcJ2uZypztB42XQ67z96bxTvRozzEVEVT4_4szpMjEj3Nmxy9kIv8H7kNMUrb5tE4vTfG-kzctCq7YxU2Ff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29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.gGcx2YYcjWzNvzlpPklry4Jt59GwDQuDRRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; + String jsonInString = "{'name' : 'martina perumal'}"; + Gson gson = new Gson(); + + // Restaurant restaurantObject = gson.fromJson(restaurantJson, + // Restaurant.class); + LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); + + // Object loginReplyObject = gson.fromJson(replyJson, Object.class); + + Girl girl = gson.fromJson(jsonInString, Girl.class); + + System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); + System.out.println("value of her name " + girl.getName()); + // System.out.println("obtain token "+ loginReplyObject.authenticationResult); + } +} diff --git a/src/test/java/json/Json2Map.java b/src/test/java/json/Json2Map.java new file mode 100644 index 0000000..edeade6 --- /dev/null +++ b/src/test/java/json/Json2Map.java @@ -0,0 +1,39 @@ +package com.json; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; + +public class Json2Map { + + public static void main(String[] args) { + String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4P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miG842TeYpaNIiW46KtQ8kiZLGre9qUdPjQv9S-Ch9Cm8bDqVSunAVtTityUJMGJuxhM78hPAujGdeNfMX0qEx37MpKbQtkb_xJZaT1c0IXnu1tneqtGVxZtaZdQ4mUlBmdzamQaWhlSXvqyA\"}}"; + + Gson gson = new Gson(); + + Type authorization = new TypeToken>() { + }.getType(); + + Map authorizationMap = gson.fromJson(jsonFromMS, authorization); + + Map retMap = new Gson().fromJson(jsonFromMS, new TypeToken>() { + }.getType()); + + Map map = new Gson().fromJson(jsonFromMS, new TypeToken>() { + }.getType()); + + System.out.println("Printing Map object: " + authorizationMap.values().toString()); + + authorizationMap.keySet().iterator().forEachRemaining(System.out::println); + + System.out.println("Printing ret Map object this is bringing the values: " + retMap.values().toString()); + + map.keySet().iterator().forEachRemaining(System.out::println); + + System.out.println(retMap.get("IdToken")); + + } + +} diff --git a/src/test/java/json/TestJSONResponse.java b/src/test/java/json/TestJSONResponse.java new file mode 100644 index 0000000..df341a2 --- /dev/null +++ b/src/test/java/json/TestJSONResponse.java @@ -0,0 +1,62 @@ +package json; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import javax.json.Json; +import javax.json.stream.JsonParser; +import javax.json.stream.JsonParser.Event; + +public class TestJSONResponse { + + public static void main(String[] args) throws MalformedURLException { + // URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); + // URL url = new + // URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + + // try (InputStream is = url.openStream(); JsonParser parser = + // Json.createParser(is)) { + try { + URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + OutputStream os = conn.getOutputStream(); + // 1.The client sends their credentials (username and password) to the server. + os.write(input.getBytes()); + os.flush(); + + BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); + + JsonParser parser = (JsonParser) Json.createReader(br); + + while (parser.hasNext()) { + Event e = parser.next(); + if (e == Event.KEY_NAME) { + switch (parser.getString()) { + case "RefreshToken": + parser.next(); + System.out.print(parser.getString()); + System.out.print(": "); + break; + case "IdToken": + parser.next(); + System.out.println(parser.getString()); + System.out.println("---------"); + break; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/test/java/utilities/TestCodeGeneration.java b/src/test/java/utilities/TestCodeGeneration.java new file mode 100644 index 0000000..d670b91 --- /dev/null +++ b/src/test/java/utilities/TestCodeGeneration.java @@ -0,0 +1,15 @@ +package utilities; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.Test; + +import bean.AttendanceBean; + +public class TestCodeGeneration { + + @Test + public void testRandomCode() { + AttendanceBean at = new AttendanceBean(); + assertNotNull("data", at.generateAttendanceCode()); + } // testRandomCode() +} diff --git a/src/test/java/utilities/TestQRFunctions.java b/src/test/java/utilities/TestQRFunctions.java new file mode 100644 index 0000000..52e5dd7 --- /dev/null +++ b/src/test/java/utilities/TestQRFunctions.java @@ -0,0 +1,13 @@ +package utilities; + +import org.junit.Test; + +public class TestQRFunctions { + @Test + public void createQRCodeLocally() { + GenerateQRCode qrCode; + qrCode.createWebsiteQRCode(); + assertTrue(qrCode.validateQR = true); + } + +} From 9c62eaa7d77ae306dca9be6004ffe922dd9509a9 Mon Sep 17 00:00:00 2001 From: aleonrangel Date: Mon, 25 Sep 2023 13:29:18 +1300 Subject: [PATCH 12/32] clean up structure --- src/main/java/bean/AttendanceRegister.java | 115 ------------------ src/main/java/bean/Main.java | 62 ---------- src/main/java/bean/Room.java | 23 ---- src/test/attendance/Authorization.java | 32 ----- .../attendance/TestAuthenticationResult.java | 72 ----------- 5 files changed, 304 deletions(-) delete mode 100644 src/main/java/bean/AttendanceRegister.java delete mode 100644 src/main/java/bean/Main.java delete mode 100644 src/main/java/bean/Room.java delete mode 100644 src/test/attendance/Authorization.java delete mode 100644 src/test/attendance/TestAuthenticationResult.java diff --git a/src/main/java/bean/AttendanceRegister.java b/src/main/java/bean/AttendanceRegister.java deleted file mode 100644 index f53a98b..0000000 --- a/src/main/java/bean/AttendanceRegister.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Class AttendanceRegister - * sends invocation to webservice for confirmation of attendance. Includes prime faces UI functionality. - */ - -package bean; - -import javax.faces.application.FacesMessage; -import javax.faces.bean.ManagedBean; -import javax.faces.context.FacesContext; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; - -import com.google.gson.JsonObject; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -import service.UserService; - -@ManagedBean -public class AttendanceRegister { - - private String inputCode; - private Integer progress; - - public String confirmAttendance() { - - String replyFromMS = null; - - UserService tok = new UserService(); - String token = tok.obtainIdToken("10295765", "Value!12"); - // 1-open connection and send user and password as a POST method - ClientConfig config = new DefaultClientConfig(); - - Client client = Client.create(config); - WebResource webResource = client.resource(UriBuilder - .fromUri("https://xgdeevdwh1.execute-api.us-east-1.amazonaws.com").path("addAttendance").build()); - // Passing parameters - // {"studentId": "246810","paperId": "COMP101","status": "present"} - - MultivaluedMap formData = new MultivaluedMapImpl(); - formData.add("studentId", "246810"); - formData.add("paperId", "COMP101"); - formData.add("status", "present"); - - JsonObject jsonPayLoad = new JsonObject(); - jsonPayLoad.addProperty("studentId", "246810"); - jsonPayLoad.addProperty("paperId", "COMP101"); - jsonPayLoad.addProperty("status", "present"); - - // ClientResponse response = - // webResource.accept(MediaType.APPLICATION_JSON).header("Authorization", - // token).post(ClientResponse.class, jsonPayLoad.toString()); - ClientResponse response = webResource.header("Authorization", token).post(ClientResponse.class, - jsonPayLoad.toString()); - replyFromMS = response.getEntity(String.class); - // String replyFromMS = - // webResource.path("addAttendance").accept(MediaType.APPLICATION_JSON).header("Authorization", - // token).post(String.class, jsonPayLoad.toString()); - - System.out.println("AttendanceRegisterResponse:" + response); - - // invoke WS to confirm Attendance and validate - FacesContext context = FacesContext.getCurrentInstance(); - context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "CORRECT", "Attendance Registered!!!")); - - if (replyFromMS.isEmpty()) { - return "attendanceNOK.xhtml"; - } else { - return "attendanceOK.xhtml"; - } - } - - public Integer getProgress() { - if (progress == null) { - progress = 0; - } else { - progress = progress + (int) (Math.random() * 35); - - if (progress > 100) - progress = 100; - } - return progress; - } - - public void setProgress(Integer progress) { - this.progress = progress; - } - - public void onComplete() { - FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Time Ended")); - } - - public String onTimeout() { - FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Time Out")); - return "main.xhtml"; - } - - public void cancel() { - progress = null; - } - - public String getInputCode() { - return inputCode; - } - - public void setInputCode(String inputCode) { - this.inputCode = inputCode; - } -} \ No newline at end of file diff --git a/src/main/java/bean/Main.java b/src/main/java/bean/Main.java deleted file mode 100644 index 9b4379d..0000000 --- a/src/main/java/bean/Main.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Class Main connects to main.xhtml - * calls Web services to obtain data from random Free services online - * obtains IP and Random Bible Verse - */ - -package bean; - -import javax.annotation.PostConstruct; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; - -import service.MainService; - -@ManagedBean(name = "main") -@SessionScoped - -public class Main { - - private String bibleVerse; - private String linkedPage; - private String geoIpWS; - - @PostConstruct - public void init() { - MainService invoker = new MainService(); - // invoke web services - setGeoIpWS(invoker.invokeWSDLForIP()); - setBibleVerse(invoker.invokeRestForBibleVerse()); - } - - public String getGeoIpWS() { - return geoIpWS; - } - - public void setGeoIpWS(String geoIpWS) { - this.geoIpWS = geoIpWS; - } - - public String getBibleVerse() { - return bibleVerse; - } - - public void setBibleVerse(String bibleVerse) { - this.bibleVerse = bibleVerse; - } - - public void setLinkedPage(String linkedPage) { - this.linkedPage = linkedPage; - } - - public String getlinkedPage() { - if (linkedPage == "1") { - linkedPage = "attendance"; - System.out.println("this block page is-->" + linkedPage); - } else { - linkedPage = "registerAttendance"; - System.out.println("this else block page is-->" + linkedPage); - } - return linkedPage; - } -} \ No newline at end of file diff --git a/src/main/java/bean/Room.java b/src/main/java/bean/Room.java deleted file mode 100644 index 097d58e..0000000 --- a/src/main/java/bean/Room.java +++ /dev/null @@ -1,23 +0,0 @@ - /** - * Class Room reflects paper management UI for Lectures Rooms - * class template - */ - -package bean; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import javax.faces.bean.ManagedBean; - -@ManagedBean -// (name = "room") -public class Room { - - public String obtainSessionNumber() { - - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); - LocalDateTime now = LocalDateTime.now(); - - return dtf.format(now); - } -} diff --git a/src/test/attendance/Authorization.java b/src/test/attendance/Authorization.java deleted file mode 100644 index 069fc82..0000000 --- a/src/test/attendance/Authorization.java +++ /dev/null @@ -1,32 +0,0 @@ -/*-- com.leo.json.Authorization.java -- */ - -package com.leo.json; - -import com.google.gson.annotations.SerializedName; - -public class Authorization { - - // names have to be the same from JSON to Java Object so that it works fine. - - private ChallengeParameters challengeParameters; - // @SerializedName("AuthenticationResult") - // @Expose - private AuthenticationResult authenticationResult; - - public ChallengeParameters getChallengeParameters() { - return challengeParameters; - } - - public void setChallengeParameters(ChallengeParameters challengeParameters) { - this.challengeParameters = challengeParameters; - } - - public AuthenticationResult getAuthenticationResult() { - return authenticationResult; - } - - public void setAuthenticationResult(AuthenticationResult authenticationResult) { - this.authenticationResult = authenticationResult; - } - -} \ No newline at end of file diff --git a/src/test/attendance/TestAuthenticationResult.java b/src/test/attendance/TestAuthenticationResult.java deleted file mode 100644 index 3b9c801..0000000 --- a/src/test/attendance/TestAuthenticationResult.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.json; - -import com.google.gson.annotations.SerializedName; - -public class AuthenticationResult { - - public AuthenticationResult(String accessToken, Integer expiresIn, String tokenType, String refreshToken, - String idToken) { - this.accessToken = accessToken; - this.expiresIn = expiresIn; - this.tokenType = tokenType; - this.refreshToken = refreshToken; - this.idToken = idToken; - } - - @SerializedName("AccessToken") - private String accessToken; - - @SerializedName("ExpiresIn") - private Integer expiresIn; - - @SerializedName("TokenType") - private String tokenType; - - @SerializedName("RefreshToken") - private String refreshToken; - - @SerializedName("IdToken") - private String idToken; - - // Setters and getters - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - public Integer getExpiresIn() { - return expiresIn; - } - - public void setExpiresIn(Integer expiresIn) { - this.expiresIn = expiresIn; - } - - public String getTokenType() { - return tokenType; - } - - public void setTokenType(String tokenType) { - this.tokenType = tokenType; - } - - public String getRefreshToken() { - return refreshToken; - } - - public void setRefreshToken(String refreshToken) { - this.refreshToken = refreshToken; - } - - public String getIdToken() { - return idToken; - } - - public void setIdToken(String idToken) { - this.idToken = idToken; - } -} From dd37188d6468936364d1f82d520764b87265f48a Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Tue, 26 Sep 2023 12:20:11 +1300 Subject: [PATCH 13/32] port for cxf wsdl2java function Signed-off-by: Andres LeonRangel --- build.gradle.kts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 785e624..d73548d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,11 +12,13 @@ plugins { // https://docs.gradle.org/7.3/dsl/org.gradle.api.tasks.bundling.War.html war //wsdl - id("org.apache.cxf.cxf") version "1.0.0" + id("io.mateo.cxf-codegen") version "1.0.1" } repositories { - mavenCentral() + gradlePluginPortal() + google() + mavenCentral() } dependencies { @@ -88,11 +90,11 @@ tasks.register("singleTest") { // dependsOn("appRun") // } // } -cxf { - wsdl2java { - // wsdl info about countries - wsdl = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL" - packageName = "org.example.countryinfo" - outputDir = file("src/main/java") - } -} \ No newline at end of file +// cxf { +// wsdl2java { +// // wsdl info about countries +// wsdl = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL" +// packageName = "org.example.countryinfo" +// outputDir = file("src/main/java") +// } +// } \ No newline at end of file From 2524aea1173cf870b6a783ecef02a6be64fefa69 Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Tue, 26 Sep 2023 23:17:21 +1300 Subject: [PATCH 14/32] migrated API/services clients common directory Signed-off-by: Andres LeonRangel --- src/main/java/clients/rest/JerseyClient.java | 41 +++++ .../java/clients/rest/JerseyClientPost.java | 32 ++++ src/main/java/clients/rest/JerseyGet.java | 37 ++++ .../java/clients/rest/JerseyJsonResponse.java | 36 ++++ .../java/clients/rest/JerseyJsonSimpler.java | 28 +++ src/main/java/clients/rest/JerseyPost.java | 36 ++++ .../java/clients/rest/JerseyPostHeader.java | 24 +++ src/main/java/clients/rest/JerseyTest.java | 36 ++++ src/main/java/clients/rest/NetClientPost.java | 56 ++++++ .../clients/rest/PostAuthenticationToken.java | 85 +++++++++ .../java/clients/rest/TestJSONResponse.java | 62 +++++++ .../java/clients/rest/TestRestClient.java | 38 ++++ src/main/java/clients/wsdl/geoIP/GeoIP.java | 172 ++++++++++++++++++ .../java/clients/wsdl/geoIP/GeoIPService.java | 98 ++++++++++ .../clients/wsdl/geoIP/GeoIPServiceSoap.java | 55 ++++++ .../java/clients/wsdl/geoIP/GetGeoIP.java | 70 +++++++ .../clients/wsdl/geoIP/GetGeoIPContext.java | 37 ++++ .../wsdl/geoIP/GetGeoIPContextResponse.java | 69 +++++++ .../clients/wsdl/geoIP/GetGeoIPResponse.java | 69 +++++++ .../clients/wsdl/geoIP/ObjectFactory.java | 90 +++++++++ .../java/clients/wsdl/geoIP/package-info.java | 6 + 21 files changed, 1177 insertions(+) create mode 100644 src/main/java/clients/rest/JerseyClient.java create mode 100644 src/main/java/clients/rest/JerseyClientPost.java create mode 100644 src/main/java/clients/rest/JerseyGet.java create mode 100644 src/main/java/clients/rest/JerseyJsonResponse.java create mode 100644 src/main/java/clients/rest/JerseyJsonSimpler.java create mode 100644 src/main/java/clients/rest/JerseyPost.java create mode 100644 src/main/java/clients/rest/JerseyPostHeader.java create mode 100644 src/main/java/clients/rest/JerseyTest.java create mode 100644 src/main/java/clients/rest/NetClientPost.java create mode 100644 src/main/java/clients/rest/PostAuthenticationToken.java create mode 100644 src/main/java/clients/rest/TestJSONResponse.java create mode 100644 src/main/java/clients/rest/TestRestClient.java create mode 100644 src/main/java/clients/wsdl/geoIP/GeoIP.java create mode 100644 src/main/java/clients/wsdl/geoIP/GeoIPService.java create mode 100644 src/main/java/clients/wsdl/geoIP/GeoIPServiceSoap.java create mode 100644 src/main/java/clients/wsdl/geoIP/GetGeoIP.java create mode 100644 src/main/java/clients/wsdl/geoIP/GetGeoIPContext.java create mode 100644 src/main/java/clients/wsdl/geoIP/GetGeoIPContextResponse.java create mode 100644 src/main/java/clients/wsdl/geoIP/GetGeoIPResponse.java create mode 100644 src/main/java/clients/wsdl/geoIP/ObjectFactory.java create mode 100644 src/main/java/clients/wsdl/geoIP/package-info.java diff --git a/src/main/java/clients/rest/JerseyClient.java b/src/main/java/clients/rest/JerseyClient.java new file mode 100644 index 0000000..46fb03e --- /dev/null +++ b/src/main/java/clients/rest/JerseyClient.java @@ -0,0 +1,41 @@ +package testing.rest; + +import java.io.IOException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; +import org.apache.http.client.ClientProtocolException; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; + +public class JerseyClient { + + /** + * @param args + * @throws ClientProtocolException + * @throws IOException + */ + + public void obtainJSONResponse() throws ClientProtocolException, IOException { + + // Invoke REST service with GET Method + ClientConfig config = new DefaultClientConfig(); + Client client = Client.create(config); + + WebResource service = client + .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); + + // getting JSON data + System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( + "Authorization", + "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") + .get(String.class)); + } + + public void obtainXMLResponse() throws ClientProtocolException, IOException { + // getting XML data + // System.out.println("with + // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); + } +} \ No newline at end of file diff --git a/src/main/java/clients/rest/JerseyClientPost.java b/src/main/java/clients/rest/JerseyClientPost.java new file mode 100644 index 0000000..4b58e7f --- /dev/null +++ b/src/main/java/clients/rest/JerseyClientPost.java @@ -0,0 +1,32 @@ +package jersey; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; + +public class JerseyClientPost { + + public static void main(String[] args) { + + try { + Client client = Client.create(); + WebResource webResource = client.resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); + + if (response.getStatus() != 201) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatus()); + } + + System.out.println("Output from Server .... \n"); + String output = response.getEntity(String.class); + System.out.println(output); + + } catch (Exception e) { + + e.printStackTrace(); + + } + } +} \ No newline at end of file diff --git a/src/main/java/clients/rest/JerseyGet.java b/src/main/java/clients/rest/JerseyGet.java new file mode 100644 index 0000000..e04c856 --- /dev/null +++ b/src/main/java/clients/rest/JerseyGet.java @@ -0,0 +1,37 @@ +package jersey; + +import java.io.IOException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; +import org.apache.http.client.ClientProtocolException; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; + +public class JerseyGet { + + /** + * @param args + * @throws ClientProtocolException + * @throws IOException + */ + public static void main(String[] args) throws ClientProtocolException, IOException { + + ClientConfig config = new DefaultClientConfig(); + Client client = Client.create(config); + + WebResource service = client + .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); + + // getting JSON data + System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( + "Authorization", + "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") + .get(String.class)); + + // getting XML data + // System.out.println("with + // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); + } +} \ No newline at end of file diff --git a/src/main/java/clients/rest/JerseyJsonResponse.java b/src/main/java/clients/rest/JerseyJsonResponse.java new file mode 100644 index 0000000..9521ae6 --- /dev/null +++ b/src/main/java/clients/rest/JerseyJsonResponse.java @@ -0,0 +1,36 @@ +package jersey; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; + +public class JerseyJsonResponse { + + public static void main(String[] args) { + try { + String baseuri = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login/"; + Client client = Client.create(); + + WebResource webResource = client.resource(baseuri); + + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + // POST method + ClientResponse response = webResource.accept("application/json").type("type:application/json") + .post(ClientResponse.class, input); + + // check response status code + if (response.getStatus() != 200) { + throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); + } + + // display response + String output = response.getEntity(String.class); + System.out.println("Output from Server .... "); + System.out.println(output + "\n"); + } catch (Exception e) { + e.printStackTrace(); + } + + } // main() +} diff --git a/src/main/java/clients/rest/JerseyJsonSimpler.java b/src/main/java/clients/rest/JerseyJsonSimpler.java new file mode 100644 index 0000000..8941a7e --- /dev/null +++ b/src/main/java/clients/rest/JerseyJsonSimpler.java @@ -0,0 +1,28 @@ +package testing.rest; + +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.representation.Form; + +public class JerseyJsonSimpler { + + public static void main(String[] args) { + + try { + Client client = (Client) ClientBuilder.newClient(); + WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); + + Form form = new Form(); + form.add("id", "10295765"); + form.add("password", "Value!12"); + // ClientResponse response = + // WebResource.class.type(MediaType.TEXT_PLAIN).post(ClientResponse.class, + // form); + } catch (Exception e) { + e.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/src/main/java/clients/rest/JerseyPost.java b/src/main/java/clients/rest/JerseyPost.java new file mode 100644 index 0000000..ddbac2a --- /dev/null +++ b/src/main/java/clients/rest/JerseyPost.java @@ -0,0 +1,36 @@ +package testing.rest; + +import java.io.IOException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriBuilder; +import org.apache.http.client.ClientProtocolException; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class JerseyPost { + + public static void main(String[] args) throws ClientProtocolException, IOException { + + ClientConfig config = new DefaultClientConfig(); + + Client client = Client.create(config); + + WebResource webResource = client + .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/").build()); + + MultivaluedMap formData = new MultivaluedMapImpl(); + + formData.add("id", "10295765"); + formData.add("password", "Value!12"); + + ClientResponse response = webResource.path("dev").path("login").type(MediaType.APPLICATION_FORM_URLENCODED) + .post(ClientResponse.class, formData); + + System.out.println("Response " + response.getEntity(String.class)); + } +} diff --git a/src/main/java/clients/rest/JerseyPostHeader.java b/src/main/java/clients/rest/JerseyPostHeader.java new file mode 100644 index 0000000..ae8f69e --- /dev/null +++ b/src/main/java/clients/rest/JerseyPostHeader.java @@ -0,0 +1,24 @@ +package testing.rest; + +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.representation.Form; + +public class JerseyPostHeader { + + Client client = (Client) ClientBuilder.newClient(); + WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); + + Form form = new Form(); + // form.param("x", "foo"); + // form.param("y", "bar"); + + // String bean = + // target.request(MediaType.APPLICATION_JSON_TYPE).post(MediaType.APPLICATION_FORM_URLENCODED_TYPE, + // String.class); +} diff --git a/src/main/java/clients/rest/JerseyTest.java b/src/main/java/clients/rest/JerseyTest.java new file mode 100644 index 0000000..a474dc2 --- /dev/null +++ b/src/main/java/clients/rest/JerseyTest.java @@ -0,0 +1,36 @@ +package testing.rest; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Response; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; + +import bean.AttendanceRegister; + +public class JerseyTest { + + public static void main(String[] args) { + testAttendanceRegister(); + // responseREST(); + } + + String responseREST() { + // Client client =(Client) ClientBuilder.newClient(); + Client client = Client.create(); + WebResource target = client.resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + Response response = ((WebTarget) target).request("application/json").post(Entity.json(input)); + // System.out.println(response.toString()); + + return response.toString(); + } + + static void testAttendanceRegister() { + AttendanceRegister att = new AttendanceRegister(); + att.confirmAttendance(); + } + +} diff --git a/src/main/java/clients/rest/NetClientPost.java b/src/main/java/clients/rest/NetClientPost.java new file mode 100644 index 0000000..213b3af --- /dev/null +++ b/src/main/java/clients/rest/NetClientPost.java @@ -0,0 +1,56 @@ +package testing.rest; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +public class NetClientPost { + + // http://localhost:8080/RESTfulExample/json/product/post + public static void main(String[] args) { + + try { + URL url = new URL("https://fahze41owc.execute-api.us-east-1.amazonaws.com/dev/user"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + + String input = "{\r\n" + + " \"id\": \"102030\",\r\n" + + " \"firstName\": \"Julito\",\r\n" + + " \"lastName\": \"Schwartzenegger\",\r\n" + + " \"type\": \"administrator\"\r\n" + + "}"; + + OutputStream os = conn.getOutputStream(); + os.write(input.getBytes()); + os.flush(); + + if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { + throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); + } + + BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); + + String output; + System.out.println("Output from Server .... \n"); + while ((output = br.readLine()) != null) { + System.out.println(output); + } + + conn.disconnect(); + + } catch (MalformedURLException e) { + + e.printStackTrace(); + + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/src/main/java/clients/rest/PostAuthenticationToken.java b/src/main/java/clients/rest/PostAuthenticationToken.java new file mode 100644 index 0000000..b9d37a2 --- /dev/null +++ b/src/main/java/clients/rest/PostAuthenticationToken.java @@ -0,0 +1,85 @@ +package rest; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonReader; + +public class PostAuthenticationToken { + + // authentication scheme based on tokens follow these steps, steps are numbered + public static void main(String[] args) { + + try { + + URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + OutputStream os = conn.getOutputStream(); + // 1.The client sends their credentials (username and password) to the server. + os.write(input.getBytes()); + os.flush(); + + if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { + throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); + } + + BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); + + String output; + // 2.The server authenticates the credentials and, if they are valid, generate a + // token for the user. + System.out.println("Output from Server .... \n"); + while ((output = br.readLine()) != null) { + JsonReader rdr = Json.createReader(br); + System.out.println("creates object"); + // rdr.readObject(); + System.out.println("obtain object" + rdr.toString()); + System.out.println("prints output " + br.readLine()); + + JsonObject obj = rdr.readObject(); + System.out.println("before reading object"); + + JsonArray results = obj.getJsonArray("AuthenticationResult"); + // obj.getJsonString(arg0) + System.out.print("value type: " + results.getValueType()); + + // for (JsonObject result : results.getValuesAs(JsonObject.class)) { + // System.out.print("value type: "+results.getValueType()); + // System.out.println("token"+ result.getString("IdToken")); + // } + + System.out.println(output); + } // end of while + + System.out.println("prints output 1" + br.readLine()); + + /// put object in hashmap somehow + + // disconnects + conn.disconnect(); + + } catch (MalformedURLException e) { + + e.printStackTrace(); + + } catch (IOException e) { + + e.printStackTrace(); + + } + } +} \ No newline at end of file diff --git a/src/main/java/clients/rest/TestJSONResponse.java b/src/main/java/clients/rest/TestJSONResponse.java new file mode 100644 index 0000000..fec4be0 --- /dev/null +++ b/src/main/java/clients/rest/TestJSONResponse.java @@ -0,0 +1,62 @@ +package jersey; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import javax.json.Json; +import javax.json.stream.JsonParser; +import javax.json.stream.JsonParser.Event; + +public class TestJSONResponse { + + public static void main(String[] args) throws MalformedURLException { + // URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); + // URL url = new + // URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + + // try (InputStream is = url.openStream(); JsonParser parser = + // Json.createParser(is)) { + try { + URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + OutputStream os = conn.getOutputStream(); + // 1.The client sends their credentials (username and password) to the server. + os.write(input.getBytes()); + os.flush(); + + BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); + + JsonParser parser = (JsonParser) Json.createReader(br); + + while (parser.hasNext()) { + Event e = parser.next(); + if (e == Event.KEY_NAME) { + switch (parser.getString()) { + case "RefreshToken": + parser.next(); + System.out.print(parser.getString()); + System.out.print(": "); + break; + case "IdToken": + parser.next(); + System.out.println(parser.getString()); + System.out.println("---------"); + break; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/clients/rest/TestRestClient.java b/src/main/java/clients/rest/TestRestClient.java new file mode 100644 index 0000000..342011d --- /dev/null +++ b/src/main/java/clients/rest/TestRestClient.java @@ -0,0 +1,38 @@ +package rest; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; + +public class TestRestClient { + string AWS_URL = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"; + + public void checkServiceAvailability() { + + } + + public void testAWSConnectAPI() { + + try { + + Client client = Client.create(); + WebResource webResource = client.resource(+AWS_URL); + String input = "{\"id\":\"10295765\",\"password\":\"TestPassword!12\"}"; + ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); + + if (response.getStatus() != 201) { + throw new RuntimeException("Failed : HTTP error code : " + + response.getStatus()); + } + + System.out.println("Output from Server .... \n"); + String output = response.getEntity(String.class); + System.out.println(output); + + } catch (Exception e) { + + e.printStackTrace(); + + } + } +} diff --git a/src/main/java/clients/wsdl/geoIP/GeoIP.java b/src/main/java/clients/wsdl/geoIP/GeoIP.java new file mode 100644 index 0000000..1e66ceb --- /dev/null +++ b/src/main/java/clients/wsdl/geoIP/GeoIP.java @@ -0,0 +1,172 @@ +/** + * Class GeoIP imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for GeoIP complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType name="GeoIP">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="ReturnCode" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="IP" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="ReturnCodeDetails" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="CountryName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="CountryCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "GeoIP", propOrder = { + "returnCode", + "ip", + "returnCodeDetails", + "countryName", + "countryCode" +}) +public class GeoIP { + + @XmlElement(name = "ReturnCode") + protected int returnCode; + @XmlElement(name = "IP") + protected String ip; + @XmlElement(name = "ReturnCodeDetails") + protected String returnCodeDetails; + @XmlElement(name = "CountryName") + protected String countryName; + @XmlElement(name = "CountryCode") + protected String countryCode; + + /** + * Gets the value of the returnCode property. + * + */ + public int getReturnCode() { + return returnCode; + } + + /** + * Sets the value of the returnCode property. + * + */ + public void setReturnCode(int value) { + this.returnCode = value; + } + + /** + * Gets the value of the ip property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIP() { + return ip; + } + + /** + * Sets the value of the ip property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIP(String value) { + this.ip = value; + } + + /** + * Gets the value of the returnCodeDetails property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getReturnCodeDetails() { + return returnCodeDetails; + } + + /** + * Sets the value of the returnCodeDetails property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setReturnCodeDetails(String value) { + this.returnCodeDetails = value; + } + + /** + * Gets the value of the countryName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountryName() { + return countryName; + } + + /** + * Sets the value of the countryName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountryName(String value) { + this.countryName = value; + } + + /** + * Gets the value of the countryCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCountryCode() { + return countryCode; + } + + /** + * Sets the value of the countryCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCountryCode(String value) { + this.countryCode = value; + } + +} diff --git a/src/main/java/clients/wsdl/geoIP/GeoIPService.java b/src/main/java/clients/wsdl/geoIP/GeoIPService.java new file mode 100644 index 0000000..7771643 --- /dev/null +++ b/src/main/java/clients/wsdl/geoIP/GeoIPService.java @@ -0,0 +1,98 @@ +/** + * Class GeoIPService imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package wsclient; + +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.WebServiceFeature; + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebServiceClient(name = "GeoIPService", targetNamespace = "http://www.webservicex.net/", wsdlLocation = "http://www.webservicex.net/geoipservice.asmx?WSDL") +public class GeoIPService + extends Service { + + private final static URL GEOIPSERVICE_WSDL_LOCATION; + private final static WebServiceException GEOIPSERVICE_EXCEPTION; + private final static QName GEOIPSERVICE_QNAME = new QName("http://www.webservicex.net/", "GeoIPService"); + + static { + URL url = null; + WebServiceException e = null; + try { + url = new URL("http://www.webservicex.net/geoipservice.asmx?WSDL"); + } catch (MalformedURLException ex) { + e = new WebServiceException(ex); + } + GEOIPSERVICE_WSDL_LOCATION = url; + GEOIPSERVICE_EXCEPTION = e; + } + + public GeoIPService() { + super(__getWsdlLocation(), GEOIPSERVICE_QNAME); + } + + public GeoIPService(WebServiceFeature... features) { + super(__getWsdlLocation(), GEOIPSERVICE_QNAME, features); + } + + public GeoIPService(URL wsdlLocation) { + super(wsdlLocation, GEOIPSERVICE_QNAME); + } + + public GeoIPService(URL wsdlLocation, WebServiceFeature... features) { + super(wsdlLocation, GEOIPSERVICE_QNAME, features); + } + + public GeoIPService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public GeoIPService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * @return + * returns GeoIPServiceSoap + */ + @WebEndpoint(name = "GeoIPServiceSoap") + public GeoIPServiceSoap getGeoIPServiceSoap() { + return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure + * on the proxy. Supported features not in the + * features parameter will have their default + * values. + * @return + * returns GeoIPServiceSoap + */ + @WebEndpoint(name = "GeoIPServiceSoap") + public GeoIPServiceSoap getGeoIPServiceSoap(WebServiceFeature... features) { + return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class, + features); + } + + private static URL __getWsdlLocation() { + if (GEOIPSERVICE_EXCEPTION != null) { + throw GEOIPSERVICE_EXCEPTION; + } + return GEOIPSERVICE_WSDL_LOCATION; + } +} diff --git a/src/main/java/clients/wsdl/geoIP/GeoIPServiceSoap.java b/src/main/java/clients/wsdl/geoIP/GeoIPServiceSoap.java new file mode 100644 index 0000000..22a84bb --- /dev/null +++ b/src/main/java/clients/wsdl/geoIP/GeoIPServiceSoap.java @@ -0,0 +1,55 @@ +/** + * Class GeoIPServiceSoap imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package wsclient; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebService(name = "GeoIPServiceSoap", targetNamespace = "http://www.webservicex.net/") +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface GeoIPServiceSoap { + + /** + * GeoIPService - GetGeoIP enables you to easily look up countries by IP + * addresses + * + * @param ipAddress + * @return + * returns wsclient.GeoIP + */ + @WebMethod(operationName = "GetGeoIP", action = "http://www.webservicex.net/GetGeoIP") + @WebResult(name = "GetGeoIPResult", targetNamespace = "http://www.webservicex.net/") + @RequestWrapper(localName = "GetGeoIP", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIP") + @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPResponse") + public GeoIP getGeoIP( + @WebParam(name = "IPAddress", targetNamespace = "http://www.webservicex.net/") String ipAddress); + + /** + * GeoIPService - GetGeoIPContext enables you to easily look up countries by + * Context + * + * @return + * returns wsclient.GeoIP + */ + @WebMethod(operationName = "GetGeoIPContext", action = "http://www.webservicex.net/GetGeoIPContext") + @WebResult(name = "GetGeoIPContextResult", targetNamespace = "http://www.webservicex.net/") + @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContext") + @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContextResponse") + public GeoIP getGeoIPContext(); +} diff --git a/src/main/java/clients/wsdl/geoIP/GetGeoIP.java b/src/main/java/clients/wsdl/geoIP/GetGeoIP.java new file mode 100644 index 0000000..ab3a42f --- /dev/null +++ b/src/main/java/clients/wsdl/geoIP/GetGeoIP.java @@ -0,0 +1,70 @@ +/** + * Class GetGeoIP imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for anonymous complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="IPAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "ipAddress" +}) +@XmlRootElement(name = "GetGeoIP") +public class GetGeoIP { + + @XmlElement(name = "IPAddress") + protected String ipAddress; + + /** + * Gets the value of the ipAddress property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIPAddress() { + return ipAddress; + } + + /** + * Sets the value of the ipAddress property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIPAddress(String value) { + this.ipAddress = value; + } +} diff --git a/src/main/java/clients/wsdl/geoIP/GetGeoIPContext.java b/src/main/java/clients/wsdl/geoIP/GetGeoIPContext.java new file mode 100644 index 0000000..5a9adbc --- /dev/null +++ b/src/main/java/clients/wsdl/geoIP/GetGeoIPContext.java @@ -0,0 +1,37 @@ +/** + * Class GetGeoIPContext imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for anonymous complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "GetGeoIPContext") +public class GetGeoIPContext { + +} diff --git a/src/main/java/clients/wsdl/geoIP/GetGeoIPContextResponse.java b/src/main/java/clients/wsdl/geoIP/GetGeoIPContextResponse.java new file mode 100644 index 0000000..eabac05 --- /dev/null +++ b/src/main/java/clients/wsdl/geoIP/GetGeoIPContextResponse.java @@ -0,0 +1,69 @@ +/** + * Class getGeoIPContextResult imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for anonymous complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetGeoIPContextResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getGeoIPContextResult" +}) +@XmlRootElement(name = "GetGeoIPContextResponse") +public class GetGeoIPContextResponse { + + @XmlElement(name = "GetGeoIPContextResult") + protected GeoIP getGeoIPContextResult; + + /** + * Gets the value of the getGeoIPContextResult property. + * + * @return + * possible object is + * {@link GeoIP } + * + */ + public GeoIP getGetGeoIPContextResult() { + return getGeoIPContextResult; + } + + /** + * Sets the value of the getGeoIPContextResult property. + * + * @param value + * allowed object is + * {@link GeoIP } + * + */ + public void setGetGeoIPContextResult(GeoIP value) { + this.getGeoIPContextResult = value; + } + +} diff --git a/src/main/java/clients/wsdl/geoIP/GetGeoIPResponse.java b/src/main/java/clients/wsdl/geoIP/GetGeoIPResponse.java new file mode 100644 index 0000000..fa15f74 --- /dev/null +++ b/src/main/java/clients/wsdl/geoIP/GetGeoIPResponse.java @@ -0,0 +1,69 @@ +/** + * Class getGeoIPResult imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package wsclient; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

+ * Java class for anonymous complex type. + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetGeoIPResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getGeoIPResult" +}) +@XmlRootElement(name = "GetGeoIPResponse") +public class GetGeoIPResponse { + + @XmlElement(name = "GetGeoIPResult") + protected GeoIP getGeoIPResult; + + /** + * Gets the value of the getGeoIPResult property. + * + * @return + * possible object is + * {@link GeoIP } + * + */ + public GeoIP getGetGeoIPResult() { + return getGeoIPResult; + } + + /** + * Sets the value of the getGeoIPResult property. + * + * @param value + * allowed object is + * {@link GeoIP } + * + */ + public void setGetGeoIPResult(GeoIP value) { + this.getGeoIPResult = value; + } +} \ No newline at end of file diff --git a/src/main/java/clients/wsdl/geoIP/ObjectFactory.java b/src/main/java/clients/wsdl/geoIP/ObjectFactory.java new file mode 100644 index 0000000..a81a6eb --- /dev/null +++ b/src/main/java/clients/wsdl/geoIP/ObjectFactory.java @@ -0,0 +1,90 @@ +/** + * Class ObjectFactory imported from WSDL with java tool + * replicates WSDL to invoke External Web service + */ + +package wsclient; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the wsclient package. + *

+ * An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _GeoIP_QNAME = new QName("http://www.webservicex.net/", "GeoIP"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema + * derived classes for package: wsclient + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link GeoIP } + * + */ + public GeoIP createGeoIP() { + return new GeoIP(); + } + + /** + * Create an instance of {@link GetGeoIP } + * + */ + public GetGeoIP createGetGeoIP() { + return new GetGeoIP(); + } + + /** + * Create an instance of {@link GetGeoIPResponse } + * + */ + public GetGeoIPResponse createGetGeoIPResponse() { + return new GetGeoIPResponse(); + } + + /** + * Create an instance of {@link GetGeoIPContextResponse } + * + */ + public GetGeoIPContextResponse createGetGeoIPContextResponse() { + return new GetGeoIPContextResponse(); + } + + /** + * Create an instance of {@link GetGeoIPContext } + * + */ + public GetGeoIPContext createGetGeoIPContext() { + return new GetGeoIPContext(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GeoIP }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.webservicex.net/", name = "GeoIP") + public JAXBElement createGeoIP(GeoIP value) { + return new JAXBElement(_GeoIP_QNAME, GeoIP.class, null, value); + } + +} diff --git a/src/main/java/clients/wsdl/geoIP/package-info.java b/src/main/java/clients/wsdl/geoIP/package-info.java new file mode 100644 index 0000000..485323c --- /dev/null +++ b/src/main/java/clients/wsdl/geoIP/package-info.java @@ -0,0 +1,6 @@ +/** + * injects annotation for java tool to work and invoke the WSDL + */ + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.webservicex.net/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package wsclient; From 5e5cd2448e789d3d1dd074cff1422ada983837bd Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Tue, 26 Sep 2023 23:17:57 +1300 Subject: [PATCH 15/32] clean up resources move stuff and re-organize code and intent Signed-off-by: Andres LeonRangel --- .../java/entity/AuthenticationResult.java | 2 +- src/test/restclient/JerseyClient.java | 41 ----- src/test/restclient/JerseyClientPost.java | 32 ---- src/test/restclient/JerseyGet.java | 37 ---- src/test/restclient/JerseyJsonResponse.java | 36 ---- src/test/restclient/JerseyJsonSimpler.java | 28 --- src/test/restclient/JerseyPost.java | 36 ---- src/test/restclient/JerseyPostHeader.java | 24 --- src/test/restclient/JerseyTest.java | 36 ---- src/test/restclient/NetClientPost.java | 56 ------ .../restclient/PostAuthenticationToken.java | 85 --------- src/test/restclient/TestJSONResponse.java | 62 ------- src/test/restclient/TestRestClient.java | 38 ---- src/test/wsclient/GeoIP.java | 172 ------------------ src/test/wsclient/GeoIPService.java | 98 ---------- src/test/wsclient/GeoIPServiceSoap.java | 55 ------ src/test/wsclient/GetGeoIP.java | 70 ------- src/test/wsclient/GetGeoIPContext.java | 37 ---- .../wsclient/GetGeoIPContextResponse.java | 69 ------- src/test/wsclient/GetGeoIPResponse.java | 69 ------- src/test/wsclient/ObjectFactory.java | 90 --------- src/test/wsclient/package-info.java | 6 - 22 files changed, 1 insertion(+), 1178 deletions(-) delete mode 100644 src/test/restclient/JerseyClient.java delete mode 100644 src/test/restclient/JerseyClientPost.java delete mode 100644 src/test/restclient/JerseyGet.java delete mode 100644 src/test/restclient/JerseyJsonResponse.java delete mode 100644 src/test/restclient/JerseyJsonSimpler.java delete mode 100644 src/test/restclient/JerseyPost.java delete mode 100644 src/test/restclient/JerseyPostHeader.java delete mode 100644 src/test/restclient/JerseyTest.java delete mode 100644 src/test/restclient/NetClientPost.java delete mode 100644 src/test/restclient/PostAuthenticationToken.java delete mode 100644 src/test/restclient/TestJSONResponse.java delete mode 100644 src/test/restclient/TestRestClient.java delete mode 100644 src/test/wsclient/GeoIP.java delete mode 100644 src/test/wsclient/GeoIPService.java delete mode 100644 src/test/wsclient/GeoIPServiceSoap.java delete mode 100644 src/test/wsclient/GetGeoIP.java delete mode 100644 src/test/wsclient/GetGeoIPContext.java delete mode 100644 src/test/wsclient/GetGeoIPContextResponse.java delete mode 100644 src/test/wsclient/GetGeoIPResponse.java delete mode 100644 src/test/wsclient/ObjectFactory.java delete mode 100644 src/test/wsclient/package-info.java diff --git a/src/main/java/entity/AuthenticationResult.java b/src/main/java/entity/AuthenticationResult.java index ce25292..7c15dbf 100644 --- a/src/main/java/entity/AuthenticationResult.java +++ b/src/main/java/entity/AuthenticationResult.java @@ -72,4 +72,4 @@ public String getIdToken() { public void setIdToken(String idToken) { this.idToken = idToken; } -} +} \ No newline at end of file diff --git a/src/test/restclient/JerseyClient.java b/src/test/restclient/JerseyClient.java deleted file mode 100644 index 46fb03e..0000000 --- a/src/test/restclient/JerseyClient.java +++ /dev/null @@ -1,41 +0,0 @@ -package testing.rest; - -import java.io.IOException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriBuilder; -import org.apache.http.client.ClientProtocolException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - -public class JerseyClient { - - /** - * @param args - * @throws ClientProtocolException - * @throws IOException - */ - - public void obtainJSONResponse() throws ClientProtocolException, IOException { - - // Invoke REST service with GET Method - ClientConfig config = new DefaultClientConfig(); - Client client = Client.create(config); - - WebResource service = client - .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); - - // getting JSON data - System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( - "Authorization", - "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") - .get(String.class)); - } - - public void obtainXMLResponse() throws ClientProtocolException, IOException { - // getting XML data - // System.out.println("with - // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); - } -} \ No newline at end of file diff --git a/src/test/restclient/JerseyClientPost.java b/src/test/restclient/JerseyClientPost.java deleted file mode 100644 index 4b58e7f..0000000 --- a/src/test/restclient/JerseyClientPost.java +++ /dev/null @@ -1,32 +0,0 @@ -package jersey; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - -public class JerseyClientPost { - - public static void main(String[] args) { - - try { - Client client = Client.create(); - WebResource webResource = client.resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); - - if (response.getStatus() != 201) { - throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); - } - - System.out.println("Output from Server .... \n"); - String output = response.getEntity(String.class); - System.out.println(output); - - } catch (Exception e) { - - e.printStackTrace(); - - } - } -} \ No newline at end of file diff --git a/src/test/restclient/JerseyGet.java b/src/test/restclient/JerseyGet.java deleted file mode 100644 index e04c856..0000000 --- a/src/test/restclient/JerseyGet.java +++ /dev/null @@ -1,37 +0,0 @@ -package jersey; - -import java.io.IOException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriBuilder; -import org.apache.http.client.ClientProtocolException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - -public class JerseyGet { - - /** - * @param args - * @throws ClientProtocolException - * @throws IOException - */ - public static void main(String[] args) throws ClientProtocolException, IOException { - - ClientConfig config = new DefaultClientConfig(); - Client client = Client.create(config); - - WebResource service = client - .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); - - // getting JSON data - System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( - "Authorization", - "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") - .get(String.class)); - - // getting XML data - // System.out.println("with - // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); - } -} \ No newline at end of file diff --git a/src/test/restclient/JerseyJsonResponse.java b/src/test/restclient/JerseyJsonResponse.java deleted file mode 100644 index 9521ae6..0000000 --- a/src/test/restclient/JerseyJsonResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package jersey; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - -public class JerseyJsonResponse { - - public static void main(String[] args) { - try { - String baseuri = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login/"; - Client client = Client.create(); - - WebResource webResource = client.resource(baseuri); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - // POST method - ClientResponse response = webResource.accept("application/json").type("type:application/json") - .post(ClientResponse.class, input); - - // check response status code - if (response.getStatus() != 200) { - throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); - } - - // display response - String output = response.getEntity(String.class); - System.out.println("Output from Server .... "); - System.out.println(output + "\n"); - } catch (Exception e) { - e.printStackTrace(); - } - - } // main() -} diff --git a/src/test/restclient/JerseyJsonSimpler.java b/src/test/restclient/JerseyJsonSimpler.java deleted file mode 100644 index 8941a7e..0000000 --- a/src/test/restclient/JerseyJsonSimpler.java +++ /dev/null @@ -1,28 +0,0 @@ -package testing.rest; - -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.representation.Form; - -public class JerseyJsonSimpler { - - public static void main(String[] args) { - - try { - Client client = (Client) ClientBuilder.newClient(); - WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); - - Form form = new Form(); - form.add("id", "10295765"); - form.add("password", "Value!12"); - // ClientResponse response = - // WebResource.class.type(MediaType.TEXT_PLAIN).post(ClientResponse.class, - // form); - } catch (Exception e) { - e.printStackTrace(); - } - - } -} \ No newline at end of file diff --git a/src/test/restclient/JerseyPost.java b/src/test/restclient/JerseyPost.java deleted file mode 100644 index ddbac2a..0000000 --- a/src/test/restclient/JerseyPost.java +++ /dev/null @@ -1,36 +0,0 @@ -package testing.rest; - -import java.io.IOException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; -import org.apache.http.client.ClientProtocolException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -public class JerseyPost { - - public static void main(String[] args) throws ClientProtocolException, IOException { - - ClientConfig config = new DefaultClientConfig(); - - Client client = Client.create(config); - - WebResource webResource = client - .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/").build()); - - MultivaluedMap formData = new MultivaluedMapImpl(); - - formData.add("id", "10295765"); - formData.add("password", "Value!12"); - - ClientResponse response = webResource.path("dev").path("login").type(MediaType.APPLICATION_FORM_URLENCODED) - .post(ClientResponse.class, formData); - - System.out.println("Response " + response.getEntity(String.class)); - } -} diff --git a/src/test/restclient/JerseyPostHeader.java b/src/test/restclient/JerseyPostHeader.java deleted file mode 100644 index ae8f69e..0000000 --- a/src/test/restclient/JerseyPostHeader.java +++ /dev/null @@ -1,24 +0,0 @@ -package testing.rest; - -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.representation.Form; - -public class JerseyPostHeader { - - Client client = (Client) ClientBuilder.newClient(); - WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); - - Form form = new Form(); - // form.param("x", "foo"); - // form.param("y", "bar"); - - // String bean = - // target.request(MediaType.APPLICATION_JSON_TYPE).post(MediaType.APPLICATION_FORM_URLENCODED_TYPE, - // String.class); -} diff --git a/src/test/restclient/JerseyTest.java b/src/test/restclient/JerseyTest.java deleted file mode 100644 index a474dc2..0000000 --- a/src/test/restclient/JerseyTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package testing.rest; - -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Response; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; - -import bean.AttendanceRegister; - -public class JerseyTest { - - public static void main(String[] args) { - testAttendanceRegister(); - // responseREST(); - } - - String responseREST() { - // Client client =(Client) ClientBuilder.newClient(); - Client client = Client.create(); - WebResource target = client.resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - Response response = ((WebTarget) target).request("application/json").post(Entity.json(input)); - // System.out.println(response.toString()); - - return response.toString(); - } - - static void testAttendanceRegister() { - AttendanceRegister att = new AttendanceRegister(); - att.confirmAttendance(); - } - -} diff --git a/src/test/restclient/NetClientPost.java b/src/test/restclient/NetClientPost.java deleted file mode 100644 index 213b3af..0000000 --- a/src/test/restclient/NetClientPost.java +++ /dev/null @@ -1,56 +0,0 @@ -package testing.rest; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -public class NetClientPost { - - // http://localhost:8080/RESTfulExample/json/product/post - public static void main(String[] args) { - - try { - URL url = new URL("https://fahze41owc.execute-api.us-east-1.amazonaws.com/dev/user"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\r\n" + - " \"id\": \"102030\",\r\n" + - " \"firstName\": \"Julito\",\r\n" + - " \"lastName\": \"Schwartzenegger\",\r\n" + - " \"type\": \"administrator\"\r\n" + - "}"; - - OutputStream os = conn.getOutputStream(); - os.write(input.getBytes()); - os.flush(); - - if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { - throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); - } - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - String output; - System.out.println("Output from Server .... \n"); - while ((output = br.readLine()) != null) { - System.out.println(output); - } - - conn.disconnect(); - - } catch (MalformedURLException e) { - - e.printStackTrace(); - - } catch (IOException e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/src/test/restclient/PostAuthenticationToken.java b/src/test/restclient/PostAuthenticationToken.java deleted file mode 100644 index b9d37a2..0000000 --- a/src/test/restclient/PostAuthenticationToken.java +++ /dev/null @@ -1,85 +0,0 @@ -package rest; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonReader; - -public class PostAuthenticationToken { - - // authentication scheme based on tokens follow these steps, steps are numbered - public static void main(String[] args) { - - try { - - URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - OutputStream os = conn.getOutputStream(); - // 1.The client sends their credentials (username and password) to the server. - os.write(input.getBytes()); - os.flush(); - - if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { - throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); - } - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - String output; - // 2.The server authenticates the credentials and, if they are valid, generate a - // token for the user. - System.out.println("Output from Server .... \n"); - while ((output = br.readLine()) != null) { - JsonReader rdr = Json.createReader(br); - System.out.println("creates object"); - // rdr.readObject(); - System.out.println("obtain object" + rdr.toString()); - System.out.println("prints output " + br.readLine()); - - JsonObject obj = rdr.readObject(); - System.out.println("before reading object"); - - JsonArray results = obj.getJsonArray("AuthenticationResult"); - // obj.getJsonString(arg0) - System.out.print("value type: " + results.getValueType()); - - // for (JsonObject result : results.getValuesAs(JsonObject.class)) { - // System.out.print("value type: "+results.getValueType()); - // System.out.println("token"+ result.getString("IdToken")); - // } - - System.out.println(output); - } // end of while - - System.out.println("prints output 1" + br.readLine()); - - /// put object in hashmap somehow - - // disconnects - conn.disconnect(); - - } catch (MalformedURLException e) { - - e.printStackTrace(); - - } catch (IOException e) { - - e.printStackTrace(); - - } - } -} \ No newline at end of file diff --git a/src/test/restclient/TestJSONResponse.java b/src/test/restclient/TestJSONResponse.java deleted file mode 100644 index fec4be0..0000000 --- a/src/test/restclient/TestJSONResponse.java +++ /dev/null @@ -1,62 +0,0 @@ -package jersey; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import javax.json.Json; -import javax.json.stream.JsonParser; -import javax.json.stream.JsonParser.Event; - -public class TestJSONResponse { - - public static void main(String[] args) throws MalformedURLException { - // URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); - // URL url = new - // URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - - // try (InputStream is = url.openStream(); JsonParser parser = - // Json.createParser(is)) { - try { - URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - OutputStream os = conn.getOutputStream(); - // 1.The client sends their credentials (username and password) to the server. - os.write(input.getBytes()); - os.flush(); - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - JsonParser parser = (JsonParser) Json.createReader(br); - - while (parser.hasNext()) { - Event e = parser.next(); - if (e == Event.KEY_NAME) { - switch (parser.getString()) { - case "RefreshToken": - parser.next(); - System.out.print(parser.getString()); - System.out.print(": "); - break; - case "IdToken": - parser.next(); - System.out.println(parser.getString()); - System.out.println("---------"); - break; - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/test/restclient/TestRestClient.java b/src/test/restclient/TestRestClient.java deleted file mode 100644 index 342011d..0000000 --- a/src/test/restclient/TestRestClient.java +++ /dev/null @@ -1,38 +0,0 @@ -package rest; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - -public class TestRestClient { - string AWS_URL = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"; - - public void checkServiceAvailability() { - - } - - public void testAWSConnectAPI() { - - try { - - Client client = Client.create(); - WebResource webResource = client.resource(+AWS_URL); - String input = "{\"id\":\"10295765\",\"password\":\"TestPassword!12\"}"; - ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); - - if (response.getStatus() != 201) { - throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); - } - - System.out.println("Output from Server .... \n"); - String output = response.getEntity(String.class); - System.out.println(output); - - } catch (Exception e) { - - e.printStackTrace(); - - } - } -} diff --git a/src/test/wsclient/GeoIP.java b/src/test/wsclient/GeoIP.java deleted file mode 100644 index 1e66ceb..0000000 --- a/src/test/wsclient/GeoIP.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Class GeoIP imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for GeoIP complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType name="GeoIP">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="ReturnCode" type="{http://www.w3.org/2001/XMLSchema}int"/>
- *         <element name="IP" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="ReturnCodeDetails" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="CountryName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="CountryCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "GeoIP", propOrder = { - "returnCode", - "ip", - "returnCodeDetails", - "countryName", - "countryCode" -}) -public class GeoIP { - - @XmlElement(name = "ReturnCode") - protected int returnCode; - @XmlElement(name = "IP") - protected String ip; - @XmlElement(name = "ReturnCodeDetails") - protected String returnCodeDetails; - @XmlElement(name = "CountryName") - protected String countryName; - @XmlElement(name = "CountryCode") - protected String countryCode; - - /** - * Gets the value of the returnCode property. - * - */ - public int getReturnCode() { - return returnCode; - } - - /** - * Sets the value of the returnCode property. - * - */ - public void setReturnCode(int value) { - this.returnCode = value; - } - - /** - * Gets the value of the ip property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIP() { - return ip; - } - - /** - * Sets the value of the ip property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIP(String value) { - this.ip = value; - } - - /** - * Gets the value of the returnCodeDetails property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getReturnCodeDetails() { - return returnCodeDetails; - } - - /** - * Sets the value of the returnCodeDetails property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setReturnCodeDetails(String value) { - this.returnCodeDetails = value; - } - - /** - * Gets the value of the countryName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCountryName() { - return countryName; - } - - /** - * Sets the value of the countryName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCountryName(String value) { - this.countryName = value; - } - - /** - * Gets the value of the countryCode property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCountryCode() { - return countryCode; - } - - /** - * Sets the value of the countryCode property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCountryCode(String value) { - this.countryCode = value; - } - -} diff --git a/src/test/wsclient/GeoIPService.java b/src/test/wsclient/GeoIPService.java deleted file mode 100644 index 7771643..0000000 --- a/src/test/wsclient/GeoIPService.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Class GeoIPService imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package wsclient; - -import java.net.MalformedURLException; -import java.net.URL; -import javax.xml.namespace.QName; -import javax.xml.ws.Service; -import javax.xml.ws.WebEndpoint; -import javax.xml.ws.WebServiceClient; -import javax.xml.ws.WebServiceException; -import javax.xml.ws.WebServiceFeature; - -/** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.9-b130926.1035 - * Generated source version: 2.2 - * - */ -@WebServiceClient(name = "GeoIPService", targetNamespace = "http://www.webservicex.net/", wsdlLocation = "http://www.webservicex.net/geoipservice.asmx?WSDL") -public class GeoIPService - extends Service { - - private final static URL GEOIPSERVICE_WSDL_LOCATION; - private final static WebServiceException GEOIPSERVICE_EXCEPTION; - private final static QName GEOIPSERVICE_QNAME = new QName("http://www.webservicex.net/", "GeoIPService"); - - static { - URL url = null; - WebServiceException e = null; - try { - url = new URL("http://www.webservicex.net/geoipservice.asmx?WSDL"); - } catch (MalformedURLException ex) { - e = new WebServiceException(ex); - } - GEOIPSERVICE_WSDL_LOCATION = url; - GEOIPSERVICE_EXCEPTION = e; - } - - public GeoIPService() { - super(__getWsdlLocation(), GEOIPSERVICE_QNAME); - } - - public GeoIPService(WebServiceFeature... features) { - super(__getWsdlLocation(), GEOIPSERVICE_QNAME, features); - } - - public GeoIPService(URL wsdlLocation) { - super(wsdlLocation, GEOIPSERVICE_QNAME); - } - - public GeoIPService(URL wsdlLocation, WebServiceFeature... features) { - super(wsdlLocation, GEOIPSERVICE_QNAME, features); - } - - public GeoIPService(URL wsdlLocation, QName serviceName) { - super(wsdlLocation, serviceName); - } - - public GeoIPService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { - super(wsdlLocation, serviceName, features); - } - - /** - * @return - * returns GeoIPServiceSoap - */ - @WebEndpoint(name = "GeoIPServiceSoap") - public GeoIPServiceSoap getGeoIPServiceSoap() { - return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class); - } - - /** - * - * @param features - * A list of {@link javax.xml.ws.WebServiceFeature} to configure - * on the proxy. Supported features not in the - * features parameter will have their default - * values. - * @return - * returns GeoIPServiceSoap - */ - @WebEndpoint(name = "GeoIPServiceSoap") - public GeoIPServiceSoap getGeoIPServiceSoap(WebServiceFeature... features) { - return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class, - features); - } - - private static URL __getWsdlLocation() { - if (GEOIPSERVICE_EXCEPTION != null) { - throw GEOIPSERVICE_EXCEPTION; - } - return GEOIPSERVICE_WSDL_LOCATION; - } -} diff --git a/src/test/wsclient/GeoIPServiceSoap.java b/src/test/wsclient/GeoIPServiceSoap.java deleted file mode 100644 index 22a84bb..0000000 --- a/src/test/wsclient/GeoIPServiceSoap.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Class GeoIPServiceSoap imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package wsclient; - -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebResult; -import javax.jws.WebService; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.ws.RequestWrapper; -import javax.xml.ws.ResponseWrapper; - -/** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.9-b130926.1035 - * Generated source version: 2.2 - * - */ -@WebService(name = "GeoIPServiceSoap", targetNamespace = "http://www.webservicex.net/") -@XmlSeeAlso({ - ObjectFactory.class -}) -public interface GeoIPServiceSoap { - - /** - * GeoIPService - GetGeoIP enables you to easily look up countries by IP - * addresses - * - * @param ipAddress - * @return - * returns wsclient.GeoIP - */ - @WebMethod(operationName = "GetGeoIP", action = "http://www.webservicex.net/GetGeoIP") - @WebResult(name = "GetGeoIPResult", targetNamespace = "http://www.webservicex.net/") - @RequestWrapper(localName = "GetGeoIP", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIP") - @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPResponse") - public GeoIP getGeoIP( - @WebParam(name = "IPAddress", targetNamespace = "http://www.webservicex.net/") String ipAddress); - - /** - * GeoIPService - GetGeoIPContext enables you to easily look up countries by - * Context - * - * @return - * returns wsclient.GeoIP - */ - @WebMethod(operationName = "GetGeoIPContext", action = "http://www.webservicex.net/GetGeoIPContext") - @WebResult(name = "GetGeoIPContextResult", targetNamespace = "http://www.webservicex.net/") - @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContext") - @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContextResponse") - public GeoIP getGeoIPContext(); -} diff --git a/src/test/wsclient/GetGeoIP.java b/src/test/wsclient/GetGeoIP.java deleted file mode 100644 index ab3a42f..0000000 --- a/src/test/wsclient/GetGeoIP.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Class GetGeoIP imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="IPAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "ipAddress" -}) -@XmlRootElement(name = "GetGeoIP") -public class GetGeoIP { - - @XmlElement(name = "IPAddress") - protected String ipAddress; - - /** - * Gets the value of the ipAddress property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIPAddress() { - return ipAddress; - } - - /** - * Sets the value of the ipAddress property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIPAddress(String value) { - this.ipAddress = value; - } -} diff --git a/src/test/wsclient/GetGeoIPContext.java b/src/test/wsclient/GetGeoIPContext.java deleted file mode 100644 index 5a9adbc..0000000 --- a/src/test/wsclient/GetGeoIPContext.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Class GetGeoIPContext imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "") -@XmlRootElement(name = "GetGeoIPContext") -public class GetGeoIPContext { - -} diff --git a/src/test/wsclient/GetGeoIPContextResponse.java b/src/test/wsclient/GetGeoIPContextResponse.java deleted file mode 100644 index eabac05..0000000 --- a/src/test/wsclient/GetGeoIPContextResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Class getGeoIPContextResult imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="GetGeoIPContextResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "getGeoIPContextResult" -}) -@XmlRootElement(name = "GetGeoIPContextResponse") -public class GetGeoIPContextResponse { - - @XmlElement(name = "GetGeoIPContextResult") - protected GeoIP getGeoIPContextResult; - - /** - * Gets the value of the getGeoIPContextResult property. - * - * @return - * possible object is - * {@link GeoIP } - * - */ - public GeoIP getGetGeoIPContextResult() { - return getGeoIPContextResult; - } - - /** - * Sets the value of the getGeoIPContextResult property. - * - * @param value - * allowed object is - * {@link GeoIP } - * - */ - public void setGetGeoIPContextResult(GeoIP value) { - this.getGeoIPContextResult = value; - } - -} diff --git a/src/test/wsclient/GetGeoIPResponse.java b/src/test/wsclient/GetGeoIPResponse.java deleted file mode 100644 index fa15f74..0000000 --- a/src/test/wsclient/GetGeoIPResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Class getGeoIPResult imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="GetGeoIPResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "getGeoIPResult" -}) -@XmlRootElement(name = "GetGeoIPResponse") -public class GetGeoIPResponse { - - @XmlElement(name = "GetGeoIPResult") - protected GeoIP getGeoIPResult; - - /** - * Gets the value of the getGeoIPResult property. - * - * @return - * possible object is - * {@link GeoIP } - * - */ - public GeoIP getGetGeoIPResult() { - return getGeoIPResult; - } - - /** - * Sets the value of the getGeoIPResult property. - * - * @param value - * allowed object is - * {@link GeoIP } - * - */ - public void setGetGeoIPResult(GeoIP value) { - this.getGeoIPResult = value; - } -} \ No newline at end of file diff --git a/src/test/wsclient/ObjectFactory.java b/src/test/wsclient/ObjectFactory.java deleted file mode 100644 index a81a6eb..0000000 --- a/src/test/wsclient/ObjectFactory.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Class ObjectFactory imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package wsclient; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the wsclient package. - *

- * An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private final static QName _GeoIP_QNAME = new QName("http://www.webservicex.net/", "GeoIP"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema - * derived classes for package: wsclient - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link GeoIP } - * - */ - public GeoIP createGeoIP() { - return new GeoIP(); - } - - /** - * Create an instance of {@link GetGeoIP } - * - */ - public GetGeoIP createGetGeoIP() { - return new GetGeoIP(); - } - - /** - * Create an instance of {@link GetGeoIPResponse } - * - */ - public GetGeoIPResponse createGetGeoIPResponse() { - return new GetGeoIPResponse(); - } - - /** - * Create an instance of {@link GetGeoIPContextResponse } - * - */ - public GetGeoIPContextResponse createGetGeoIPContextResponse() { - return new GetGeoIPContextResponse(); - } - - /** - * Create an instance of {@link GetGeoIPContext } - * - */ - public GetGeoIPContext createGetGeoIPContext() { - return new GetGeoIPContext(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link GeoIP }{@code >}} - * - */ - @XmlElementDecl(namespace = "http://www.webservicex.net/", name = "GeoIP") - public JAXBElement createGeoIP(GeoIP value) { - return new JAXBElement(_GeoIP_QNAME, GeoIP.class, null, value); - } - -} diff --git a/src/test/wsclient/package-info.java b/src/test/wsclient/package-info.java deleted file mode 100644 index 485323c..0000000 --- a/src/test/wsclient/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * injects annotation for java tool to work and invoke the WSDL - */ - -@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.webservicex.net/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package wsclient; From f346264c9a21de0bd73bdaacfe8008965ee04437 Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Wed, 27 Sep 2023 11:52:31 +1300 Subject: [PATCH 16/32] mermaid diagram GraphQL client Signed-off-by: Andres LeonRangel --- README.md | 24 ++++++++++++++ .../java/clients/GraphQL/GraphQLClient.java | 31 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/main/java/clients/GraphQL/GraphQLClient.java diff --git a/README.md b/README.md index 8e7bd57..6e9114d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ - [Attendance WebApp UI](#attendance-webapp-ui) - [Refer to the Wiki for details on the project](#refer-to-the-wiki-for-details-on-the-project) - [Project general guidelines](#project-general-guidelines) + - [API/Services Architectures](#apiservices-architectures) + - [Extra mermaid diagram](#extra-mermaid-diagram) - [Setup](#setup) - [Build Web Package](#build-web-package) - [Maven Build](#maven-build) @@ -72,6 +74,28 @@ To find out more, visit: 3. Latest releases by using git tags 4. API references. API docs +## API/Services Architectures +```mermaid +graph LR + REST --> JSON + REST --> XML + REST --> Webhooks + REST --> gRPC + REST --> GraphQL + REST --> WebSockets + gRPC --> Protobuf + GraphQL --> Queries + GraphQL --> Mutations + WebSockets --> Full-duplex-communication + WebSockets --> Real-time-updates + Webhooks --> HTTP-callbacks + Webhooks --> Event-driven-architecture +``` +## Extra mermaid diagram +circular references + +[![](https://mermaid.ink/img/pako:eNptksEOgjAQRH-F7Fl-gIMXNV4wUTDx0kulKxCEklIOhvDvtmAoXeypfTOdySY7QCYFQgS54m0RxAlrAnOSU3oPwnAf5Mn1QNDZOm8xoQ98pjKrUHdboZCyMngWbOIkWAdBXvRCafRa8KJ_30n6mrpx1pQWEM3rcF5SQwTXRARvRqL9KZve2yqHvSKHaY1TXCfsoEZV81KYBRislYEusEYGkbkKrioGrBmNj_dapp8mg-jF3x3uoG8F13gsuVmceqEoSi3VZV6pabPGL4act8s?type=png)](https://mermaid.live/edit#pako:eNptksEOgjAQRH-F7Fl-gIMXNV4wUTDx0kulKxCEklIOhvDvtmAoXeypfTOdySY7QCYFQgS54m0RxAlrAnOSU3oPwnAf5Mn1QNDZOm8xoQ98pjKrUHdboZCyMngWbOIkWAdBXvRCafRa8KJ_30n6mrpx1pQWEM3rcF5SQwTXRARvRqL9KZve2yqHvSKHaY1TXCfsoEZV81KYBRislYEusEYGkbkKrioGrBmNj_dapp8mg-jF3x3uoG8F13gsuVmceqEoSi3VZV6pabPGL4act8s) + ## Setup > Tested in Win11 with WSL, Github codespaces and Ubuntu22 diff --git a/src/main/java/clients/GraphQL/GraphQLClient.java b/src/main/java/clients/GraphQL/GraphQLClient.java new file mode 100644 index 0000000..e9fc8f3 --- /dev/null +++ b/src/main/java/clients/GraphQL/GraphQLClient.java @@ -0,0 +1,31 @@ +import com.graphql.java.client.GraphQLClient; +import com.graphql.java.client.GraphQLClientBuilder; +import com.graphql.java.client.GraphQLRequest; +import com.graphql.java.client.GraphQLResponse; + +public class GraphQLClient { + + private final GraphQLClient graphQLClient; + + public GraphQLClientExample(String graphQLAPIEndpointURL) { + graphQLClient = GraphQLClientBuilder.newClient(graphQLAPIEndpointURL).build(); + } + + public GraphQLResponse executeQuery(String query) { + GraphQLRequest graphQLRequest = new GraphQLRequest(query); + return graphQLClient.execute(graphQLRequest); + } + + public static void main(String[] args) { + GraphQLClientExample graphQLClientExample = new GraphQLClientExample("https://graphql.example.com"); + + // Execute a GraphQL query + GraphQLResponse graphQLResponse = graphQLClientExample.executeQuery("{ hello }"); + + // Parse the GraphQL response + String hello = graphQLResponse.getData().get("hello").toString(); + + // Print the result + System.out.println(hello); + } +} \ No newline at end of file From 94c85fea7a25d5ba4144c1739148233575532d7a Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Tue, 10 Oct 2023 13:13:19 +1300 Subject: [PATCH 17/32] upgrade gradle 8.3 intelliJ IDE Signed-off-by: Andres LeonRangel --- .idea/.gitignore | 3 + .idea/.name | 1 + .idea/compiler.xml | 6 + .idea/gradle.xml | 16 + .idea/jarRepositories.xml | 30 ++ .idea/misc.xml | 5 + .idea/vcs.xml | 6 + build.gradle.kts | 69 ++-- gradle/wrapper/gradle-wrapper.properties | 3 +- gradlew | 0 src/main/resources/webServiceSOAPDemo.wsdl | 419 +++++++++++++++++++++ 11 files changed, 513 insertions(+), 45 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/compiler.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml mode change 100644 => 100755 gradlew create mode 100644 src/main/resources/webServiceSOAPDemo.wsdl diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..d0874b5 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +AttendWebApp \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..ce1c62c --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..6c68d51 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f99ad97 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index d73548d..1cf65c9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,4 @@ -import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent - /* * This file was generated by the Gradle 'init' task * This project uses @Incubating APIs which are subject to change @@ -11,14 +9,15 @@ plugins { // id ("com.adarshr.test-logger") version "3.0.0" // https://docs.gradle.org/7.3/dsl/org.gradle.api.tasks.bundling.War.html war - //wsdl - id("io.mateo.cxf-codegen") version "1.0.1" + id ("jacoco") + //wsdl + id("com.github.bjornvester.wsdl2java") version "2.0.2" } repositories { - gradlePluginPortal() - google() - mavenCentral() + gradlePluginPortal() + google() + mavenCentral() } dependencies { @@ -35,18 +34,17 @@ dependencies { implementation("javax.servlet:javax.servlet-api:3.1.0") // https://mvnrepository.com/artifact/com.google.zxing/javase implementation("com.google.zxing:javase:3.5.1") - // https://mvnrepository.com/artifact/com.google.zxing/core implementation("com.google.zxing:core:3.5.1") testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0") testImplementation("io.jsonwebtoken:jjwt:0.7.0") - implementation("org.apache.cxf:cxf-rt-frontend-jaxws:3.4.5") - + // dependency below only needed if using the Java 8 version of @Generated (through "jdk8") on Java 9 or later + implementation("javax.annotation:javax.annotation-api:1.3.2") } group = "soa.nz.aut" version = "0.0.1" -description = "Class Attendance WebApp" +description = "Student Attendance WebApp" java.sourceCompatibility = JavaVersion.VERSION_1_8 tasks.war { @@ -60,41 +58,24 @@ tasks.war { } tasks { - test { - reports { - html.isEnabled = true - junitXml.isEnabled = true + named("jacocoTestReport") { + reports { + } + } + test { + useJUnitPlatform() + testLogging.events = setOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED) } - useJUnitPlatform() - testLogging.events = setOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED) - } } tasks.register("singleTest") { - group = "Verification" - description = "Runs a test to create a local QR code" - filter { - includeTestsMatching("utilities.TestQRFunctions.createQRCodeLocally") - } + group = "Verification" + description = "Runs a test to create a local QR code" + filter { + includeTestsMatching("utilities.TestQRFunctions.createQRCodeLocally") + } } - -// task{ utilities -// testlogger{ -// setTheme("mocha") -// showExceptions=true -// showStackTraces=true -// } -// } -// afterEvaluate { -// tasks.getByName("run") { -// dependsOn("appRun") -// } -// } -// cxf { -// wsdl2java { -// // wsdl info about countries -// wsdl = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL" -// packageName = "org.example.countryinfo" -// outputDir = file("src/main/java") -// } -// } \ No newline at end of file +// https://plugins.gradle.org/plugin/com.github.bjornvester.wsdl2java +wsdl2java { + // Set properties here... +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e589..a673105 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +#after upgrade run ./gradlew wrapper --gradle-version 8.3 \ No newline at end of file diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/resources/webServiceSOAPDemo.wsdl b/src/main/resources/webServiceSOAPDemo.wsdl new file mode 100644 index 0000000..73d3d46 --- /dev/null +++ b/src/main/resources/webServiceSOAPDemo.wsdl @@ -0,0 +1,419 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8a9759be363e9c62c577ef8025418bcd2a5f4c3c Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Fri, 27 Oct 2023 11:57:36 +1300 Subject: [PATCH 18/32] stable wsdl2java gradle task Signed-off-by: Andres LeonRangel --- .idea/multi-cloud-WebApp-Attendance.iml | 9 + build.gradle.kts | 21 ++- src/main/bindings/bindings.xjb | 13 ++ src/main/resources/wsdl/NumberConversion.wsdl | 154 ++++++++++++++++++ 4 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 .idea/multi-cloud-WebApp-Attendance.iml create mode 100644 src/main/bindings/bindings.xjb create mode 100644 src/main/resources/wsdl/NumberConversion.wsdl diff --git a/.idea/multi-cloud-WebApp-Attendance.iml b/.idea/multi-cloud-WebApp-Attendance.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/multi-cloud-WebApp-Attendance.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 1cf65c9..e39d65f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,6 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent /* - * This file was generated by the Gradle 'init' task - * This project uses @Incubating APIs which are subject to change + * file generated by Gradle 'init' task. @Incubating APIs subject to change */ plugins { @@ -10,7 +9,6 @@ plugins { // https://docs.gradle.org/7.3/dsl/org.gradle.api.tasks.bundling.War.html war id ("jacoco") - //wsdl id("com.github.bjornvester.wsdl2java") version "2.0.2" } @@ -40,6 +38,7 @@ dependencies { testImplementation("io.jsonwebtoken:jjwt:0.7.0") // dependency below only needed if using the Java 8 version of @Generated (through "jdk8") on Java 9 or later implementation("javax.annotation:javax.annotation-api:1.3.2") + implementation("io.github.threeten-jaxb:threeten-jaxb-core:2.1.0") // Use Java Date/Time API instead of clunky GregorianCalendar class } group = "soa.nz.aut" @@ -76,6 +75,20 @@ tasks.register("singleTest") { } } // https://plugins.gradle.org/plugin/com.github.bjornvester.wsdl2java +// https://www.w3schools.com/xml/tempconvert.asmx?WSDL wsdl2java { - // Set properties here... + wsdlDir.set(layout.projectDirectory.dir("src/main/resources/wsdl")) + bindingFile.set(layout.projectDirectory.file("src/main/bindings/bindings.xjb")) + + includes.set( + listOf( + "src/main/resources/wsdl/NumberConversion.wsdl" + ) + ) + // includesWithOptions.set( + // mapOf( + // "**/ServiceTemp.wsdl" to listOf("-wsdlLocation", "https://www.w3schools.com/xml/tempconvert.asmx?WSDL") + // ) + // ) + // default output directory $buildDir/generated/sources/wsdl2java/java } \ No newline at end of file diff --git a/src/main/bindings/bindings.xjb b/src/main/bindings/bindings.xjb new file mode 100644 index 0000000..6aee12d --- /dev/null +++ b/src/main/bindings/bindings.xjb @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/wsdl/NumberConversion.wsdl b/src/main/resources/wsdl/NumberConversion.wsdl new file mode 100644 index 0000000..8303c8a --- /dev/null +++ b/src/main/resources/wsdl/NumberConversion.wsdl @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From fad2e168ca7d1aadbefbd1e760f507bff13b790b Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Sat, 28 Oct 2023 22:24:36 +1300 Subject: [PATCH 19/32] tweaking IntelliJ functionality Signed-off-by: Andres LeonRangel --- .idea/misc.xml | 1 - .idea/multi-cloud-WebApp-Attendance.iml | 9 - .idea/uiDesigner.xml | 124 +++++++++++++ pom.xml | 172 ++++++++++++++++++ .../CelsiusToFahrenheit.java | 64 +++++++ .../CelsiusToFahrenheitResponse.java | 64 +++++++ .../FahrenheitToCelsius.java | 64 +++++++ .../FahrenheitToCelsiusResponse.java | 64 +++++++ .../temperatureConvert/ObjectFactory.java | 81 +++++++++ .../wsdl/temperatureConvert/TempConvert.java | 135 ++++++++++++++ .../TempConvertHttpPost.java | 36 ++++ .../temperatureConvert/TempConvertSoap.java | 40 ++++ .../wsdl/temperatureConvert/package-info.java | 2 + .../ServiceInvokationTest.java | 3 +- .../ui}/AttendanceGenerateTest.java | 0 .../java/wsdl/TemperatureConvertTest.java | 2 + src/test/json/ConversionJSON2Object.java | 30 --- src/test/json/ConversionJson2Map.java | 39 ---- src/test/json/JSON2Object.java | 24 --- src/test/json/Json2Map.java | 39 ---- 20 files changed, 849 insertions(+), 144 deletions(-) delete mode 100644 .idea/multi-cloud-WebApp-Attendance.iml create mode 100644 .idea/uiDesigner.xml create mode 100644 pom.xml create mode 100644 src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java create mode 100644 src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java create mode 100644 src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java create mode 100644 src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java create mode 100644 src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java create mode 100644 src/main/java/clients/wsdl/temperatureConvert/TempConvert.java create mode 100644 src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java create mode 100644 src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java create mode 100644 src/main/java/clients/wsdl/temperatureConvert/package-info.java rename src/test/{wsdl => java/serviceClients}/ServiceInvokationTest.java (96%) rename src/test/{ux => java/ui}/AttendanceGenerateTest.java (100%) create mode 100644 src/test/java/wsdl/TemperatureConvertTest.java delete mode 100644 src/test/json/ConversionJSON2Object.java delete mode 100644 src/test/json/ConversionJson2Map.java delete mode 100644 src/test/json/JSON2Object.java delete mode 100644 src/test/json/Json2Map.java diff --git a/.idea/misc.xml b/.idea/misc.xml index f99ad97..1003eec 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/.idea/multi-cloud-WebApp-Attendance.iml b/.idea/multi-cloud-WebApp-Attendance.iml deleted file mode 100644 index d6ebd48..0000000 --- a/.idea/multi-cloud-WebApp-Attendance.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9773b94 --- /dev/null +++ b/pom.xml @@ -0,0 +1,172 @@ + + 4.0.0 + com.soa + AttendWebApp + war + 0.0.1-SNAPSHOT + Class Attendance WebApp + http://maven.apache.org + + + + prime-repo + PrimeFaces Maven Repository + http://repository.primefaces.org + default + + + + + + + org.primefaces.extensions + primefaces-extensions + 6.0.0 + + + + org.primefaces + primefaces + ${primefaces.version} + + + + junit + junit + ${junit.version} + test + + + javax.servlet + javax.servlet-api + ${servlet.version} + provided + + + + com.sun.faces + jsf-api + ${mojarra.version} + + + com.sun.faces + jsf-impl + ${mojarra.version} + + + + + javax.json + javax.json-api + 1.1 + + + + io.jsonwebtoken + jjwt + ${jjwt.version} + test + + + + + javax.ws.rs + javax.ws.rs-api + 2.1 + + + + + com.sun.jersey + jersey-client + 1.19.4 + + + com.google.code.gson + gson + 2.8.9 + + + + org.apache.httpcomponents + httpclient + 4.5.3 + + + + org.glassfish.jersey.core + jersey-common + 2.22.2 + compile + + + org.slf4j + slf4j-api + 2.0.0-alpha1 + + + org.slf4j + slf4j-simple + 2.0.0-alpha1 + + + + + AttendanceWebApp + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + ${java.version} + ${java.version} + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + http://localhost:8080/manager/text + TomcatServer + /AttendWebApp + + + + org.apache.cxf + cxf-codegen-plugin + ${cxf.version} + + + generate-sources + generate-sources + + ${project.build.directory}/generated-sources/cxf + + + ${basedir}/src/main/resources/wsdl/NumberConversion.wsdl + + + + + wsdl2java + + + + + + + + 17 + 4.12 + 3.1.0 + 2.2.12 + 6.0 + 3.3 + UTF-8 + 0.7.0 + 4.0.3 + + \ No newline at end of file diff --git a/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java b/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java new file mode 100644 index 0000000..bc7aa62 --- /dev/null +++ b/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java @@ -0,0 +1,64 @@ + +package https.www_w3schools_com.xml; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Celsius" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "celsius" +}) +@XmlRootElement(name = "CelsiusToFahrenheit") +public class CelsiusToFahrenheit { + + @XmlElement(name = "Celsius") + protected String celsius; + + /** + * Gets the value of the celsius property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCelsius() { + return celsius; + } + + /** + * Sets the value of the celsius property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCelsius(String value) { + this.celsius = value; + } + +} diff --git a/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java b/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java new file mode 100644 index 0000000..8177c07 --- /dev/null +++ b/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java @@ -0,0 +1,64 @@ + +package https.www_w3schools_com.xml; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="CelsiusToFahrenheitResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "celsiusToFahrenheitResult" +}) +@XmlRootElement(name = "CelsiusToFahrenheitResponse") +public class CelsiusToFahrenheitResponse { + + @XmlElement(name = "CelsiusToFahrenheitResult") + protected String celsiusToFahrenheitResult; + + /** + * Gets the value of the celsiusToFahrenheitResult property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCelsiusToFahrenheitResult() { + return celsiusToFahrenheitResult; + } + + /** + * Sets the value of the celsiusToFahrenheitResult property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCelsiusToFahrenheitResult(String value) { + this.celsiusToFahrenheitResult = value; + } + +} diff --git a/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java b/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java new file mode 100644 index 0000000..c00e84f --- /dev/null +++ b/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java @@ -0,0 +1,64 @@ + +package https.www_w3schools_com.xml; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Fahrenheit" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "fahrenheit" +}) +@XmlRootElement(name = "FahrenheitToCelsius") +public class FahrenheitToCelsius { + + @XmlElement(name = "Fahrenheit") + protected String fahrenheit; + + /** + * Gets the value of the fahrenheit property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFahrenheit() { + return fahrenheit; + } + + /** + * Sets the value of the fahrenheit property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFahrenheit(String value) { + this.fahrenheit = value; + } + +} diff --git a/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java b/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java new file mode 100644 index 0000000..1783980 --- /dev/null +++ b/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java @@ -0,0 +1,64 @@ + +package https.www_w3schools_com.xml; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="FahrenheitToCelsiusResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "fahrenheitToCelsiusResult" +}) +@XmlRootElement(name = "FahrenheitToCelsiusResponse") +public class FahrenheitToCelsiusResponse { + + @XmlElement(name = "FahrenheitToCelsiusResult") + protected String fahrenheitToCelsiusResult; + + /** + * Gets the value of the fahrenheitToCelsiusResult property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFahrenheitToCelsiusResult() { + return fahrenheitToCelsiusResult; + } + + /** + * Sets the value of the fahrenheitToCelsiusResult property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFahrenheitToCelsiusResult(String value) { + this.fahrenheitToCelsiusResult = value; + } + +} diff --git a/src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java b/src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java new file mode 100644 index 0000000..da118dd --- /dev/null +++ b/src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java @@ -0,0 +1,81 @@ + +package https.www_w3schools_com.xml; + +import javax.xml.namespace.QName; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.annotation.XmlElementDecl; +import jakarta.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the https.www_w3schools_com.xml package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _String_QNAME = new QName("https://www.w3schools.com/xml/", "string"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: https.www_w3schools_com.xml + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link FahrenheitToCelsius } + * + */ + public FahrenheitToCelsius createFahrenheitToCelsius() { + return new FahrenheitToCelsius(); + } + + /** + * Create an instance of {@link FahrenheitToCelsiusResponse } + * + */ + public FahrenheitToCelsiusResponse createFahrenheitToCelsiusResponse() { + return new FahrenheitToCelsiusResponse(); + } + + /** + * Create an instance of {@link CelsiusToFahrenheit } + * + */ + public CelsiusToFahrenheit createCelsiusToFahrenheit() { + return new CelsiusToFahrenheit(); + } + + /** + * Create an instance of {@link CelsiusToFahrenheitResponse } + * + */ + public CelsiusToFahrenheitResponse createCelsiusToFahrenheitResponse() { + return new CelsiusToFahrenheitResponse(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} + * + * @param value + * Java instance representing xml element's value. + * @return + * the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} + */ + @XmlElementDecl(namespace = "https://www.w3schools.com/xml/", name = "string") + public JAXBElement createString(String value) { + return new JAXBElement(_String_QNAME, String.class, null, value); + } + +} diff --git a/src/main/java/clients/wsdl/temperatureConvert/TempConvert.java b/src/main/java/clients/wsdl/temperatureConvert/TempConvert.java new file mode 100644 index 0000000..cafbb9c --- /dev/null +++ b/src/main/java/clients/wsdl/temperatureConvert/TempConvert.java @@ -0,0 +1,135 @@ +package https.www_w3schools_com.xml; + +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.namespace.QName; +import jakarta.xml.ws.WebEndpoint; +import jakarta.xml.ws.WebServiceClient; +import jakarta.xml.ws.WebServiceFeature; +import jakarta.xml.ws.Service; + +/** + * This class was generated by Apache CXF 4.0.3 + * 2023-10-28T21:23:45.149+13:00 + * Generated source version: 4.0.3 + * + */ +@WebServiceClient(name = "TempConvert", + wsdlLocation = "file:/home/ws/code/gitHub/multi-cloud-WebApp-Attendance/src/main/resources/wsdl/NumberConversion.wsdl", + targetNamespace = "https://www.w3schools.com/xml/") +public class TempConvert extends Service { + + public final static URL WSDL_LOCATION; + + public final static QName SERVICE = new QName("https://www.w3schools.com/xml/", "TempConvert"); + public final static QName TempConvertSoap = new QName("https://www.w3schools.com/xml/", "TempConvertSoap"); + public final static QName TempConvertSoap12 = new QName("https://www.w3schools.com/xml/", "TempConvertSoap12"); + public final static QName TempConvertHttpPost = new QName("https://www.w3schools.com/xml/", "TempConvertHttpPost"); + static { + URL url = null; + try { + url = new URL("file:/home/ws/code/gitHub/multi-cloud-WebApp-Attendance/src/main/resources/wsdl/NumberConversion.wsdl"); + } catch (MalformedURLException e) { + java.util.logging.Logger.getLogger(TempConvert.class.getName()) + .log(java.util.logging.Level.INFO, + "Can not initialize the default wsdl from {0}", "file:/home/ws/code/gitHub/multi-cloud-WebApp-Attendance/src/main/resources/wsdl/NumberConversion.wsdl"); + } + WSDL_LOCATION = url; + } + + public TempConvert(URL wsdlLocation) { + super(wsdlLocation, SERVICE); + } + + public TempConvert(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public TempConvert() { + super(WSDL_LOCATION, SERVICE); + } + + public TempConvert(WebServiceFeature ... features) { + super(WSDL_LOCATION, SERVICE, features); + } + + public TempConvert(URL wsdlLocation, WebServiceFeature ... features) { + super(wsdlLocation, SERVICE, features); + } + + public TempConvert(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) { + super(wsdlLocation, serviceName, features); + } + + + + + /** + * + * @return + * returns TempConvertSoap + */ + @WebEndpoint(name = "TempConvertSoap") + public TempConvertSoap getTempConvertSoap() { + return super.getPort(TempConvertSoap, TempConvertSoap.class); + } + + /** + * + * @param features + * A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns TempConvertSoap + */ + @WebEndpoint(name = "TempConvertSoap") + public TempConvertSoap getTempConvertSoap(WebServiceFeature... features) { + return super.getPort(TempConvertSoap, TempConvertSoap.class, features); + } + + + /** + * + * @return + * returns TempConvertSoap + */ + @WebEndpoint(name = "TempConvertSoap12") + public TempConvertSoap getTempConvertSoap12() { + return super.getPort(TempConvertSoap12, TempConvertSoap.class); + } + + /** + * + * @param features + * A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns TempConvertSoap + */ + @WebEndpoint(name = "TempConvertSoap12") + public TempConvertSoap getTempConvertSoap12(WebServiceFeature... features) { + return super.getPort(TempConvertSoap12, TempConvertSoap.class, features); + } + + + /** + * + * @return + * returns TempConvertHttpPost + */ + @WebEndpoint(name = "TempConvertHttpPost") + public TempConvertHttpPost getTempConvertHttpPost() { + return super.getPort(TempConvertHttpPost, TempConvertHttpPost.class); + } + + /** + * + * @param features + * A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns TempConvertHttpPost + */ + @WebEndpoint(name = "TempConvertHttpPost") + public TempConvertHttpPost getTempConvertHttpPost(WebServiceFeature... features) { + return super.getPort(TempConvertHttpPost, TempConvertHttpPost.class, features); + } + +} diff --git a/src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java b/src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java new file mode 100644 index 0000000..39637af --- /dev/null +++ b/src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java @@ -0,0 +1,36 @@ +package https.www_w3schools_com.xml; + +import jakarta.jws.WebMethod; +import jakarta.jws.WebParam; +import jakarta.jws.WebResult; +import jakarta.jws.WebService; +import jakarta.jws.soap.SOAPBinding; +import jakarta.xml.bind.annotation.XmlSeeAlso; + +/** + * This class was generated by Apache CXF 4.0.3 + * 2023-10-28T21:23:45.129+13:00 + * Generated source version: 4.0.3 + * + */ +@WebService(targetNamespace = "https://www.w3schools.com/xml/", name = "TempConvertHttpPost") +@XmlSeeAlso({ObjectFactory.class}) +@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +public interface TempConvertHttpPost { + + @WebMethod(operationName = "CelsiusToFahrenheit") + @WebResult(name = "string", targetNamespace = "https://www.w3schools.com/xml/", partName = "Body") + public java.lang.String celsiusToFahrenheit( + + @WebParam(partName = "Celsius", name = "Celsius", targetNamespace = "") + java.lang.String celsius + ); + + @WebMethod(operationName = "FahrenheitToCelsius") + @WebResult(name = "string", targetNamespace = "https://www.w3schools.com/xml/", partName = "Body") + public java.lang.String fahrenheitToCelsius( + + @WebParam(partName = "Fahrenheit", name = "Fahrenheit", targetNamespace = "") + java.lang.String fahrenheit + ); +} diff --git a/src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java b/src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java new file mode 100644 index 0000000..45509b2 --- /dev/null +++ b/src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java @@ -0,0 +1,40 @@ +package https.www_w3schools_com.xml; + +import jakarta.jws.WebMethod; +import jakarta.jws.WebParam; +import jakarta.jws.WebResult; +import jakarta.jws.WebService; +import jakarta.xml.bind.annotation.XmlSeeAlso; +import jakarta.xml.ws.RequestWrapper; +import jakarta.xml.ws.ResponseWrapper; + +/** + * This class was generated by Apache CXF 4.0.3 + * 2023-10-28T21:23:45.025+13:00 + * Generated source version: 4.0.3 + * + */ +@WebService(targetNamespace = "https://www.w3schools.com/xml/", name = "TempConvertSoap") +@XmlSeeAlso({ObjectFactory.class}) +public interface TempConvertSoap { + + @WebMethod(operationName = "CelsiusToFahrenheit", action = "https://www.w3schools.com/xml/CelsiusToFahrenheit") + @RequestWrapper(localName = "CelsiusToFahrenheit", targetNamespace = "https://www.w3schools.com/xml/", className = "https.www_w3schools_com.xml.CelsiusToFahrenheit") + @ResponseWrapper(localName = "CelsiusToFahrenheitResponse", targetNamespace = "https://www.w3schools.com/xml/", className = "https.www_w3schools_com.xml.CelsiusToFahrenheitResponse") + @WebResult(name = "CelsiusToFahrenheitResult", targetNamespace = "https://www.w3schools.com/xml/") + public java.lang.String celsiusToFahrenheit( + + @WebParam(name = "Celsius", targetNamespace = "https://www.w3schools.com/xml/") + java.lang.String celsius + ); + + @WebMethod(operationName = "FahrenheitToCelsius", action = "https://www.w3schools.com/xml/FahrenheitToCelsius") + @RequestWrapper(localName = "FahrenheitToCelsius", targetNamespace = "https://www.w3schools.com/xml/", className = "https.www_w3schools_com.xml.FahrenheitToCelsius") + @ResponseWrapper(localName = "FahrenheitToCelsiusResponse", targetNamespace = "https://www.w3schools.com/xml/", className = "https.www_w3schools_com.xml.FahrenheitToCelsiusResponse") + @WebResult(name = "FahrenheitToCelsiusResult", targetNamespace = "https://www.w3schools.com/xml/") + public java.lang.String fahrenheitToCelsius( + + @WebParam(name = "Fahrenheit", targetNamespace = "https://www.w3schools.com/xml/") + java.lang.String fahrenheit + ); +} diff --git a/src/main/java/clients/wsdl/temperatureConvert/package-info.java b/src/main/java/clients/wsdl/temperatureConvert/package-info.java new file mode 100644 index 0000000..36aa4eb --- /dev/null +++ b/src/main/java/clients/wsdl/temperatureConvert/package-info.java @@ -0,0 +1,2 @@ +@jakarta.xml.bind.annotation.XmlSchema(namespace = "https://www.w3schools.com/xml/", elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED) +package https.www_w3schools_com.xml; diff --git a/src/test/wsdl/ServiceInvokationTest.java b/src/test/java/serviceClients/ServiceInvokationTest.java similarity index 96% rename from src/test/wsdl/ServiceInvokationTest.java rename to src/test/java/serviceClients/ServiceInvokationTest.java index 848ec17..2aa47e7 100644 --- a/src/test/wsdl/ServiceInvokationTest.java +++ b/src/test/java/serviceClients/ServiceInvokationTest.java @@ -1,4 +1,4 @@ -package attendance.wsdl; +package wsdl; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -15,7 +15,6 @@ public class ServiceInvokationTest { @Test public void testWSDLSuccess() { - assertTrue(testService.invokeWSDLForIP().length() > 2); // System.out.println(testService.invokeWSDLForIP()); } diff --git a/src/test/ux/AttendanceGenerateTest.java b/src/test/java/ui/AttendanceGenerateTest.java similarity index 100% rename from src/test/ux/AttendanceGenerateTest.java rename to src/test/java/ui/AttendanceGenerateTest.java diff --git a/src/test/java/wsdl/TemperatureConvertTest.java b/src/test/java/wsdl/TemperatureConvertTest.java new file mode 100644 index 0000000..d4bd019 --- /dev/null +++ b/src/test/java/wsdl/TemperatureConvertTest.java @@ -0,0 +1,2 @@ +package wsdl;public class TemperatureConvertTest { +} diff --git a/src/test/json/ConversionJSON2Object.java b/src/test/json/ConversionJSON2Object.java deleted file mode 100644 index d699a45..0000000 --- a/src/test/json/ConversionJSON2Object.java +++ /dev/null @@ -1,30 +0,0 @@ -package attendance.gson; - -import com.google.gson.Gson; - -import entity.LoginReply; - -public class ConversionJSON2Object { - - public static void main(String[] args) { - // TODO Auto-generated method stub: use a variable for the token - - String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1MTc5MyIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.ZGB_kCYoU4vDREr6teZQyIyRT2MZkpmGyleAgsgzMRIauq7RpqgL_HUZukqSK6E5mtNxux6hihzl5CaP9jcY26u4zJTnYASBJwE4iqqggNqhp82PtFdxipf5ZvYAyF3uVTPCeiRGrxJSyoQpEWVUPDYaqj1ak1b2oTExH8sG1oOmYcaACAWY4mkjueFJCrgcWov3SyWDyMKCE7ZhaloJkcJ2uZypztB42XQ67z96bxTvRozzEVEVT4_4szpMjEj3Nmxy9kIv8H7kNMUrb5tE4vTfG-kzctCq7YxU2FfJhDTR_feoRohcjWZp-Zyl2BYFjNXl42ZZEk-TlLHov73izA\",\"ExpiresIn\":3600,\"TokenType\":\"Bearer\",\"RefreshToken\":\"eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiUlNBLU9BRVAifQ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RRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; - - String jsonInString = "{'name' : 'martina perumal'}"; - - Gson gson = new Gson(); - - // Restaurant restaurantObject = gson.fromJson(restaurantJson, - // Restaurant.class); - LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); - - // Object loginReplyObject = gson.fromJson(replyJson, Object.class); - - Girl girl = gson.fromJson(jsonInString, Girl.class); - - System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); - System.out.println("value of her name " + girl.getName()); - // System.out.println("obtain token "+ loginReplyObject.authenticationResult); - } -} diff --git a/src/test/json/ConversionJson2Map.java b/src/test/json/ConversionJson2Map.java deleted file mode 100644 index e6f491d..0000000 --- a/src/test/json/ConversionJson2Map.java +++ /dev/null @@ -1,39 +0,0 @@ -package attendance.gson; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -public class ConversionJson2Map { - - public static void main(String[] args) { - String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2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XvqyA\"}}"; - - Gson gson = new Gson(); - - Type authorization = new TypeToken>() { - }.getType(); - // TODO Auto-generated method stub - - Map authorizationMap = gson.fromJson(jsonFromMS, authorization); - - Map retMap = new Gson().fromJson(jsonFromMS, new TypeToken>() { - }.getType()); - - Map map = new Gson().fromJson(jsonFromMS, - new TypeToken>() { - }.getType()); - - System.out.println("Printing Map object: " + authorizationMap.values().toString()); - - authorizationMap.keySet().iterator().forEachRemaining(System.out::println); - - System.out.println("Printing ret Map object this is bringing the values: " + retMap.values().toString()); - - map.keySet().iterator().forEachRemaining(System.out::println); - - System.out.println(retMap.get("IdToken")); - } -} diff --git a/src/test/json/JSON2Object.java b/src/test/json/JSON2Object.java deleted file mode 100644 index 9f46c05..0000000 --- a/src/test/json/JSON2Object.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.leo.json; - -import com.google.gson.Gson; - -public class JSON2Object { - - public static void main(String[] args) { - String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1MTc5MyIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2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OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTExNzEzNSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.gGcx2YYcjWzNvzlpPklry4Jt59GwDQuDRRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; - String jsonInString = "{'name' : 'martina perumal'}"; - Gson gson = new Gson(); - - // Restaurant restaurantObject = gson.fromJson(restaurantJson, - // Restaurant.class); - LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); - - // Object loginReplyObject = gson.fromJson(replyJson, Object.class); - - Girl girl = gson.fromJson(jsonInString, Girl.class); - - System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); - System.out.println("value of her name " + girl.getName()); - // System.out.println("obtain token "+ loginReplyObject.authenticationResult); - } -} diff --git a/src/test/json/Json2Map.java b/src/test/json/Json2Map.java deleted file mode 100644 index edeade6..0000000 --- a/src/test/json/Json2Map.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.json; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -public class Json2Map { - - public static void main(String[] args) { - String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImp0aSI6ImI4MzY3ZjcwLTA5MDktNGI0Mi1hNDI2LWM2ZTYyY2M3ZTI0YSIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.jfGvw9FX5-XBcVVaY21wL7F7Y6KRzRdLweCybx819JdRES2f-m4qGeftAZdzoRuLDJ4QfbGqJdJ1V19MKcw070qdz_zd3JFMo3ev9-1yrzQ9vr9hQR6Utk7cBLs_AGQlXHt2wNimvW7mPj_yyyjLa5LTveX0W-hZ5ZG2FSuiAE6dTmmSZs-FEjwZRPTNbjDVKHHr8QRBFq43gg23PkRCAriLO02ymrVblKCx_kqKvYbvNed_RB0IeGZP_Ll27F34-xdZz6r_zAcgxvOqafa5wPAbOvgCubE_rWviCujhgIa4qe_nqkqMIJhm0B3xOk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iwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.N2vUTeKskoSGGnZNNQkoJrjqQSTwCRsAyoVzU8HoSESciE97PbHu_rsDBHdlIvExQgZOJUDH2fi2ZTVXL0qw_dw_1oy5PY0ss6iF9Ya8vNvwJ4QIg0nGLJEEWO6y9h81bUiy8WYOyC0uCy4FKPBzxu-VjO_ZkJwQZLlhkx56cPXhQI9JFbwQDeyxJDF9duOGiZkWYmiG842TeYpaNIiW46KtQ8kiZLGre9qUdPjQv9S-Ch9Cm8bDqVSunAVtTityUJMGJuxhM78hPAujGdeNfMX0qEx37MpKbQtkb_xJZaT1c0IXnu1tneqtGVxZtaZdQ4mUlBmdzamQaWhlSXvqyA\"}}"; - - Gson gson = new Gson(); - - Type authorization = new TypeToken>() { - }.getType(); - - Map authorizationMap = gson.fromJson(jsonFromMS, authorization); - - Map retMap = new Gson().fromJson(jsonFromMS, new TypeToken>() { - }.getType()); - - Map map = new Gson().fromJson(jsonFromMS, new TypeToken>() { - }.getType()); - - System.out.println("Printing Map object: " + authorizationMap.values().toString()); - - authorizationMap.keySet().iterator().forEachRemaining(System.out::println); - - System.out.println("Printing ret Map object this is bringing the values: " + retMap.values().toString()); - - map.keySet().iterator().forEachRemaining(System.out::println); - - System.out.println(retMap.get("IdToken")); - - } - -} From 3b0c3f7d8d5db49fec8b4cee80db7673d85c0ad5 Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Sat, 28 Oct 2023 22:58:30 +1300 Subject: [PATCH 20/32] gradle wrapper rebuilt IntelliJ Signed-off-by: Andres LeonRangel --- .README.md.swp | Bin 0 -> 16384 bytes README.md | 38 +++++++++++++++++++++++ build.gradle.kts | 10 +++--- gradle/wrapper/gradle-wrapper.properties | 3 +- gradlew | 31 +++++++++++++----- gradlew.bat | 15 +++++---- 6 files changed, 77 insertions(+), 20 deletions(-) create mode 100644 .README.md.swp diff --git a/.README.md.swp b/.README.md.swp new file mode 100644 index 0000000000000000000000000000000000000000..cd067bdf9345b37f1f437d4c660ceee2f5a44f26 GIT binary patch literal 16384 zcmeHOU2Ggj9Uo|Eff7IzkdRRNZ!AO{Ja@K}($q~Oxv|^WbsE>_)M>3qncJPa+j@6r z*$NG;-_6<_T$2&6v33vZO)e`a^@&UPAAeE^|7 z<(JFN$A4!2Uo-RDO?US3l}mKCH81e_xDa1{=6-$u{R`r=-}$sqp*C@<;=T^K_J$u7 zZVrNYXI=Sg_uM;s!)BsAFp+K#v$kh^-R=kZ#iHAeiZBnP7n;JCTe`cLByus&b?mFy z)9sDr#idKjt;oNz)TXAPjRqPG{1-H!@MN9u{x9-{AJ6}*`~ROm zCd5yGM}fb8REQq~>%b?0H;xJMUErI52P^`20)P655Z?p74m=FZ0e`(ii06SPfX@JL zeHiV4KLWo5egXUdco|p)R)9|dcK~mHNQhT}UjaV{z5tv8e*Hm|0WSl~zzp!}?Pv>p z8+ab*13h2~xDEL2ZD3e*<0zeg?biXFZ|MIIz-z!y0c#KI z4_=UZMW|9rbx)@nZ$)HcYKoTk@>Efz(?|tA`GM-EDiYVPUl)WA-lP~9vy+jO=V^IY z$GP;=0N+xj-XO@emlvr%-1Oq+=DPG$7yHw=1!igELd92WBP>SzwtY5Ir z*He?5Zqc)HHkLb^wsbW5WO*rWvXEs>mQ>1`EWLVZZL(msbNNvLEhht7+h9$X%4cgV zuCKH^I^7Lm9a7FUm%&;9m|mxVs1CKt(7U@&MHa+;!V5B#t9~Zt zThuYVe5g`QzE1FN47>oUS(x}mt~&G5psRffVoFTZ+KWQ!1)&ymEn11Q9HzDUrX)3( zD`emwPr)5X(W=^2_0QGiW%P&=ljbZ-#rw3fw2W_`xqv9+^RpB047rzuU_!h()E)*qLHmpxH-N;9<)-!q?1G_O(pk`t z=|nY?E%Z2nkYCcdf|~q#id=DRG$YJ@iZ(a`DL0f4G;ss!VdcKX1!m1E$E*iuDmvQ2Ohf}YJJzkFrgM6Poa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n z!Hi;D^;6;}3!Uj1OPWMDKj#Dz8`fo?39<~sxoLDdYcO-{X9KmPL65J*U{XK?c}$Lv zcaJqh!+}5-V9Mb>tTl{7qd**Bnbx-aumr#M>1t=mPBwGA97w}@5%Vo^!9)r4;QHZ~ z%s1Fcwq}7Yv#6Tz8P#%I=5yT4n6Uv>Jt2)bpv-n1nxf*(c~S;_Q%Ab9gqDz&TAMK1 z0&QY|+J-bl7ss27reNu$VGxE)7Fjp*AuEI49Q|lL!U?jWRTdL_6DyF3PBz@(WkXCt z+cfEW570GQclXstAz^_!iT1#K!hlbMKAW)*11vjOx~Lt<5}fZi(s0)eRC@imT%MVo zdRf<^rIIBCUBnf0tvOa-mpGWlW9gujvHA%itBY43goGY6!2w#u=fUn(<-xvN9mL8- znC35EeF1*VJf6*imfpqV5tn%Iv`)oy3qr6$T>|7059S2og&dICHa -db -wv -p <[wsdl-namespace =]package-name>* -sn -d + +Here’s what some of the options mean1: + +-fe frontend-name: Specifies the frontend. Default is JAXWS. +-db databinding-name: Specifies the databinding. Default is JAXB. +-wv wsdl-version: Specifies the WSDL version. Default is WSDL1.1. +-p [ wsdl-namespace= ] PackageName: Specifies zero, or more, package names to use for the generated code. +-sn service-name: The WSDL service name to use for the generated code. +-d output-directory: The directory where the generated code will be placed. +Compile and run the generated code: Once you have generated the code, you can compile and run it as you would with any other Java code. +Please note that if your WSDL file is secured (for example, accessed over HTTPS), you might encounter issues with SSL handshake3. In such cases, you might need to manually download and reference any XSD files used in your WSDL2. + +Remember to replace , , , <[wsdl-namespace =]package-name>*, , , and with your actual values. + +For more advanced usage and options, please refer to the official Apache CXF documentation. https://cxf.apache.org/docs/wsdl-to-java.html + +2023-10-28 +after some serious struggle trying to get wdl2java to work for a simple WSDL file i found online i have found a solution +- i tried using multiple plugins in gradle kotlin DSL. fail +- i tried switching to maven and using the official CXF. Fail several times +- in maven upgraded to java17 and ajdusted simple settings OK +- I followed docs https://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html and https://cxf.apache.org/docs/wsdl-to-java.html +- wsdl is ready + diff --git a/build.gradle.kts b/build.gradle.kts index e39d65f..cf44f76 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,9 +33,9 @@ dependencies { // https://mvnrepository.com/artifact/com.google.zxing/javase implementation("com.google.zxing:javase:3.5.1") implementation("com.google.zxing:core:3.5.1") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0") - testImplementation("io.jsonwebtoken:jjwt:0.7.0") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2") + testImplementation("io.jsonwebtoken:jjwt:0.9.1") // dependency below only needed if using the Java 8 version of @Generated (through "jdk8") on Java 9 or later implementation("javax.annotation:javax.annotation-api:1.3.2") implementation("io.github.threeten-jaxb:threeten-jaxb-core:2.1.0") // Use Java Date/Time API instead of clunky GregorianCalendar class @@ -44,7 +44,7 @@ dependencies { group = "soa.nz.aut" version = "0.0.1" description = "Student Attendance WebApp" -java.sourceCompatibility = JavaVersion.VERSION_1_8 +java.sourceCompatibility = JavaVersion.VERSION_17 tasks.war { archiveBaseName.set("Attendance") @@ -77,7 +77,7 @@ tasks.register("singleTest") { // https://plugins.gradle.org/plugin/com.github.bjornvester.wsdl2java // https://www.w3schools.com/xml/tempconvert.asmx?WSDL wsdl2java { - wsdlDir.set(layout.projectDirectory.dir("src/main/resources/wsdl")) + // wsdlDir.set(layout.projectDirectory.dir("src/main/resources/wsdl")) bindingFile.set(layout.projectDirectory.file("src/main/bindings/bindings.xjb")) includes.set( diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a673105..ac72c34 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -#after upgrade run ./gradlew wrapper --gradle-version 8.3 \ No newline at end of file diff --git a/gradlew b/gradlew index 1b6c787..0adc8e1 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +198,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -205,6 +214,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal From 0925d83237a0857e02a192de1ac3a4d3049a2985 Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Sat, 28 Oct 2023 23:01:14 +1300 Subject: [PATCH 21/32] maven cxf generate WSDL2Java clean up of java files and content Signed-off-by: Andres LeonRangel --- .README.md.swp | Bin 16384 -> 0 bytes .../java/clients/wsdl/geoIP/GeoIPService.java | 1 - .../temperatureConvert/CelsiusToFahrenheit.java | 4 ++-- .../CelsiusToFahrenheitResponse.java | 2 +- .../temperatureConvert/FahrenheitToCelsius.java | 2 +- .../wsdl/temperatureConvert/ObjectFactory.java | 3 +-- .../temperatureConvert/TempConvertHttpPost.java | 2 +- .../temperatureConvert/TempConvertSoap.java | 2 +- 8 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 .README.md.swp diff --git a/.README.md.swp b/.README.md.swp deleted file mode 100644 index cd067bdf9345b37f1f437d4c660ceee2f5a44f26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHOU2Ggj9Uo|Eff7IzkdRRNZ!AO{Ja@K}($q~Oxv|^WbsE>_)M>3qncJPa+j@6r z*$NG;-_6<_T$2&6v33vZO)e`a^@&UPAAeE^|7 z<(JFN$A4!2Uo-RDO?US3l}mKCH81e_xDa1{=6-$u{R`r=-}$sqp*C@<;=T^K_J$u7 zZVrNYXI=Sg_uM;s!)BsAFp+K#v$kh^-R=kZ#iHAeiZBnP7n;JCTe`cLByus&b?mFy z)9sDr#idKjt;oNz)TXAPjRqPG{1-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nf0tvOa-mpGWlW9gujvHA%itBY43goGY6!2w#u=fUn(<-xvN9mL8- znC35EeF1*VJf6*imfpqV5tn%Iv`)oy3qr6$T>|7059S2og&dICHaJava class for anonymous complex type. * diff --git a/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java b/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java index 8177c07..5b41f23 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java +++ b/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java @@ -1,5 +1,5 @@ -package https.www_w3schools_com.xml; +package clients.wsdl.temperatureConvert; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java b/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java index c00e84f..7566192 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java +++ b/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java @@ -1,5 +1,5 @@ -package https.www_w3schools_com.xml; +package clients.wsdl.temperatureConvert; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java b/src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java index da118dd..d45fb5d 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java +++ b/src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java @@ -1,12 +1,11 @@ -package https.www_w3schools_com.xml; +package clients.wsdl.temperatureConvert; import javax.xml.namespace.QName; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.annotation.XmlElementDecl; import jakarta.xml.bind.annotation.XmlRegistry; - /** * This object contains factory methods for each * Java content interface and Java element interface diff --git a/src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java b/src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java index 39637af..337b328 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java +++ b/src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java @@ -1,4 +1,4 @@ -package https.www_w3schools_com.xml; +package clients.wsdl.temperatureConvert; import jakarta.jws.WebMethod; import jakarta.jws.WebParam; diff --git a/src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java b/src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java index 45509b2..67da0e9 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java +++ b/src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java @@ -1,4 +1,4 @@ -package https.www_w3schools_com.xml; +package clients.wsdl.temperatureConvert; import jakarta.jws.WebMethod; import jakarta.jws.WebParam; From 1d81d392ef2a35c58a0a84a5c9aec9ed822b8315 Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Sat, 28 Oct 2023 23:02:31 +1300 Subject: [PATCH 22/32] VsCode workspace settings Signed-off-by: Andres LeonRangel --- multi-cloud-WebApp-Attendance.code-workspace | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 multi-cloud-WebApp-Attendance.code-workspace diff --git a/multi-cloud-WebApp-Attendance.code-workspace b/multi-cloud-WebApp-Attendance.code-workspace new file mode 100644 index 0000000..15c77e1 --- /dev/null +++ b/multi-cloud-WebApp-Attendance.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "java.configuration.updateBuildConfiguration": "automatic" + } +} \ No newline at end of file From 62710964aaae212fc7ae8632589e69c31f41fae1 Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Sat, 28 Oct 2023 23:03:31 +1300 Subject: [PATCH 23/32] Code Cleanup mostly done by IntelliJ structure package re-naming Signed-off-by: Andres LeonRangel --- .../java/clients/GraphQL/GraphQLClient.java | 8 +- src/main/java/service/MainService.java | 8 +- src/main/resources/webServiceSOAPDemo.wsdl | 419 ------------------ src/test/java/json/ConversionJson2Map.java | 16 +- src/test/java/json/Json2Map.java | 5 - src/test/java/json/TestJSONResponse.java | 7 +- .../serviceClients/ServiceInvokationTest.java | 2 +- .../java/wsdl/TemperatureConvertTest.java | 22 +- 8 files changed, 41 insertions(+), 446 deletions(-) delete mode 100644 src/main/resources/webServiceSOAPDemo.wsdl diff --git a/src/main/java/clients/GraphQL/GraphQLClient.java b/src/main/java/clients/GraphQL/GraphQLClient.java index e9fc8f3..ef1b0d5 100644 --- a/src/main/java/clients/GraphQL/GraphQLClient.java +++ b/src/main/java/clients/GraphQL/GraphQLClient.java @@ -1,3 +1,5 @@ +package clients.GraphQL; + import com.graphql.java.client.GraphQLClient; import com.graphql.java.client.GraphQLClientBuilder; import com.graphql.java.client.GraphQLRequest; @@ -7,7 +9,11 @@ public class GraphQLClient { private final GraphQLClient graphQLClient; - public GraphQLClientExample(String graphQLAPIEndpointURL) { + public GraphQLClient() { + graphQLClient = new GraphQLClient(); + } + + public void GraphQLClientExample(String graphQLAPIEndpointURL) { graphQLClient = GraphQLClientBuilder.newClient(graphQLAPIEndpointURL).build(); } diff --git a/src/main/java/service/MainService.java b/src/main/java/service/MainService.java index 01b9d67..b296e48 100644 --- a/src/main/java/service/MainService.java +++ b/src/main/java/service/MainService.java @@ -17,20 +17,16 @@ public class MainService { public String invokeWSDLForIP() { // GeoIPService service = new GeoIPService(); // GeoIP ipService = service.getGeoIPServiceSoap().getGeoIPContext(); - String result = "WSDL and SOAP being deprecated"; - //String result = ipService.getCountryCode().concat(": ")+ipService.getCountryName().concat(", IP is: ")+ipService.getIP().concat(" the return code details are: ")+ipService.getReturnCodeDetails(); + //String result = ipService.getCountryName().concat(", IP is: ")+ipService.getIP().concat("code details are: ")+ipService.getReturnCodeDetails(); // String wsdlResult = ipService.getCountryCode().concat(": ")+ipService.getCountryName().concat(", IP is: ")+ipService.getIP().concat(" the return code details are: ")+ipService.getReturnCodeDetails(); - return result; + return "GeoIP Web Service No longer functions"; } - public String invokeRestForBibleVerse() { - ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); WebResource service = client.resource(UriBuilder.fromUri("http://labs.bible.org/api/?passage=random").build()); - return service.get(String.class); } diff --git a/src/main/resources/webServiceSOAPDemo.wsdl b/src/main/resources/webServiceSOAPDemo.wsdl deleted file mode 100644 index 73d3d46..0000000 --- a/src/main/resources/webServiceSOAPDemo.wsdl +++ /dev/null @@ -1,419 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/java/json/ConversionJson2Map.java b/src/test/java/json/ConversionJson2Map.java index e6f491d..cbe36b8 100644 --- a/src/test/java/json/ConversionJson2Map.java +++ b/src/test/java/json/ConversionJson2Map.java @@ -1,29 +1,27 @@ -package attendance.gson; +package json; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import entity.Authorization; + import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; public class ConversionJson2Map { - - public static void main(String[] args) { + public void convertJSON2Map() { String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3B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x56cPXhQI9JFbwQDeyxJDF9duOGiZkWYmiG842TeYpaNIiW46KtQ8kiZLGre9qUdPjQv9S-Ch9Cm8bDqVSunAVtTityUJMGJuxhM78hPAujGdeNfMX0qEx37MpKbQtkb_xJZaT1c0IXnu1tneqtGVxZtaZdQ4mUlBmdzamQaWhlSXvqyA\"}}"; Gson gson = new Gson(); - - Type authorization = new TypeToken>() { + Type authorization = new TypeToken>() { }.getType(); - // TODO Auto-generated method stub - - Map authorizationMap = gson.fromJson(jsonFromMS, authorization); + Map authorizationMap = gson.fromJson(jsonFromMS, authorization); Map retMap = new Gson().fromJson(jsonFromMS, new TypeToken>() { }.getType()); Map map = new Gson().fromJson(jsonFromMS, - new TypeToken>() { + new TypeToken>() { }.getType()); System.out.println("Printing Map object: " + authorizationMap.values().toString()); diff --git a/src/test/java/json/Json2Map.java b/src/test/java/json/Json2Map.java index edeade6..638d64a 100644 --- a/src/test/java/json/Json2Map.java +++ b/src/test/java/json/Json2Map.java @@ -25,15 +25,10 @@ public static void main(String[] args) { }.getType()); System.out.println("Printing Map object: " + authorizationMap.values().toString()); - authorizationMap.keySet().iterator().forEachRemaining(System.out::println); - System.out.println("Printing ret Map object this is bringing the values: " + retMap.values().toString()); - map.keySet().iterator().forEachRemaining(System.out::println); - System.out.println(retMap.get("IdToken")); } - } diff --git a/src/test/java/json/TestJSONResponse.java b/src/test/java/json/TestJSONResponse.java index df341a2..bd8499d 100644 --- a/src/test/java/json/TestJSONResponse.java +++ b/src/test/java/json/TestJSONResponse.java @@ -1,15 +1,14 @@ package json; +import javax.json.Json; +import javax.json.stream.JsonParser; +import javax.json.stream.JsonParser.Event; import java.io.BufferedReader; -import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; -import javax.json.Json; -import javax.json.stream.JsonParser; -import javax.json.stream.JsonParser.Event; public class TestJSONResponse { diff --git a/src/test/java/serviceClients/ServiceInvokationTest.java b/src/test/java/serviceClients/ServiceInvokationTest.java index 2aa47e7..4e00ce1 100644 --- a/src/test/java/serviceClients/ServiceInvokationTest.java +++ b/src/test/java/serviceClients/ServiceInvokationTest.java @@ -1,4 +1,4 @@ -package wsdl; +package serviceClients; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/wsdl/TemperatureConvertTest.java b/src/test/java/wsdl/TemperatureConvertTest.java index d4bd019..7eb2495 100644 --- a/src/test/java/wsdl/TemperatureConvertTest.java +++ b/src/test/java/wsdl/TemperatureConvertTest.java @@ -1,2 +1,22 @@ -package wsdl;public class TemperatureConvertTest { +package wsdl; +import clients.wsdl.temperatureConvert.TempConvertSoap; +import clients.wsdl.temperatureConvert.TempConvert; +import org.junit.Assert; +import org.junit.Test; + +public class TemperatureConvertTest { + @Test + public void testCelsiusToFahrenheit() { + // Create an instance of the service + TempConvert service = new TempConvert(); + TempConvertSoap port = service.getTempConvertSoap(); + + // Test conversion from Celsius to Fahrenheit + String celsius = "100"; + String expectedFahrenheit = "212"; + String actualFahrenheit = port.celsiusToFahrenheit(celsius); + + // Assert that the expected Fahrenheit value matches the actual Fahrenheit value + Assert.assertEquals(expectedFahrenheit, actualFahrenheit); + } } From a28edddd12a06b3ba9ec0ac500cb38a7a72a6edb Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Sat, 4 Nov 2023 23:09:33 +1300 Subject: [PATCH 24/32] refactored full structure Signed-off-by: Andres LeonRangel --- .idea/compiler.xml | 2 +- .idea/misc.xml | 3 +- build.gradle.kts | 3 ++ src/main/java/bean/AttendanceBean.java | 7 ++-- src/main/java/bean/MainMenu.java | 2 +- src/main/java/bean/Paper.java | 3 -- .../java/clients/GraphQL/GraphQLClient.java | 37 ------------------- .../clients/GraphQL/GraphQLClient.java | 28 ++++++++++++++ .../clients/rest/JerseyClient.java | 2 +- .../clients/rest/JerseyPostHeader.java | 3 +- .../CelsiusToFahrenheit.java | 2 +- .../CelsiusToFahrenheitResponse.java | 2 +- .../FahrenheitToCelsius.java | 2 +- .../FahrenheitToCelsiusResponse.java | 2 +- .../temperatureConvert/ObjectFactory.java | 4 +- .../wsdl/temperatureConvert/TempConvert.java | 5 +-- .../TempConvertHttpPost.java | 2 +- .../temperatureConvert/TempConvertSoap.java | 2 +- .../wsdl/temperatureConvert/package-info.java | 2 +- .../wsclient/GeoIPServiceSoap.java | 10 ++--- .../rest/JerseyAttendance.java} | 11 +++--- .../rest/JerseyClientAuthLogin.java} | 4 +- .../rest/JerseyGetSession.java} | 4 +- .../JerseyJSONAuthorizationResponse.java} | 4 +- .../rest/JerseyJsonSimpleLogin.java} | 6 +-- .../serviceClients/rest/JerseyPostLogin.java} | 4 +- .../rest/NetClientPostUserLogin.java} | 4 +- .../serviceClients/rest/PostAuthToken.java} | 5 +-- .../rest/TestJSONResponse.java | 0 .../serviceClients}/rest/TestRestClient.java | 0 .../serviceClients/soap}/geoIP/GeoIP.java | 2 +- .../soap}/geoIP/GeoIPService.java | 2 +- .../soap}/geoIP/GeoIPServiceSoap.java | 12 +++--- .../serviceClients/soap}/geoIP/GetGeoIP.java | 2 +- .../soap}/geoIP/GetGeoIPContext.java | 2 +- .../soap}/geoIP/GetGeoIPContextResponse.java | 2 +- .../soap}/geoIP/GetGeoIPResponse.java | 2 +- .../soap}/geoIP/ObjectFactory.java | 2 +- .../soap}/geoIP/package-info.java | 2 +- .../java/wsdl/TemperatureConvertTest.java | 4 +- 40 files changed, 91 insertions(+), 106 deletions(-) delete mode 100644 src/main/java/clients/GraphQL/GraphQLClient.java create mode 100644 src/main/java/service/clients/GraphQL/GraphQLClient.java rename src/main/java/{ => service}/clients/rest/JerseyClient.java (98%) rename src/main/java/{ => service}/clients/rest/JerseyPostHeader.java (96%) rename src/main/java/{ => service}/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java (96%) rename src/main/java/{ => service}/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java (97%) rename src/main/java/{ => service}/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java (96%) rename src/main/java/{ => service}/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java (97%) rename src/main/java/{ => service}/clients/wsdl/temperatureConvert/ObjectFactory.java (95%) rename src/main/java/{ => service}/clients/wsdl/temperatureConvert/TempConvert.java (98%) rename src/main/java/{ => service}/clients/wsdl/temperatureConvert/TempConvertHttpPost.java (96%) rename src/main/java/{ => service}/clients/wsdl/temperatureConvert/TempConvertSoap.java (97%) rename src/main/java/{ => service}/clients/wsdl/temperatureConvert/package-info.java (75%) rename src/{main/java/clients/rest/JerseyTest.java => test/java/serviceClients/rest/JerseyAttendance.java} (97%) rename src/{main/java/clients/rest/JerseyClientPost.java => test/java/serviceClients/rest/JerseyClientAuthLogin.java} (93%) rename src/{main/java/clients/rest/JerseyGet.java => test/java/serviceClients/rest/JerseyGetSession.java} (97%) rename src/{main/java/clients/rest/JerseyJsonResponse.java => test/java/serviceClients/rest/JerseyJSONAuthorizationResponse.java} (93%) rename src/{main/java/clients/rest/JerseyJsonSimpler.java => test/java/serviceClients/rest/JerseyJsonSimpleLogin.java} (89%) rename src/{main/java/clients/rest/JerseyPost.java => test/java/serviceClients/rest/JerseyPostLogin.java} (95%) rename src/{main/java/clients/rest/NetClientPost.java => test/java/serviceClients/rest/NetClientPostUserLogin.java} (96%) rename src/{main/java/clients/rest/PostAuthenticationToken.java => test/java/serviceClients/rest/PostAuthToken.java} (98%) rename src/{main/java/clients => test/java/serviceClients}/rest/TestJSONResponse.java (100%) rename src/{main/java/clients => test/java/serviceClients}/rest/TestRestClient.java (100%) rename src/{main/java/clients/wsdl => test/java/serviceClients/soap}/geoIP/GeoIP.java (99%) rename src/{main/java/clients/wsdl => test/java/serviceClients/soap}/geoIP/GeoIPService.java (98%) rename src/{main/java/clients/wsdl => test/java/serviceClients/soap}/geoIP/GeoIPServiceSoap.java (81%) rename src/{main/java/clients/wsdl => test/java/serviceClients/soap}/geoIP/GetGeoIP.java (97%) rename src/{main/java/clients/wsdl => test/java/serviceClients/soap}/geoIP/GetGeoIPContext.java (95%) rename src/{main/java/clients/wsdl => test/java/serviceClients/soap}/geoIP/GetGeoIPContextResponse.java (98%) rename src/{main/java/clients/wsdl => test/java/serviceClients/soap}/geoIP/GetGeoIPResponse.java (97%) rename src/{main/java/clients/wsdl => test/java/serviceClients/soap}/geoIP/ObjectFactory.java (98%) rename src/{main/java/clients/wsdl => test/java/serviceClients/soap}/geoIP/package-info.java (86%) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 61a9130..b589d56 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 1003eec..f5db0c5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,5 @@ + - + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index cf44f76..349990b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,6 +39,9 @@ dependencies { // dependency below only needed if using the Java 8 version of @Generated (through "jdk8") on Java 9 or later implementation("javax.annotation:javax.annotation-api:1.3.2") implementation("io.github.threeten-jaxb:threeten-jaxb-core:2.1.0") // Use Java Date/Time API instead of clunky GregorianCalendar class + implementation("com.graphql-java-kickstart:graphql-webclient-spring-boot-starter:2.0.1") + implementation("com.graphql-java:graphql-java:20.7") + implementation("com.graphql-java-generator:graphql-java-runtime:1.18") } group = "soa.nz.aut" diff --git a/src/main/java/bean/AttendanceBean.java b/src/main/java/bean/AttendanceBean.java index 2224855..3e3d20e 100644 --- a/src/main/java/bean/AttendanceBean.java +++ b/src/main/java/bean/AttendanceBean.java @@ -28,7 +28,7 @@ public class AttendanceBean { public void init() { // invokes service class to populate classes classes = new ArrayList(); - classes.add("SOA"); + classes.add("Micro Services Architecture"); classes.add("Service Science"); classes.add("Service Based Design"); classes.add("Cloud Computing"); @@ -97,6 +97,5 @@ public void setRandomCode(String randomCode) { this.randomCode = randomCode; } } -/* - * End of AttendanceBean.java - */ +// End of AttendanceBean.java + diff --git a/src/main/java/bean/MainMenu.java b/src/main/java/bean/MainMenu.java index 15234f1..2f32d66 100644 --- a/src/main/java/bean/MainMenu.java +++ b/src/main/java/bean/MainMenu.java @@ -1,6 +1,6 @@ /** * Class MainMenu and controls main menu navigation - * links to mainMenu bean and .xhtml file. + * links to mainMenu bean and .xhtml file */ package bean; diff --git a/src/main/java/bean/Paper.java b/src/main/java/bean/Paper.java index 3fa70ff..78dd2c7 100644 --- a/src/main/java/bean/Paper.java +++ b/src/main/java/bean/Paper.java @@ -43,13 +43,11 @@ public class Paper { /** * No args constructor for use in serialization - * */ public Paper() { } /** - * * @param id * @param updatedAt * @param stream @@ -192,7 +190,6 @@ public Paper withRoom(String room) { } public String obtainLectureName() { - return "Lecturers Name String"; } } diff --git a/src/main/java/clients/GraphQL/GraphQLClient.java b/src/main/java/clients/GraphQL/GraphQLClient.java deleted file mode 100644 index ef1b0d5..0000000 --- a/src/main/java/clients/GraphQL/GraphQLClient.java +++ /dev/null @@ -1,37 +0,0 @@ -package clients.GraphQL; - -import com.graphql.java.client.GraphQLClient; -import com.graphql.java.client.GraphQLClientBuilder; -import com.graphql.java.client.GraphQLRequest; -import com.graphql.java.client.GraphQLResponse; - -public class GraphQLClient { - - private final GraphQLClient graphQLClient; - - public GraphQLClient() { - graphQLClient = new GraphQLClient(); - } - - public void GraphQLClientExample(String graphQLAPIEndpointURL) { - graphQLClient = GraphQLClientBuilder.newClient(graphQLAPIEndpointURL).build(); - } - - public GraphQLResponse executeQuery(String query) { - GraphQLRequest graphQLRequest = new GraphQLRequest(query); - return graphQLClient.execute(graphQLRequest); - } - - public static void main(String[] args) { - GraphQLClientExample graphQLClientExample = new GraphQLClientExample("https://graphql.example.com"); - - // Execute a GraphQL query - GraphQLResponse graphQLResponse = graphQLClientExample.executeQuery("{ hello }"); - - // Parse the GraphQL response - String hello = graphQLResponse.getData().get("hello").toString(); - - // Print the result - System.out.println(hello); - } -} \ No newline at end of file diff --git a/src/main/java/service/clients/GraphQL/GraphQLClient.java b/src/main/java/service/clients/GraphQL/GraphQLClient.java new file mode 100644 index 0000000..d1d2b63 --- /dev/null +++ b/src/main/java/service/clients/GraphQL/GraphQLClient.java @@ -0,0 +1,28 @@ +package service.clients.GraphQL; + +import org.springframework.web.reactive.function.client.WebClient; +import com.graphql_java_generator.client.GraphQLConfiguration; +import com.graphql_java_generator.client.GraphQLWebClient; + +public class GraphQLClient { + + public static void main(String[] args) { + // Create a WebClient + WebClient webClient = WebClient.create("http://localhost:8080/graphql"); + + // Create a GraphQLConfiguration + GraphQLConfiguration graphQLConfiguration = new GraphQLConfiguration(webClient); + + // Create a GraphQLWebClient + GraphQLWebClient graphQLWebClient = new GraphQLWebClient(graphQLConfiguration); + + // Define a query + String query = "{ helloWorld }"; + + // Execute the query + String response = graphQLWebClient.executeQuery(query); + + // Print the response + System.out.println(response); + } +} \ No newline at end of file diff --git a/src/main/java/clients/rest/JerseyClient.java b/src/main/java/service/clients/rest/JerseyClient.java similarity index 98% rename from src/main/java/clients/rest/JerseyClient.java rename to src/main/java/service/clients/rest/JerseyClient.java index 46fb03e..c582c47 100644 --- a/src/main/java/clients/rest/JerseyClient.java +++ b/src/main/java/service/clients/rest/JerseyClient.java @@ -1,4 +1,4 @@ -package testing.rest; +package service.clients.rest; import java.io.IOException; import javax.ws.rs.core.MediaType; diff --git a/src/main/java/clients/rest/JerseyPostHeader.java b/src/main/java/service/clients/rest/JerseyPostHeader.java similarity index 96% rename from src/main/java/clients/rest/JerseyPostHeader.java rename to src/main/java/service/clients/rest/JerseyPostHeader.java index ae8f69e..1ab46e5 100644 --- a/src/main/java/clients/rest/JerseyPostHeader.java +++ b/src/main/java/service/clients/rest/JerseyPostHeader.java @@ -1,4 +1,4 @@ -package testing.rest; +package service.clients.rest; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; @@ -17,7 +17,6 @@ public class JerseyPostHeader { Form form = new Form(); // form.param("x", "foo"); // form.param("y", "bar"); - // String bean = // target.request(MediaType.APPLICATION_JSON_TYPE).post(MediaType.APPLICATION_FORM_URLENCODED_TYPE, // String.class); diff --git a/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java b/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java similarity index 96% rename from src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java rename to src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java index 2b93004..a420283 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java +++ b/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java @@ -1,5 +1,5 @@ -package clients.wsdl.temperatureConvert; +package service.clients.wsdl.temperatureConvert; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java b/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java similarity index 97% rename from src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java rename to src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java index 5b41f23..1f2975c 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java +++ b/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java @@ -1,5 +1,5 @@ -package clients.wsdl.temperatureConvert; +package service.clients.wsdl.temperatureConvert; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java b/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java similarity index 96% rename from src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java rename to src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java index 7566192..a671fa5 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java +++ b/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java @@ -1,5 +1,5 @@ -package clients.wsdl.temperatureConvert; +package service.clients.wsdl.temperatureConvert; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java b/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java similarity index 97% rename from src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java rename to src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java index 1783980..93bc1c5 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java +++ b/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java @@ -1,5 +1,5 @@ -package https.www_w3schools_com.xml; +package service.clients.wsdl.temperatureConvert; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java b/src/main/java/service/clients/wsdl/temperatureConvert/ObjectFactory.java similarity index 95% rename from src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java rename to src/main/java/service/clients/wsdl/temperatureConvert/ObjectFactory.java index d45fb5d..fa12a61 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/ObjectFactory.java +++ b/src/main/java/service/clients/wsdl/temperatureConvert/ObjectFactory.java @@ -1,5 +1,5 @@ -package clients.wsdl.temperatureConvert; +package service.clients.wsdl.temperatureConvert; import javax.xml.namespace.QName; import jakarta.xml.bind.JAXBElement; @@ -44,6 +44,7 @@ public FahrenheitToCelsius createFahrenheitToCelsius() { * Create an instance of {@link FahrenheitToCelsiusResponse } * */ +// public FahrenheitToCelsiusResponse createFahrenheitToCelsiusResponse() { public FahrenheitToCelsiusResponse createFahrenheitToCelsiusResponse() { return new FahrenheitToCelsiusResponse(); } @@ -76,5 +77,4 @@ public CelsiusToFahrenheitResponse createCelsiusToFahrenheitResponse() { public JAXBElement createString(String value) { return new JAXBElement(_String_QNAME, String.class, null, value); } - } diff --git a/src/main/java/clients/wsdl/temperatureConvert/TempConvert.java b/src/main/java/service/clients/wsdl/temperatureConvert/TempConvert.java similarity index 98% rename from src/main/java/clients/wsdl/temperatureConvert/TempConvert.java rename to src/main/java/service/clients/wsdl/temperatureConvert/TempConvert.java index cafbb9c..46054cd 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/TempConvert.java +++ b/src/main/java/service/clients/wsdl/temperatureConvert/TempConvert.java @@ -1,4 +1,4 @@ -package https.www_w3schools_com.xml; +package service.clients.wsdl.temperatureConvert; import java.net.MalformedURLException; import java.net.URL; @@ -61,9 +61,6 @@ public TempConvert(URL wsdlLocation, QName serviceName, WebServiceFeature ... fe super(wsdlLocation, serviceName, features); } - - - /** * * @return diff --git a/src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java b/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertHttpPost.java similarity index 96% rename from src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java rename to src/main/java/service/clients/wsdl/temperatureConvert/TempConvertHttpPost.java index 337b328..4a5d41b 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/TempConvertHttpPost.java +++ b/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertHttpPost.java @@ -1,4 +1,4 @@ -package clients.wsdl.temperatureConvert; +package service.clients.wsdl.temperatureConvert; import jakarta.jws.WebMethod; import jakarta.jws.WebParam; diff --git a/src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java b/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertSoap.java similarity index 97% rename from src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java rename to src/main/java/service/clients/wsdl/temperatureConvert/TempConvertSoap.java index 67da0e9..38eddcc 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/TempConvertSoap.java +++ b/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertSoap.java @@ -1,4 +1,4 @@ -package clients.wsdl.temperatureConvert; +package service.clients.wsdl.temperatureConvert; import jakarta.jws.WebMethod; import jakarta.jws.WebParam; diff --git a/src/main/java/clients/wsdl/temperatureConvert/package-info.java b/src/main/java/service/clients/wsdl/temperatureConvert/package-info.java similarity index 75% rename from src/main/java/clients/wsdl/temperatureConvert/package-info.java rename to src/main/java/service/clients/wsdl/temperatureConvert/package-info.java index 36aa4eb..7834922 100644 --- a/src/main/java/clients/wsdl/temperatureConvert/package-info.java +++ b/src/main/java/service/clients/wsdl/temperatureConvert/package-info.java @@ -1,2 +1,2 @@ @jakarta.xml.bind.annotation.XmlSchema(namespace = "https://www.w3schools.com/xml/", elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED) -package https.www_w3schools_com.xml; +package service.clients.wsdl.temperatureConvert; diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java b/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java index e51bfa8..d6a98d3 100644 --- a/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java +++ b/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java @@ -31,12 +31,12 @@ public interface GeoIPServiceSoap { * * @param ipAddress * @return - * returns wsclient.GeoIP + * returns serviceClients.geoIP.GeoIP */ @WebMethod(operationName = "GetGeoIP", action = "http://www.webservicex.net/GetGeoIP") @WebResult(name = "GetGeoIPResult", targetNamespace = "http://www.webservicex.net/") @RequestWrapper(localName = "GetGeoIP", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIP") - @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPResponse") + @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPResponse") public GeoIP getGeoIP( @WebParam(name = "IPAddress", targetNamespace = "http://www.webservicex.net/") String ipAddress); @@ -45,11 +45,11 @@ public GeoIP getGeoIP( * Context * * @return - * returns wsclient.GeoIP + * returns serviceClients.geoIP.GeoIP */ @WebMethod(operationName = "GetGeoIPContext", action = "http://www.webservicex.net/GetGeoIPContext") @WebResult(name = "GetGeoIPContextResult", targetNamespace = "http://www.webservicex.net/") - @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContext") - @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContextResponse") + @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPContext") + @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPContextResponse") public GeoIP getGeoIPContext(); } diff --git a/src/main/java/clients/rest/JerseyTest.java b/src/test/java/serviceClients/rest/JerseyAttendance.java similarity index 97% rename from src/main/java/clients/rest/JerseyTest.java rename to src/test/java/serviceClients/rest/JerseyAttendance.java index a474dc2..1f03338 100644 --- a/src/main/java/clients/rest/JerseyTest.java +++ b/src/test/java/serviceClients/rest/JerseyAttendance.java @@ -1,13 +1,12 @@ -package testing.rest; - -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Response; +package serviceClients.rest; +import bean.AttendanceRegister; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; -import bean.AttendanceRegister; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Response; public class JerseyTest { diff --git a/src/main/java/clients/rest/JerseyClientPost.java b/src/test/java/serviceClients/rest/JerseyClientAuthLogin.java similarity index 93% rename from src/main/java/clients/rest/JerseyClientPost.java rename to src/test/java/serviceClients/rest/JerseyClientAuthLogin.java index 4b58e7f..d49e9c4 100644 --- a/src/main/java/clients/rest/JerseyClientPost.java +++ b/src/test/java/serviceClients/rest/JerseyClientAuthLogin.java @@ -1,10 +1,10 @@ -package jersey; +package serviceClients.rest; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; -public class JerseyClientPost { +public class JerseyClientAuthLogin { public static void main(String[] args) { diff --git a/src/main/java/clients/rest/JerseyGet.java b/src/test/java/serviceClients/rest/JerseyGetSession.java similarity index 97% rename from src/main/java/clients/rest/JerseyGet.java rename to src/test/java/serviceClients/rest/JerseyGetSession.java index e04c856..22ce803 100644 --- a/src/main/java/clients/rest/JerseyGet.java +++ b/src/test/java/serviceClients/rest/JerseyGetSession.java @@ -1,4 +1,4 @@ -package jersey; +package serviceClients.rest; import java.io.IOException; import javax.ws.rs.core.MediaType; @@ -9,7 +9,7 @@ import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; -public class JerseyGet { +public class JerseyGetSession { /** * @param args diff --git a/src/main/java/clients/rest/JerseyJsonResponse.java b/src/test/java/serviceClients/rest/JerseyJSONAuthorizationResponse.java similarity index 93% rename from src/main/java/clients/rest/JerseyJsonResponse.java rename to src/test/java/serviceClients/rest/JerseyJSONAuthorizationResponse.java index 9521ae6..756133b 100644 --- a/src/main/java/clients/rest/JerseyJsonResponse.java +++ b/src/test/java/serviceClients/rest/JerseyJSONAuthorizationResponse.java @@ -1,10 +1,10 @@ -package jersey; +package serviceClients.rest; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; -public class JerseyJsonResponse { +public class JerseyJSONAuthorizationResponse { public static void main(String[] args) { try { diff --git a/src/main/java/clients/rest/JerseyJsonSimpler.java b/src/test/java/serviceClients/rest/JerseyJsonSimpleLogin.java similarity index 89% rename from src/main/java/clients/rest/JerseyJsonSimpler.java rename to src/test/java/serviceClients/rest/JerseyJsonSimpleLogin.java index 8941a7e..78a8114 100644 --- a/src/main/java/clients/rest/JerseyJsonSimpler.java +++ b/src/test/java/serviceClients/rest/JerseyJsonSimpleLogin.java @@ -1,12 +1,12 @@ -package testing.rest; +package serviceClients.rest; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; + import com.sun.jersey.api.client.Client; import com.sun.jersey.api.representation.Form; -public class JerseyJsonSimpler { +public class JerseyJsonSimpleLogin { public static void main(String[] args) { diff --git a/src/main/java/clients/rest/JerseyPost.java b/src/test/java/serviceClients/rest/JerseyPostLogin.java similarity index 95% rename from src/main/java/clients/rest/JerseyPost.java rename to src/test/java/serviceClients/rest/JerseyPostLogin.java index ddbac2a..5499218 100644 --- a/src/main/java/clients/rest/JerseyPost.java +++ b/src/test/java/serviceClients/rest/JerseyPostLogin.java @@ -1,4 +1,4 @@ -package testing.rest; +package serviceClients.rest; import java.io.IOException; import javax.ws.rs.core.MediaType; @@ -12,7 +12,7 @@ import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.core.util.MultivaluedMapImpl; -public class JerseyPost { +public class JerseyPostLogin { public static void main(String[] args) throws ClientProtocolException, IOException { diff --git a/src/main/java/clients/rest/NetClientPost.java b/src/test/java/serviceClients/rest/NetClientPostUserLogin.java similarity index 96% rename from src/main/java/clients/rest/NetClientPost.java rename to src/test/java/serviceClients/rest/NetClientPostUserLogin.java index 213b3af..505c40b 100644 --- a/src/main/java/clients/rest/NetClientPost.java +++ b/src/test/java/serviceClients/rest/NetClientPostUserLogin.java @@ -1,4 +1,4 @@ -package testing.rest; +package serviceClients.rest; import java.io.BufferedReader; import java.io.IOException; @@ -8,7 +8,7 @@ import java.net.MalformedURLException; import java.net.URL; -public class NetClientPost { +public class NetClientPostUserLogin { // http://localhost:8080/RESTfulExample/json/product/post public static void main(String[] args) { diff --git a/src/main/java/clients/rest/PostAuthenticationToken.java b/src/test/java/serviceClients/rest/PostAuthToken.java similarity index 98% rename from src/main/java/clients/rest/PostAuthenticationToken.java rename to src/test/java/serviceClients/rest/PostAuthToken.java index b9d37a2..73948d4 100644 --- a/src/main/java/clients/rest/PostAuthenticationToken.java +++ b/src/test/java/serviceClients/rest/PostAuthToken.java @@ -1,4 +1,4 @@ -package rest; +package serviceClients.rest; import java.io.BufferedReader; import java.io.IOException; @@ -13,13 +13,12 @@ import javax.json.JsonObject; import javax.json.JsonReader; -public class PostAuthenticationToken { +public class PostAuthToken { // authentication scheme based on tokens follow these steps, steps are numbered public static void main(String[] args) { try { - URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); diff --git a/src/main/java/clients/rest/TestJSONResponse.java b/src/test/java/serviceClients/rest/TestJSONResponse.java similarity index 100% rename from src/main/java/clients/rest/TestJSONResponse.java rename to src/test/java/serviceClients/rest/TestJSONResponse.java diff --git a/src/main/java/clients/rest/TestRestClient.java b/src/test/java/serviceClients/rest/TestRestClient.java similarity index 100% rename from src/main/java/clients/rest/TestRestClient.java rename to src/test/java/serviceClients/rest/TestRestClient.java diff --git a/src/main/java/clients/wsdl/geoIP/GeoIP.java b/src/test/java/serviceClients/soap/geoIP/GeoIP.java similarity index 99% rename from src/main/java/clients/wsdl/geoIP/GeoIP.java rename to src/test/java/serviceClients/soap/geoIP/GeoIP.java index 1e66ceb..daa1a2d 100644 --- a/src/main/java/clients/wsdl/geoIP/GeoIP.java +++ b/src/test/java/serviceClients/soap/geoIP/GeoIP.java @@ -3,7 +3,7 @@ * replicates WSDL to invoke External Web service */ -package wsclient; +package serviceClients.soap.geoIP; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/geoIP/GeoIPService.java b/src/test/java/serviceClients/soap/geoIP/GeoIPService.java similarity index 98% rename from src/main/java/clients/wsdl/geoIP/GeoIPService.java rename to src/test/java/serviceClients/soap/geoIP/GeoIPService.java index 0c66e65..474ca00 100644 --- a/src/main/java/clients/wsdl/geoIP/GeoIPService.java +++ b/src/test/java/serviceClients/soap/geoIP/GeoIPService.java @@ -3,7 +3,7 @@ * replicates WSDL to invoke External Web service */ -package wsclient; +package serviceClients.soap.geoIP; import java.net.MalformedURLException; import java.net.URL; diff --git a/src/main/java/clients/wsdl/geoIP/GeoIPServiceSoap.java b/src/test/java/serviceClients/soap/geoIP/GeoIPServiceSoap.java similarity index 81% rename from src/main/java/clients/wsdl/geoIP/GeoIPServiceSoap.java rename to src/test/java/serviceClients/soap/geoIP/GeoIPServiceSoap.java index 22a84bb..110a680 100644 --- a/src/main/java/clients/wsdl/geoIP/GeoIPServiceSoap.java +++ b/src/test/java/serviceClients/soap/geoIP/GeoIPServiceSoap.java @@ -3,7 +3,7 @@ * replicates WSDL to invoke External Web service */ -package wsclient; +package serviceClients.soap.geoIP; import javax.jws.WebMethod; import javax.jws.WebParam; @@ -31,12 +31,12 @@ public interface GeoIPServiceSoap { * * @param ipAddress * @return - * returns wsclient.GeoIP + * returns serviceClients.geoIP.GeoIP */ @WebMethod(operationName = "GetGeoIP", action = "http://www.webservicex.net/GetGeoIP") @WebResult(name = "GetGeoIPResult", targetNamespace = "http://www.webservicex.net/") @RequestWrapper(localName = "GetGeoIP", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIP") - @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPResponse") + @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPResponse") public GeoIP getGeoIP( @WebParam(name = "IPAddress", targetNamespace = "http://www.webservicex.net/") String ipAddress); @@ -45,11 +45,11 @@ public GeoIP getGeoIP( * Context * * @return - * returns wsclient.GeoIP + * returns serviceClients.geoIP.GeoIP */ @WebMethod(operationName = "GetGeoIPContext", action = "http://www.webservicex.net/GetGeoIPContext") @WebResult(name = "GetGeoIPContextResult", targetNamespace = "http://www.webservicex.net/") - @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContext") - @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIPContextResponse") + @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPContext") + @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPContextResponse") public GeoIP getGeoIPContext(); } diff --git a/src/main/java/clients/wsdl/geoIP/GetGeoIP.java b/src/test/java/serviceClients/soap/geoIP/GetGeoIP.java similarity index 97% rename from src/main/java/clients/wsdl/geoIP/GetGeoIP.java rename to src/test/java/serviceClients/soap/geoIP/GetGeoIP.java index ab3a42f..1de1760 100644 --- a/src/main/java/clients/wsdl/geoIP/GetGeoIP.java +++ b/src/test/java/serviceClients/soap/geoIP/GetGeoIP.java @@ -3,7 +3,7 @@ * replicates WSDL to invoke External Web service */ -package wsclient; +package serviceClients.soap.geoIP; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/geoIP/GetGeoIPContext.java b/src/test/java/serviceClients/soap/geoIP/GetGeoIPContext.java similarity index 95% rename from src/main/java/clients/wsdl/geoIP/GetGeoIPContext.java rename to src/test/java/serviceClients/soap/geoIP/GetGeoIPContext.java index 5a9adbc..718624c 100644 --- a/src/main/java/clients/wsdl/geoIP/GetGeoIPContext.java +++ b/src/test/java/serviceClients/soap/geoIP/GetGeoIPContext.java @@ -3,7 +3,7 @@ * replicates WSDL to invoke External Web service */ -package wsclient; +package serviceClients.soap.geoIP; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/geoIP/GetGeoIPContextResponse.java b/src/test/java/serviceClients/soap/geoIP/GetGeoIPContextResponse.java similarity index 98% rename from src/main/java/clients/wsdl/geoIP/GetGeoIPContextResponse.java rename to src/test/java/serviceClients/soap/geoIP/GetGeoIPContextResponse.java index eabac05..5e6ad18 100644 --- a/src/main/java/clients/wsdl/geoIP/GetGeoIPContextResponse.java +++ b/src/test/java/serviceClients/soap/geoIP/GetGeoIPContextResponse.java @@ -3,7 +3,7 @@ * replicates WSDL to invoke External Web service */ -package wsclient; +package serviceClients.soap.geoIP; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/geoIP/GetGeoIPResponse.java b/src/test/java/serviceClients/soap/geoIP/GetGeoIPResponse.java similarity index 97% rename from src/main/java/clients/wsdl/geoIP/GetGeoIPResponse.java rename to src/test/java/serviceClients/soap/geoIP/GetGeoIPResponse.java index fa15f74..23694f2 100644 --- a/src/main/java/clients/wsdl/geoIP/GetGeoIPResponse.java +++ b/src/test/java/serviceClients/soap/geoIP/GetGeoIPResponse.java @@ -3,7 +3,7 @@ * replicates WSDL to invoke External Web service */ -package wsclient; +package serviceClients.soap.geoIP; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/clients/wsdl/geoIP/ObjectFactory.java b/src/test/java/serviceClients/soap/geoIP/ObjectFactory.java similarity index 98% rename from src/main/java/clients/wsdl/geoIP/ObjectFactory.java rename to src/test/java/serviceClients/soap/geoIP/ObjectFactory.java index a81a6eb..19d701c 100644 --- a/src/main/java/clients/wsdl/geoIP/ObjectFactory.java +++ b/src/test/java/serviceClients/soap/geoIP/ObjectFactory.java @@ -3,7 +3,7 @@ * replicates WSDL to invoke External Web service */ -package wsclient; +package serviceClients.soap.geoIP; import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; diff --git a/src/main/java/clients/wsdl/geoIP/package-info.java b/src/test/java/serviceClients/soap/geoIP/package-info.java similarity index 86% rename from src/main/java/clients/wsdl/geoIP/package-info.java rename to src/test/java/serviceClients/soap/geoIP/package-info.java index 485323c..d9bc054 100644 --- a/src/main/java/clients/wsdl/geoIP/package-info.java +++ b/src/test/java/serviceClients/soap/geoIP/package-info.java @@ -3,4 +3,4 @@ */ @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.webservicex.net/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package wsclient; +package serviceClients.soap.geoIP; diff --git a/src/test/java/wsdl/TemperatureConvertTest.java b/src/test/java/wsdl/TemperatureConvertTest.java index 7eb2495..f4d20e7 100644 --- a/src/test/java/wsdl/TemperatureConvertTest.java +++ b/src/test/java/wsdl/TemperatureConvertTest.java @@ -1,6 +1,6 @@ package wsdl; -import clients.wsdl.temperatureConvert.TempConvertSoap; -import clients.wsdl.temperatureConvert.TempConvert; +import service.clients.wsdl.temperatureConvert.TempConvertSoap; +import service.clients.wsdl.temperatureConvert.TempConvert; import org.junit.Assert; import org.junit.Test; From 61b54b9889bfc65a4f5919ba6f3a42ef5d192c63 Mon Sep 17 00:00:00 2001 From: alionranger Date: Mon, 4 Dec 2023 21:15:43 +1300 Subject: [PATCH 25/32] maven cleanup --- README.md | 68 +++++-------------- maven/readme.md | 42 ++++++++++++ pom.xml | 172 ------------------------------------------------ 3 files changed, 57 insertions(+), 225 deletions(-) create mode 100644 maven/readme.md delete mode 100644 pom.xml diff --git a/README.md b/README.md index 3b9893a..2ed2fd6 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ - [API/Services Architectures](#apiservices-architectures) - [Extra mermaid diagram](#extra-mermaid-diagram) - [Setup](#setup) - - [Build Web Package](#build-web-package) - - [Maven Build](#maven-build) +- [Build WebApp](#build-webapp) + - [Gradle Build Web Package](#gradle-build-web-package) + - [Maven Build](#maven-build) +- [Package WebApp](#package-webapp) - [Docker Image Build](#docker-image-build) - [Available Tomcat versions](#available-tomcat-versions) +- [Run WebApp](#run-webapp) - [Docker execution](#docker-execution) - - [Maven Stages](#maven-stages) - - [Run the maven build Locally](#run-the-maven-build-locally) - [Docker](#docker) - [Run and test the container webapp](#run-and-test-the-container-webapp) - - [Build using maven docker container](#build-using-maven-docker-container) - [Editing project diagrams](#editing-project-diagrams) - [GitHub Vulnerability report](#github-vulnerability-report) - [Web services client](#web-services-client) @@ -108,17 +108,17 @@ git clone repo - open repo in chosen IDE IDEs can be Eclipse, IntelliJ (suggested) or use online IDE (Github codespaces) - -## Build Web Package +# Build WebApp +## Gradle Build Web Package - Pack the WebArchive file. Generate the .WAR file ``` bash gradle clean build --console plain --warning-mode all ``` -### Maven Build +## Maven Build > maven has been deprecated and moved to [maven](./maven) -if you still want to build with maven run `mvn package` +# Package WebApp ## Docker Image Build - Build the app image with Docker. Deploy .WAR file in Tomcat refer to https://hub.docker.com/_/tomcat @@ -131,6 +131,7 @@ Use the tag latest or a particular version e.g. aleon1220/soa:v2 or aleon1220/so - 7.0.109 = `TOMCAT_VERSION_DOCKER_TAG="7.0.109-jdk8-openjdk"` - 9.0.78 = `TOMCAT_VERSION_DOCKER_TAG="9.0.78-jre8"` +# Run WebApp ## Docker execution Run the tomcat server with the pre-built WAR web Archive file ```bash @@ -149,22 +150,11 @@ docker container exec -it $CONTAINER_NAME /bin/bash - The URl is URL:8888/Attendance-0.0.1 [AttendanceWebApp](http://localhost:8888/Attendance-0.0.1) - - clean up docker container environment ``` bash docker stop $(docker ps --quiet) docker rm $(docker container ls --all --quiet) ``` -## Maven Stages - -### Run the maven build Locally - -- build the project locally with a locally installed maven client - -```bash -mvn verify -``` ---- ## Docker ### Run and test the container webapp @@ -172,34 +162,6 @@ mvn verify docker build --tag aleon1220/soa:latest . docker run -itd --publish 8888:8080 --name attendance_webapp_container aleon1220/soa:latest ``` -### Build using maven docker container - -Refer to maven docker official image https://hub.docker.com/_/maven -is best to have maven locally installed - -- Create a volume - -```bash -docker volume create --name maven-repo-volume -``` - -- Docker container build using the volume above - -```bash -docker run -it -v maven-repo-volume:/root/.m2 maven mvn archetype:generate # will download artifacts -``` - -- Docker container run and build using the maven image - -```bash -docker run -it --rm --name my-maven-project -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3.3-jdk-8 mvn clean install -``` - -- docker run build using bind volume mount - -```bash -docker run -it --name my-maven-project -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3.3-jdk-8 mvn clean install -``` ## Editing project diagrams - go to [diagrams.net](https://app.diagrams.net/?src=about) @@ -217,11 +179,12 @@ wsdl2java is a command-line tool from Apache CXF used to generate Java code from Download the WSDL file: You need to have the WSDL document saved on your local machine2. -Run the wsdl2java command: The basic syntax of the command is as follows1: - +Run the wsdl2java command: The basic syntax of the command is as follows: +```bash wsdl2java -fe -db -wv -p <[wsdl-namespace =]package-name>* -sn -d +``` -Here’s what some of the options mean1: +Here’s what some of the options mean: -fe frontend-name: Specifies the frontend. Default is JAXWS. -db databinding-name: Specifies the databinding. Default is JAXB. @@ -237,10 +200,9 @@ Remember to replace , , , <[wsd For more advanced usage and options, please refer to the official Apache CXF documentation. https://cxf.apache.org/docs/wsdl-to-java.html 2023-10-28 -after some serious struggle trying to get wdl2java to work for a simple WSDL file i found online i have found a solution +after some serious struggle trying to get wdl2java to work for a simple WSDL file I found online i have found a solution - i tried using multiple plugins in gradle kotlin DSL. fail - i tried switching to maven and using the official CXF. Fail several times - in maven upgraded to java17 and ajdusted simple settings OK - I followed docs https://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html and https://cxf.apache.org/docs/wsdl-to-java.html - wsdl is ready - diff --git a/maven/readme.md b/maven/readme.md new file mode 100644 index 0000000..b1bb1eb --- /dev/null +++ b/maven/readme.md @@ -0,0 +1,42 @@ +# Maven Builds +--- +### Maven Stages +if you still want to build with maven +```bash +mvn package +``` + +- build the project locally with a locally installed maven client + +```bash +mvn verify +``` + +### Build using maven docker container +Refer to maven docker official image https://hub.docker.com/_/maven +is best to have maven locally installed + +- Create a volume + +```bash +docker volume create --name maven-repo-volume +``` + +- Docker container build using the volume above + +```bash +docker run -it -v maven-repo-volume:/root/.m2 maven mvn archetype:generate # will download artifacts +``` + +- Docker container run and build using the maven image + +```bash +docker run -it --rm --name my-maven-project -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3.3-jdk-8 mvn clean install +``` + +- docker run build using bind volume mount + +```bash +docker run -it --name my-maven-project -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3.3-jdk-8 mvn clean install +``` +--- \ No newline at end of file diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 9773b94..0000000 --- a/pom.xml +++ /dev/null @@ -1,172 +0,0 @@ - - 4.0.0 - com.soa - AttendWebApp - war - 0.0.1-SNAPSHOT - Class Attendance WebApp - http://maven.apache.org - - - - prime-repo - PrimeFaces Maven Repository - http://repository.primefaces.org - default - - - - - - - org.primefaces.extensions - primefaces-extensions - 6.0.0 - - - - org.primefaces - primefaces - ${primefaces.version} - - - - junit - junit - ${junit.version} - test - - - javax.servlet - javax.servlet-api - ${servlet.version} - provided - - - - com.sun.faces - jsf-api - ${mojarra.version} - - - com.sun.faces - jsf-impl - ${mojarra.version} - - - - - javax.json - javax.json-api - 1.1 - - - - io.jsonwebtoken - jjwt - ${jjwt.version} - test - - - - - javax.ws.rs - javax.ws.rs-api - 2.1 - - - - - com.sun.jersey - jersey-client - 1.19.4 - - - com.google.code.gson - gson - 2.8.9 - - - - org.apache.httpcomponents - httpclient - 4.5.3 - - - - org.glassfish.jersey.core - jersey-common - 2.22.2 - compile - - - org.slf4j - slf4j-api - 2.0.0-alpha1 - - - org.slf4j - slf4j-simple - 2.0.0-alpha1 - - - - - AttendanceWebApp - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.plugin.version} - - ${java.version} - ${java.version} - - - - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - - http://localhost:8080/manager/text - TomcatServer - /AttendWebApp - - - - org.apache.cxf - cxf-codegen-plugin - ${cxf.version} - - - generate-sources - generate-sources - - ${project.build.directory}/generated-sources/cxf - - - ${basedir}/src/main/resources/wsdl/NumberConversion.wsdl - - - - - wsdl2java - - - - - - - - 17 - 4.12 - 3.1.0 - 2.2.12 - 6.0 - 3.3 - UTF-8 - 0.7.0 - 4.0.3 - - \ No newline at end of file From 37fc9d4edbd5f61e2ecaa2e76aab0121a17e7c4c Mon Sep 17 00:00:00 2001 From: alionranger Date: Mon, 4 Dec 2023 21:44:52 +1300 Subject: [PATCH 26/32] LDAP basic setup authentication --- docker-compose.yml | 18 ++++ ldap/university.ldif | 11 ++ src/main/java/util/AuthenticateLDAP.java | 119 ++++++++++++++++++++++ src/main/java/util/AuthenticateToken.java | 114 +++++++++++++++++++++ 4 files changed, 262 insertions(+) create mode 100644 docker-compose.yml create mode 100644 ldap/university.ldif create mode 100644 src/main/java/util/AuthenticateLDAP.java create mode 100644 src/main/java/util/AuthenticateToken.java diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4f32fca --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3' +services: + openldap: + image: osixia/openldap:1.2.4 + environment: + LDAP_ORGANISATION: "IT Latinos NZ" + LDAP_DOMAIN: "latintech.org" + LDAP_ADMIN_PASSWORD: ${LDAP_ADMIN_PASS} + ports: + - 389:389 + - 636:636 + volumes: + - ./ldap:/var/lib/ldap + - ./ldap:/etc/ldap/slapd.d + webapp: + image: aleon1220/soa:latest + ports: + - 8080:8080 diff --git a/ldap/university.ldif b/ldap/university.ldif new file mode 100644 index 0000000..18de194 --- /dev/null +++ b/ldap/university.ldif @@ -0,0 +1,11 @@ +dn: ou=lecturers,dc=university,dc=nz,dc=andres +objectClass: organizationalUnit +ou: lecturers + +dn: ou=staff,dc=university,dc=nz,dc=andres +objectClass: organizationalUnit +ou: staff + +dn: ou=students,dc=university,dc=nz,dc=andres +objectClass: organizationalUnit +ou: students diff --git a/src/main/java/util/AuthenticateLDAP.java b/src/main/java/util/AuthenticateLDAP.java new file mode 100644 index 0000000..36df6d4 --- /dev/null +++ b/src/main/java/util/AuthenticateLDAP.java @@ -0,0 +1,119 @@ +// utility class involved with business logid +// authenticate LDAP UserName or Email call LdapAuth.authenticateUserAndGetInfo (username,password); +// Note: Configure ldapURI ,requiredAttributes ,ADSearchPaths,accountSuffex + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.*; + +import javax.naming.*; + +import java.util.regex.*; + +import javax.naming.directory.*; + +import javax.naming.ldap.InitialLdapContext; + +import javax.naming.ldap.LdapContext; + +public class AuthenticateLDAP { + + private static String ldapURI; + private static String[] requiredAttributes; + private static String[] ADSearchPaths; + private static String accountSuffex; + private final static String contextFactory = "com.sun.jndi.ldap.LdapCtxFactory"; + // private final static String ldapURI = "ldap://52.40.50.72:389/DC=corp,DC=local"; + + // private static String[] requiredAttributes = { "cn", "givenName", "sn", "userPrincipalName", "sAMAccountName", "objectSid" }; + // see you active directory user OU's hierarchy + // private static String[] ADSearchPaths = + // { + // "OU=O365 Synced Accounts,OU=ALL USERS", + // "OU=Users,OU=O365 Synced Accounts,OU=ALL USERS", + // "OU=In-House,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS", + // "OU=Torbram Users,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS", + // "OU=Migrated Users,OU=TES-Users" + // }; + + // private static String accountSuffex = "@corp.local"; // this will be used if + // user name is just provided + + static { + try ((InputStream inputStream = LdapAuth.class.getClassLoader().getResourceAsStream("ldap.properties")) { + + Properties properties = new Properties(); + properties.load(inputStream); + + ldapURI = properties.getProperty("ldapURI"); + requiredAttributes = properties.getProperty("requiredAttributes").split(","); + ADSearchPaths = properties.getProperty("ADSearchPaths").split(";"); + accountSuffex = properties.getProperty("accountSuffex"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void authenticateUserAndGetInfo(String user, String password) throws Exception { + + try { + + Hashtable env = new Hashtable(); + + env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory); + + env.put(Context.PROVIDER_URL, ldapURI); + + env.put(Context.SECURITY_AUTHENTICATION, "simple"); + + env.put(Context.SECURITY_PRINCIPAL, user); + + env.put(Context.SECURITY_CREDENTIALS, password); + + DirContext ctx = new InitialDirContext(env); + + String filter = "(sAMAccountName=" + user + ")"; // default for search filter username + + if (user.contains("@")) // if user name is a email then + { + // String parts[] = user.split("\\@"); + // use different filter for email + filter = "(userPrincipalName=" + user + ")"; + } + + SearchControls ctrl = new SearchControls(); + ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE); + ctrl.setReturningAttributes(requiredAttributes); + + NamingEnumeration userInfo = null; + + Integer i = 0; + do { + userInfo = ctx.search(ADSearchPaths[i], filter, ctrl); + i++; + + } while (!userInfo.hasMore() && i < ADSearchPaths.length); + + if (userInfo.hasMore()) { + + SearchResult UserDetails = (SearchResult) userInfo.next(); + Attributes userAttr = UserDetails.getAttributes(); + System.out.println("adEmail = " + userAttr.get("userPrincipalName").get(0).toString()); + + System.out.println("adFirstName = " + userAttr.get("givenName").get(0).toString()); + + System.out.println("adLastName = " + userAttr.get("sn").get(0).toString()); + + System.out.println("name = " + userAttr.get("cn").get(0).toString()); + + System.out.println("AdFullName = " + userAttr.get("cn").get(0).toString()); + + } + + userInfo.close(); + + } catch (javax.naming.AuthenticationException e) { + + } + } +} \ No newline at end of file diff --git a/src/main/java/util/AuthenticateToken.java b/src/main/java/util/AuthenticateToken.java new file mode 100644 index 0000000..76e86d6 --- /dev/null +++ b/src/main/java/util/AuthenticateToken.java @@ -0,0 +1,114 @@ +/** + * Class AttendanceRegister + * sends invocation to webservice for confirmation of attendance. Includes prime faces UI functionality. + */ + +package util; + +import javax.faces.application.FacesMessage; +import javax.faces.bean.ManagedBean; +import javax.faces.context.FacesContext; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriBuilder; + +import com.google.gson.JsonObject; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +import service.UserService; + +@ManagedBean +public class AuthenticateToken { + + private String inputCode; + private Integer progress; + + public String confirmAttendance() { + + String replyFromMS = null; + + UserService tok = new UserService(); + String token = tok.obtainIdToken("10295765", "Value!12"); + // 1-open connection and send user and password as a POST method + ClientConfig config = new DefaultClientConfig(); + + Client client = Client.create(config); + WebResource webResource = client.resource(UriBuilder + .fromUri("https://xgdeevdwh1.execute-api.us-east-1.amazonaws.com").path("addAttendance").build()); + // Passing parameters + // {"studentId": "246810","paperId": "COMP101","status": "present"} + + MultivaluedMap formData = new MultivaluedMapImpl(); + formData.add("studentId", "246810"); + formData.add("paperId", "COMP101"); + formData.add("status", "present"); + + JsonObject jsonPayLoad = new JsonObject(); + jsonPayLoad.addProperty("studentId", "246810"); + jsonPayLoad.addProperty("paperId", "COMP101"); + jsonPayLoad.addProperty("status", "present"); + + // ClientResponse response = + // webResource.accept(MediaType.APPLICATION_JSON).header("Authorization", + // token).post(ClientResponse.class, jsonPayLoad.toString()); + ClientResponse response = webResource.header("Authorization", token).post(ClientResponse.class, + jsonPayLoad.toString()); + replyFromMS = response.getEntity(String.class); + // webResource.path("addAttendance").accept(MediaType.APPLICATION_JSON).header("Authorization", + // token).post(String.class, jsonPayLoad.toString()); + + System.out.println("AttendanceRegisterResponse:" + response); + + // invoke WS to confirm Attendance and validate + FacesContext context = FacesContext.getCurrentInstance(); + context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "CORRECT", "Attendance Registered!!!")); + + if (replyFromMS.isEmpty()) { + return "attendanceNOK.xhtml"; + } else { + return "attendanceOK.xhtml"; + } + } + + public Integer getProgress() { + if (progress == null) { + progress = 0; + } else { + progress = progress + (int) (Math.random() * 35); + + if (progress > 100) + progress = 100; + } + return progress; + } + + public void setProgress(Integer progress) { + this.progress = progress; + } + + public void onComplete() { + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Time Ended")); + } + + public String onTimeout() { + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Time Out")); + return "main.xhtml"; + } + + public void cancel() { + progress = null; + } + + public String getInputCode() { + return inputCode; + } + + public void setInputCode(String inputCode) { + this.inputCode = inputCode; + } +} \ No newline at end of file From ba06df12d94beb63b28d823ac0842084180b0808 Mon Sep 17 00:00:00 2001 From: alionranger Date: Mon, 4 Dec 2023 21:45:32 +1300 Subject: [PATCH 27/32] LDAP properties test local authentication --- src/main/resources/ldap.properties | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/resources/ldap.properties diff --git a/src/main/resources/ldap.properties b/src/main/resources/ldap.properties new file mode 100644 index 0000000..005aaad --- /dev/null +++ b/src/main/resources/ldap.properties @@ -0,0 +1,5 @@ +# ldap.properties +ldapURI=ldap://20.200.200.200:389/DC=corp,DC=local +requiredAttributes=cn,givenName,sn,displayName,userPrincipalName,sAMAccountName,objectSid,userAccountControl +ADSearchPaths=OU=O365 Synced Accounts,OU=ALL USERS;OU=Users,OU=O365 Synced Accounts,OU=ALL USERS;OU=In-House,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS;OU=Torbram Users,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS;OU=Migrated Users,OU=TES-Users +accountSuffix=@corp.local From e850efdff4a035a50e11e3f25707e511d73fff75 Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Tue, 5 Dec 2023 17:00:11 +1300 Subject: [PATCH 28/32] Full clean-up remove complexities - simplified readme with attendance web app context - gradle file includes testing libraries - added docker-compose for stack testing - deleted or moved some classes to a project https://github.com/aleon1220/MeshWeave - adding functionality to test authentication towards LDAP and Active Directory - settings for LDAP testing Signed-off-by: Andres LeonRangel --- README.md | 143 +++++---------- build.gradle.kts | 19 ++ docker-compose.yml | 2 + src/main/java/service/AttendanceService.java | 1 - src/main/java/service/MainService.java | 33 ---- .../clients/GraphQL/GraphQLClient.java | 28 --- .../service/clients/rest/JerseyClient.java | 41 ----- .../clients/rest/JerseyPostHeader.java | 23 --- .../CelsiusToFahrenheit.java | 64 ------- .../CelsiusToFahrenheitResponse.java | 64 ------- .../FahrenheitToCelsius.java | 64 ------- .../FahrenheitToCelsiusResponse.java | 64 ------- .../temperatureConvert/ObjectFactory.java | 80 -------- .../wsdl/temperatureConvert/TempConvert.java | 132 -------------- .../TempConvertHttpPost.java | 36 ---- .../temperatureConvert/TempConvertSoap.java | 40 ---- .../wsdl/temperatureConvert/package-info.java | 2 - src/main/java/util/AuthenticateAD.java | 135 ++++++++++++++ src/main/java/util/AuthenticateLDAP.java | 119 ------------ src/main/java/util/AuthenticateOpenLDAP.java | 45 +++++ src/main/resources/ad.properties | 10 + src/main/resources/ldap.properties | 13 +- src/test/attendance/login/TestLogin.java | 31 ---- .../student/StudentAuthenticationResult.java | 72 -------- .../student/StudentAuthorization.java | 31 ---- src/test/attendance/student/TestStudent.java | 25 --- .../student/StudentAuthenticationResult.java | 2 +- .../student/StudentAuthorization.java | 2 +- .../auth/ldap/TestLDAPAuthentication.java | 95 ++++++++++ .../auth}/login/LoginReply.java | 5 +- .../{attendance => auth}/login/TestLogin.java | 2 +- .../token}/PostAuthenticationToken.java | 2 +- .../token/TestTokenAuthentication.java} | 6 +- .../restclient/JerseyClient.java | 41 ----- .../restclient/JerseyClientPost.java | 33 ---- .../restclient/JerseyGet.java | 37 ---- .../restclient/JerseyJsonResponse.java | 36 ---- .../restclient/JerseyJsonSimpler.java | 28 --- .../restclient/JerseyPost.java | 36 ---- .../restclient/JerseyPostHeader.java | 24 --- .../restclient/JerseyTest.java | 36 ---- .../restclient/NetClientPost.java | 56 ------ .../restclient/TestRestClient.java | 38 ---- .../wsclient/GeoIP.java | 172 ------------------ .../wsclient/GeoIPService.java | 98 ---------- .../wsclient/GeoIPServiceSoap.java | 55 ------ .../wsclient/GetGeoIP.java | 70 ------- .../wsclient/GetGeoIPContext.java | 37 ---- .../wsclient/GetGeoIPContextResponse.java | 69 ------- .../wsclient/GetGeoIPResponse.java | 69 ------- .../wsclient/ObjectFactory.java | 90 --------- .../wsclient/package-info.java | 6 - .../wsdlclient/MockCountryInfoService.java | 16 -- .../wsdlclient/ServiceInvokationTest.java | 28 --- src/test/java/json/Json2Map.java | 34 ---- ...ct.java => TestConversionJSON2Object.java} | 2 +- ...n2Map.java => TestConversionJson2Map.java} | 26 ++- .../{JSON2Object.java => TestJSON2YAML.java} | 2 +- .../serviceClients/ServiceInvokationTest.java | 27 --- .../serviceClients/rest/JerseyAttendance.java | 35 ---- .../rest/JerseyClientAuthLogin.java | 32 ---- .../serviceClients/rest/JerseyGetSession.java | 37 ---- .../rest/JerseyJSONAuthorizationResponse.java | 36 ---- .../rest/JerseyJsonSimpleLogin.java | 28 --- .../serviceClients/rest/JerseyPostLogin.java | 36 ---- .../rest/NetClientPostUserLogin.java | 56 ------ .../serviceClients/rest/PostAuthToken.java | 84 --------- .../serviceClients/rest/TestJSONResponse.java | 62 ------- .../serviceClients/rest/TestRestClient.java | 38 ---- .../java/serviceClients/soap/geoIP/GeoIP.java | 172 ------------------ .../soap/geoIP/GeoIPService.java | 97 ---------- .../soap/geoIP/GeoIPServiceSoap.java | 55 ------ .../serviceClients/soap/geoIP/GetGeoIP.java | 70 ------- .../soap/geoIP/GetGeoIPContext.java | 37 ---- .../soap/geoIP/GetGeoIPContextResponse.java | 69 ------- .../soap/geoIP/GetGeoIPResponse.java | 69 ------- .../soap/geoIP/ObjectFactory.java | 90 --------- .../soap/geoIP/package-info.java | 6 - .../java/wsdl/TemperatureConvertTest.java | 22 --- 79 files changed, 400 insertions(+), 3328 deletions(-) delete mode 100644 src/main/java/service/MainService.java delete mode 100644 src/main/java/service/clients/GraphQL/GraphQLClient.java delete mode 100644 src/main/java/service/clients/rest/JerseyClient.java delete mode 100644 src/main/java/service/clients/rest/JerseyPostHeader.java delete mode 100644 src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java delete mode 100644 src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java delete mode 100644 src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java delete mode 100644 src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java delete mode 100644 src/main/java/service/clients/wsdl/temperatureConvert/ObjectFactory.java delete mode 100644 src/main/java/service/clients/wsdl/temperatureConvert/TempConvert.java delete mode 100644 src/main/java/service/clients/wsdl/temperatureConvert/TempConvertHttpPost.java delete mode 100644 src/main/java/service/clients/wsdl/temperatureConvert/TempConvertSoap.java delete mode 100644 src/main/java/service/clients/wsdl/temperatureConvert/package-info.java create mode 100644 src/main/java/util/AuthenticateAD.java delete mode 100644 src/main/java/util/AuthenticateLDAP.java create mode 100644 src/main/java/util/AuthenticateOpenLDAP.java create mode 100644 src/main/resources/ad.properties delete mode 100644 src/test/attendance/login/TestLogin.java delete mode 100644 src/test/attendance/student/StudentAuthenticationResult.java delete mode 100644 src/test/attendance/student/StudentAuthorization.java delete mode 100644 src/test/attendance/student/TestStudent.java create mode 100644 src/test/java/auth/ldap/TestLDAPAuthentication.java rename src/test/{attendance => java/auth}/login/LoginReply.java (91%) rename src/test/java/{attendance => auth}/login/TestLogin.java (95%) rename src/test/java/{external/tokenauthentication => auth/token}/PostAuthenticationToken.java (98%) rename src/test/java/{attendance/login/TestAuthenticationResult.java => auth/token/TestTokenAuthentication.java} (88%) delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyClient.java delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyClientPost.java delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyGet.java delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyJsonResponse.java delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyJsonSimpler.java delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyPost.java delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyPostHeader.java delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/JerseyTest.java delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/NetClientPost.java delete mode 100644 src/test/java/external/composite-app-mock-services/restclient/TestRestClient.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GeoIP.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GeoIPService.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GetGeoIP.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContext.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContextResponse.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPResponse.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsclient/ObjectFactory.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsclient/package-info.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsdlclient/MockCountryInfoService.java delete mode 100644 src/test/java/external/composite-app-mock-services/wsdlclient/ServiceInvokationTest.java delete mode 100644 src/test/java/json/Json2Map.java rename src/test/java/json/{ConversionJSON2Object.java => TestConversionJSON2Object.java} (99%) rename src/test/java/json/{ConversionJson2Map.java => TestConversionJson2Map.java} (50%) rename src/test/java/json/{JSON2Object.java => TestJSON2YAML.java} (99%) delete mode 100644 src/test/java/serviceClients/ServiceInvokationTest.java delete mode 100644 src/test/java/serviceClients/rest/JerseyAttendance.java delete mode 100644 src/test/java/serviceClients/rest/JerseyClientAuthLogin.java delete mode 100644 src/test/java/serviceClients/rest/JerseyGetSession.java delete mode 100644 src/test/java/serviceClients/rest/JerseyJSONAuthorizationResponse.java delete mode 100644 src/test/java/serviceClients/rest/JerseyJsonSimpleLogin.java delete mode 100644 src/test/java/serviceClients/rest/JerseyPostLogin.java delete mode 100644 src/test/java/serviceClients/rest/NetClientPostUserLogin.java delete mode 100644 src/test/java/serviceClients/rest/PostAuthToken.java delete mode 100644 src/test/java/serviceClients/rest/TestJSONResponse.java delete mode 100644 src/test/java/serviceClients/rest/TestRestClient.java delete mode 100644 src/test/java/serviceClients/soap/geoIP/GeoIP.java delete mode 100644 src/test/java/serviceClients/soap/geoIP/GeoIPService.java delete mode 100644 src/test/java/serviceClients/soap/geoIP/GeoIPServiceSoap.java delete mode 100644 src/test/java/serviceClients/soap/geoIP/GetGeoIP.java delete mode 100644 src/test/java/serviceClients/soap/geoIP/GetGeoIPContext.java delete mode 100644 src/test/java/serviceClients/soap/geoIP/GetGeoIPContextResponse.java delete mode 100644 src/test/java/serviceClients/soap/geoIP/GetGeoIPResponse.java delete mode 100644 src/test/java/serviceClients/soap/geoIP/ObjectFactory.java delete mode 100644 src/test/java/serviceClients/soap/geoIP/package-info.java delete mode 100644 src/test/java/wsdl/TemperatureConvertTest.java diff --git a/README.md b/README.md index 2ed2fd6..b446ba9 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,24 @@ - [Attendance WebApp](#attendance-webapp) - [Introduction](#introduction) + - [Security warnings](#security-warnings) - [Attendance WebApp Architecture (re-architected)](#attendance-webapp-architecture-re-architected) - [2018-Attendance WebApp high level Architecture](#2018-attendance-webapp-high-level-architecture) - [Attendance WebApp UI](#attendance-webapp-ui) - [Refer to the Wiki for details on the project](#refer-to-the-wiki-for-details-on-the-project) - [Project general guidelines](#project-general-guidelines) - - [API/Services Architectures](#apiservices-architectures) - - [Extra mermaid diagram](#extra-mermaid-diagram) - - [Setup](#setup) -- [Build WebApp](#build-webapp) - - [Gradle Build Web Package](#gradle-build-web-package) - - [Maven Build](#maven-build) -- [Package WebApp](#package-webapp) - - [Docker Image Build](#docker-image-build) - - [Available Tomcat versions](#available-tomcat-versions) -- [Run WebApp](#run-webapp) - - [Docker execution](#docker-execution) - - [Docker](#docker) - - [Run and test the container webapp](#run-and-test-the-container-webapp) +- [Setup](#setup) + - [Build WebApp](#build-webapp) + - [Gradle Build Web Package](#gradle-build-web-package) + - [Maven Build](#maven-build) + - [Package WebApp](#package-webapp) + - [Docker Image Build](#docker-image-build) + - [Available Tomcat versions](#available-tomcat-versions) + - [Run WebApp](#run-webapp) + - [Container Execution](#container-execution) + - [Docker execution](#docker-execution) + - [Docker-compose](#docker-compose) - [Editing project diagrams](#editing-project-diagrams) - [GitHub Vulnerability report](#github-vulnerability-report) - - [Web services client](#web-services-client) - - [SOAP](#soap) # Attendance WebApp @@ -39,7 +36,8 @@ The idea is that you have a short timeframe to submit a random generated code by The application is a proof of concept for Service orientation and Service interoperability in the cloud -> Security Warning +## Security warnings +> Security Warnings to check GitHub found 2 vulnerabilities on aleon1220/multi-cloud-WebApp-Attendance's default branch (2 moderate). To find out more, visit: [This project security report](https://github.com/aleon1220/multi-cloud-WebApp-Attendance/security) @@ -76,63 +74,59 @@ To find out more, visit: 3. Latest releases by using git tags 4. API references. API docs -## API/Services Architectures -```mermaid -graph LR - REST --> JSON - REST --> XML - REST --> Webhooks - REST --> gRPC - REST --> GraphQL - REST --> WebSockets - gRPC --> Protobuf - GraphQL --> Queries - GraphQL --> Mutations - WebSockets --> Full-duplex-communication - WebSockets --> Real-time-updates - Webhooks --> HTTP-callbacks - Webhooks --> Event-driven-architecture -``` -## Extra mermaid diagram -circular references - -[![](https://mermaid.ink/img/pako:eNptksEOgjAQRH-F7Fl-gIMXNV4wUTDx0kulKxCEklIOhvDvtmAoXeypfTOdySY7QCYFQgS54m0RxAlrAnOSU3oPwnAf5Mn1QNDZOm8xoQ98pjKrUHdboZCyMngWbOIkWAdBXvRCafRa8KJ_30n6mrpx1pQWEM3rcF5SQwTXRARvRqL9KZve2yqHvSKHaY1TXCfsoEZV81KYBRislYEusEYGkbkKrioGrBmNj_dapp8mg-jF3x3uoG8F13gsuVmceqEoSi3VZV6pabPGL4act8s?type=png)](https://mermaid.live/edit#pako:eNptksEOgjAQRH-F7Fl-gIMXNV4wUTDx0kulKxCEklIOhvDvtmAoXeypfTOdySY7QCYFQgS54m0RxAlrAnOSU3oPwnAf5Mn1QNDZOm8xoQ98pjKrUHdboZCyMngWbOIkWAdBXvRCafRa8KJ_30n6mrpx1pQWEM3rcF5SQwTXRARvRqL9KZve2yqHvSKHaY1TXCfsoEZV81KYBRislYEusEYGkbkKrioGrBmNj_dapp8mg-jF3x3uoG8F13gsuVmceqEoSi3VZV6pabPGL4act8s) - -## Setup -> Tested in Win11 with WSL, Github codespaces and Ubuntu22 +# Setup +> Tested in Win11 with WSL, Github codespaces and Linux Ubuntu 22 -- Clone repo +- Clone repo HTTPS ```bash -git clone repo +git clone https://github.com/aleon1220/multi-cloud-WebApp-Attendance.git +``` +- Clone Repo SSH +```bash +git clone git@github.com:aleon1220/multi-cloud-WebApp-Attendance.git ``` - - open repo in chosen IDE IDEs can be Eclipse, IntelliJ (suggested) or use online IDE (Github codespaces) -# Build WebApp -## Gradle Build Web Package + +## Build WebApp +### Gradle Build Web Package - Pack the WebArchive file. Generate the .WAR file ``` bash gradle clean build --console plain --warning-mode all ``` -## Maven Build +### Maven Build > maven has been deprecated and moved to [maven](./maven) -# Package WebApp -## Docker Image Build +## Package WebApp +### Docker Image Build - Build the app image with Docker. Deploy .WAR file in Tomcat refer to https://hub.docker.com/_/tomcat ```bash docker build --tag aleon1220/soa:latest . ``` -### Available Tomcat versions +#### Available Tomcat versions Use the tag latest or a particular version e.g. aleon1220/soa:v2 or aleon1220/soa:latest - 7.0.109 = `TOMCAT_VERSION_DOCKER_TAG="7.0.109-jdk8-openjdk"` - 9.0.78 = `TOMCAT_VERSION_DOCKER_TAG="9.0.78-jre8"` -# Run WebApp -## Docker execution +## Run WebApp +### Container Execution +#### Docker execution + +##### Run from [Docker Hub](https://hub.docker.com/repository/docker/aleon1220/soa/general) +Test the immutable webapp from Docker +```bash +docker run -itd --publish 8888:8080 --name attendance_webapp_container aleon1220/soa:latest +``` + +##### local build & Run +Test the container webapp after building the image locally +```bash +docker build --tag aleon1220/soa:latest . +docker run -itd --publish 8888:8080 --name attendance_webapp_container aleon1220/soa:latest +``` Run the tomcat server with the pre-built WAR web Archive file ```bash docker run -itd --publish 8888:8080 aleon1220/soa:latest @@ -141,26 +135,21 @@ docker run -itd --publish 8888:8080 aleon1220/soa:latest ``` bash CONTAINER_NAME=$(docker container ls --all --filter publish=8888 --format "{{.Names}}") ``` - - Access the Docker container via CLI - ```bash docker container exec -it $CONTAINER_NAME /bin/bash ``` - - The URl is URL:8888/Attendance-0.0.1 [AttendanceWebApp](http://localhost:8888/Attendance-0.0.1) - - clean up docker container environment ``` bash docker stop $(docker ps --quiet) docker rm $(docker container ls --all --quiet) ``` -## Docker -### Run and test the container webapp +#### Docker-compose + ```bash -docker build --tag aleon1220/soa:latest . -docker run -itd --publish 8888:8080 --name attendance_webapp_container aleon1220/soa:latest +export LDAP_ADMIN_PASS=$(op read "op://uqbpxejq7gifvi6mg3c7xxokre/jvuj7juvlxlg7delckucvidqhi/password") ``` ## Editing project diagrams @@ -170,39 +159,3 @@ docker run -itd --publish 8888:8080 --name attendance_webapp_container aleon1220 ## GitHub Vulnerability report https://github.com/aleon1220/multi-cloud-WebApp-Attendance/security/dependabot - -## Web services client -### SOAP -get a WSDL online and then use a CXF utility to generate the java code - -wsdl2java is a command-line tool from Apache CXF used to generate Java code from a WSDL document1. Here’s how you can use it: - -Download the WSDL file: You need to have the WSDL document saved on your local machine2. - -Run the wsdl2java command: The basic syntax of the command is as follows: -```bash -wsdl2java -fe -db -wv -p <[wsdl-namespace =]package-name>* -sn -d -``` - -Here’s what some of the options mean: - --fe frontend-name: Specifies the frontend. Default is JAXWS. --db databinding-name: Specifies the databinding. Default is JAXB. --wv wsdl-version: Specifies the WSDL version. Default is WSDL1.1. --p [ wsdl-namespace= ] PackageName: Specifies zero, or more, package names to use for the generated code. --sn service-name: The WSDL service name to use for the generated code. --d output-directory: The directory where the generated code will be placed. -Compile and run the generated code: Once you have generated the code, you can compile and run it as you would with any other Java code. -Please note that if your WSDL file is secured (for example, accessed over HTTPS), you might encounter issues with SSL handshake3. In such cases, you might need to manually download and reference any XSD files used in your WSDL2. - -Remember to replace , , , <[wsdl-namespace =]package-name>*, , , and with your actual values. - -For more advanced usage and options, please refer to the official Apache CXF documentation. https://cxf.apache.org/docs/wsdl-to-java.html - -2023-10-28 -after some serious struggle trying to get wdl2java to work for a simple WSDL file I found online i have found a solution -- i tried using multiple plugins in gradle kotlin DSL. fail -- i tried switching to maven and using the official CXF. Fail several times -- in maven upgraded to java17 and ajdusted simple settings OK -- I followed docs https://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html and https://cxf.apache.org/docs/wsdl-to-java.html -- wsdl is ready diff --git a/build.gradle.kts b/build.gradle.kts index 349990b..1440e67 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,6 +42,17 @@ dependencies { implementation("com.graphql-java-kickstart:graphql-webclient-spring-boot-starter:2.0.1") implementation("com.graphql-java:graphql-java:20.7") implementation("com.graphql-java-generator:graphql-java-runtime:1.18") + // JUnit 4 framework for unit testing + testImplementation("junit:junit:4.13.2") + // JUnit Jupiter API and Engine for unit testing + testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0") + // Mockito for mocking in tests + testImplementation("org.mockito:mockito-core:4.5.1") + // https://central.sonatype.com/artifact/com.unboundid/unboundid-ldapsdk + implementation("com.unboundid:unboundid-ldapsdk:6.0.11") + // https://github.com/google/gson library JSON serialization/deserialization + implementation("com.google.code.gson:gson:2.10.1") } group = "soa.nz.aut" @@ -77,6 +88,14 @@ tasks.register("singleTest") { includeTestsMatching("utilities.TestQRFunctions.createQRCodeLocally") } } + +tasks.register("openLDAP") { + description = "Runs openLDAP authentication testing" + filter { + includeTestsMatching("TestLDAPAuthentication.testMockOpenLDAPAdminSearch") + } +} + // https://plugins.gradle.org/plugin/com.github.bjornvester.wsdl2java // https://www.w3schools.com/xml/tempconvert.asmx?WSDL wsdl2java { diff --git a/docker-compose.yml b/docker-compose.yml index 4f32fca..a90ecff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,8 @@ version: '3' services: openldap: + # https://github.com/osixia/docker-openldap + # https://www.openldap.org image: osixia/openldap:1.2.4 environment: LDAP_ORGANISATION: "IT Latinos NZ" diff --git a/src/main/java/service/AttendanceService.java b/src/main/java/service/AttendanceService.java index b47b937..b926217 100644 --- a/src/main/java/service/AttendanceService.java +++ b/src/main/java/service/AttendanceService.java @@ -5,7 +5,6 @@ package service; - //Class is used to show invokations to entities MS public class AttendanceService { diff --git a/src/main/java/service/MainService.java b/src/main/java/service/MainService.java deleted file mode 100644 index b296e48..0000000 --- a/src/main/java/service/MainService.java +++ /dev/null @@ -1,33 +0,0 @@ - /** - * Class MainService - * invokes two external Web Services - */ - -package service; - -import javax.ws.rs.core.UriBuilder; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - -public class MainService { - - public String invokeWSDLForIP() { - // GeoIPService service = new GeoIPService(); - // GeoIP ipService = service.getGeoIPServiceSoap().getGeoIPContext(); - //String result = ipService.getCountryName().concat(", IP is: ")+ipService.getIP().concat("code details are: ")+ipService.getReturnCodeDetails(); - // String wsdlResult = ipService.getCountryCode().concat(": ")+ipService.getCountryName().concat(", IP is: ")+ipService.getIP().concat(" the return code details are: ")+ipService.getReturnCodeDetails(); - return "GeoIP Web Service No longer functions"; - } - - public String invokeRestForBibleVerse() { - ClientConfig config = new DefaultClientConfig(); - Client client = Client.create(config); - - WebResource service = client.resource(UriBuilder.fromUri("http://labs.bible.org/api/?passage=random").build()); - return service.get(String.class); - } - -} diff --git a/src/main/java/service/clients/GraphQL/GraphQLClient.java b/src/main/java/service/clients/GraphQL/GraphQLClient.java deleted file mode 100644 index d1d2b63..0000000 --- a/src/main/java/service/clients/GraphQL/GraphQLClient.java +++ /dev/null @@ -1,28 +0,0 @@ -package service.clients.GraphQL; - -import org.springframework.web.reactive.function.client.WebClient; -import com.graphql_java_generator.client.GraphQLConfiguration; -import com.graphql_java_generator.client.GraphQLWebClient; - -public class GraphQLClient { - - public static void main(String[] args) { - // Create a WebClient - WebClient webClient = WebClient.create("http://localhost:8080/graphql"); - - // Create a GraphQLConfiguration - GraphQLConfiguration graphQLConfiguration = new GraphQLConfiguration(webClient); - - // Create a GraphQLWebClient - GraphQLWebClient graphQLWebClient = new GraphQLWebClient(graphQLConfiguration); - - // Define a query - String query = "{ helloWorld }"; - - // Execute the query - String response = graphQLWebClient.executeQuery(query); - - // Print the response - System.out.println(response); - } -} \ No newline at end of file diff --git a/src/main/java/service/clients/rest/JerseyClient.java b/src/main/java/service/clients/rest/JerseyClient.java deleted file mode 100644 index c582c47..0000000 --- a/src/main/java/service/clients/rest/JerseyClient.java +++ /dev/null @@ -1,41 +0,0 @@ -package service.clients.rest; - -import java.io.IOException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriBuilder; -import org.apache.http.client.ClientProtocolException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - -public class JerseyClient { - - /** - * @param args - * @throws ClientProtocolException - * @throws IOException - */ - - public void obtainJSONResponse() throws ClientProtocolException, IOException { - - // Invoke REST service with GET Method - ClientConfig config = new DefaultClientConfig(); - Client client = Client.create(config); - - WebResource service = client - .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); - - // getting JSON data - System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( - "Authorization", - "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") - .get(String.class)); - } - - public void obtainXMLResponse() throws ClientProtocolException, IOException { - // getting XML data - // System.out.println("with - // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); - } -} \ No newline at end of file diff --git a/src/main/java/service/clients/rest/JerseyPostHeader.java b/src/main/java/service/clients/rest/JerseyPostHeader.java deleted file mode 100644 index 1ab46e5..0000000 --- a/src/main/java/service/clients/rest/JerseyPostHeader.java +++ /dev/null @@ -1,23 +0,0 @@ -package service.clients.rest; - -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.representation.Form; - -public class JerseyPostHeader { - - Client client = (Client) ClientBuilder.newClient(); - WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); - - Form form = new Form(); - // form.param("x", "foo"); - // form.param("y", "bar"); - // String bean = - // target.request(MediaType.APPLICATION_JSON_TYPE).post(MediaType.APPLICATION_FORM_URLENCODED_TYPE, - // String.class); -} diff --git a/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java b/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java deleted file mode 100644 index a420283..0000000 --- a/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheit.java +++ /dev/null @@ -1,64 +0,0 @@ - -package service.clients.wsdl.temperatureConvert; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - -// Service at https://www.w3schools.com/xml/tempconvert.asmx?WSDL -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Celsius" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "celsius" -}) -@XmlRootElement(name = "CelsiusToFahrenheit") -public class CelsiusToFahrenheit { - - @XmlElement(name = "Celsius") - protected String celsius; - - /** - * Gets the value of the celsius property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCelsius() { - return celsius; - } - - /** - * Sets the value of the celsius property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCelsius(String value) { - this.celsius = value; - } - -} diff --git a/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java b/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java deleted file mode 100644 index 1f2975c..0000000 --- a/src/main/java/service/clients/wsdl/temperatureConvert/CelsiusToFahrenheitResponse.java +++ /dev/null @@ -1,64 +0,0 @@ - -package service.clients.wsdl.temperatureConvert; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="CelsiusToFahrenheitResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "celsiusToFahrenheitResult" -}) -@XmlRootElement(name = "CelsiusToFahrenheitResponse") -public class CelsiusToFahrenheitResponse { - - @XmlElement(name = "CelsiusToFahrenheitResult") - protected String celsiusToFahrenheitResult; - - /** - * Gets the value of the celsiusToFahrenheitResult property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCelsiusToFahrenheitResult() { - return celsiusToFahrenheitResult; - } - - /** - * Sets the value of the celsiusToFahrenheitResult property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCelsiusToFahrenheitResult(String value) { - this.celsiusToFahrenheitResult = value; - } - -} diff --git a/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java b/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java deleted file mode 100644 index a671fa5..0000000 --- a/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsius.java +++ /dev/null @@ -1,64 +0,0 @@ - -package service.clients.wsdl.temperatureConvert; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Fahrenheit" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "fahrenheit" -}) -@XmlRootElement(name = "FahrenheitToCelsius") -public class FahrenheitToCelsius { - - @XmlElement(name = "Fahrenheit") - protected String fahrenheit; - - /** - * Gets the value of the fahrenheit property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getFahrenheit() { - return fahrenheit; - } - - /** - * Sets the value of the fahrenheit property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setFahrenheit(String value) { - this.fahrenheit = value; - } - -} diff --git a/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java b/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java deleted file mode 100644 index 93bc1c5..0000000 --- a/src/main/java/service/clients/wsdl/temperatureConvert/FahrenheitToCelsiusResponse.java +++ /dev/null @@ -1,64 +0,0 @@ - -package service.clients.wsdl.temperatureConvert; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="FahrenheitToCelsiusResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "fahrenheitToCelsiusResult" -}) -@XmlRootElement(name = "FahrenheitToCelsiusResponse") -public class FahrenheitToCelsiusResponse { - - @XmlElement(name = "FahrenheitToCelsiusResult") - protected String fahrenheitToCelsiusResult; - - /** - * Gets the value of the fahrenheitToCelsiusResult property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getFahrenheitToCelsiusResult() { - return fahrenheitToCelsiusResult; - } - - /** - * Sets the value of the fahrenheitToCelsiusResult property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setFahrenheitToCelsiusResult(String value) { - this.fahrenheitToCelsiusResult = value; - } - -} diff --git a/src/main/java/service/clients/wsdl/temperatureConvert/ObjectFactory.java b/src/main/java/service/clients/wsdl/temperatureConvert/ObjectFactory.java deleted file mode 100644 index fa12a61..0000000 --- a/src/main/java/service/clients/wsdl/temperatureConvert/ObjectFactory.java +++ /dev/null @@ -1,80 +0,0 @@ - -package service.clients.wsdl.temperatureConvert; - -import javax.xml.namespace.QName; -import jakarta.xml.bind.JAXBElement; -import jakarta.xml.bind.annotation.XmlElementDecl; -import jakarta.xml.bind.annotation.XmlRegistry; - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the https.www_w3schools_com.xml package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private final static QName _String_QNAME = new QName("https://www.w3schools.com/xml/", "string"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: https.www_w3schools_com.xml - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link FahrenheitToCelsius } - * - */ - public FahrenheitToCelsius createFahrenheitToCelsius() { - return new FahrenheitToCelsius(); - } - - /** - * Create an instance of {@link FahrenheitToCelsiusResponse } - * - */ -// public FahrenheitToCelsiusResponse createFahrenheitToCelsiusResponse() { - public FahrenheitToCelsiusResponse createFahrenheitToCelsiusResponse() { - return new FahrenheitToCelsiusResponse(); - } - - /** - * Create an instance of {@link CelsiusToFahrenheit } - * - */ - public CelsiusToFahrenheit createCelsiusToFahrenheit() { - return new CelsiusToFahrenheit(); - } - - /** - * Create an instance of {@link CelsiusToFahrenheitResponse } - * - */ - public CelsiusToFahrenheitResponse createCelsiusToFahrenheitResponse() { - return new CelsiusToFahrenheitResponse(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} - */ - @XmlElementDecl(namespace = "https://www.w3schools.com/xml/", name = "string") - public JAXBElement createString(String value) { - return new JAXBElement(_String_QNAME, String.class, null, value); - } -} diff --git a/src/main/java/service/clients/wsdl/temperatureConvert/TempConvert.java b/src/main/java/service/clients/wsdl/temperatureConvert/TempConvert.java deleted file mode 100644 index 46054cd..0000000 --- a/src/main/java/service/clients/wsdl/temperatureConvert/TempConvert.java +++ /dev/null @@ -1,132 +0,0 @@ -package service.clients.wsdl.temperatureConvert; - -import java.net.MalformedURLException; -import java.net.URL; -import javax.xml.namespace.QName; -import jakarta.xml.ws.WebEndpoint; -import jakarta.xml.ws.WebServiceClient; -import jakarta.xml.ws.WebServiceFeature; -import jakarta.xml.ws.Service; - -/** - * This class was generated by Apache CXF 4.0.3 - * 2023-10-28T21:23:45.149+13:00 - * Generated source version: 4.0.3 - * - */ -@WebServiceClient(name = "TempConvert", - wsdlLocation = "file:/home/ws/code/gitHub/multi-cloud-WebApp-Attendance/src/main/resources/wsdl/NumberConversion.wsdl", - targetNamespace = "https://www.w3schools.com/xml/") -public class TempConvert extends Service { - - public final static URL WSDL_LOCATION; - - public final static QName SERVICE = new QName("https://www.w3schools.com/xml/", "TempConvert"); - public final static QName TempConvertSoap = new QName("https://www.w3schools.com/xml/", "TempConvertSoap"); - public final static QName TempConvertSoap12 = new QName("https://www.w3schools.com/xml/", "TempConvertSoap12"); - public final static QName TempConvertHttpPost = new QName("https://www.w3schools.com/xml/", "TempConvertHttpPost"); - static { - URL url = null; - try { - url = new URL("file:/home/ws/code/gitHub/multi-cloud-WebApp-Attendance/src/main/resources/wsdl/NumberConversion.wsdl"); - } catch (MalformedURLException e) { - java.util.logging.Logger.getLogger(TempConvert.class.getName()) - .log(java.util.logging.Level.INFO, - "Can not initialize the default wsdl from {0}", "file:/home/ws/code/gitHub/multi-cloud-WebApp-Attendance/src/main/resources/wsdl/NumberConversion.wsdl"); - } - WSDL_LOCATION = url; - } - - public TempConvert(URL wsdlLocation) { - super(wsdlLocation, SERVICE); - } - - public TempConvert(URL wsdlLocation, QName serviceName) { - super(wsdlLocation, serviceName); - } - - public TempConvert() { - super(WSDL_LOCATION, SERVICE); - } - - public TempConvert(WebServiceFeature ... features) { - super(WSDL_LOCATION, SERVICE, features); - } - - public TempConvert(URL wsdlLocation, WebServiceFeature ... features) { - super(wsdlLocation, SERVICE, features); - } - - public TempConvert(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) { - super(wsdlLocation, serviceName, features); - } - - /** - * - * @return - * returns TempConvertSoap - */ - @WebEndpoint(name = "TempConvertSoap") - public TempConvertSoap getTempConvertSoap() { - return super.getPort(TempConvertSoap, TempConvertSoap.class); - } - - /** - * - * @param features - * A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. - * @return - * returns TempConvertSoap - */ - @WebEndpoint(name = "TempConvertSoap") - public TempConvertSoap getTempConvertSoap(WebServiceFeature... features) { - return super.getPort(TempConvertSoap, TempConvertSoap.class, features); - } - - - /** - * - * @return - * returns TempConvertSoap - */ - @WebEndpoint(name = "TempConvertSoap12") - public TempConvertSoap getTempConvertSoap12() { - return super.getPort(TempConvertSoap12, TempConvertSoap.class); - } - - /** - * - * @param features - * A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. - * @return - * returns TempConvertSoap - */ - @WebEndpoint(name = "TempConvertSoap12") - public TempConvertSoap getTempConvertSoap12(WebServiceFeature... features) { - return super.getPort(TempConvertSoap12, TempConvertSoap.class, features); - } - - - /** - * - * @return - * returns TempConvertHttpPost - */ - @WebEndpoint(name = "TempConvertHttpPost") - public TempConvertHttpPost getTempConvertHttpPost() { - return super.getPort(TempConvertHttpPost, TempConvertHttpPost.class); - } - - /** - * - * @param features - * A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. - * @return - * returns TempConvertHttpPost - */ - @WebEndpoint(name = "TempConvertHttpPost") - public TempConvertHttpPost getTempConvertHttpPost(WebServiceFeature... features) { - return super.getPort(TempConvertHttpPost, TempConvertHttpPost.class, features); - } - -} diff --git a/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertHttpPost.java b/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertHttpPost.java deleted file mode 100644 index 4a5d41b..0000000 --- a/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertHttpPost.java +++ /dev/null @@ -1,36 +0,0 @@ -package service.clients.wsdl.temperatureConvert; - -import jakarta.jws.WebMethod; -import jakarta.jws.WebParam; -import jakarta.jws.WebResult; -import jakarta.jws.WebService; -import jakarta.jws.soap.SOAPBinding; -import jakarta.xml.bind.annotation.XmlSeeAlso; - -/** - * This class was generated by Apache CXF 4.0.3 - * 2023-10-28T21:23:45.129+13:00 - * Generated source version: 4.0.3 - * - */ -@WebService(targetNamespace = "https://www.w3schools.com/xml/", name = "TempConvertHttpPost") -@XmlSeeAlso({ObjectFactory.class}) -@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) -public interface TempConvertHttpPost { - - @WebMethod(operationName = "CelsiusToFahrenheit") - @WebResult(name = "string", targetNamespace = "https://www.w3schools.com/xml/", partName = "Body") - public java.lang.String celsiusToFahrenheit( - - @WebParam(partName = "Celsius", name = "Celsius", targetNamespace = "") - java.lang.String celsius - ); - - @WebMethod(operationName = "FahrenheitToCelsius") - @WebResult(name = "string", targetNamespace = "https://www.w3schools.com/xml/", partName = "Body") - public java.lang.String fahrenheitToCelsius( - - @WebParam(partName = "Fahrenheit", name = "Fahrenheit", targetNamespace = "") - java.lang.String fahrenheit - ); -} diff --git a/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertSoap.java b/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertSoap.java deleted file mode 100644 index 38eddcc..0000000 --- a/src/main/java/service/clients/wsdl/temperatureConvert/TempConvertSoap.java +++ /dev/null @@ -1,40 +0,0 @@ -package service.clients.wsdl.temperatureConvert; - -import jakarta.jws.WebMethod; -import jakarta.jws.WebParam; -import jakarta.jws.WebResult; -import jakarta.jws.WebService; -import jakarta.xml.bind.annotation.XmlSeeAlso; -import jakarta.xml.ws.RequestWrapper; -import jakarta.xml.ws.ResponseWrapper; - -/** - * This class was generated by Apache CXF 4.0.3 - * 2023-10-28T21:23:45.025+13:00 - * Generated source version: 4.0.3 - * - */ -@WebService(targetNamespace = "https://www.w3schools.com/xml/", name = "TempConvertSoap") -@XmlSeeAlso({ObjectFactory.class}) -public interface TempConvertSoap { - - @WebMethod(operationName = "CelsiusToFahrenheit", action = "https://www.w3schools.com/xml/CelsiusToFahrenheit") - @RequestWrapper(localName = "CelsiusToFahrenheit", targetNamespace = "https://www.w3schools.com/xml/", className = "https.www_w3schools_com.xml.CelsiusToFahrenheit") - @ResponseWrapper(localName = "CelsiusToFahrenheitResponse", targetNamespace = "https://www.w3schools.com/xml/", className = "https.www_w3schools_com.xml.CelsiusToFahrenheitResponse") - @WebResult(name = "CelsiusToFahrenheitResult", targetNamespace = "https://www.w3schools.com/xml/") - public java.lang.String celsiusToFahrenheit( - - @WebParam(name = "Celsius", targetNamespace = "https://www.w3schools.com/xml/") - java.lang.String celsius - ); - - @WebMethod(operationName = "FahrenheitToCelsius", action = "https://www.w3schools.com/xml/FahrenheitToCelsius") - @RequestWrapper(localName = "FahrenheitToCelsius", targetNamespace = "https://www.w3schools.com/xml/", className = "https.www_w3schools_com.xml.FahrenheitToCelsius") - @ResponseWrapper(localName = "FahrenheitToCelsiusResponse", targetNamespace = "https://www.w3schools.com/xml/", className = "https.www_w3schools_com.xml.FahrenheitToCelsiusResponse") - @WebResult(name = "FahrenheitToCelsiusResult", targetNamespace = "https://www.w3schools.com/xml/") - public java.lang.String fahrenheitToCelsius( - - @WebParam(name = "Fahrenheit", targetNamespace = "https://www.w3schools.com/xml/") - java.lang.String fahrenheit - ); -} diff --git a/src/main/java/service/clients/wsdl/temperatureConvert/package-info.java b/src/main/java/service/clients/wsdl/temperatureConvert/package-info.java deleted file mode 100644 index 7834922..0000000 --- a/src/main/java/service/clients/wsdl/temperatureConvert/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -@jakarta.xml.bind.annotation.XmlSchema(namespace = "https://www.w3schools.com/xml/", elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED) -package service.clients.wsdl.temperatureConvert; diff --git a/src/main/java/util/AuthenticateAD.java b/src/main/java/util/AuthenticateAD.java new file mode 100644 index 0000000..f84dfca --- /dev/null +++ b/src/main/java/util/AuthenticateAD.java @@ -0,0 +1,135 @@ +// utility class authenticate LDAP call LdapAuth.authenticateUserAndGetInfo (username,password); +// Note: Configure ldapURI ,requiredAttributes ,ADSearchPaths,accountSuffex + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +import javax.naming.*; +import java.util.regex.*; +import javax.naming.directory.*; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; + +public class AuthenticateAD { + /* + * you could use a secure connection such as LDAPS (LDAP over SSL/TLS) or + * StartTLS (LDAP over TLS) + * Use a secure password storage mechanism: Consider using a secure password + * storage mechanism such as a password hash or a secure encryption algorithm + * Handle errors and exceptions more robustly: The code currently catches and + * prints out errors and exceptions, but it does not provide specific error + * handling or recovery mechanisms. + * You could consider adding more robust error handling and recovery mechanisms + * to the code to ensure that it can handle a variety of error conditions and + * recover gracefully. + * Implement rate limiting: The code currently does not implement any rate + * limiting mechanisms, which could potentially allow an attacker to perform a + * brute force attack on the AD server. You could consider implementing rate + * limiting mechanisms such as sleeping between authentication attempts or + * limiting the number of authentication attempts per user. + * Use a more secure algorithm for searching the AD: The code currently uses the + * `objectClass=*` search filter, which can be inefficient and may return a + * large number of results. You could consider using a more specific search + * filter such as `(&(objectClass=user)(sAMAccountName=*))`, which only return user objects + * reduce the amount of data transferred over the network + * Use a more secure algorithm for binding to the AD: The code currently uses + * the `bind` method to authenticate the user, which can be vulnerable to replay + * attacks. You could consider using a more secure algorithm such as the + * `saslBind` method, which supports SASL (Simple Authentication and Security + * Layer) and is less vulnerable to replay attacks. + * Use a more secure algorithm for retrieving user information: The code + * currently uses the `search` method to retrieve user information, which can be + * inefficient and may return a large amount of data. You could consider using a + * more specific method such as `getAttribute` or `getAttributes` to retrieve + * only the specific user information that you need. + * Use a more secure algorithm for storing user information: The code currently + * stores user information in a `Map`, which is not secure. You could consider + * using a more secure storage mechanism such as a secure database or a secure + * file storage system to protect the user's information. + */ + + private static String ldapURI; + private static String[] requiredAttributes; + private static String[] ADSearchPaths; + private static String accountSuffex; + private final static String contextFactory = "com.sun.jndi.ldap.LdapCtxFactory"; + // private final static String ldapURI = + // "ldap://52.40.50.72:389/DC=corp,DC=local"; + // private static String[] requiredAttributes = { + // "cn","givenName","sn","userPrincipalName","sAMAccountName","objectSid" }; + // see you active directory user OU's hierarchy + // private static String[] ADSearchPaths = { + // "OU=O365 Synced Accounts,OU=ALL USERS", + // "OU=Users,OU=O365 Synced Accounts,OU=ALL USERS", + // "OU=In-House,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS", + // "OU=Migrated Users + // }; + // private static String accountSuffex = "@corp.local"; // this will be used if + // user name is just provided + + public void readFromPropertiesFile() { + try (InputStream inputStream = AuthenticateAD.class.getClassLoader().getResourceAsStream("ad.properties")) { + Properties properties = new Properties(); + properties.load(inputStream); + ldapURI = properties.getProperty("ldapURI"); + requiredAttributes = properties.getProperty("requiredAttributes").split(","); + ADSearchPaths = properties.getProperty("ADSearchPaths").split(";"); + accountSuffex = properties.getProperty("accountSuffex"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void authenticateUserAndGetInfo(String user, String password) throws Exception { + try { + Hashtable env = new Hashtable(); + env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory); + env.put(Context.PROVIDER_URL, ldapURI); + env.put(Context.SECURITY_AUTHENTICATION, "simple"); + env.put(Context.SECURITY_PRINCIPAL, user); + env.put(Context.SECURITY_CREDENTIALS, password); + + DirContext ctx = new InitialDirContext(env); + + String filter = "(sAMAccountName=" + user + ")"; // default for search filter username + + if (user.contains("@")) // if user name is a email then + { + // String parts[] = user.split("\\@"); + // use different filter for email + filter = "(userPrincipalName=" + user + ")"; + } + + SearchControls ctrl = new SearchControls(); + ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE); + ctrl.setReturningAttributes(requiredAttributes); + + NamingEnumeration userInfo = null; + + Integer i = 0; + do { + userInfo = ctx.search(ADSearchPaths[i], filter, ctrl); + i++; + + } while (!userInfo.hasMore() && i < ADSearchPaths.length); + + if (userInfo.hasMore()) { + + SearchResult UserDetails = (SearchResult) userInfo.next(); + Attributes userAttr = UserDetails.getAttributes(); + System.out.println("adEmail = " + userAttr.get("userPrincipalName").get(0).toString()); + System.out.println("adFirstName = " + userAttr.get("givenName").get(0).toString()); + System.out.println("adLastName = " + userAttr.get("sn").get(0).toString()); + System.out.println("name = " + userAttr.get("cn").get(0).toString()); + System.out.println("AdFullName = " + userAttr.get("cn").get(0).toString()); + } + + userInfo.close(); + + } catch (javax.naming.AuthenticationException e) { + + } + } +} \ No newline at end of file diff --git a/src/main/java/util/AuthenticateLDAP.java b/src/main/java/util/AuthenticateLDAP.java deleted file mode 100644 index 36df6d4..0000000 --- a/src/main/java/util/AuthenticateLDAP.java +++ /dev/null @@ -1,119 +0,0 @@ -// utility class involved with business logid -// authenticate LDAP UserName or Email call LdapAuth.authenticateUserAndGetInfo (username,password); -// Note: Configure ldapURI ,requiredAttributes ,ADSearchPaths,accountSuffex - -import java.io.FileInputStream; -import java.io.IOException; -import java.util.*; - -import javax.naming.*; - -import java.util.regex.*; - -import javax.naming.directory.*; - -import javax.naming.ldap.InitialLdapContext; - -import javax.naming.ldap.LdapContext; - -public class AuthenticateLDAP { - - private static String ldapURI; - private static String[] requiredAttributes; - private static String[] ADSearchPaths; - private static String accountSuffex; - private final static String contextFactory = "com.sun.jndi.ldap.LdapCtxFactory"; - // private final static String ldapURI = "ldap://52.40.50.72:389/DC=corp,DC=local"; - - // private static String[] requiredAttributes = { "cn", "givenName", "sn", "userPrincipalName", "sAMAccountName", "objectSid" }; - // see you active directory user OU's hierarchy - // private static String[] ADSearchPaths = - // { - // "OU=O365 Synced Accounts,OU=ALL USERS", - // "OU=Users,OU=O365 Synced Accounts,OU=ALL USERS", - // "OU=In-House,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS", - // "OU=Torbram Users,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS", - // "OU=Migrated Users,OU=TES-Users" - // }; - - // private static String accountSuffex = "@corp.local"; // this will be used if - // user name is just provided - - static { - try ((InputStream inputStream = LdapAuth.class.getClassLoader().getResourceAsStream("ldap.properties")) { - - Properties properties = new Properties(); - properties.load(inputStream); - - ldapURI = properties.getProperty("ldapURI"); - requiredAttributes = properties.getProperty("requiredAttributes").split(","); - ADSearchPaths = properties.getProperty("ADSearchPaths").split(";"); - accountSuffex = properties.getProperty("accountSuffex"); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void authenticateUserAndGetInfo(String user, String password) throws Exception { - - try { - - Hashtable env = new Hashtable(); - - env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory); - - env.put(Context.PROVIDER_URL, ldapURI); - - env.put(Context.SECURITY_AUTHENTICATION, "simple"); - - env.put(Context.SECURITY_PRINCIPAL, user); - - env.put(Context.SECURITY_CREDENTIALS, password); - - DirContext ctx = new InitialDirContext(env); - - String filter = "(sAMAccountName=" + user + ")"; // default for search filter username - - if (user.contains("@")) // if user name is a email then - { - // String parts[] = user.split("\\@"); - // use different filter for email - filter = "(userPrincipalName=" + user + ")"; - } - - SearchControls ctrl = new SearchControls(); - ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE); - ctrl.setReturningAttributes(requiredAttributes); - - NamingEnumeration userInfo = null; - - Integer i = 0; - do { - userInfo = ctx.search(ADSearchPaths[i], filter, ctrl); - i++; - - } while (!userInfo.hasMore() && i < ADSearchPaths.length); - - if (userInfo.hasMore()) { - - SearchResult UserDetails = (SearchResult) userInfo.next(); - Attributes userAttr = UserDetails.getAttributes(); - System.out.println("adEmail = " + userAttr.get("userPrincipalName").get(0).toString()); - - System.out.println("adFirstName = " + userAttr.get("givenName").get(0).toString()); - - System.out.println("adLastName = " + userAttr.get("sn").get(0).toString()); - - System.out.println("name = " + userAttr.get("cn").get(0).toString()); - - System.out.println("AdFullName = " + userAttr.get("cn").get(0).toString()); - - } - - userInfo.close(); - - } catch (javax.naming.AuthenticationException e) { - - } - } -} \ No newline at end of file diff --git a/src/main/java/util/AuthenticateOpenLDAP.java b/src/main/java/util/AuthenticateOpenLDAP.java new file mode 100644 index 0000000..0757b3e --- /dev/null +++ b/src/main/java/util/AuthenticateOpenLDAP.java @@ -0,0 +1,45 @@ +package util; + +import com.unboundid.ldap.sdk.*; +import com.unboundid.util.ssl.SSLUtil; +import com.unboundid.util.ssl.TrustAllTrustManager; +import javax.net.ssl.SSLSocketFactory; + +public class AuthenticateOpenLDAP { + public void openLDAPAdminSearch() { + // LDAP connection parameters + String ldapURL = "ldap://localhost"; + String bindDN = "cn=admin,dc=my-company,dc=com"; + String bindPassword = System.getenv("LDAP_ADMIN_PASS"); + String baseDN = "dc=my-company,dc=com"; + String searchFilter = "(objectClass=*)"; // Modify this filter as needed + + // Connect to the LDAP server + LDAPConnection connection = null; + try { + // If using SSL/TLS, initialize SSLSocketFactory (optional) + // SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager()); + // SSLSocketFactory socketFactory = sslUtil.createSSLSocketFactory(); + // connection = new LDAPConnection(socketFactory, "localhost", 636); + + // For non-SSL connection + connection = new LDAPConnection("localhost", 389); + connection.bind(bindDN, bindPassword); + + // Perform the search + SearchResult searchResult = connection.search(baseDN, SearchScope.SUB, searchFilter); + + // Process the search results + for (SearchResultEntry entry : searchResult.getSearchEntries()) { + System.out.println(entry.toLDIFString()); + } + } catch (LDAPException e) { + e.printStackTrace(); + } finally { + // Disconnect from the LDAP server + if (connection != null) { + connection.close(); + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/ad.properties b/src/main/resources/ad.properties new file mode 100644 index 0000000..bfefa90 --- /dev/null +++ b/src/main/resources/ad.properties @@ -0,0 +1,10 @@ +# Active Directory properties +ldapURI=ldap://20.200.200.200:389/DC=corp,DC=local +requiredAttributes=cn,givenName,sn,displayName,userPrincipalName,sAMAccountName,objectSid,userAccountControl +ADSearchPaths=OU=O365 Synced Accounts,OU=ALL USERS;OU=Users,OU=O365 Synced Accounts,OU=ALL USERS;OU=In-House,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS;OU=Torbram Users,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS;OU=Migrated Users,OU=TES-Users +accountSuffix=@corp.local + +# userPrincipalName: This attribute represents the user principal name (UPN) of the user. It is a unique identifier for the user within the Active Directory domain. +# sAMAccountName: This attribute represents the user's SAM account name. It is a legacy attribute used in older versions of Active Directory. +# objectSid: This attribute represents the security identifier (SID) of the user. It is a unique identifier for the user within the Active Directory domain. +# userAccountControl: This attribute represents the user account control (UAC) of the user. Specifies the user's permissions and access rights within the Active Directory domain. \ No newline at end of file diff --git a/src/main/resources/ldap.properties b/src/main/resources/ldap.properties index 005aaad..97fa939 100644 --- a/src/main/resources/ldap.properties +++ b/src/main/resources/ldap.properties @@ -1,5 +1,10 @@ # ldap.properties -ldapURI=ldap://20.200.200.200:389/DC=corp,DC=local -requiredAttributes=cn,givenName,sn,displayName,userPrincipalName,sAMAccountName,objectSid,userAccountControl -ADSearchPaths=OU=O365 Synced Accounts,OU=ALL USERS;OU=Users,OU=O365 Synced Accounts,OU=ALL USERS;OU=In-House,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS;OU=Torbram Users,OU=Users,OU=O365 Synced Accounts,OU=ALL USERS;OU=Migrated Users,OU=TES-Users -accountSuffix=@corp.local +# https://www.openldap.org/ +ldapURI=ldap://localhost:389/DC=my-company,DC=com +# objectClass: attribute specifies the object class of the entry in the directory. Defines type of object that the entry represents. Active Directory, the object class is 'user', while in OpenLDAP, it is 'inetOrgPerson'. +# objectCategory: specifies the object category of the entry in the directory. Defines the purpose or role of the object. in Active Directory, the object category is 'person', while in OpenLDAP, it is 'top'. +# objectGUID: This attribute uniquely identifies the entry in the directory. It is generated automatically by OpenLDAP and should not be modified manually. +# givenName: This attribute represents the given name of the user. It is the first name of the user. +# sn: This attribute represents the surname (family name) of the user. +# displayName: This attribute represents the display name of the user. It is the name that the user wants to be displayed. +requiredAttributes=objectClass,objectCategory,objectGUID,givenName,sn,displayName diff --git a/src/test/attendance/login/TestLogin.java b/src/test/attendance/login/TestLogin.java deleted file mode 100644 index d078644..0000000 --- a/src/test/attendance/login/TestLogin.java +++ /dev/null @@ -1,31 +0,0 @@ -package attendance.login; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import bean.UserBean; - -public class TestLogin { - - @Test - public void GetToken() { - // fail("Not yet implemented"); - } - - @Test - public void loginGeneralUser() { - UserBean user = new UserBean(); - user.setId("10295765"); - user.setPassword("Value!12"); - // System.out.println("assert result"+user.login()); - assertTrue(user.login() == "main"); - } - - public void loginGeneralUserNOK() { - } - - public void loginLecturer() { - } - -} \ No newline at end of file diff --git a/src/test/attendance/student/StudentAuthenticationResult.java b/src/test/attendance/student/StudentAuthenticationResult.java deleted file mode 100644 index 2a29d77..0000000 --- a/src/test/attendance/student/StudentAuthenticationResult.java +++ /dev/null @@ -1,72 +0,0 @@ -package attendance.gson; - -import com.google.gson.annotations.SerializedName; - -public class StudentAuthenticationResult { - - public StudentAuthenticationResult(String accessToken, Integer expiresIn, String tokenType, String refreshToken, - String idToken) { - this.accessToken = accessToken; - this.expiresIn = expiresIn; - this.tokenType = tokenType; - this.refreshToken = refreshToken; - this.idToken = idToken; - } - - @SerializedName("AccessToken") - private String accessToken; - - @SerializedName("ExpiresIn") - private Integer expiresIn; - - @SerializedName("TokenType") - private String tokenType; - - @SerializedName("RefreshToken") - private String refreshToken; - - @SerializedName("IdToken") - private String idToken; - - // Setters and getters - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - public Integer getExpiresIn() { - return expiresIn; - } - - public void setExpiresIn(Integer expiresIn) { - this.expiresIn = expiresIn; - } - - public String getTokenType() { - return tokenType; - } - - public void setTokenType(String tokenType) { - this.tokenType = tokenType; - } - - public String getRefreshToken() { - return refreshToken; - } - - public void setRefreshToken(String refreshToken) { - this.refreshToken = refreshToken; - } - - public String getIdToken() { - return idToken; - } - - public void setIdToken(String idToken) { - this.idToken = idToken; - } -} diff --git a/src/test/attendance/student/StudentAuthorization.java b/src/test/attendance/student/StudentAuthorization.java deleted file mode 100644 index d4df42b..0000000 --- a/src/test/attendance/student/StudentAuthorization.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.student; - -import com.google.gson.annotations.SerializedName; - -import entity.ChallengeParameters; - -public class StudentAuthorization { - - // names have to be the same from JSON to Java Object so that it works fine. - - private ChallengeParameters challengeParameters; - // @SerializedName("AuthenticationResult") - // @Expose - private StudentAuthenticationResult authenticationResult; - - public ChallengeParameters getChallengeParameters() { - return challengeParameters; - } - - public void setChallengeParameters(ChallengeParameters challengeParameters) { - this.challengeParameters = challengeParameters; - } - - public StudentAuthenticationResult getAuthenticationResult() { - return authenticationResult; - } - - public void setAuthenticationResult(StudentAuthenticationResult authenticationResult) { - this.authenticationResult = authenticationResult; - } -} \ No newline at end of file diff --git a/src/test/attendance/student/TestStudent.java b/src/test/attendance/student/TestStudent.java deleted file mode 100644 index be1a249..0000000 --- a/src/test/attendance/student/TestStudent.java +++ /dev/null @@ -1,25 +0,0 @@ -package attendance.student; - -import javax.faces.bean.ManagedBean; - -@ManagedBean -public class TestStudent { - - private String name; - - public String sayHello() { - if (name != null && !name.trim().equals("")) { - return "Hello, " + name + "!"; - } else { - return null; - } - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/src/test/java/attendance/student/StudentAuthenticationResult.java b/src/test/java/attendance/student/StudentAuthenticationResult.java index 2a29d77..d2ff0c5 100644 --- a/src/test/java/attendance/student/StudentAuthenticationResult.java +++ b/src/test/java/attendance/student/StudentAuthenticationResult.java @@ -1,4 +1,4 @@ -package attendance.gson; +package attendance.student; import com.google.gson.annotations.SerializedName; diff --git a/src/test/java/attendance/student/StudentAuthorization.java b/src/test/java/attendance/student/StudentAuthorization.java index d4df42b..db768bf 100644 --- a/src/test/java/attendance/student/StudentAuthorization.java +++ b/src/test/java/attendance/student/StudentAuthorization.java @@ -1,4 +1,4 @@ -package test.student; +package attendance.student; import com.google.gson.annotations.SerializedName; diff --git a/src/test/java/auth/ldap/TestLDAPAuthentication.java b/src/test/java/auth/ldap/TestLDAPAuthentication.java new file mode 100644 index 0000000..c6bcc70 --- /dev/null +++ b/src/test/java/auth/ldap/TestLDAPAuthentication.java @@ -0,0 +1,95 @@ +package auth.ldap; + +import org.junit.Test; +import org.mockito.Mockito; +import static org.junit.Assert.assertTrue; +import com.unboundid.ldap.sdk.LDAPConnection; +import com.unboundid.ldap.sdk.LDAPException; +import com.unboundid.ldap.sdk.SearchRequest; +import com.unboundid.ldap.sdk.SearchResult; +import com.unboundid.ldap.sdk.SearchResultEntry; +import com.unboundid.ldap.sdk.SearchScope; + +import util.AuthenticateOpenLDAP; + +public class TestLDAPAuthentication { + // - Mocks LDAPConnection to avoid real connection + // - Mocks search result and entries returned + // - Stubs the behavior for the mocks + // - Calls the method under test + // - Verifies expected methods are called on the mocks + + @Test + public void testMockOpenLDAPAdminSearch() { + // Mock LDAPConnection + LDAPConnection connectionMock = Mockito.mock(LDAPConnection.class); + + // Mock search result + SearchResult searchResultMock = Mockito.mock(SearchResult.class); + Mockito.when(connectionMock.search(Mockito.anyString(), Mockito.any(), Mockito.anyString())) + .thenReturn(searchResultMock); + + // Mock search result entries + SearchResultEntry entry1 = Mockito.mock(SearchResultEntry.class); + SearchResultEntry entry2 = Mockito.mock(SearchResultEntry.class); + + // Stub searchEntries to return mocked entries + Mockito.when(searchResultMock.getSearchEntries()).thenReturn(new SearchResultEntry[] { entry1, entry2 }); + + // Test the method + AuthenticateOpenLDAP ldapAuth = new AuthenticateOpenLDAP(); + ldapAuth.openLDAPAdminSearch(); + + // Verify search was called + Mockito.verify(connectionMock).search(Mockito.anyString(), Mockito.any(), Mockito.anyString()); + + // Verify entry processing + Mockito.verify(entry1).toLDIFString(); + Mockito.verify(entry2).toLDIFString(); + + // Verify connection closed + Mockito.verify(connectionMock).close(); + } + + @Test + public void testOpenLDAPAdminSearch_withOpenLDAP() { + + // Test parameters + String ldapURL = "ldap://localhost"; + String ldapHost = "localhost"; + int ldapPort = 389; + String bindDN = "cn=admin,dc=my-company,dc=com"; + var bindPassword = "adminpassword"; + String baseDN = "dc=my-company,dc=com"; + String searchFilter = "(objectClass=*)"; + + // Connect to OpenLDAP + // Establishing a connection to the LDAP server + try (LDAPConnection connection = new LDAPConnection(ldapHost, ldapPort, bindDN, bindPassword)) { + System.out.println("Connected to the LDAP server."); + + SearchRequest searchRequest = new SearchRequest(baseDN, SearchScope.SUB, searchFilter); + // Performing the search + SearchResult result = connection.search(baseDN, SearchScope.SUB, "(objectClass=*)"); + + // Verify search returned results + assertTrue(result.getEntryCount() > 0); + + // Print entries + for (SearchResultEntry entry : result.getSearchEntries()) { + System.out.println(entry.toLDIFString()); + } + + SearchResult searchResult = connection.search(searchRequest); + System.out.println("Search returned " + searchResult.getEntryCount() + " entries."); + + // Process the search results as needed + // Close connection + connection.close(); + } catch (LDAPException e) { + System.err.println("Error connecting to the LDAP server: " + e.getMessage()); + e.printStackTrace(); + } + + } +} diff --git a/src/test/attendance/login/LoginReply.java b/src/test/java/auth/login/LoginReply.java similarity index 91% rename from src/test/attendance/login/LoginReply.java rename to src/test/java/auth/login/LoginReply.java index fe289ad..7f3d9b5 100644 --- a/src/test/attendance/login/LoginReply.java +++ b/src/test/java/auth/login/LoginReply.java @@ -1,8 +1,11 @@ -package com.json; +package auth.login; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import entity.AuthenticationResult; +import entity.ChallengeParameters; + public class LoginReply { @SerializedName("ChallengeParameters") diff --git a/src/test/java/attendance/login/TestLogin.java b/src/test/java/auth/login/TestLogin.java similarity index 95% rename from src/test/java/attendance/login/TestLogin.java rename to src/test/java/auth/login/TestLogin.java index 3eed44e..7e3b0da 100644 --- a/src/test/java/attendance/login/TestLogin.java +++ b/src/test/java/auth/login/TestLogin.java @@ -1,4 +1,4 @@ -package attendance.login; +package auth.login; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/external/tokenauthentication/PostAuthenticationToken.java b/src/test/java/auth/token/PostAuthenticationToken.java similarity index 98% rename from src/test/java/external/tokenauthentication/PostAuthenticationToken.java rename to src/test/java/auth/token/PostAuthenticationToken.java index 8c93550..f6e3965 100644 --- a/src/test/java/external/tokenauthentication/PostAuthenticationToken.java +++ b/src/test/java/auth/token/PostAuthenticationToken.java @@ -1,4 +1,4 @@ -package external.tokenauthentication; +package auth.token; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/test/java/attendance/login/TestAuthenticationResult.java b/src/test/java/auth/token/TestTokenAuthentication.java similarity index 88% rename from src/test/java/attendance/login/TestAuthenticationResult.java rename to src/test/java/auth/token/TestTokenAuthentication.java index 85d629e..ba48b04 100644 --- a/src/test/java/attendance/login/TestAuthenticationResult.java +++ b/src/test/java/auth/token/TestTokenAuthentication.java @@ -1,10 +1,10 @@ -package attendance.login; +package auth.token; import com.google.gson.annotations.SerializedName; -public class TestAuthenticationResult { +public class TestTokenAuthentication { - public TestAuthenticationResult(String accessToken, Integer expiresIn, String tokenType, String refreshToken, + public TestTokenAuthentication(String accessToken, Integer expiresIn, String tokenType, String refreshToken, String idToken) { this.accessToken = accessToken; this.expiresIn = expiresIn; diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyClient.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyClient.java deleted file mode 100644 index 27af2ad..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/JerseyClient.java +++ /dev/null @@ -1,41 +0,0 @@ -package external.services.restclient; - -import java.io.IOException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriBuilder; -import org.apache.http.client.ClientProtocolException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - -public class JerseyClient { - - /** - * @param args - * @throws ClientProtocolException - * @throws IOException - */ - - public void obtainJSONResponse() throws ClientProtocolException, IOException { - - // Invoke REST service with GET Method - ClientConfig config = new DefaultClientConfig(); - Client client = Client.create(config); - - WebResource service = client - .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); - - // getting JSON data - System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( - "Authorization", - "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") - .get(String.class)); - } - - public void obtainXMLResponse() throws ClientProtocolException, IOException { - // getting XML data - // System.out.println("with - // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); - } -} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyClientPost.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyClientPost.java deleted file mode 100644 index dfcb8d2..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/JerseyClientPost.java +++ /dev/null @@ -1,33 +0,0 @@ -package external.services.restclient; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - -public class JerseyClientPost { - - public static void main(String[] args) { - - try { - Client client = Client.create(); - WebResource webResource = client - .resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); - - if (response.getStatus() != 201) { - throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); - } - - System.out.println("Output from Server .... \n"); - String output = response.getEntity(String.class); - System.out.println(output); - - } catch (Exception e) { - - e.printStackTrace(); - - } - } -} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyGet.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyGet.java deleted file mode 100644 index 7306244..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/JerseyGet.java +++ /dev/null @@ -1,37 +0,0 @@ -package external.services.restclient; - -import java.io.IOException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriBuilder; -import org.apache.http.client.ClientProtocolException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - -public class JerseyGet { - - /** - * @param args - * @throws ClientProtocolException - * @throws IOException - */ - public static void main(String[] args) throws ClientProtocolException, IOException { - - ClientConfig config = new DefaultClientConfig(); - Client client = Client.create(config); - - WebResource service = client - .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); - - // getting JSON data - System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( - "Authorization", - "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") - .get(String.class)); - - // getting XML data - // System.out.println("with - // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); - } -} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonResponse.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonResponse.java deleted file mode 100644 index d4e8bb9..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package external.services.restclient; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - -public class JerseyJsonResponse { - - public static void main(String[] args) { - try { - String baseuri = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login/"; - Client client = Client.create(); - - WebResource webResource = client.resource(baseuri); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - // POST method - ClientResponse response = webResource.accept("application/json").type("type:application/json") - .post(ClientResponse.class, input); - - // check response status code - if (response.getStatus() != 200) { - throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); - } - - // display response - String output = response.getEntity(String.class); - System.out.println("Output from Server .... "); - System.out.println(output + "\n"); - } catch (Exception e) { - e.printStackTrace(); - } - - } // main() -} diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonSimpler.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonSimpler.java deleted file mode 100644 index ec56267..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/JerseyJsonSimpler.java +++ /dev/null @@ -1,28 +0,0 @@ -package external.services.restclient; - -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.representation.Form; - -public class JerseyJsonSimpler { - - public static void main(String[] args) { - - try { - Client client = (Client) ClientBuilder.newClient(); - WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); - - Form form = new Form(); - form.add("id", "10295765"); - form.add("password", "Value!12"); - // ClientResponse response = - // WebResource.class.type(MediaType.TEXT_PLAIN).post(ClientResponse.class, - // form); - } catch (Exception e) { - e.printStackTrace(); - } - - } -} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyPost.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyPost.java deleted file mode 100644 index 1cee7b6..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/JerseyPost.java +++ /dev/null @@ -1,36 +0,0 @@ -package external.services.restclient; - -import java.io.IOException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; -import org.apache.http.client.ClientProtocolException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -public class JerseyPost { - - public static void main(String[] args) throws ClientProtocolException, IOException { - - ClientConfig config = new DefaultClientConfig(); - - Client client = Client.create(config); - - WebResource webResource = client - .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/").build()); - - MultivaluedMap formData = new MultivaluedMapImpl(); - - formData.add("id", "10295765"); - formData.add("password", "Value!12"); - - ClientResponse response = webResource.path("dev").path("login").type(MediaType.APPLICATION_FORM_URLENCODED) - .post(ClientResponse.class, formData); - - System.out.println("Response " + response.getEntity(String.class)); - } -} diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyPostHeader.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyPostHeader.java deleted file mode 100644 index e9c68c5..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/JerseyPostHeader.java +++ /dev/null @@ -1,24 +0,0 @@ -package external.services.restclient; - -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.representation.Form; - -public class JerseyPostHeader { - - Client client = (Client) ClientBuilder.newClient(); - WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); - - Form form = new Form(); - // form.param("x", "foo"); - // form.param("y", "bar"); - - // String bean = - // target.request(MediaType.APPLICATION_JSON_TYPE).post(MediaType.APPLICATION_FORM_URLENCODED_TYPE, - // String.class); -} diff --git a/src/test/java/external/composite-app-mock-services/restclient/JerseyTest.java b/src/test/java/external/composite-app-mock-services/restclient/JerseyTest.java deleted file mode 100644 index 6cee1e0..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/JerseyTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package external.services.restclient; - -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Response; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; - -import util.AuthenticateToken; - -public class JerseyTest { - - public static void main(String[] args) { - testAttendanceRegister(); - // responseREST(); - } - - String responseREST() { - // Client client =(Client) ClientBuilder.newClient(); - Client client = Client.create(); - WebResource target = client.resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - Response response = ((WebTarget) target).request("application/json").post(Entity.json(input)); - // System.out.println(response.toString()); - - return response.toString(); - } - - static void testAttendanceRegister() { - AuthenticateToken att = new AuthenticateToken(); - att.confirmAttendance(); - } - -} diff --git a/src/test/java/external/composite-app-mock-services/restclient/NetClientPost.java b/src/test/java/external/composite-app-mock-services/restclient/NetClientPost.java deleted file mode 100644 index 1e71581..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/NetClientPost.java +++ /dev/null @@ -1,56 +0,0 @@ -package external.services.restclient; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -public class NetClientPost { - - // http://localhost:8080/RESTfulExample/json/product/post - public static void main(String[] args) { - - try { - URL url = new URL("https://fahze41owc.execute-api.us-east-1.amazonaws.com/dev/user"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\r\n" + - " \"id\": \"102030\",\r\n" + - " \"firstName\": \"Julito\",\r\n" + - " \"lastName\": \"Schwartzenegger\",\r\n" + - " \"type\": \"administrator\"\r\n" + - "}"; - - OutputStream os = conn.getOutputStream(); - os.write(input.getBytes()); - os.flush(); - - if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { - throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); - } - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - String output; - System.out.println("Output from Server .... \n"); - while ((output = br.readLine()) != null) { - System.out.println(output); - } - - conn.disconnect(); - - } catch (MalformedURLException e) { - - e.printStackTrace(); - - } catch (IOException e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/restclient/TestRestClient.java b/src/test/java/external/composite-app-mock-services/restclient/TestRestClient.java deleted file mode 100644 index 8b4f929..0000000 --- a/src/test/java/external/composite-app-mock-services/restclient/TestRestClient.java +++ /dev/null @@ -1,38 +0,0 @@ -package external.services.restclient; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - -public class TestRestClient { - string AWS_URL = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"; - - public void checkServiceAvailability() { - - } - - public void testAWSConnectAPI() { - - try { - - Client client = Client.create(); - WebResource webResource = client.resource(+AWS_URL); - String input = "{\"id\":\"10295765\",\"password\":\"TestPassword!12\"}"; - ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); - - if (response.getStatus() != 201) { - throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); - } - - System.out.println("Output from Server .... \n"); - String output = response.getEntity(String.class); - System.out.println(output); - - } catch (Exception e) { - - e.printStackTrace(); - - } - } -} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GeoIP.java b/src/test/java/external/composite-app-mock-services/wsclient/GeoIP.java deleted file mode 100644 index 8a58a95..0000000 --- a/src/test/java/external/composite-app-mock-services/wsclient/GeoIP.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Class GeoIP imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package external.services.wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for GeoIP complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType name="GeoIP">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="ReturnCode" type="{http://www.w3.org/2001/XMLSchema}int"/>
- *         <element name="IP" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="ReturnCodeDetails" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="CountryName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="CountryCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "GeoIP", propOrder = { - "returnCode", - "ip", - "returnCodeDetails", - "countryName", - "countryCode" -}) -public class GeoIP { - - @XmlElement(name = "ReturnCode") - protected int returnCode; - @XmlElement(name = "IP") - protected String ip; - @XmlElement(name = "ReturnCodeDetails") - protected String returnCodeDetails; - @XmlElement(name = "CountryName") - protected String countryName; - @XmlElement(name = "CountryCode") - protected String countryCode; - - /** - * Gets the value of the returnCode property. - * - */ - public int getReturnCode() { - return returnCode; - } - - /** - * Sets the value of the returnCode property. - * - */ - public void setReturnCode(int value) { - this.returnCode = value; - } - - /** - * Gets the value of the ip property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIP() { - return ip; - } - - /** - * Sets the value of the ip property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIP(String value) { - this.ip = value; - } - - /** - * Gets the value of the returnCodeDetails property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getReturnCodeDetails() { - return returnCodeDetails; - } - - /** - * Sets the value of the returnCodeDetails property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setReturnCodeDetails(String value) { - this.returnCodeDetails = value; - } - - /** - * Gets the value of the countryName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCountryName() { - return countryName; - } - - /** - * Sets the value of the countryName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCountryName(String value) { - this.countryName = value; - } - - /** - * Gets the value of the countryCode property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCountryCode() { - return countryCode; - } - - /** - * Sets the value of the countryCode property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCountryCode(String value) { - this.countryCode = value; - } - -} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GeoIPService.java b/src/test/java/external/composite-app-mock-services/wsclient/GeoIPService.java deleted file mode 100644 index 718e2c7..0000000 --- a/src/test/java/external/composite-app-mock-services/wsclient/GeoIPService.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Class GeoIPService imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package external.services.wsclient; - -import java.net.MalformedURLException; -import java.net.URL; -import javax.xml.namespace.QName; -import javax.xml.ws.Service; -import javax.xml.ws.WebEndpoint; -import javax.xml.ws.WebServiceClient; -import javax.xml.ws.WebServiceException; -import javax.xml.ws.WebServiceFeature; - -/** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.9-b130926.1035 - * Generated source version: 2.2 - * - */ -@WebServiceClient(name = "GeoIPService", targetNamespace = "http://www.webservicex.net/", wsdlLocation = "http://www.webservicex.net/geoipservice.asmx?WSDL") -public class GeoIPService - extends Service { - - private final static URL GEOIPSERVICE_WSDL_LOCATION; - private final static WebServiceException GEOIPSERVICE_EXCEPTION; - private final static QName GEOIPSERVICE_QNAME = new QName("http://www.webservicex.net/", "GeoIPService"); - - static { - URL url = null; - WebServiceException e = null; - try { - url = new URL("http://www.webservicex.net/geoipservice.asmx?WSDL"); - } catch (MalformedURLException ex) { - e = new WebServiceException(ex); - } - GEOIPSERVICE_WSDL_LOCATION = url; - GEOIPSERVICE_EXCEPTION = e; - } - - public GeoIPService() { - super(__getWsdlLocation(), GEOIPSERVICE_QNAME); - } - - public GeoIPService(WebServiceFeature... features) { - super(__getWsdlLocation(), GEOIPSERVICE_QNAME, features); - } - - public GeoIPService(URL wsdlLocation) { - super(wsdlLocation, GEOIPSERVICE_QNAME); - } - - public GeoIPService(URL wsdlLocation, WebServiceFeature... features) { - super(wsdlLocation, GEOIPSERVICE_QNAME, features); - } - - public GeoIPService(URL wsdlLocation, QName serviceName) { - super(wsdlLocation, serviceName); - } - - public GeoIPService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { - super(wsdlLocation, serviceName, features); - } - - /** - * @return - * returns GeoIPServiceSoap - */ - @WebEndpoint(name = "GeoIPServiceSoap") - public GeoIPServiceSoap getGeoIPServiceSoap() { - return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class); - } - - /** - * - * @param features - * A list of {@link javax.xml.ws.WebServiceFeature} to configure - * on the proxy. Supported features not in the - * features parameter will have their default - * values. - * @return - * returns GeoIPServiceSoap - */ - @WebEndpoint(name = "GeoIPServiceSoap") - public GeoIPServiceSoap getGeoIPServiceSoap(WebServiceFeature... features) { - return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class, - features); - } - - private static URL __getWsdlLocation() { - if (GEOIPSERVICE_EXCEPTION != null) { - throw GEOIPSERVICE_EXCEPTION; - } - return GEOIPSERVICE_WSDL_LOCATION; - } -} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java b/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java deleted file mode 100644 index d6a98d3..0000000 --- a/src/test/java/external/composite-app-mock-services/wsclient/GeoIPServiceSoap.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Class GeoIPServiceSoap imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package external.services.wsclient; - -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebResult; -import javax.jws.WebService; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.ws.RequestWrapper; -import javax.xml.ws.ResponseWrapper; - -/** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.9-b130926.1035 - * Generated source version: 2.2 - * - */ -@WebService(name = "GeoIPServiceSoap", targetNamespace = "http://www.webservicex.net/") -@XmlSeeAlso({ - ObjectFactory.class -}) -public interface GeoIPServiceSoap { - - /** - * GeoIPService - GetGeoIP enables you to easily look up countries by IP - * addresses - * - * @param ipAddress - * @return - * returns serviceClients.geoIP.GeoIP - */ - @WebMethod(operationName = "GetGeoIP", action = "http://www.webservicex.net/GetGeoIP") - @WebResult(name = "GetGeoIPResult", targetNamespace = "http://www.webservicex.net/") - @RequestWrapper(localName = "GetGeoIP", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIP") - @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPResponse") - public GeoIP getGeoIP( - @WebParam(name = "IPAddress", targetNamespace = "http://www.webservicex.net/") String ipAddress); - - /** - * GeoIPService - GetGeoIPContext enables you to easily look up countries by - * Context - * - * @return - * returns serviceClients.geoIP.GeoIP - */ - @WebMethod(operationName = "GetGeoIPContext", action = "http://www.webservicex.net/GetGeoIPContext") - @WebResult(name = "GetGeoIPContextResult", targetNamespace = "http://www.webservicex.net/") - @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPContext") - @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPContextResponse") - public GeoIP getGeoIPContext(); -} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIP.java b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIP.java deleted file mode 100644 index 821b804..0000000 --- a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIP.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Class GetGeoIP imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package external.services.wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="IPAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "ipAddress" -}) -@XmlRootElement(name = "GetGeoIP") -public class GetGeoIP { - - @XmlElement(name = "IPAddress") - protected String ipAddress; - - /** - * Gets the value of the ipAddress property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIPAddress() { - return ipAddress; - } - - /** - * Sets the value of the ipAddress property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIPAddress(String value) { - this.ipAddress = value; - } -} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContext.java b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContext.java deleted file mode 100644 index c1a2d5a..0000000 --- a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContext.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Class GetGeoIPContext imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package external.services.wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "") -@XmlRootElement(name = "GetGeoIPContext") -public class GetGeoIPContext { - -} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContextResponse.java b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContextResponse.java deleted file mode 100644 index 7d94432..0000000 --- a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPContextResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Class getGeoIPContextResult imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package external.services.wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="GetGeoIPContextResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "getGeoIPContextResult" -}) -@XmlRootElement(name = "GetGeoIPContextResponse") -public class GetGeoIPContextResponse { - - @XmlElement(name = "GetGeoIPContextResult") - protected GeoIP getGeoIPContextResult; - - /** - * Gets the value of the getGeoIPContextResult property. - * - * @return - * possible object is - * {@link GeoIP } - * - */ - public GeoIP getGetGeoIPContextResult() { - return getGeoIPContextResult; - } - - /** - * Sets the value of the getGeoIPContextResult property. - * - * @param value - * allowed object is - * {@link GeoIP } - * - */ - public void setGetGeoIPContextResult(GeoIP value) { - this.getGeoIPContextResult = value; - } - -} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPResponse.java b/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPResponse.java deleted file mode 100644 index 8ce29b2..0000000 --- a/src/test/java/external/composite-app-mock-services/wsclient/GetGeoIPResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Class getGeoIPResult imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package external.services.wsclient; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="GetGeoIPResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "getGeoIPResult" -}) -@XmlRootElement(name = "GetGeoIPResponse") -public class GetGeoIPResponse { - - @XmlElement(name = "GetGeoIPResult") - protected GeoIP getGeoIPResult; - - /** - * Gets the value of the getGeoIPResult property. - * - * @return - * possible object is - * {@link GeoIP } - * - */ - public GeoIP getGetGeoIPResult() { - return getGeoIPResult; - } - - /** - * Sets the value of the getGeoIPResult property. - * - * @param value - * allowed object is - * {@link GeoIP } - * - */ - public void setGetGeoIPResult(GeoIP value) { - this.getGeoIPResult = value; - } -} \ No newline at end of file diff --git a/src/test/java/external/composite-app-mock-services/wsclient/ObjectFactory.java b/src/test/java/external/composite-app-mock-services/wsclient/ObjectFactory.java deleted file mode 100644 index f94606f..0000000 --- a/src/test/java/external/composite-app-mock-services/wsclient/ObjectFactory.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Class ObjectFactory imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package external.services.wsclient; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the wsclient package. - *

- * An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private final static QName _GeoIP_QNAME = new QName("http://www.webservicex.net/", "GeoIP"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema - * derived classes for package: wsclient - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link GeoIP } - * - */ - public GeoIP createGeoIP() { - return new GeoIP(); - } - - /** - * Create an instance of {@link GetGeoIP } - * - */ - public GetGeoIP createGetGeoIP() { - return new GetGeoIP(); - } - - /** - * Create an instance of {@link GetGeoIPResponse } - * - */ - public GetGeoIPResponse createGetGeoIPResponse() { - return new GetGeoIPResponse(); - } - - /** - * Create an instance of {@link GetGeoIPContextResponse } - * - */ - public GetGeoIPContextResponse createGetGeoIPContextResponse() { - return new GetGeoIPContextResponse(); - } - - /** - * Create an instance of {@link GetGeoIPContext } - * - */ - public GetGeoIPContext createGetGeoIPContext() { - return new GetGeoIPContext(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link GeoIP }{@code >}} - * - */ - @XmlElementDecl(namespace = "http://www.webservicex.net/", name = "GeoIP") - public JAXBElement createGeoIP(GeoIP value) { - return new JAXBElement(_GeoIP_QNAME, GeoIP.class, null, value); - } - -} diff --git a/src/test/java/external/composite-app-mock-services/wsclient/package-info.java b/src/test/java/external/composite-app-mock-services/wsclient/package-info.java deleted file mode 100644 index a7a776e..0000000 --- a/src/test/java/external/composite-app-mock-services/wsclient/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * injects annotation for java tool to work and invoke the WSDL - */ - -@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.webservicex.net/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package external.services.wsclient; diff --git a/src/test/java/external/composite-app-mock-services/wsdlclient/MockCountryInfoService.java b/src/test/java/external/composite-app-mock-services/wsdlclient/MockCountryInfoService.java deleted file mode 100644 index a1f9c31..0000000 --- a/src/test/java/external/composite-app-mock-services/wsdlclient/MockCountryInfoService.java +++ /dev/null @@ -1,16 +0,0 @@ -import org.apache.cxf.jaxws.JaxWsServerFactoryBean; -import org.example.countryinfo.CountryInfoService; - -public class MockCountryInfoService implements CountryInfoService { - // Implement the methods from the CountryInfoService interface here - - public static void main(String[] args) { - MockCountryInfoService mockService = new MockCountryInfoService(); - - JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); - factory.setServiceClass(CountryInfoService.class); - factory.setAddress("http://localhost:8080/"); - factory.setServiceBean(mockService); - factory.create(); - } -} diff --git a/src/test/java/external/composite-app-mock-services/wsdlclient/ServiceInvokationTest.java b/src/test/java/external/composite-app-mock-services/wsdlclient/ServiceInvokationTest.java deleted file mode 100644 index fd7800b..0000000 --- a/src/test/java/external/composite-app-mock-services/wsdlclient/ServiceInvokationTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package external.services.wsdlclient; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import service.MainService; -import util.AuthenticateToken; - -public class ServiceInvokationTest { - - MainService testService = new MainService(); - AuthenticateToken attend = new AuthenticateToken(); - - @Test - public void testWSDLSuccess() { - - assertTrue(testService.invokeWSDLForIP().length() > 2); - // System.out.println(testService.invokeWSDLForIP()); - } - - @Test - public void testRestBibleSuccess() { - assertTrue(testService.invokeRestForBibleVerse().length() > 2); - // System.out.println(testService.invokeRestForBibleVerse()); - } -} diff --git a/src/test/java/json/Json2Map.java b/src/test/java/json/Json2Map.java deleted file mode 100644 index 638d64a..0000000 --- a/src/test/java/json/Json2Map.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.json; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -public class Json2Map { - - public static void main(String[] args) { - String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImp0aSI6ImI4MzY3ZjcwLTA5MDktNGI0Mi1hNDI2LWM2ZTYyY2M3ZTI0YSIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.jfGvw9FX5-XBcVVaY21wL7F7Y6KRzRdLweCybx819JdRES2f-m4qGeftAZdzoRuLDJ4QfbGqJdJ1V19MKcw070qdz_zd3JFMo3ev9-1yrzQ9vr9hQR6Utk7cBLs_AGQlXHt2wNimvW7mPj_yyyjLa5LTveX0W-hZ5ZG2FSuiAE6dTmmSZs-FEjwZRPTNbjDVKHHr8QRBFq43gg23PkRCAriLO02ymrVblKCx_kqKvYbvNed_RB0IeGZP_Ll27F34-xdZz6r_zAcgxvOqafa5wPAbOvgCubE_rW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p1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.N2vUTeKskoSGGnZNNQkoJrjqQSTwCRsAyoVzU8HoSESciE97PbHu_rsDBHdlIvExQgZOJUDH2fi2ZTVXL0qw_dw_1oy5PY0ss6iF9Ya8vNvwJ4QIg0nGLJEEWO6y9h81bUiy8WYOyC0uCy4FKPBzxu-VjO_ZkJwQZLlhkx56cPXhQI9JFbwQDeyxJDF9duOGiZkWYmiG842TeYpaNIiW46KtQ8kiZLGre9qUdPjQv9S-Ch9Cm8bDqVSunAVtTityUJMGJuxhM78hPAujGdeNfMX0qEx37MpKbQtkb_xJZaT1c0IXnu1tneqtGVxZtaZdQ4mUlBmdzamQaWhlSXvqyA\"}}"; - - Gson gson = new Gson(); - - Type authorization = new TypeToken>() { - }.getType(); - - Map authorizationMap = gson.fromJson(jsonFromMS, authorization); - - Map retMap = new Gson().fromJson(jsonFromMS, new TypeToken>() { - }.getType()); - - Map map = new Gson().fromJson(jsonFromMS, new TypeToken>() { - }.getType()); - - System.out.println("Printing Map object: " + authorizationMap.values().toString()); - authorizationMap.keySet().iterator().forEachRemaining(System.out::println); - System.out.println("Printing ret Map object this is bringing the values: " + retMap.values().toString()); - map.keySet().iterator().forEachRemaining(System.out::println); - System.out.println(retMap.get("IdToken")); - - } -} diff --git a/src/test/java/json/ConversionJSON2Object.java b/src/test/java/json/TestConversionJSON2Object.java similarity index 99% rename from src/test/java/json/ConversionJSON2Object.java rename to src/test/java/json/TestConversionJSON2Object.java index d699a45..f2e23a5 100644 --- a/src/test/java/json/ConversionJSON2Object.java +++ b/src/test/java/json/TestConversionJSON2Object.java @@ -4,7 +4,7 @@ import entity.LoginReply; -public class ConversionJSON2Object { +public class TestConversionJSON2Object { public static void main(String[] args) { // TODO Auto-generated method stub: use a variable for the token diff --git a/src/test/java/json/ConversionJson2Map.java b/src/test/java/json/TestConversionJson2Map.java similarity index 50% rename from src/test/java/json/ConversionJson2Map.java rename to src/test/java/json/TestConversionJson2Map.java index cbe36b8..1376f2e 100644 --- a/src/test/java/json/ConversionJson2Map.java +++ b/src/test/java/json/TestConversionJson2Map.java @@ -3,12 +3,11 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import entity.Authorization; - import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; -public class ConversionJson2Map { +public class TestConversionJson2Map { public void convertJSON2Map() { String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImp0aSI6ImI4MzY3ZjcwLTA5MDktNGI0Mi1hNDI2LWM2ZTYyY2M3ZTI0YSIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.jfGvw9FX5-XBcVVaY21wL7F7Y6KRzRdLweCybx819JdRES2f-m4qGeftAZdzoRuLDJ4QfbGqJdJ1V19MKcw070qdz_zd3JFMo3ev9-1yrzQ9vr9hQR6Utk7cBLs_AGQlXHt2wNimvW7mPj_yyyjLa5LTveX0W-hZ5ZG2FSuiAE6dTmmSZs-FEjwZRPTNbjDVKHHr8QRBFq43g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pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.N2vUTeKskoSGGnZNNQkoJrjqQSTwCRsAyoVzU8HoSESciE97PbHu_rsDBHdlIvExQgZOJUDH2fi2ZTVXL0qw_dw_1oy5PY0ss6iF9Ya8vNvwJ4QIg0nGLJEEWO6y9h81bUiy8WYOyC0uCy4FKPBzxu-VjO_ZkJwQZLlhkx56cPXhQI9JFbwQDeyxJDF9duOGiZkWYmiG842TeYpaNIiW46KtQ8kiZLGre9qUdPjQv9S-Ch9Cm8bDqVSunAVtTityUJMGJuxhM78hPAujGdeNfMX0qEx37MpKbQtkb_xJZaT1c0IXnu1tneqtGVxZtaZdQ4mUlBmdzamQaWhlSXvqyA\"}}"; @@ -34,4 +33,27 @@ public void convertJSON2Map() { System.out.println(retMap.get("IdToken")); } + + public void convertJSONtoMapStructure() { + String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImp0aSI6ImI4MzY3Z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vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTA4NTg2OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.N2vUTeKskoSGGnZNNQkoJrjqQSTwCRsAyoVzU8HoSESciE97PbHu_rsDBHdlIvExQgZOJUDH2fi2ZTVXL0qw_dw_1oy5PY0ss6iF9Ya8vNvwJ4QIg0nGLJEEWO6y9h81bUiy8WYOyC0uCy4FKPBzxu-VjO_ZkJwQZLlhkx56cPXhQI9JFbwQDeyxJDF9duOGiZkWYmiG842TeYpaNIiW46KtQ8kiZLGre9qUdPjQv9S-Ch9Cm8bDqVSunAVtTityUJMGJuxhM78hPAujGdeNfMX0qEx37MpKbQtkb_xJZaT1c0IXnu1tneqtGVxZtaZdQ4mUlBmdzamQaWhlSXvqyA\"}}"; + + Gson gson = new Gson(); + + Type authorization = new TypeToken>() { + }.getType(); + + Map authorizationMap = gson.fromJson(jsonFromMS, authorization); + + Map retMap = new Gson().fromJson(jsonFromMS, new TypeToken>() { + }.getType()); + + Map map = new Gson().fromJson(jsonFromMS, new TypeToken>() { + }.getType()); + + System.out.println("Printing Map object: " + authorizationMap.values().toString()); + authorizationMap.keySet().iterator().forEachRemaining(System.out::println); + System.out.println("Printing ret Map object this is bringing the values: " + retMap.values().toString()); + map.keySet().iterator().forEachRemaining(System.out::println); + System.out.println(retMap.get("IdToken")); + } } diff --git a/src/test/java/json/JSON2Object.java b/src/test/java/json/TestJSON2YAML.java similarity index 99% rename from src/test/java/json/JSON2Object.java rename to src/test/java/json/TestJSON2YAML.java index 9f46c05..64acb2b 100644 --- a/src/test/java/json/JSON2Object.java +++ b/src/test/java/json/TestJSON2YAML.java @@ -2,7 +2,7 @@ import com.google.gson.Gson; -public class JSON2Object { +public class TestJSON2YAML { public static void main(String[] args) { String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1MTc5MyIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.ZGB_kCYoU4vDREr6teZQyIyRT2MZkpmGyleAgsgzMRIauq7RpqgL_HUZukqSK6E5mtNxux6hihzl5CaP9jcY26u4zJTnYASBJwE4iqqggNqhp82PtFdxipf5ZvYAyF3uVTPCeiRGrxJSyoQp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lbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTExNzEzNSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.gGcx2YYcjWzNvzlpPklry4Jt59GwDQuDRRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; diff --git a/src/test/java/serviceClients/ServiceInvokationTest.java b/src/test/java/serviceClients/ServiceInvokationTest.java deleted file mode 100644 index 4e00ce1..0000000 --- a/src/test/java/serviceClients/ServiceInvokationTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package serviceClients; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import bean.AttendanceRegister; -import service.MainService; - -public class ServiceInvokationTest { - - MainService testService = new MainService(); - AttendanceRegister attend = new AttendanceRegister(); - - @Test - public void testWSDLSuccess() { - assertTrue(testService.invokeWSDLForIP().length() > 2); - // System.out.println(testService.invokeWSDLForIP()); - } - - @Test - public void testRestBibleSuccess() { - assertTrue(testService.invokeRestForBibleVerse().length() > 2); - // System.out.println(testService.invokeRestForBibleVerse()); - } -} diff --git a/src/test/java/serviceClients/rest/JerseyAttendance.java b/src/test/java/serviceClients/rest/JerseyAttendance.java deleted file mode 100644 index 1f03338..0000000 --- a/src/test/java/serviceClients/rest/JerseyAttendance.java +++ /dev/null @@ -1,35 +0,0 @@ -package serviceClients.rest; - -import bean.AttendanceRegister; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; - -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Response; - -public class JerseyTest { - - public static void main(String[] args) { - testAttendanceRegister(); - // responseREST(); - } - - String responseREST() { - // Client client =(Client) ClientBuilder.newClient(); - Client client = Client.create(); - WebResource target = client.resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - Response response = ((WebTarget) target).request("application/json").post(Entity.json(input)); - // System.out.println(response.toString()); - - return response.toString(); - } - - static void testAttendanceRegister() { - AttendanceRegister att = new AttendanceRegister(); - att.confirmAttendance(); - } - -} diff --git a/src/test/java/serviceClients/rest/JerseyClientAuthLogin.java b/src/test/java/serviceClients/rest/JerseyClientAuthLogin.java deleted file mode 100644 index d49e9c4..0000000 --- a/src/test/java/serviceClients/rest/JerseyClientAuthLogin.java +++ /dev/null @@ -1,32 +0,0 @@ -package serviceClients.rest; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - -public class JerseyClientAuthLogin { - - public static void main(String[] args) { - - try { - Client client = Client.create(); - WebResource webResource = client.resource("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); - - if (response.getStatus() != 201) { - throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); - } - - System.out.println("Output from Server .... \n"); - String output = response.getEntity(String.class); - System.out.println(output); - - } catch (Exception e) { - - e.printStackTrace(); - - } - } -} \ No newline at end of file diff --git a/src/test/java/serviceClients/rest/JerseyGetSession.java b/src/test/java/serviceClients/rest/JerseyGetSession.java deleted file mode 100644 index 22ce803..0000000 --- a/src/test/java/serviceClients/rest/JerseyGetSession.java +++ /dev/null @@ -1,37 +0,0 @@ -package serviceClients.rest; - -import java.io.IOException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriBuilder; -import org.apache.http.client.ClientProtocolException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - -public class JerseyGetSession { - - /** - * @param args - * @throws ClientProtocolException - * @throws IOException - */ - public static void main(String[] args) throws ClientProtocolException, IOException { - - ClientConfig config = new DefaultClientConfig(); - Client client = Client.create(config); - - WebResource service = client - .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com").build()); - - // getting JSON data - System.out.println("With JSON" + service.path("dev").path("session").accept(MediaType.APPLICATION_JSON).header( - "Authorization", - "eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTAyMTU0OSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MDI1MTQ5LCJpYXQiOjE1MDUwMjE1NDksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.pL9EmmsbB-pxTCXRmDmAAnfMBhLgEY39tbNf0LMhHWF_sSFTB6gYELxnfNa3ITMEEV_wwgvJ-9USb3nHh1G8JkNDxDVCS0S0q4U81GZDqA8USGzA4mklTg1qROlHQkKFipaKQia8U9oLZSIGp6HrpvtQN7wOm9S_0Z5ePXN2REgYsWKobfkLI3dHICACt0RANRBLlXNlQC1F8Hj7dl7UbeQkCZqgj_J_GcxHHLHBRRERO4Koz09gYBhpVrWZZlbUJpwAk3OVCesj7Wz73xjpE2ckm9x6SLkzxC8W5FLvyH5rbiD7Dif9xIVB6jV1pz9GIwMGqzcSWT0LIujw90hoNg") - .get(String.class)); - - // getting XML data - // System.out.println("with - // XML"+service.path("dev").path("session").accept(MediaType.APPLICATION_XML).get(String.class)); - } -} \ No newline at end of file diff --git a/src/test/java/serviceClients/rest/JerseyJSONAuthorizationResponse.java b/src/test/java/serviceClients/rest/JerseyJSONAuthorizationResponse.java deleted file mode 100644 index 756133b..0000000 --- a/src/test/java/serviceClients/rest/JerseyJSONAuthorizationResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package serviceClients.rest; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - -public class JerseyJSONAuthorizationResponse { - - public static void main(String[] args) { - try { - String baseuri = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login/"; - Client client = Client.create(); - - WebResource webResource = client.resource(baseuri); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - // POST method - ClientResponse response = webResource.accept("application/json").type("type:application/json") - .post(ClientResponse.class, input); - - // check response status code - if (response.getStatus() != 200) { - throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); - } - - // display response - String output = response.getEntity(String.class); - System.out.println("Output from Server .... "); - System.out.println(output + "\n"); - } catch (Exception e) { - e.printStackTrace(); - } - - } // main() -} diff --git a/src/test/java/serviceClients/rest/JerseyJsonSimpleLogin.java b/src/test/java/serviceClients/rest/JerseyJsonSimpleLogin.java deleted file mode 100644 index 78a8114..0000000 --- a/src/test/java/serviceClients/rest/JerseyJsonSimpleLogin.java +++ /dev/null @@ -1,28 +0,0 @@ -package serviceClients.rest; - -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.representation.Form; - -public class JerseyJsonSimpleLogin { - - public static void main(String[] args) { - - try { - Client client = (Client) ClientBuilder.newClient(); - WebTarget target = ((javax.ws.rs.client.Client) client).target("http://localhost:9998").path("resource"); - - Form form = new Form(); - form.add("id", "10295765"); - form.add("password", "Value!12"); - // ClientResponse response = - // WebResource.class.type(MediaType.TEXT_PLAIN).post(ClientResponse.class, - // form); - } catch (Exception e) { - e.printStackTrace(); - } - - } -} \ No newline at end of file diff --git a/src/test/java/serviceClients/rest/JerseyPostLogin.java b/src/test/java/serviceClients/rest/JerseyPostLogin.java deleted file mode 100644 index 5499218..0000000 --- a/src/test/java/serviceClients/rest/JerseyPostLogin.java +++ /dev/null @@ -1,36 +0,0 @@ -package serviceClients.rest; - -import java.io.IOException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; -import org.apache.http.client.ClientProtocolException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -public class JerseyPostLogin { - - public static void main(String[] args) throws ClientProtocolException, IOException { - - ClientConfig config = new DefaultClientConfig(); - - Client client = Client.create(config); - - WebResource webResource = client - .resource(UriBuilder.fromUri("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/").build()); - - MultivaluedMap formData = new MultivaluedMapImpl(); - - formData.add("id", "10295765"); - formData.add("password", "Value!12"); - - ClientResponse response = webResource.path("dev").path("login").type(MediaType.APPLICATION_FORM_URLENCODED) - .post(ClientResponse.class, formData); - - System.out.println("Response " + response.getEntity(String.class)); - } -} diff --git a/src/test/java/serviceClients/rest/NetClientPostUserLogin.java b/src/test/java/serviceClients/rest/NetClientPostUserLogin.java deleted file mode 100644 index 505c40b..0000000 --- a/src/test/java/serviceClients/rest/NetClientPostUserLogin.java +++ /dev/null @@ -1,56 +0,0 @@ -package serviceClients.rest; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -public class NetClientPostUserLogin { - - // http://localhost:8080/RESTfulExample/json/product/post - public static void main(String[] args) { - - try { - URL url = new URL("https://fahze41owc.execute-api.us-east-1.amazonaws.com/dev/user"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\r\n" + - " \"id\": \"102030\",\r\n" + - " \"firstName\": \"Julito\",\r\n" + - " \"lastName\": \"Schwartzenegger\",\r\n" + - " \"type\": \"administrator\"\r\n" + - "}"; - - OutputStream os = conn.getOutputStream(); - os.write(input.getBytes()); - os.flush(); - - if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { - throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); - } - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - String output; - System.out.println("Output from Server .... \n"); - while ((output = br.readLine()) != null) { - System.out.println(output); - } - - conn.disconnect(); - - } catch (MalformedURLException e) { - - e.printStackTrace(); - - } catch (IOException e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/src/test/java/serviceClients/rest/PostAuthToken.java b/src/test/java/serviceClients/rest/PostAuthToken.java deleted file mode 100644 index 73948d4..0000000 --- a/src/test/java/serviceClients/rest/PostAuthToken.java +++ /dev/null @@ -1,84 +0,0 @@ -package serviceClients.rest; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonReader; - -public class PostAuthToken { - - // authentication scheme based on tokens follow these steps, steps are numbered - public static void main(String[] args) { - - try { - URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - OutputStream os = conn.getOutputStream(); - // 1.The client sends their credentials (username and password) to the server. - os.write(input.getBytes()); - os.flush(); - - if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { - throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); - } - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - String output; - // 2.The server authenticates the credentials and, if they are valid, generate a - // token for the user. - System.out.println("Output from Server .... \n"); - while ((output = br.readLine()) != null) { - JsonReader rdr = Json.createReader(br); - System.out.println("creates object"); - // rdr.readObject(); - System.out.println("obtain object" + rdr.toString()); - System.out.println("prints output " + br.readLine()); - - JsonObject obj = rdr.readObject(); - System.out.println("before reading object"); - - JsonArray results = obj.getJsonArray("AuthenticationResult"); - // obj.getJsonString(arg0) - System.out.print("value type: " + results.getValueType()); - - // for (JsonObject result : results.getValuesAs(JsonObject.class)) { - // System.out.print("value type: "+results.getValueType()); - // System.out.println("token"+ result.getString("IdToken")); - // } - - System.out.println(output); - } // end of while - - System.out.println("prints output 1" + br.readLine()); - - /// put object in hashmap somehow - - // disconnects - conn.disconnect(); - - } catch (MalformedURLException e) { - - e.printStackTrace(); - - } catch (IOException e) { - - e.printStackTrace(); - - } - } -} \ No newline at end of file diff --git a/src/test/java/serviceClients/rest/TestJSONResponse.java b/src/test/java/serviceClients/rest/TestJSONResponse.java deleted file mode 100644 index fec4be0..0000000 --- a/src/test/java/serviceClients/rest/TestJSONResponse.java +++ /dev/null @@ -1,62 +0,0 @@ -package jersey; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import javax.json.Json; -import javax.json.stream.JsonParser; -import javax.json.stream.JsonParser.Event; - -public class TestJSONResponse { - - public static void main(String[] args) throws MalformedURLException { - // URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); - // URL url = new - // URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - - // try (InputStream is = url.openStream(); JsonParser parser = - // Json.createParser(is)) { - try { - URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - OutputStream os = conn.getOutputStream(); - // 1.The client sends their credentials (username and password) to the server. - os.write(input.getBytes()); - os.flush(); - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - JsonParser parser = (JsonParser) Json.createReader(br); - - while (parser.hasNext()) { - Event e = parser.next(); - if (e == Event.KEY_NAME) { - switch (parser.getString()) { - case "RefreshToken": - parser.next(); - System.out.print(parser.getString()); - System.out.print(": "); - break; - case "IdToken": - parser.next(); - System.out.println(parser.getString()); - System.out.println("---------"); - break; - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/test/java/serviceClients/rest/TestRestClient.java b/src/test/java/serviceClients/rest/TestRestClient.java deleted file mode 100644 index 342011d..0000000 --- a/src/test/java/serviceClients/rest/TestRestClient.java +++ /dev/null @@ -1,38 +0,0 @@ -package rest; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - -public class TestRestClient { - string AWS_URL = "https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"; - - public void checkServiceAvailability() { - - } - - public void testAWSConnectAPI() { - - try { - - Client client = Client.create(); - WebResource webResource = client.resource(+AWS_URL); - String input = "{\"id\":\"10295765\",\"password\":\"TestPassword!12\"}"; - ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input); - - if (response.getStatus() != 201) { - throw new RuntimeException("Failed : HTTP error code : " - + response.getStatus()); - } - - System.out.println("Output from Server .... \n"); - String output = response.getEntity(String.class); - System.out.println(output); - - } catch (Exception e) { - - e.printStackTrace(); - - } - } -} diff --git a/src/test/java/serviceClients/soap/geoIP/GeoIP.java b/src/test/java/serviceClients/soap/geoIP/GeoIP.java deleted file mode 100644 index daa1a2d..0000000 --- a/src/test/java/serviceClients/soap/geoIP/GeoIP.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Class GeoIP imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package serviceClients.soap.geoIP; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for GeoIP complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType name="GeoIP">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="ReturnCode" type="{http://www.w3.org/2001/XMLSchema}int"/>
- *         <element name="IP" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="ReturnCodeDetails" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="CountryName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="CountryCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "GeoIP", propOrder = { - "returnCode", - "ip", - "returnCodeDetails", - "countryName", - "countryCode" -}) -public class GeoIP { - - @XmlElement(name = "ReturnCode") - protected int returnCode; - @XmlElement(name = "IP") - protected String ip; - @XmlElement(name = "ReturnCodeDetails") - protected String returnCodeDetails; - @XmlElement(name = "CountryName") - protected String countryName; - @XmlElement(name = "CountryCode") - protected String countryCode; - - /** - * Gets the value of the returnCode property. - * - */ - public int getReturnCode() { - return returnCode; - } - - /** - * Sets the value of the returnCode property. - * - */ - public void setReturnCode(int value) { - this.returnCode = value; - } - - /** - * Gets the value of the ip property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIP() { - return ip; - } - - /** - * Sets the value of the ip property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIP(String value) { - this.ip = value; - } - - /** - * Gets the value of the returnCodeDetails property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getReturnCodeDetails() { - return returnCodeDetails; - } - - /** - * Sets the value of the returnCodeDetails property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setReturnCodeDetails(String value) { - this.returnCodeDetails = value; - } - - /** - * Gets the value of the countryName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCountryName() { - return countryName; - } - - /** - * Sets the value of the countryName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCountryName(String value) { - this.countryName = value; - } - - /** - * Gets the value of the countryCode property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCountryCode() { - return countryCode; - } - - /** - * Sets the value of the countryCode property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCountryCode(String value) { - this.countryCode = value; - } - -} diff --git a/src/test/java/serviceClients/soap/geoIP/GeoIPService.java b/src/test/java/serviceClients/soap/geoIP/GeoIPService.java deleted file mode 100644 index 474ca00..0000000 --- a/src/test/java/serviceClients/soap/geoIP/GeoIPService.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Class GeoIPService imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package serviceClients.soap.geoIP; - -import java.net.MalformedURLException; -import java.net.URL; -import javax.xml.namespace.QName; -import javax.xml.ws.Service; -import javax.xml.ws.WebEndpoint; -import javax.xml.ws.WebServiceClient; -import javax.xml.ws.WebServiceException; -import javax.xml.ws.WebServiceFeature; - -/** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.9-b130926.1035 - * Generated source version: 2.2 - */ -@WebServiceClient(name = "GeoIPService", targetNamespace = "http://www.webservicex.net/", wsdlLocation = "http://www.webservicex.net/geoipservice.asmx?WSDL") -public class GeoIPService - extends Service { - - private final static URL GEOIPSERVICE_WSDL_LOCATION; - private final static WebServiceException GEOIPSERVICE_EXCEPTION; - private final static QName GEOIPSERVICE_QNAME = new QName("http://www.webservicex.net/", "GeoIPService"); - - static { - URL url = null; - WebServiceException e = null; - try { - url = new URL("http://www.webservicex.net/geoipservice.asmx?WSDL"); - } catch (MalformedURLException ex) { - e = new WebServiceException(ex); - } - GEOIPSERVICE_WSDL_LOCATION = url; - GEOIPSERVICE_EXCEPTION = e; - } - - public GeoIPService() { - super(__getWsdlLocation(), GEOIPSERVICE_QNAME); - } - - public GeoIPService(WebServiceFeature... features) { - super(__getWsdlLocation(), GEOIPSERVICE_QNAME, features); - } - - public GeoIPService(URL wsdlLocation) { - super(wsdlLocation, GEOIPSERVICE_QNAME); - } - - public GeoIPService(URL wsdlLocation, WebServiceFeature... features) { - super(wsdlLocation, GEOIPSERVICE_QNAME, features); - } - - public GeoIPService(URL wsdlLocation, QName serviceName) { - super(wsdlLocation, serviceName); - } - - public GeoIPService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { - super(wsdlLocation, serviceName, features); - } - - /** - * @return - * returns GeoIPServiceSoap - */ - @WebEndpoint(name = "GeoIPServiceSoap") - public GeoIPServiceSoap getGeoIPServiceSoap() { - return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class); - } - - /** - * - * @param features - * A list of {@link javax.xml.ws.WebServiceFeature} to configure - * on the proxy. Supported features not in the - * features parameter will have their default - * values. - * @return - * returns GeoIPServiceSoap - */ - @WebEndpoint(name = "GeoIPServiceSoap") - public GeoIPServiceSoap getGeoIPServiceSoap(WebServiceFeature... features) { - return super.getPort(new QName("http://www.webservicex.net/", "GeoIPServiceSoap"), GeoIPServiceSoap.class, - features); - } - - private static URL __getWsdlLocation() { - if (GEOIPSERVICE_EXCEPTION != null) { - throw GEOIPSERVICE_EXCEPTION; - } - return GEOIPSERVICE_WSDL_LOCATION; - } -} diff --git a/src/test/java/serviceClients/soap/geoIP/GeoIPServiceSoap.java b/src/test/java/serviceClients/soap/geoIP/GeoIPServiceSoap.java deleted file mode 100644 index 110a680..0000000 --- a/src/test/java/serviceClients/soap/geoIP/GeoIPServiceSoap.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Class GeoIPServiceSoap imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package serviceClients.soap.geoIP; - -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebResult; -import javax.jws.WebService; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.ws.RequestWrapper; -import javax.xml.ws.ResponseWrapper; - -/** - * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.2.9-b130926.1035 - * Generated source version: 2.2 - * - */ -@WebService(name = "GeoIPServiceSoap", targetNamespace = "http://www.webservicex.net/") -@XmlSeeAlso({ - ObjectFactory.class -}) -public interface GeoIPServiceSoap { - - /** - * GeoIPService - GetGeoIP enables you to easily look up countries by IP - * addresses - * - * @param ipAddress - * @return - * returns serviceClients.geoIP.GeoIP - */ - @WebMethod(operationName = "GetGeoIP", action = "http://www.webservicex.net/GetGeoIP") - @WebResult(name = "GetGeoIPResult", targetNamespace = "http://www.webservicex.net/") - @RequestWrapper(localName = "GetGeoIP", targetNamespace = "http://www.webservicex.net/", className = "wsclient.GetGeoIP") - @ResponseWrapper(localName = "GetGeoIPResponse", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPResponse") - public GeoIP getGeoIP( - @WebParam(name = "IPAddress", targetNamespace = "http://www.webservicex.net/") String ipAddress); - - /** - * GeoIPService - GetGeoIPContext enables you to easily look up countries by - * Context - * - * @return - * returns serviceClients.geoIP.GeoIP - */ - @WebMethod(operationName = "GetGeoIPContext", action = "http://www.webservicex.net/GetGeoIPContext") - @WebResult(name = "GetGeoIPContextResult", targetNamespace = "http://www.webservicex.net/") - @RequestWrapper(localName = "GetGeoIPContext", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPContext") - @ResponseWrapper(localName = "GetGeoIPContextResponse", targetNamespace = "http://www.webservicex.net/", className = "serviceClients.geoIP.GetGeoIPContextResponse") - public GeoIP getGeoIPContext(); -} diff --git a/src/test/java/serviceClients/soap/geoIP/GetGeoIP.java b/src/test/java/serviceClients/soap/geoIP/GetGeoIP.java deleted file mode 100644 index 1de1760..0000000 --- a/src/test/java/serviceClients/soap/geoIP/GetGeoIP.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Class GetGeoIP imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package serviceClients.soap.geoIP; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="IPAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "ipAddress" -}) -@XmlRootElement(name = "GetGeoIP") -public class GetGeoIP { - - @XmlElement(name = "IPAddress") - protected String ipAddress; - - /** - * Gets the value of the ipAddress property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIPAddress() { - return ipAddress; - } - - /** - * Sets the value of the ipAddress property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIPAddress(String value) { - this.ipAddress = value; - } -} diff --git a/src/test/java/serviceClients/soap/geoIP/GetGeoIPContext.java b/src/test/java/serviceClients/soap/geoIP/GetGeoIPContext.java deleted file mode 100644 index 718624c..0000000 --- a/src/test/java/serviceClients/soap/geoIP/GetGeoIPContext.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Class GetGeoIPContext imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package serviceClients.soap.geoIP; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "") -@XmlRootElement(name = "GetGeoIPContext") -public class GetGeoIPContext { - -} diff --git a/src/test/java/serviceClients/soap/geoIP/GetGeoIPContextResponse.java b/src/test/java/serviceClients/soap/geoIP/GetGeoIPContextResponse.java deleted file mode 100644 index 5e6ad18..0000000 --- a/src/test/java/serviceClients/soap/geoIP/GetGeoIPContextResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Class getGeoIPContextResult imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package serviceClients.soap.geoIP; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="GetGeoIPContextResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "getGeoIPContextResult" -}) -@XmlRootElement(name = "GetGeoIPContextResponse") -public class GetGeoIPContextResponse { - - @XmlElement(name = "GetGeoIPContextResult") - protected GeoIP getGeoIPContextResult; - - /** - * Gets the value of the getGeoIPContextResult property. - * - * @return - * possible object is - * {@link GeoIP } - * - */ - public GeoIP getGetGeoIPContextResult() { - return getGeoIPContextResult; - } - - /** - * Sets the value of the getGeoIPContextResult property. - * - * @param value - * allowed object is - * {@link GeoIP } - * - */ - public void setGetGeoIPContextResult(GeoIP value) { - this.getGeoIPContextResult = value; - } - -} diff --git a/src/test/java/serviceClients/soap/geoIP/GetGeoIPResponse.java b/src/test/java/serviceClients/soap/geoIP/GetGeoIPResponse.java deleted file mode 100644 index 23694f2..0000000 --- a/src/test/java/serviceClients/soap/geoIP/GetGeoIPResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Class getGeoIPResult imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package serviceClients.soap.geoIP; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="GetGeoIPResult" type="{http://www.webservicex.net/}GeoIP" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "getGeoIPResult" -}) -@XmlRootElement(name = "GetGeoIPResponse") -public class GetGeoIPResponse { - - @XmlElement(name = "GetGeoIPResult") - protected GeoIP getGeoIPResult; - - /** - * Gets the value of the getGeoIPResult property. - * - * @return - * possible object is - * {@link GeoIP } - * - */ - public GeoIP getGetGeoIPResult() { - return getGeoIPResult; - } - - /** - * Sets the value of the getGeoIPResult property. - * - * @param value - * allowed object is - * {@link GeoIP } - * - */ - public void setGetGeoIPResult(GeoIP value) { - this.getGeoIPResult = value; - } -} \ No newline at end of file diff --git a/src/test/java/serviceClients/soap/geoIP/ObjectFactory.java b/src/test/java/serviceClients/soap/geoIP/ObjectFactory.java deleted file mode 100644 index 19d701c..0000000 --- a/src/test/java/serviceClients/soap/geoIP/ObjectFactory.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Class ObjectFactory imported from WSDL with java tool - * replicates WSDL to invoke External Web service - */ - -package serviceClients.soap.geoIP; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the wsclient package. - *

- * An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private final static QName _GeoIP_QNAME = new QName("http://www.webservicex.net/", "GeoIP"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema - * derived classes for package: wsclient - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link GeoIP } - * - */ - public GeoIP createGeoIP() { - return new GeoIP(); - } - - /** - * Create an instance of {@link GetGeoIP } - * - */ - public GetGeoIP createGetGeoIP() { - return new GetGeoIP(); - } - - /** - * Create an instance of {@link GetGeoIPResponse } - * - */ - public GetGeoIPResponse createGetGeoIPResponse() { - return new GetGeoIPResponse(); - } - - /** - * Create an instance of {@link GetGeoIPContextResponse } - * - */ - public GetGeoIPContextResponse createGetGeoIPContextResponse() { - return new GetGeoIPContextResponse(); - } - - /** - * Create an instance of {@link GetGeoIPContext } - * - */ - public GetGeoIPContext createGetGeoIPContext() { - return new GetGeoIPContext(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link GeoIP }{@code >}} - * - */ - @XmlElementDecl(namespace = "http://www.webservicex.net/", name = "GeoIP") - public JAXBElement createGeoIP(GeoIP value) { - return new JAXBElement(_GeoIP_QNAME, GeoIP.class, null, value); - } - -} diff --git a/src/test/java/serviceClients/soap/geoIP/package-info.java b/src/test/java/serviceClients/soap/geoIP/package-info.java deleted file mode 100644 index d9bc054..0000000 --- a/src/test/java/serviceClients/soap/geoIP/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * injects annotation for java tool to work and invoke the WSDL - */ - -@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.webservicex.net/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package serviceClients.soap.geoIP; diff --git a/src/test/java/wsdl/TemperatureConvertTest.java b/src/test/java/wsdl/TemperatureConvertTest.java deleted file mode 100644 index f4d20e7..0000000 --- a/src/test/java/wsdl/TemperatureConvertTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package wsdl; -import service.clients.wsdl.temperatureConvert.TempConvertSoap; -import service.clients.wsdl.temperatureConvert.TempConvert; -import org.junit.Assert; -import org.junit.Test; - -public class TemperatureConvertTest { - @Test - public void testCelsiusToFahrenheit() { - // Create an instance of the service - TempConvert service = new TempConvert(); - TempConvertSoap port = service.getTempConvertSoap(); - - // Test conversion from Celsius to Fahrenheit - String celsius = "100"; - String expectedFahrenheit = "212"; - String actualFahrenheit = port.celsiusToFahrenheit(celsius); - - // Assert that the expected Fahrenheit value matches the actual Fahrenheit value - Assert.assertEquals(expectedFahrenheit, actualFahrenheit); - } -} From 76fd47157ad00d1e2e302a4cf459d5d0613bfe27 Mon Sep 17 00:00:00 2001 From: alionranger Date: Thu, 7 Dec 2023 16:54:18 +1300 Subject: [PATCH 29/32] Create QR code website --- src/main/java/service/GenerateQRCode.java | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/service/GenerateQRCode.java diff --git a/src/main/java/service/GenerateQRCode.java b/src/main/java/service/GenerateQRCode.java new file mode 100644 index 0000000..fc03469 --- /dev/null +++ b/src/main/java/service/GenerateQRCode.java @@ -0,0 +1,24 @@ +package service; + +import java.io.IOException; +import java.nio.file.Paths; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; + +public class GenerateQRCode { + + public void createWebsiteQRCode() throws WriterException, IOException { + String qrData = "www.andres.nz"; + String localPath = "/home/aleonrangel"; + boolean validateQR = false; + + BitMatrix matrix = new MultiFormatWriter().encode(qrData, BarcodeFormat.QR_CODE, 500, 500, null); + MatrixToImageWriter.writeToPath(matrix, "png", Paths.get(localPath), null); + System.out.println("QR code created"); + validateQR = true; + } +} From 4699db8431e7b2aa4fe5ab956331714fb820aab4 Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Thu, 7 Dec 2023 21:20:59 +1300 Subject: [PATCH 30/32] Upgrade Gradle 8.5 Signed-off-by: Andres LeonRangel --- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34..1af9e09 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 0adc8e1..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -202,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ From b9e64fef000787afb59fb5c5af0e39bd2f1ab189 Mon Sep 17 00:00:00 2001 From: Andres LeonRangel Date: Thu, 7 Dec 2023 23:22:02 +1300 Subject: [PATCH 31/32] CODE Make Testing module work gradle report generates Signed-off-by: Andres LeonRangel --- docker-compose.yml | 40 ++++----- src/main/java/service/GenerateQRCode.java | 47 ++++++----- .../auth/ldap/TestLDAPAuthentication.java | 23 ++++-- src/test/java/auth/login/LoginReply.java | 2 +- .../java/json/TestConversionJSON2Object.java | 11 +-- .../java/json/TestConversionJson2Map.java | 1 + src/test/java/json/TestJSON2YAML.java | 67 ++++++++++++--- src/test/java/json/TestJSONResponse.java | 61 -------------- src/test/java/json/TestJSONToken.java | 82 +++++++++++++++++++ src/test/java/utilities/TestQRFunctions.java | 37 ++++++--- 10 files changed, 223 insertions(+), 148 deletions(-) delete mode 100644 src/test/java/json/TestJSONResponse.java create mode 100644 src/test/java/json/TestJSONToken.java diff --git a/docker-compose.yml b/docker-compose.yml index a90ecff..313827f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,20 @@ -version: '3' -services: - openldap: - # https://github.com/osixia/docker-openldap - # https://www.openldap.org - image: osixia/openldap:1.2.4 - environment: - LDAP_ORGANISATION: "IT Latinos NZ" - LDAP_DOMAIN: "latintech.org" - LDAP_ADMIN_PASSWORD: ${LDAP_ADMIN_PASS} - ports: - - 389:389 - - 636:636 - volumes: - - ./ldap:/var/lib/ldap - - ./ldap:/etc/ldap/slapd.d - webapp: - image: aleon1220/soa:latest - ports: - - 8080:8080 +version: '3' +services: + openldap: + # https://github.com/osixia/docker-openldap + # https://www.openldap.org + image: osixia/openldap:1.2.4 + environment: + LDAP_ORGANISATION: "IT Latinos NZ" + LDAP_DOMAIN: "latintech.org" + LDAP_ADMIN_PASSWORD: ${LDAP_ADMIN_PASS} + ports: + - 389:389 + - 636:636 + volumes: + - ./ldap:/var/lib/ldap + - ./ldap:/etc/ldap/slapd.d + webapp: + image: aleon1220/soa:latest + ports: + - 8080:8080 diff --git a/src/main/java/service/GenerateQRCode.java b/src/main/java/service/GenerateQRCode.java index fc03469..c4ec2c7 100644 --- a/src/main/java/service/GenerateQRCode.java +++ b/src/main/java/service/GenerateQRCode.java @@ -1,24 +1,23 @@ -package service; - -import java.io.IOException; -import java.nio.file.Paths; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatWriter; -import com.google.zxing.WriterException; -import com.google.zxing.client.j2se.MatrixToImageWriter; -import com.google.zxing.common.BitMatrix; - -public class GenerateQRCode { - - public void createWebsiteQRCode() throws WriterException, IOException { - String qrData = "www.andres.nz"; - String localPath = "/home/aleonrangel"; - boolean validateQR = false; - - BitMatrix matrix = new MultiFormatWriter().encode(qrData, BarcodeFormat.QR_CODE, 500, 500, null); - MatrixToImageWriter.writeToPath(matrix, "png", Paths.get(localPath), null); - System.out.println("QR code created"); - validateQR = true; - } -} +package service; + +import java.io.IOException; +import java.nio.file.Paths; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; + +public class GenerateQRCode { + public boolean validateQR = false; + + public void createWebsiteQRCode() throws WriterException, IOException { + String qrData = "www.andres.nz"; + String localPath = "/home/aleonrangel"; + BitMatrix matrix = new MultiFormatWriter().encode(qrData, BarcodeFormat.QR_CODE, 500, 500, null); + MatrixToImageWriter.writeToPath(matrix, "png", Paths.get(localPath), null); + System.out.println("QR code created"); + validateQR = true; + } +} diff --git a/src/test/java/auth/ldap/TestLDAPAuthentication.java b/src/test/java/auth/ldap/TestLDAPAuthentication.java index c6bcc70..f486e57 100644 --- a/src/test/java/auth/ldap/TestLDAPAuthentication.java +++ b/src/test/java/auth/ldap/TestLDAPAuthentication.java @@ -1,10 +1,15 @@ package auth.ldap; import org.junit.Test; -import org.mockito.Mockito; import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import org.mockito.Mockito; import com.unboundid.ldap.sdk.LDAPConnection; import com.unboundid.ldap.sdk.LDAPException; +import com.unboundid.ldap.sdk.LDAPSearchException; import com.unboundid.ldap.sdk.SearchRequest; import com.unboundid.ldap.sdk.SearchResult; import com.unboundid.ldap.sdk.SearchResultEntry; @@ -20,7 +25,7 @@ public class TestLDAPAuthentication { // - Verifies expected methods are called on the mocks @Test - public void testMockOpenLDAPAdminSearch() { + public void testMockOpenLDAPAdminSearch() throws LDAPSearchException { // Mock LDAPConnection LDAPConnection connectionMock = Mockito.mock(LDAPConnection.class); @@ -32,16 +37,21 @@ public void testMockOpenLDAPAdminSearch() { // Mock search result entries SearchResultEntry entry1 = Mockito.mock(SearchResultEntry.class); SearchResultEntry entry2 = Mockito.mock(SearchResultEntry.class); - + SearchResultEntry[] ldapResult = new SearchResultEntry[] { entry1, entry2 }; + List resultList = Arrays.asList(ldapResult); // Stub searchEntries to return mocked entries - Mockito.when(searchResultMock.getSearchEntries()).thenReturn(new SearchResultEntry[] { entry1, entry2 }); + Mockito.when(searchResultMock.getSearchEntries()).thenReturn(resultList); // Test the method AuthenticateOpenLDAP ldapAuth = new AuthenticateOpenLDAP(); ldapAuth.openLDAPAdminSearch(); // Verify search was called - Mockito.verify(connectionMock).search(Mockito.anyString(), Mockito.any(), Mockito.anyString()); + try { + Mockito.verify(connectionMock).search(Mockito.anyString(), Mockito.any(), Mockito.anyString()); + } catch (LDAPSearchException e) { + e.printStackTrace(); + } // Verify entry processing Mockito.verify(entry1).toLDIFString(); @@ -53,7 +63,6 @@ public void testMockOpenLDAPAdminSearch() { @Test public void testOpenLDAPAdminSearch_withOpenLDAP() { - // Test parameters String ldapURL = "ldap://localhost"; String ldapHost = "localhost"; @@ -61,7 +70,7 @@ public void testOpenLDAPAdminSearch_withOpenLDAP() { String bindDN = "cn=admin,dc=my-company,dc=com"; var bindPassword = "adminpassword"; String baseDN = "dc=my-company,dc=com"; - String searchFilter = "(objectClass=*)"; + String searchFilter = "(objectClass=*)"; // Connect to OpenLDAP // Establishing a connection to the LDAP server diff --git a/src/test/java/auth/login/LoginReply.java b/src/test/java/auth/login/LoginReply.java index 7f3d9b5..74142d4 100644 --- a/src/test/java/auth/login/LoginReply.java +++ b/src/test/java/auth/login/LoginReply.java @@ -35,6 +35,6 @@ public void setAuthenticationResult(AuthenticationResult authenticationResult) { public String toString() { // return getClass()+"challenge"+challengeParameters+"data in // authent"+authenticationResult.getIdToken(); - return getClass() + " Not obtaining really much"; + return getClass() + "JSON Overriding functionality"; } } diff --git a/src/test/java/json/TestConversionJSON2Object.java b/src/test/java/json/TestConversionJSON2Object.java index f2e23a5..6b9bc7a 100644 --- a/src/test/java/json/TestConversionJSON2Object.java +++ b/src/test/java/json/TestConversionJSON2Object.java @@ -1,4 +1,4 @@ -package attendance.gson; +package json; import com.google.gson.Gson; @@ -7,12 +7,7 @@ public class TestConversionJSON2Object { public static void main(String[] args) { - // TODO Auto-generated method stub: use a variable for the token - String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1MTc5MyIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.ZGB_kCYoU4v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QiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTExNzEzNSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.gGcx2YYcjWzNvzlpPklry4Jt59GwDQuDRRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; - - String jsonInString = "{'name' : 'martina perumal'}"; - Gson gson = new Gson(); // Restaurant restaurantObject = gson.fromJson(restaurantJson, @@ -20,11 +15,7 @@ public static void main(String[] args) { LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); // Object loginReplyObject = gson.fromJson(replyJson, Object.class); - - Girl girl = gson.fromJson(jsonInString, Girl.class); - System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); - System.out.println("value of her name " + girl.getName()); // System.out.println("obtain token "+ loginReplyObject.authenticationResult); } } diff --git a/src/test/java/json/TestConversionJson2Map.java b/src/test/java/json/TestConversionJson2Map.java index 1376f2e..3ac0ccb 100644 --- a/src/test/java/json/TestConversionJson2Map.java +++ b/src/test/java/json/TestConversionJson2Map.java @@ -10,6 +10,7 @@ public class TestConversionJson2Map { public void convertJSON2Map() { String jsonFromMS = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MDg5NDY5LCJpYXQiOjE1MDUwODU4NjksImp0aSI6ImI4MzY3ZjcwLTA5MDktNGI0Mi1hNDI2LWM2ZTYyY2M3ZTI0YSIsImNsaWVudF9pZCI6IjFlOHRlZm1sY2wyaDI5MHZuaDlyY2VmbnZyIiwidXNlcm5hbWUiOiIxMDI5NTc2NSJ9.jfGvw9FX5-XBcVVaY21wL7F7Y6KRzRdLweCybx819JdRES2f-m4qGeftAZdzoRuLDJ4QfbGqJdJ1V19MKcw070qdz_zd3JFMo3ev9-1yrzQ9vr9hQR6Utk7cBLs_AGQlXHt2wNimvW7mPj_yyyjLa5LTveX0W-hZ5ZG2FSuiAE6dTmmSZs-FEjwZRPTNbjDVKHHr8QRBFq43gg23PkRCAriLO02ymrVblKCx_kqKvYbvNed_RB0IeGZP_Ll27F34-xdZz6r_zAcgxvOqafa5wPAbOvgCubE_rWviCujhgIa4qe_nqkqMIJhm0B3xOkG6K7Ju2yOy0rNSOzYI5JzRaA\",\"ExpiresIn\":3600,\"T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ksImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.N2vUTeKskoSGGnZNNQkoJrjqQSTwCRsAyoVzU8HoSESciE97PbHu_rsDBHdlIvExQgZOJUDH2fi2ZTVXL0qw_dw_1oy5PY0ss6iF9Ya8vNvwJ4QIg0nGLJEEWO6y9h81bUiy8WYOyC0uCy4FKPBzxu-VjO_ZkJwQZLlhkx56cPXhQI9JFbwQDeyxJDF9duOGiZkWYmiG842TeYpaNIiW46KtQ8kiZLGre9qUdPjQv9S-Ch9Cm8bDqVSunAVtTityUJMGJuxhM78hPAujGdeNfMX0qEx37MpKbQtkb_xJZaT1c0IXnu1tneqtGVxZtaZdQ4mUlBmdzamQaWhlSXvqyA\"}}"; + String jsonInString = "{'name' : 'Alejandra Rangel'}"; Gson gson = new Gson(); Type authorization = new TypeToken>() { diff --git a/src/test/java/json/TestJSON2YAML.java b/src/test/java/json/TestJSON2YAML.java index 64acb2b..cbd5d0f 100644 --- a/src/test/java/json/TestJSON2YAML.java +++ b/src/test/java/json/TestJSON2YAML.java @@ -1,24 +1,67 @@ -package com.leo.json; +package json; import com.google.gson.Gson; +import org.yaml.snakeyaml.Yaml; +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.Map; public class TestJSON2YAML { - public static void main(String[] args) { - String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEh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iBf_zmlVaiSciPXsqg.zouwNDBSKRVFp88zPU2pUA\",\"IdToken\":\"eyJraWQiOiJKQWJRaHNlTTVldFRBMk1vMlpoNGs5Mlp2ZmFHaU5zWWtVQlFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTExNzEzNSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.gGcx2YYcjWzNvzlpPklry4Jt59GwDQuDRRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; - String jsonInString = "{'name' : 'martina perumal'}"; + // Test method to convert JSON to YAML + @Test + public void testJsonToYamlConversion() { + String jsonInput = "{\"name\":\"John\", \"age\":30}"; + Gson gson = new Gson(); + Yaml yaml = new Yaml(); + + // Convert JSON to a Map + Map map = gson.fromJson(jsonInput, Map.class); + + // Convert Map to YAML + String yamlOutput = yaml.dump(map); + + // Assert that YAML output is not null or empty + assertNotNull("YAML output should not be null", yamlOutput); + assertFalse("YAML output should not be empty", yamlOutput.isEmpty()); + } + + // Test method to convert YAML to JSON + @Test + public void testYamlToJsonConversion() { + String yamlInput = "name: John\nage: 30"; + Gson gson = new Gson(); + Yaml yaml = new Yaml(); + + // Convert YAML to a Map + Map map = yaml.load(yamlInput); + + // Convert Map to JSON + String jsonOutput = gson.toJson(map); + + // Assert that JSON output is not null or empty + assertNotNull("JSON output should not be null", jsonOutput); + assertFalse("JSON output should not be empty", jsonOutput.isEmpty()); + } + + // Test method to check if YAML output matches expected structure + @Test + public void testYamlStructure() { + String jsonInput = "{\"name\":\"John\", \"age\":30}"; Gson gson = new Gson(); + Yaml yaml = new Yaml(); - // Restaurant restaurantObject = gson.fromJson(restaurantJson, - // Restaurant.class); - LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); + // Convert JSON to a Map + Map map = gson.fromJson(jsonInput, Map.class); - // Object loginReplyObject = gson.fromJson(replyJson, Object.class); + // Convert Map to YAML + String yamlOutput = yaml.dump(map); - Girl girl = gson.fromJson(jsonInString, Girl.class); + // Expected YAML structure + String expectedYaml = "name: John\nage: 30\n"; - System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); - System.out.println("value of her name " + girl.getName()); - // System.out.println("obtain token "+ loginReplyObject.authenticationResult); + // Assert that the YAML output matches the expected structure + assertEquals("YAML output should match the expected structure", expectedYaml, yamlOutput); } } diff --git a/src/test/java/json/TestJSONResponse.java b/src/test/java/json/TestJSONResponse.java deleted file mode 100644 index bd8499d..0000000 --- a/src/test/java/json/TestJSONResponse.java +++ /dev/null @@ -1,61 +0,0 @@ -package json; - -import javax.json.Json; -import javax.json.stream.JsonParser; -import javax.json.stream.JsonParser.Event; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -public class TestJSONResponse { - - public static void main(String[] args) throws MalformedURLException { - // URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); - // URL url = new - // URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - - // try (InputStream is = url.openStream(); JsonParser parser = - // Json.createParser(is)) { - try { - URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); - - String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; - - OutputStream os = conn.getOutputStream(); - // 1.The client sends their credentials (username and password) to the server. - os.write(input.getBytes()); - os.flush(); - - BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); - - JsonParser parser = (JsonParser) Json.createReader(br); - - while (parser.hasNext()) { - Event e = parser.next(); - if (e == Event.KEY_NAME) { - switch (parser.getString()) { - case "RefreshToken": - parser.next(); - System.out.print(parser.getString()); - System.out.print(": "); - break; - case "IdToken": - parser.next(); - System.out.println(parser.getString()); - System.out.println("---------"); - break; - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/test/java/json/TestJSONToken.java b/src/test/java/json/TestJSONToken.java new file mode 100644 index 0000000..0fd72b1 --- /dev/null +++ b/src/test/java/json/TestJSONToken.java @@ -0,0 +1,82 @@ +package json; + +import javax.json.Json; +import javax.json.stream.JsonParser; +import javax.json.stream.JsonParser.Event; + +import org.junit.Test; + +import com.google.gson.Gson; + +import auth.login.LoginReply; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +public class TestJSONToken { + + @Test + public void testMalformedURL() throws MalformedURLException { + // URL url = new URL("https://graph.facebook.com/search?q=java&type=post"); + // URL url = new + // URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + + // try (InputStream is = url.openStream(); JsonParser parser = + // Json.createParser(is)) { + try { + URL url = new URL("https://ctpoixww04.execute-api.us-east-1.amazonaws.com/dev/login"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + + String input = "{\"id\":\"10295765\",\"password\":\"Value!12\"}"; + + OutputStream os = conn.getOutputStream(); + // 1.The client sends their credentials (username and password) to the server. + os.write(input.getBytes()); + os.flush(); + + BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); + + JsonParser parser = (JsonParser) Json.createReader(br); + + while (parser.hasNext()) { + Event e = parser.next(); + if (e == Event.KEY_NAME) { + switch (parser.getString()) { + case "RefreshToken": + parser.next(); + System.out.print(parser.getString()); + System.out.print(": "); + break; + case "IdToken": + parser.next(); + System.out.println(parser.getString()); + System.out.println("---------"); + break; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void formatTokenJSONResponse() { + String replyJson = "{\"ChallengeParameters\":{},\"AuthenticationResult\":{\"AccessToken\":\"eyJraWQiOiJ6M2pWR1lscDVsS2VHVzRXMkwrU3BtdjN4UzIwWGFCU1FvZFlvdWg1WkU4PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImp0aSI6ImNiMjdkZjJiLTIwOWQtNGU1MC05ZTI4LThjYTAyOGY1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lFNbG1cL1Mybz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2MWI5ZTI4NC1kMzVhLTQ0M2YtOTlhNy04MGY0OWE4YTI4NmQiLCJhdWQiOiIxZTh0ZWZtbGNsMmgyOTB2bmg5cmNlZm52ciIsImNvZ25pdG86Z3JvdXBzIjpbImFkbWluaXN0cmF0b3IiXSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTUwNTExNzEzNSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfMEhkMUtvTTVhIiwiY29nbml0bzp1c2VybmFtZSI6IjEwMjk1NzY1IiwiZXhwIjoxNTA1MTIwNzM1LCJpYXQiOjE1MDUxMTcxMzUsImVtYWlsIjoiam9uYXRoYW4udEB4dHJhLmNvLm56In0.gGcx2YYcjWzNvzlpPklry4Jt59GwDQuDRRIFfJGaf06hMKi0Cin31Ox7AD4CaRUmbUXzxh395Bb6bPS9cGdh5oa2hIveC27bwHpO7Eij6voEXdifS98_CTk_zKrAfH1U4qAHapemHA9eQqNnrGm0PtNHTo9Nh7ptrU_04Fc9askTjUnj3fOuDQTp1bLEJwwHbV7oBeQQlA6pYXvWvRwpj0col8N904w4QxoNNNEtYxIYbLtJkj3w-ZogJ9VPkKL_B3ayKTfle3nQ-PHrXyzYpBK89h39Hp2IiOddY-Ihl8iVuj8RziTUiMZ-0jTOToCAa8gQ813DGAtca0i4ffw3hg\"}}"; + Gson gson = new Gson(); + + // Restaurant restaurantObject = gson.fromJson(restaurantJson, + // Restaurant.class); + LoginReply loginReplyObject = gson.fromJson(replyJson, LoginReply.class); + + // Object loginReplyObject = gson.fromJson(replyJson, Object.class); + System.out.println("value " + loginReplyObject.getAuthenticationResult().getIdToken()); + System.out.println("obtain token "+ loginReplyObject.getAuthenticationResult().getAccessToken()); + } +} diff --git a/src/test/java/utilities/TestQRFunctions.java b/src/test/java/utilities/TestQRFunctions.java index 52e5dd7..c984d83 100644 --- a/src/test/java/utilities/TestQRFunctions.java +++ b/src/test/java/utilities/TestQRFunctions.java @@ -1,13 +1,24 @@ -package utilities; - -import org.junit.Test; - -public class TestQRFunctions { - @Test - public void createQRCodeLocally() { - GenerateQRCode qrCode; - qrCode.createWebsiteQRCode(); - assertTrue(qrCode.validateQR = true); - } - -} +package utilities; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.junit.Test; + +import com.google.zxing.WriterException; + +import service.GenerateQRCode; + +public class TestQRFunctions { + @Test + public void createQRCodeLocally() { + GenerateQRCode qrCode = new GenerateQRCode(); + try { + qrCode.createWebsiteQRCode(); + } catch (WriterException | IOException e) { + e.printStackTrace(); + } + assertTrue(qrCode.validateQR); + } // End of createQRCodeLocally() +} // End of Class Declaration From 0d4412633003f948d84512dc6e1e7a3c2b617e40 Mon Sep 17 00:00:00 2001 From: vijaykumar95489 <152595740+vijaykumar95489@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:22:07 +0900 Subject: [PATCH 32/32] Default to 8080 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b446ba9..08a34f5 100644 --- a/README.md +++ b/README.md @@ -118,18 +118,18 @@ Use the tag latest or a particular version e.g. aleon1220/soa:v2 or aleon1220/so ##### Run from [Docker Hub](https://hub.docker.com/repository/docker/aleon1220/soa/general) Test the immutable webapp from Docker ```bash -docker run -itd --publish 8888:8080 --name attendance_webapp_container aleon1220/soa:latest +docker run -itd --publish 8080:8080 --name attendance_webapp_container aleon1220/soa:latest ``` ##### local build & Run Test the container webapp after building the image locally ```bash docker build --tag aleon1220/soa:latest . -docker run -itd --publish 8888:8080 --name attendance_webapp_container aleon1220/soa:latest +docker run -itd --publish 8080:8080 --name attendance_webapp_container aleon1220/soa:latest ``` Run the tomcat server with the pre-built WAR web Archive file ```bash -docker run -itd --publish 8888:8080 aleon1220/soa:latest +docker run -itd --publish 8080:8080 aleon1220/soa:latest ``` - get the name of the running container in port 8888 ``` bash