Merge branch 'master' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot
This commit is contained in:
commit
37bd845c5d
|
@ -1,9 +1,9 @@
|
|||
package dao.entities.security;
|
||||
package dao.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import dao.Dao;
|
||||
import entities.security.UserInfo;
|
||||
import entities.UserInfo;
|
||||
|
||||
public interface UserInfoDao extends Dao<UserInfo, UUID> {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dao.entities.security;
|
||||
package dao.entities;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -7,8 +7,8 @@ import javax.persistence.NoResultException;
|
|||
import javax.persistence.TypedQuery;
|
||||
|
||||
import dao.JpaDao;
|
||||
import entities.UserInfo;
|
||||
import entities.security.UserAuth;
|
||||
import entities.security.UserInfo;
|
||||
|
||||
|
||||
public class UserInfoDaoImpl extends JpaDao<UserInfo, UUID> implements UserInfoDao {
|
|
@ -88,6 +88,14 @@ public class DMP implements Serializable {
|
|||
private Set<Researcher> researchers;
|
||||
|
||||
|
||||
// @OneToMany(fetch = FetchType.EAGER)
|
||||
// @JoinTable(name="\"UserDMP\"",
|
||||
// joinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")},
|
||||
// inverseJoinColumns={@JoinColumn(name="user", referencedColumnName="\"ID\"")}
|
||||
// )
|
||||
// private Set<UserInfo> users;
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -168,6 +176,15 @@ public class DMP implements Serializable {
|
|||
this.researchers = researchers;
|
||||
}
|
||||
|
||||
|
||||
// public Set<UserInfo> getUsers() {
|
||||
// return users;
|
||||
// }
|
||||
//
|
||||
// public void setUsers(Set<UserInfo> users) {
|
||||
// this.users = users;
|
||||
// }
|
||||
|
||||
public String toString() {
|
||||
try {
|
||||
return new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(this);
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
//package entities;
|
||||
//
|
||||
//import java.io.Serializable;
|
||||
//import java.util.UUID;
|
||||
//
|
||||
//import javax.persistence.Column;
|
||||
//import javax.persistence.Entity;
|
||||
//import javax.persistence.GeneratedValue;
|
||||
//import javax.persistence.Id;
|
||||
//import javax.persistence.Table;
|
||||
//
|
||||
//import org.hibernate.annotations.GenericGenerator;
|
||||
//import org.hibernate.annotations.Type;
|
||||
//
|
||||
//import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
//import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
//
|
||||
//@Entity
|
||||
//@Table(name="\"UserInfo\"")
|
||||
//@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="autoid")
|
||||
//public class UserDMP implements Serializable{
|
||||
//
|
||||
// private static final long serialVersionUID = -4467370784003784660L;
|
||||
//
|
||||
//
|
||||
// @Id
|
||||
// @GeneratedValue
|
||||
// @GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
// @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
// private UUID id;
|
||||
//
|
||||
// @Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
// @Column(name = "user", nullable = false)
|
||||
// private UUID user;
|
||||
//
|
||||
// @Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
// @Column(name = "dmp", nullable = false)
|
||||
// private UUID dmp;
|
||||
//
|
||||
// @Column(name = "role")
|
||||
// private Integer role;
|
||||
//
|
||||
// public UUID getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// public void setId(UUID id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
//
|
||||
// public UUID getUser() {
|
||||
// return user;
|
||||
// }
|
||||
//
|
||||
// public void setUser(UUID user) {
|
||||
// this.user = user;
|
||||
// }
|
||||
//
|
||||
// public UUID getDmp() {
|
||||
// return dmp;
|
||||
// }
|
||||
//
|
||||
// public void setDmp(UUID dmp) {
|
||||
// this.dmp = dmp;
|
||||
// }
|
||||
//
|
||||
// public Integer getRole() {
|
||||
// return role;
|
||||
// }
|
||||
//
|
||||
// public void setRole(Integer role) {
|
||||
// this.role = role;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
|
@ -1,7 +1,8 @@
|
|||
package entities.security;
|
||||
package entities;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
@ -10,6 +11,8 @@ import javax.persistence.FetchType;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
|
@ -21,10 +24,12 @@ import org.hibernate.annotations.Type;
|
|||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
|
||||
import entities.security.UserAuth;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="\"UserInfo\"")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="autoid")
|
||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||
public class UserInfo implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1225151430484658395L;
|
||||
|
@ -32,13 +37,10 @@ public class UserInfo implements Serializable{
|
|||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "autoid", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID autoid;
|
||||
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
|
||||
@Column(name = "identification", nullable = false)
|
||||
private String identification = null;
|
||||
|
||||
@Column(name = "email", nullable = false)
|
||||
private String email = null;
|
||||
|
||||
|
@ -71,12 +73,37 @@ public class UserInfo implements Serializable{
|
|||
@Column(name = "additionalinfo", columnDefinition = "xml", nullable = true)
|
||||
private String additionalinfo;
|
||||
|
||||
public String getIdentification() {
|
||||
return identification;
|
||||
// @OneToMany(fetch = FetchType.EAGER)
|
||||
// @JoinTable(name="\"UserDMP\"",
|
||||
// joinColumns={@JoinColumn(name="user", referencedColumnName="\"ID\"")},
|
||||
// inverseJoinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")}
|
||||
// )
|
||||
// private Set<UserInfo> users;
|
||||
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setIdentification(String identification) {
|
||||
this.identification = identification;
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Date getLastloggedin() {
|
||||
return lastloggedin;
|
||||
}
|
||||
|
||||
public void setLastloggedin(Date lastloggedin) {
|
||||
this.lastloggedin = lastloggedin;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
|
@ -21,10 +21,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import dao.entities.UserInfoDao;
|
||||
import dao.entities.security.UserAuthDao;
|
||||
import dao.entities.security.UserInfoDao;
|
||||
import entities.UserInfo;
|
||||
import entities.security.UserAuth;
|
||||
import entities.security.UserInfo;
|
||||
import security.TokenSessionManager;
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package rest.proxy;
|
||||
package proxy;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
@ -57,12 +57,12 @@ public class Proxy {
|
|||
while ((inputLine = in.readLine()) != null)
|
||||
response.append(inputLine);
|
||||
in.close();
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response.toString());
|
||||
}
|
||||
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'}");
|
||||
}
|
|
@ -257,6 +257,7 @@ public class Datasets {
|
|||
try {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdDatasetProfile));
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not set dataset profile!\"}");
|
||||
}
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ public class Projects {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/project/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> setProject(@RequestBody Project project) {
|
||||
|
|
|
@ -12,8 +12,8 @@ import org.springframework.security.core.Authentication;
|
|||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import dao.entities.security.UserInfoDao;
|
||||
import entities.security.UserInfo;
|
||||
import dao.entities.UserInfoDao;
|
||||
import entities.UserInfo;
|
||||
import exceptions.NonValidTokenException;
|
||||
import security.validators.GoogleTokenValidator;
|
||||
import security.validators.NativeTokenValidator;
|
||||
|
@ -64,7 +64,6 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|||
else
|
||||
throw new AuthenticationServiceException("Authentication failed");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.google.api.client.http.HttpTransport;
|
|||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
|
||||
import entities.security.UserInfo;
|
||||
import entities.UserInfo;
|
||||
import exceptions.NonValidTokenException;
|
||||
|
||||
public class GoogleTokenValidator implements TokenValidator {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<bean id="nativeTokenValidator" class="security.validators.NativeTokenValidator" />
|
||||
|
||||
|
||||
<bean id="proxy" class="rest.proxy.Proxy">
|
||||
<bean id="proxy" class="proxy.Proxy">
|
||||
<constructor-arg type = "String" value = "${proxy.allowed.host}"/>
|
||||
</bean>
|
||||
|
||||
|
@ -100,7 +100,7 @@
|
|||
<bean id="registryDao" class="dao.entities.RegistryDaoImpl" />
|
||||
<bean id="researcherDao" class="dao.entities.ResearcherDaoImpl" />
|
||||
<bean id="serviceDao" class="dao.entities.ServiceDaoImpl" />
|
||||
<bean id="userInfoDao" class="dao.entities.security.UserInfoDaoImpl" />
|
||||
<bean id="userInfoDao" class="dao.entities.UserInfoDaoImpl" />
|
||||
<bean id="userAuthDao" class="dao.entities.security.UserAuthDaoImpl" />
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
|
||||
|
||||
|
||||
<!-- <context:property-placeholder location="classpath*:**/dmp.properties" /> -->
|
||||
<context:property-placeholder location="classpath*:**/dmp.properties" />
|
||||
|
||||
<mvc:resources mapping="resources/**" location="/resources/" />
|
||||
<mvc:annotation-driven />
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc
|
||||
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.1.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
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="proxy" />
|
||||
|
||||
|
||||
<bean id="proxy" class="proxy.Proxy">
|
||||
<constructor-arg type = "String" value = "${proxy.allowed.host}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="multipartResolver"
|
||||
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
||||
<property name="maxUploadSize" value="100000000" />
|
||||
</bean>
|
||||
|
||||
<bean id="jsonConverter"
|
||||
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
|
||||
<property name="prefixJson" value="false" />
|
||||
<property name="supportedMediaTypes" value="application/json" />
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
|
||||
<property name="messageConverters">
|
||||
<list>
|
||||
<ref bean="jsonConverter" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -16,9 +16,7 @@
|
|||
<mvc:annotation-driven />
|
||||
<context:component-scan base-package="rest" />
|
||||
|
||||
<bean id="proxy" class="rest.proxy.Proxy">
|
||||
<constructor-arg type = "String" value = "${proxy.allowed.host}"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean
|
||||
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||
|
|
|
@ -3,7 +3,20 @@
|
|||
|
||||
<display-name>dmp-backend</display-name>
|
||||
|
||||
|
||||
<servlet>
|
||||
<servlet-name>dmp-backend-proxy</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>dmp-backend-proxy</servlet-name>
|
||||
<url-pattern>/proxy/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
|
||||
<servlet>
|
||||
<servlet-name>dmp-backend-login</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
|
|
|
@ -25,7 +25,10 @@ drop table if exists "Registry" cascade;
|
|||
drop table if exists "DatasetService" cascade;
|
||||
drop table if exists "DatasetRegistry" cascade;
|
||||
drop table if exists "DatasetDataRepository" cascade;
|
||||
drop table if exists "UserInfo" cascade;
|
||||
DROP table if exists "UserDMP" cascade;
|
||||
DROP table if exists "UserInfo" cascade;
|
||||
DROP table if exists "UserAuth" cascade;
|
||||
|
||||
|
||||
|
||||
-- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
||||
|
@ -447,12 +450,13 @@ ALTER TABLE ONLY "DatasetService"
|
|||
ADD CONSTRAINT "DatasetServiceServiceReference" FOREIGN KEY ("Service") REFERENCES "Service"("ID");
|
||||
|
||||
|
||||
DROP table if exists "UserDMP";
|
||||
DROP table if exists "UserInfo";
|
||||
DROP table if exists "UserAuth";
|
||||
|
||||
CREATE TABLE "UserInfo" (
|
||||
"autoid" uuid DEFAULT uuid_generate_v4() NOT NULL,
|
||||
"identification" character varying(500) NOT NULL,
|
||||
"email" character varying(250) NOT NULL,
|
||||
"id" uuid DEFAULT uuid_generate_v4() UNIQUE NOT NULL,
|
||||
"email" character varying(250) UNIQUE NOT NULL,
|
||||
"authorization_level" smallint NOT NULL,
|
||||
"usertype" smallint NOT NULL,
|
||||
"authentication" uuid,
|
||||
|
@ -461,15 +465,13 @@ CREATE TABLE "UserInfo" (
|
|||
"created" timestamp,
|
||||
"lastloggedin" timestamp,
|
||||
"additionalinfo" xml,
|
||||
PRIMARY KEY (identification, email)
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN "UserInfo"."authorization_level" IS 'This stores the authorization level of the user: 0 admin, 1 user, being able to be extended furthermore';
|
||||
COMMENT ON COLUMN "UserInfo"."usertype" IS 'This stores the type of user: 0 -> internal, 1 external';
|
||||
|
||||
|
||||
DROP table if exists "UserAuth";
|
||||
|
||||
CREATE TABLE "UserAuth" (
|
||||
"id" uuid DEFAULT uuid_generate_v4() NOT NULL UNIQUE,
|
||||
"username" character varying(200) NOT NULL,
|
||||
|
@ -483,8 +485,21 @@ ALTER TABLE "UserInfo" ADD CONSTRAINT fkey_userinfo_userauth FOREIGN KEY ("authe
|
|||
|
||||
COMMENT ON COLUMN "UserAuth"."password" IS 'This field stores a password hash';
|
||||
|
||||
|
||||
create table "UserDMP" (
|
||||
"id" uuid DEFAULT uuid_generate_v4() NOT NULL,
|
||||
"user" uuid NOT NULL,
|
||||
"dmp" uuid NOT NUll,
|
||||
"role" integer
|
||||
);
|
||||
|
||||
ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_user FOREIGN KEY ("user") REFERENCES "UserInfo"("id");
|
||||
ALTER TABLE "UserDMP" ADD CONSTRAINT fkey_userdmp_dmp FOREIGN KEY ("dmp") REFERENCES "DMP"("ID");
|
||||
|
||||
|
||||
ALTER TABLE "UserInfo" OWNER TO dmptool;
|
||||
ALTER TABLE "UserAuth" OWNER TO dmptool;
|
||||
ALTER TABLE "UserDMP" OWNER TO dmptool;
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue