Commit 801f517b authored by Παναγιώτης Γεωργακόπουλος's avatar Παναγιώτης Γεωργακόπουλος
Browse files

project update

parent cf356679
# Πλατφόρμα WSO2 Enterprise Service Bus για την υλοποίηση των Web Services του ΥΠΠΕΘ
# Περιγραφή #
<p align="justify">
Το έργο περιλαμβάνει την δημιουργία των υπηρεσιών ιστού διαλειτουργικότητας του Υπουργείου Παιδείας, Ερευνας και Θρησκευμάτων στην πλατφόρμα WSO2 με χρήση εργαλείων ανάπτυξης Java EE (Enterprise Edition)
</p>
# Παραδοτέο
Ο ανοικτός κώδικας του project των Web Services του ΥΠΠΕΘ σε πλατφόρμα WSO2 Developer Studio
# Περιβάλλον Ανάπτυξης#
Όλα τα κείμενα και ο ανοικτός κώδικας του project των Web Services του ΥΠΠΕΘ σε πλατφόρμα WSO2 Developer Studio που υλοποιείται βρίσκονται στο https://git.minedu.gov.gr/itminedu/wso2_esb
Μπορείτε να δείτε τις προδιαγραφές του έργου σύμφωνα με τα πρότυπα της μεθοδολογίας Agile / Scrum στο https://git.minedu.gov.gr/itminedu/wso2_esb/wikis/scrum
Η αναλυτική τεκμηρίωση των λειτουργικών απαιτήσεων συντηρείται στο https://git.minedu.gov.gr/itminedu/wso2_esb/wikis/analysis
# WSO2 Enterprise Service Bus platform for the Web Services οf the Greek Ministry of Education
The project includes mainly the development of the enterprise Web Services for interoperability of the Greek Ministry of Education, Research, LifeLong Learning and Religious Affairs
# Description #
<p align="justify">
The project includes the creation of interoperability Web services provided by the Ministry of Education, Research and Religious Affairs using its WSO2 platform. The web services are developed in Java EE (Enterprise Edition development tools).
</p>
# Development Environment#
All documents and source code of developed Web Services implemented in the WSO2 Developer Studio, for WSO2 platform are available in https://git.minedu.gov.gr/itminedu/wso2_esb
You can see the project specifications according to the standards of Agile / Scrum methodology in https://git.minedu.gov.gr/itminedu/wso2_esb/wikis/scrum
The detailed documentation of functional requirements maintained in https://git.minedu.gov.gr/itminedu/wso2_esb/wikis/analysis
<p align="justify">
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry exported="true" kind="var" path="ECLIPSE_WORKSPACE/.metadata/.plugins/org.wso2.developerstudio.eclipse.libraries/lib/jsr311-api-1.1.1.jar"/>
<classpathentry kind="output" path="target"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>EDETwebservice</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.wso2.developerstudio.eclipse.jaxrs.project.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.EDETwebservice</groupId>
<artifactId>EDETwebservice</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>EDETwebservice</name>
<description>EDETwebservice</description>
<properties>
<CApp.type>webapp/jaxws</CApp.type>
</properties>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<id>wso2-nexus</id>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<id>wso2-nexus</id>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
<packagingExcludes />
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<buildcommands>
<buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
</buildcommands>
<projectnatures>
<projectnature>org.wso2.developerstudio.eclipse.jaxrs.project.nature</projectnature>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
</projectnatures>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.academicservice.query;
import javax.ws.rs.*;
/**
*
* @author pgeor
*/
@Path("/academicID")
public class Academicservice {
@GET
@Consumes("text/plain")
@Produces("text/plain")
@Path("/testServiceStatus/{id}")
public String testServiceStatus1(@PathParam("id") String id) {
id=id.trim();
String msg="StudentID sent was:"+id;
// return Response.ok(msg).build();
return msg;
}
@GET
@Consumes("text/plain")
@Produces("text/plain")
@Path("/testServiceStatus")
public String testServiceStatus2(@QueryParam("id") String id) {
id=id.trim();
String msg="StudentID sent was:"+id;
// return Response.ok(msg).build();
return msg;
}
@GET
@Consumes("text/plain")
@Produces("text/json")
@Path("/queryID")
public String queryStudentID(@QueryParam("id") String id,
@QueryParam("username") String username,
@QueryParam("password") String password) {
id = id.trim();
username=username.trim();
password=password.trim();
WebServiceClient edetConnect=new WebServiceClient(username,password,"https://academicidapp.grnet.gr/admin/web/ws/users/inspectAcademicID");
return WebServiceClient.clientConnectGetJson(edetConnect.getWebAPPURLName(),"wso2.minedu.gov.gr",id,edetConnect.getUsername(),edetConnect.getPassword());
}
@GET
@Consumes("text/plain")
@Produces("text/plain")
@Path("/queryIDnoCD")
public String queryStudentIDnocd(@QueryParam("id") String id) {
id = id.trim();
String JSONresponse="";
WebServiceClient edetConnect=new WebServiceClient("kasvestas","boldtrick666","https://academicidapp.grnet.gr/admin/web/ws/users/inspectAcademicID");
JSONresponse=WebServiceClient.clientConnectGetJson(edetConnect.getWebAPPURLName(),"wso2.minedu.gov.gr",id,edetConnect.getUsername(),edetConnect.getPassword());
if (!JSONresponse.equals("")) {
String[] filter1=JSONresponse.split(",");
String[] filter2=null;
for (String message : filter1) {
if (message.contains("webServiceSuccess")) {
filter2=message.split(":");
break;
}
}
if (filter2 != null)
return "isStudent:"+filter2[1];
else
return JSONresponse;
}
else return "EDET Web Service Unreacheable";
}
@POST
@Consumes("text/plain")
@Produces("text/json")
@Path("/queryID")
public String queryStudentID1(@QueryParam("id") String id,
@QueryParam("username") String username,
@QueryParam("password") String password) {
id = id.trim();
username=username.trim();
password=password.trim();
WebServiceClient edetConnect=new WebServiceClient(username,password,"https://academicidapp.grnet.gr/admin/web/ws/users/inspectAcademicID");
return WebServiceClient.clientConnectGetJson(edetConnect.getWebAPPURLName(),"wso2.minedu.gov.gr",id,edetConnect.getUsername(),edetConnect.getPassword());
}
@POST
@Consumes("text/plain")
@Produces("text/plain")
@Path("/queryID/noCD")
public String queryStudentIDnocd1(@QueryParam("id") String id) {
id = id.trim();
String JSONresponse="";
WebServiceClient edetConnect=new WebServiceClient("kasvestas","boldtrick666","https://academicidapp.grnet.gr/admin/web/ws/users/inspectAcademicID");
JSONresponse=WebServiceClient.clientConnectGetJson(edetConnect.getWebAPPURLName(),"wso2.minedu.gov.gr",id,edetConnect.getUsername(),edetConnect.getPassword());
if (!JSONresponse.equals("")) {
String[] filter1=JSONresponse.split(",");
String[] filter2=null;
for (String message : filter1) {
if (message.contains("webServiceSuccess")) {
filter2=message.split(":");
break;
}
}
if (filter2 != null)
return "isStudent:"+filter2[1];
else
return JSONresponse;
}
else return "EDET Web Service Unreacheable";
}
}
\ No newline at end of file
package com.academicservice.query;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.util.Base64;
import java.security.*;
/**
*
* @author pgeor
*/
public class WebServiceClient {
private String username;
private String password;
private String WebApplicationServerURL;
private String JSONobject;
private static HttpURLConnection connectionURL;
public WebServiceClient() {
this.username="";
this.password="";
this.JSONobject="";
this.WebApplicationServerURL="";
WebServiceClient.connectionURL=null;
}
public WebServiceClient(String user,String pass,String Host) {
this.username=user;
this.password=pass;
this.JSONobject="";
this.WebApplicationServerURL=Host;
WebServiceClient.connectionURL=null;
}
public WebServiceClient(String user,String pass,String Host,String jsondata) {
this.username=user;
this.password=pass;
this.WebApplicationServerURL=Host;
this.JSONobject=jsondata;
WebServiceClient.connectionURL=null;
}
public void setUsername(String user) {
this.username=user;
}
public String getUsername() {
return this.username;
}
public void setPassword(String pass) {
this.password=pass;
}
public String getPassword() {
return this.password;
}
public void setWebAPPURLName(String Host) {
this.WebApplicationServerURL=Host;
}
public String getWebAPPURLName() {
return this.WebApplicationServerURL;
}
public void setJSONObject(String object) {
this.JSONobject=object;
}
public String getJSONObject() {
return this.JSONobject;
}
public static String createJSONbody(String data) {
return "{\n" +"\"SubmissionCode\":"+data+"\n"+"}";
}
public static String clientConnectGetJson(String serverUrl,String host,String bodydata,String username,String password){
StringBuilder sb = new StringBuilder();
String http = serverUrl;
//HttpURLConnection urlConnection = null;
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(password.getBytes("UTF-8"));
byte[] HashedPasswordBytes = md.digest();
StringBuffer stringBuffer = new StringBuffer();
for (byte bytes : HashedPasswordBytes) {
stringBuffer.append(String.format("%02x", bytes & 0xff));
}
// String hashedPassword=md.digest(bytesOfPassword).toString();
//JOptionPane.showMessageDialog(null,"" + stringBuffer.toString(),
//"WARNING MESSAGE",JOptionPane.WARNING_MESSAGE,null);
String userpass=username+":"+stringBuffer.toString();
// System.out.println(md.toString());
String basicAuth = "Basic "+ new String(Base64.getEncoder().encode(userpass.getBytes()));
// JOptionPane.showMessageDialog(null,"" + basicAuth,
//"WARNING MESSAGE",JOptionPane.WARNING_MESSAGE,null);
URL url = new URL(http);
WebServiceClient.connectionURL = (HttpURLConnection) url.openConnection();
WebServiceClient.connectionURL.setDoOutput(true);
WebServiceClient.connectionURL.setRequestMethod("POST");
WebServiceClient.connectionURL.setRequestProperty("Authorization",basicAuth);
WebServiceClient.connectionURL.setUseCaches(false);
WebServiceClient.connectionURL.setConnectTimeout(50000);
WebServiceClient.connectionURL.setReadTimeout(50000);
WebServiceClient.connectionURL.setRequestProperty("Content-Type", "application/json");
WebServiceClient.connectionURL.setRequestProperty("Host", host);
WebServiceClient.connectionURL.setRequestProperty("User-Agent","AcademicIDClient/v1.0 panosgeorgak@gmail.com");
WebServiceClient.connectionURL.connect();
OutputStreamWriter out = new OutputStreamWriter(WebServiceClient.connectionURL.getOutputStream());
out.write(WebServiceClient.createJSONbody(bodydata));
out.close();
int HttpResult = WebServiceClient.connectionURL.getResponseCode();
if (HttpResult == HttpURLConnection.HTTP_OK) {
BufferedReader br = new BufferedReader(new InputStreamReader(
WebServiceClient.connectionURL.getInputStream(), "utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
// Log.e("new Test", "" + sb.toString());
// JOptionPane.showMessageDialog(null,"1:"+sb.toString(),
//"WARNING MESSAGE",JOptionPane.WARNING_MESSAGE,null);
return sb.toString();
} else {
// Log.e(" ", "" + urlConnection.getResponseMessage());
// JOptionPane.showMessageDialog(null,"" + urlConnection.getResponseMessage(),
//"WARNING MESSAGE",JOptionPane.WARNING_MESSAGE,null);
return "WebServiceClient connection error:"+WebServiceClient.connectionURL.getResponseMessage().toString();
}
} catch (MalformedURLException e) {
e.printStackTrace();
return "WebServiceClient MalformedURLException error:"+e.toString();
} catch (IOException e) {
e.printStackTrace();
return "WebServiceClient IOException error:"+e.toString();
} catch (Exception ex) {
// JOptionPane.showMessageDialog(null,"1:"+ex.toString(),
//"WARNING MESSAGE",JOptionPane.WARNING_MESSAGE,null);
return "WebServiceClient Exception error:"+ex.toString();
}
finally {
if (WebServiceClient.connectionURL != null)
WebServiceClient.connectionURL.disconnect();
}
// return null;
}
}
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ Copyright 2005-2013 WSO2, Inc. (http://wso2.com)
~
~ 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
~
~ http://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.
-->
<!--
This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
-->
<Classloading xmlns="http://wso2.org/projects/as/classloading">
<!-- Parent-first or child-first. Default behaviour is child-first.-->
<ParentFirst>false</ParentFirst>
<!--
Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF</Environments>
</Classloading>
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<bean id="AcademicserviceBean" class="com.academicservice.query.Academicservice"/>
<jaxrs:server id="Academicservice" address="/academicservice">
<jaxrs:serviceBeans>
<ref bean="AcademicserviceBean"/>
</jaxrs:serviceBeans>
</jaxrs:server>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>cxf</display-name>
<servlet>
<servlet-name>cxf</servlet-name>
<display-name>cxf</display-name>
<description>Apache CXF Endpoint</description>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>
RewriteEngine On
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^testServiceStatus/(.*)$ wrapper.php?operation=testServiceStatus&id=$1 [L]
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^testServiceStatus$ wrapper.php?operation=testServiceStatus&id=%1 [L]
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^queryIDnoCD$ wrapper.php?operation=queryIDnoCD&identity=%1 [L]
RewriteCond %{QUERY_STRING} ^id=([^&]*)&username=([^&]*)&password=(.*)$
RewriteRule ^queryID$ wrapper.php?operation=queryID&identity=%1&username=%2&password=%3 [L]
RewriteRule ^echo/(.*)$ wrapper.php?operation=echo&$1 [QSA,L]
<?php
/**
* Get params.
* operation == queryID || echo
*/
$params = [
'username' => ($username = filter_input(INPUT_GET, 'username')) ? $username : 'user',
'password' => ($password = filter_input(INPUT_GET, 'password')) ? $password : 'pass',
'identity' => ($identity = filter_input(INPUT_GET, 'identity')) ? $identity : '-1',
'operation' => (in_array($operation = filter_input(INPUT_GET, 'operation'), [
'testServiceStatus',
'queryIDnoCD', 'queryID',
'echo',
])) ? $operation : 'queryID'
];
/**
* Call remote ws
*/
function wscall($params)
{
/**
* Prep auth
*/
$pass_md5 = md5($params['password']);
$auth = "Basic " . base64_encode("{$params['username']}:{$pass_md5}");
/**
* Do the call
*/
$ch = curl_init();
$payload = json_encode(array("SubmissionCode" => $params['identity']));
curl_setopt($ch, CURLOPT_URL, "https://academicidapp.grnet.gr/admin/web/ws/users/inspectAcademicID");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: {$auth}",