Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot
This commit is contained in:
commit
0a982bd290
|
@ -254,7 +254,6 @@
|
|||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- Various libs -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
|
|
@ -1,25 +1,13 @@
|
|||
package controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import dao.entities.DMPDao;
|
||||
import entities.DMP;
|
||||
|
||||
|
||||
@Controller
|
||||
public class UIController {
|
||||
|
|
|
@ -6,9 +6,6 @@ import java.util.UUID;
|
|||
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import entities.DMP;
|
||||
import entities.DMPProfile;
|
||||
import entities.DataRepository;
|
||||
|
|
|
@ -1,59 +1,39 @@
|
|||
package rest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import dao.entities.DMPDao;
|
||||
import dao.entities.DMPProfileDao;
|
||||
import dao.entities.DMPResearcherDao;
|
||||
import dao.entities.DataRepositoryDao;
|
||||
import dao.entities.DatasetDao;
|
||||
import dao.entities.DatasetProfileDao;
|
||||
import dao.entities.DatasetProfileRulesetDao;
|
||||
import dao.entities.DatasetProfileViewstyleDao;
|
||||
import dao.entities.DatasetRegistryDao;
|
||||
import dao.entities.DatasetServiceDao;
|
||||
import dao.entities.OrganisationDao;
|
||||
import dao.entities.ProjectDao;
|
||||
import dao.entities.RegistryDao;
|
||||
import dao.entities.ResearcherDao;
|
||||
import dao.entities.ServiceDao;
|
||||
import entities.DMP;
|
||||
import entities.DMPProfile;
|
||||
import entities.DataRepository;
|
||||
import entities.Dataset;
|
||||
import entities.DatasetProfile;
|
||||
import entities.DatasetProfileRuleset;
|
||||
import entities.DatasetProfileViewstyle;
|
||||
import entities.DatasetRegistry;
|
||||
import entities.DatasetService;
|
||||
import entities.Organisation;
|
||||
import entities.Project;
|
||||
import entities.Registry;
|
||||
import entities.Service;
|
||||
import helpers.Transformers;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package rest;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Proxy {
|
||||
|
||||
private String allowedHost;
|
||||
|
||||
public Proxy(String allowedHost) throws MalformedURLException {
|
||||
this.allowedHost = new URL(allowedHost).getHost();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/proxy" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> proxy(@RequestParam("url") String remoteUrl) {
|
||||
|
||||
StringBuffer response = new StringBuffer();
|
||||
URL url;
|
||||
try {
|
||||
URL tempUrl = new URL(remoteUrl);
|
||||
// URI uri = new URI(scheme, userInfo, host, port, path, query, fragment);
|
||||
URI uri = new URI(tempUrl.getProtocol(), null, tempUrl.getHost(), tempUrl.getPort(), tempUrl.getPath(), (tempUrl.getQuery()!=null)?URLEncoder.encode(tempUrl.getQuery()):null, tempUrl.getRef());
|
||||
url = uri.toURL();
|
||||
|
||||
if(!url.getHost().equals(allowedHost))
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body("{'reason': 'You are not allowed to proxy -> "+url.getHost()+"'}");
|
||||
//if allowed, proceed
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("Accept", "application/vnd.api+json; charset=utf-8");
|
||||
|
||||
int responseCode = con.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) { // success
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
while ((inputLine = in.readLine()) != null)
|
||||
response.append(inputLine);
|
||||
in.close();
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).body("{'reason': 'Remote server responded with: "+responseCode+"'}");
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response.toString());
|
||||
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{'reason': 'Could not proxy to given host'}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
|
||||
|
||||
/*
|
||||
if (authentication != null) {
|
||||
// check whether the token is valid
|
||||
String token = (String)authentication.getCredentials();
|
||||
|
@ -47,7 +47,9 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|||
}
|
||||
else
|
||||
throw new AuthenticationServiceException("Authentication failed");
|
||||
*/
|
||||
|
||||
return new UsernamePasswordAuthenticationToken("", "", new ArrayList<>());
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.sql.Types;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.sql.SQLException;
|
|||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
//package types;
|
||||
//
|
||||
//import java.io.Serializable;
|
||||
//import java.sql.PreparedStatement;
|
||||
//import java.sql.ResultSet;
|
||||
//import java.sql.SQLException;
|
||||
//import java.sql.Types;
|
||||
//import org.hibernate.HibernateException;
|
||||
//import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
//
|
||||
///**
|
||||
// * Store and retrieve a PostgreSQL "xml" column as a Java string.
|
||||
// */
|
||||
//public class SQLXMLType implements org.hibernate.usertype.UserType {
|
||||
//
|
||||
// private final int[] sqlTypesSupported = new int[] { Types.VARCHAR };
|
||||
//
|
||||
// public int[] sqlTypes() {
|
||||
// return sqlTypesSupported;
|
||||
// }
|
||||
//
|
||||
// public Class returnedClass() {
|
||||
// return String.class;
|
||||
// }
|
||||
//
|
||||
// public boolean equals(Object x, Object y) throws HibernateException {
|
||||
// if (x == null) {
|
||||
// return y == null;
|
||||
// } else {
|
||||
// return x.equals(y);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public int hashCode(Object x) throws HibernateException {
|
||||
// return x == null ? null : x.hashCode();
|
||||
// }
|
||||
//
|
||||
// public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
||||
// assert(names.length == 1);
|
||||
// String xmldoc = rs.getString( names[0] );
|
||||
// return rs.wasNull() ? null : xmldoc;
|
||||
// }
|
||||
//
|
||||
// public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
||||
// if (value == null) {
|
||||
// st.setNull(index, Types.OTHER);
|
||||
// } else {
|
||||
// st.setObject(index, value, Types.OTHER);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public Object deepCopy(Object value) throws HibernateException {
|
||||
// if (value == null)
|
||||
// return null;
|
||||
// return new String( (String)value );
|
||||
// }
|
||||
//
|
||||
// public boolean isMutable() {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// public Serializable disassemble(Object value) throws HibernateException {
|
||||
// return (String) value;
|
||||
// }
|
||||
//
|
||||
// public Object assemble(Serializable cached, Object owner) throws HibernateException {
|
||||
// return (String) cached;
|
||||
// }
|
||||
//
|
||||
// public Object replace(Object original, Object target, Object owner) throws HibernateException {
|
||||
// return original;
|
||||
// }
|
||||
//
|
||||
// public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
|
||||
// throws HibernateException, SQLException {
|
||||
// // TODO Auto-generated method stub
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session)
|
||||
// throws HibernateException, SQLException {
|
||||
// // TODO Auto-generated method stub
|
||||
//
|
||||
// }
|
||||
//}
|
|
@ -11,9 +11,7 @@
|
|||
|
||||
<context:property-placeholder location="classpath*:**/dmp.properties" />
|
||||
|
||||
|
||||
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
|
||||
|
||||
|
||||
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
|
||||
|
||||
|
@ -26,13 +24,14 @@
|
|||
<property name="jpaDialect" ref="jpaDialect" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="proxy" class="rest.Proxy">
|
||||
<constructor-arg type = "String" value = "${proxy.allowed.host}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="springApplicationContext" class="dao.SpringJpaDaoFactory" />
|
||||
|
||||
<bean id="databaseColumnType" class="typedefinition.PostgreSQLDatabaseColumnType" />
|
||||
|
||||
|
||||
<!-- <bean id="securityConfig" class="security.SecurityConfig" /> -->
|
||||
<!-- <bean id="securityWebApplicationInitializer" class="security.SecurityWebApplicationInitializer" /> -->
|
||||
<bean id="databaseColumnType" class="typedefinition.PostgreSQLDatabaseColumnType" />
|
||||
|
||||
<bean id="tokenAuthenticationFilter" class="security.TokenAuthenticationFilter" />
|
||||
|
||||
|
|
|
@ -10,10 +10,16 @@
|
|||
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
|
||||
|
||||
|
||||
<context:property-placeholder location="classpath*:**/dmp.properties" />
|
||||
|
||||
<mvc:resources mapping="resources/**" location="/resources/" />
|
||||
<mvc:annotation-driven />
|
||||
<context:component-scan base-package="rest" />
|
||||
|
||||
<bean id="proxy" class="rest.Proxy">
|
||||
<constructor-arg type = "String" value = "${proxy.allowed.host}"/>
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||
<property name="prefix" value="/views/" />
|
||||
|
|
|
@ -5,11 +5,14 @@
|
|||
|
||||
##########################Persistence##########################################
|
||||
persistence.jdbc.driver = org.postgresql.Driver
|
||||
persistence.jdbc.url = jdbc:postgresql://develdb1.madgik.di.uoa.gr:5432/dmptool
|
||||
persistence.dbusername = dmptool
|
||||
persistence.dbpassword = dmpt00lu$r
|
||||
persistence.jdbc.url = jdbc:postgresql://host:5432/dbname
|
||||
persistence.dbusername = valid-user
|
||||
persistence.dbpassword = valid-pass
|
||||
##########################/Persistence##########################################
|
||||
|
||||
###################Allowed Proxy Service Host ############################
|
||||
proxy.allowed.host = https://eestore.paas2.uninett.no
|
||||
#######################################################
|
||||
|
||||
########################Persistence/Hibernate Generic#############################
|
||||
persistence.hibernate.show_sql = false
|
||||
|
|
Loading…
Reference in New Issue