no message

This commit is contained in:
annabakouli 2017-12-18 17:55:12 +02:00
parent 5cc601b0da
commit c1f2c615af
43 changed files with 510 additions and 1265 deletions

View File

@ -2,6 +2,7 @@ package eu.eudat.controllers;
import eu.eudat.models.login.Credentials; import eu.eudat.models.login.Credentials;
import eu.eudat.models.helpers.responses.ResponseItem; import eu.eudat.models.helpers.responses.ResponseItem;
import eu.eudat.models.login.LoginInfo;
import eu.eudat.models.security.Principal; import eu.eudat.models.security.Principal;
import eu.eudat.security.CustomAuthenticationProvider; import eu.eudat.security.CustomAuthenticationProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -19,8 +20,8 @@ public class Login {
@Autowired @Autowired
private CustomAuthenticationProvider customAuthenticationProvider; private CustomAuthenticationProvider customAuthenticationProvider;
@RequestMapping(method = RequestMethod.POST, value = { "/googlelogin" }, consumes = "application/json", produces="application/json") @RequestMapping(method = RequestMethod.POST, value = { "/externallogin" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseItem<Principal> googleLogin(@RequestBody Credentials credentials) { public @ResponseBody ResponseItem<Principal> googleLogin(@RequestBody LoginInfo credentials) {
try { try {
return new ResponseItem<Principal>().payload(customAuthenticationProvider.authenticate(credentials)).status(HttpStatus.OK); return new ResponseItem<Principal>().payload(customAuthenticationProvider.authenticate(credentials)).status(HttpStatus.OK);

View File

@ -97,10 +97,14 @@ public class Projects {
@Transactional @Transactional
@RequestMapping(method = RequestMethod.POST, value = { "/projects/add" }, consumes = "application/json", produces="application/json") @RequestMapping(method = RequestMethod.POST, value = { "/projects/createOrUpdate" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseItem<eu.eudat.entities.Project> addProject(@RequestBody eu.eudat.models.project.Project project) { public @ResponseBody ResponseItem<eu.eudat.entities.Project> addProject(@RequestBody eu.eudat.models.project.Project project) {
Project createdProject = projectDao.createOrUpdate(project.toDataModel()); try {
return new ResponseItem<eu.eudat.entities.Project>().payload(createdProject).status(HttpStatus.OK); Project createdProject = projectDao.createOrUpdate(project.toDataModel());
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK);
}catch (Exception ex){
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
}
} }

View File

@ -32,6 +32,9 @@ public class DatasetDaoImpl implements DatasetDao {
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) { public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
QueryableList<Dataset> query = databaseService.getQueryable(Dataset.class); QueryableList<Dataset> query = databaseService.getQueryable(Dataset.class);
if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%")); if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%"));
if(criteria.getStatus()!=null)query.where((builder, root) -> builder.equal(root.get("status"),criteria.getStatus()));
if(criteria.getPeriodEnd()!=null)query.where((builder, root) -> builder.lessThan(root.get("created"),criteria.getPeriodEnd()));
if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("created"),criteria.getPeriodStart()));
return query; return query;
} }

View File

@ -14,25 +14,25 @@ import java.util.UUID;
public class Credential { public class Credential {
@Id @Id
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@ManyToOne @ManyToOne
@JoinColumn(name="userid", nullable=false) @JoinColumn(name="\"UserId\"", nullable=false)
private UserInfo userInfo; private UserInfo userInfo;
@Column(name = "status", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Integer status; private Integer status;
@Column(name = "provider", nullable = false) @Column(name = "\"Provider\"", nullable = false)
private Integer provider; private Integer provider;
@Column(name = "publicValue", nullable = false) @Column(name = "\"Public\"", nullable = false)
private String publicValue; private String publicValue;
@Column(name = "secret", nullable = false) @Column(name = "\"Secret\"", nullable = false)
private String secret; private String secret;
@Column(name = "creationtime", nullable = false) @Column(name = "\"CreationTime\"", nullable = false)
private Date creationTime; private Date creationTime;
@Column(name = "lastupdatetime", nullable = false) @Column(name = "\"LastUpdateTime\"", nullable = false)
private Date lastUpdateTime; private Date lastUpdateTime;
public UUID getId() { public UUID getId() {

View File

@ -229,7 +229,14 @@ public class Project implements Serializable,DataEntity<Project> {
@Override @Override
public void update(Project entity) { public void update(Project entity) {
this.description = entity.getDescription();
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.created = entity.getCreated();
this.definition = entity.getDefinition();
this.dmps = entity.getDmps();
this.enddate = entity.getEnddate();
//this.creationUser = entity.getCreationUser(); //TODO
} }
@Override @Override

View File

@ -14,18 +14,18 @@ public class UserToken implements DataEntity<UserToken>{
private static final long serialVersionUID = 1225151430484658395L; private static final long serialVersionUID = 1225151430484658395L;
@Id @Id
@Column(name = "token", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token; private UUID token;
@OneToOne(fetch = FetchType.EAGER) @OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "userid", nullable = false) @JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo user; private UserInfo user;
@Column(name = "issuedat", nullable = false) @Column(name = "\"IssuedAt\"", nullable = false)
private Date issuedAt = null; private Date issuedAt = null;
@Column(name = "expiresat", nullable = false) @Column(name = "\"ExpiresAt\"", nullable = false)
private Date expiresAt = null; private Date expiresAt = null;
public UUID getToken() { public UUID getToken() {

View File

@ -0,0 +1,23 @@
package eu.eudat.exceptions;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
/**
* Created by ikalyvas on 12/18/2017.
*/
@ResponseStatus(value = HttpStatus.UNAUTHORIZED)
public class UnauthorisedException extends RuntimeException{
public UnauthorisedException() {
super();
}
public UnauthorisedException(String message, Throwable cause) {
super(message, cause);
}
public UnauthorisedException(String message) {
super(message);
}
public UnauthorisedException(Throwable cause) {
super(cause);
}
}

View File

@ -1,6 +1,9 @@
package eu.eudat.handlers; package eu.eudat.handlers;
import eu.eudat.exceptions.UnauthorisedException;
import eu.eudat.models.security.Principal; import eu.eudat.models.security.Principal;
import eu.eudat.services.AuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebDataBinderFactory; import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.NativeWebRequest;
@ -15,6 +18,7 @@ import java.util.UUID;
*/ */
public final class PrincipalArgumentResolver implements HandlerMethodArgumentResolver { public final class PrincipalArgumentResolver implements HandlerMethodArgumentResolver {
private AuthenticationService authenticationService;
@Override @Override
public boolean supportsParameter(MethodParameter methodParameter) { public boolean supportsParameter(MethodParameter methodParameter) {
return methodParameter.getParameterType().equals(Principal.class); return methodParameter.getParameterType().equals(Principal.class);
@ -22,12 +26,23 @@ public final class PrincipalArgumentResolver implements HandlerMethodArgumentRes
@Override @Override
public Object resolveArgument(MethodParameter methodParameter,ModelAndViewContainer modelAndViewContainer,NativeWebRequest nativeWebRequest,WebDataBinderFactory webDataBinderFactory) throws Exception { public Object resolveArgument(MethodParameter methodParameter,ModelAndViewContainer modelAndViewContainer,NativeWebRequest nativeWebRequest,WebDataBinderFactory webDataBinderFactory) throws Exception {
Principal principal = new Principal(); String token = nativeWebRequest.getHeader("AuthToken");
principal.setName("Giannis"); if(token == null)throw new UnauthorisedException("Authentication Information Is Missing");
principal.setId(UUID.randomUUID()); UUID authToken;
principal.setExpiresAt(new Date()); try{
principal.setToken(UUID.randomUUID()); authToken = UUID.fromString(token);
}catch (IllegalArgumentException ex){
throw new UnauthorisedException("Authentication Information Is Missing");
}
Principal principal = this.authenticationService.Touch(authToken);
if(principal==null)throw new UnauthorisedException("Authentication Information Missing");
return principal; return principal;
} }
@Autowired
private void PrincipalArgumentResolver(AuthenticationService authenticationService){
this.authenticationService = authenticationService;
}
} }

View File

@ -2,8 +2,37 @@ package eu.eudat.models.criteria;
import eu.eudat.entities.Dataset; import eu.eudat.entities.Dataset;
import java.util.Date;
/** /**
* Created by ikalyvas on 12/15/2017. * Created by ikalyvas on 12/15/2017.
*/ */
public class DatasetCriteria extends Criteria<Dataset>{ public class DatasetCriteria extends Criteria<Dataset>{
private Integer status;
private Date periodStart;
private Date periodEnd;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getPeriodStart() {
return periodStart;
}
public void setPeriodStart(Date periodStart) {
this.periodStart = periodStart;
}
public Date getPeriodEnd() {
return periodEnd;
}
public void setPeriodEnd(Date periodEnd) {
this.periodEnd = periodEnd;
}
} }

View File

@ -5,6 +5,7 @@ import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.dmp.DataManagementPlan; import eu.eudat.models.dmp.DataManagementPlan;
import eu.eudat.utilities.builders.DomainModelConverter; import eu.eudat.utilities.builders.DomainModelConverter;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -18,6 +19,7 @@ public class Dataset implements DataModel<eu.eudat.entities.Dataset>{
private String description; private String description;
private short status; private short status;
private String properties; private String properties;
private Date created;
private DataManagementPlan dmp; private DataManagementPlan dmp;
private DatasetProfileListingModel profile; private DatasetProfileListingModel profile;
private List<Registry> registries; private List<Registry> registries;
@ -80,7 +82,13 @@ public class Dataset implements DataModel<eu.eudat.entities.Dataset>{
this.dataRepositories = dataRepositories; this.dataRepositories = dataRepositories;
} }
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getDescription() { public String getDescription() {
return description; return description;
@ -116,6 +124,7 @@ public class Dataset implements DataModel<eu.eudat.entities.Dataset>{
this.registries = new DomainModelConverter<eu.eudat.entities.Registry,Registry>().fromDataModel(entity.getRegistries().stream().collect(Collectors.toList()), Registry.class); this.registries = new DomainModelConverter<eu.eudat.entities.Registry,Registry>().fromDataModel(entity.getRegistries().stream().collect(Collectors.toList()), Registry.class);
this.dataRepositories = new DomainModelConverter<eu.eudat.entities.DataRepository,DataRepository>().fromDataModel(entity.getDataRepositories().stream().collect(Collectors.toList()), DataRepository.class); this.dataRepositories = new DomainModelConverter<eu.eudat.entities.DataRepository,DataRepository>().fromDataModel(entity.getDataRepositories().stream().collect(Collectors.toList()), DataRepository.class);
this.services = new DomainModelConverter<eu.eudat.entities.Service,Service>().fromDataModel(entity.getServices().stream().collect(Collectors.toList()), Service.class); this.services = new DomainModelConverter<eu.eudat.entities.Service,Service>().fromDataModel(entity.getServices().stream().collect(Collectors.toList()), Service.class);
this.created = entity.getCreated();
} }
public eu.eudat.entities.Dataset toDataModel(){ public eu.eudat.entities.Dataset toDataModel(){
@ -128,6 +137,8 @@ public class Dataset implements DataModel<eu.eudat.entities.Dataset>{
entity.setStatus(this.status); entity.setStatus(this.status);
entity.setDmp(dmp.toDataModel()); entity.setDmp(dmp.toDataModel());
entity.setDescription(this.description); entity.setDescription(this.description);
entity.setCreated(this.created!=null?this.created:new Date());
entity.setModified(new Date());
entity.setProfile(profile.toDataModel()); ///TODO entity.setProfile(profile.toDataModel()); ///TODO
if(!this.registries.isEmpty()){ if(!this.registries.isEmpty()){
entity.setRegistries(new HashSet<eu.eudat.entities.Registry>()); entity.setRegistries(new HashSet<eu.eudat.entities.Registry>());

View File

@ -0,0 +1,25 @@
package eu.eudat.models.login;
/**
* Created by ikalyvas on 12/18/2017.
*/
public class LoginInfo {
private String ticket;
private String service;
public String getTicket() {
return ticket;
}
public void setTicket(String ticket) {
this.ticket = ticket;
}
public String getService() {
return service;
}
public void setService(String service) {
this.service = service;
}
}

View File

@ -9,8 +9,28 @@ import eu.eudat.entities.UserInfo;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.dmp.DataManagementPlan; import eu.eudat.models.dmp.DataManagementPlan;
public class Project implements DataModel<eu.eudat.entities.Project>{ public class Project implements DataModel<eu.eudat.entities.Project>{
public enum Status {
ACTIVE((short) 0), INACTIVE((short) 1);
private short value;
private Status(short value) { this.value = value; }
public short getValue(){return value;}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return ACTIVE;
case 1:
return INACTIVE;
default:
throw new RuntimeException("Unsupported Project Status");
}
}
}
private UUID id; private UUID id;
private List<DataManagementPlan> dmps; private List<DataManagementPlan> dmps;
@ -25,11 +45,11 @@ public class Project implements DataModel<eu.eudat.entities.Project>{
private String definition; private String definition;
private Date startdate; private Date startDate;
private Date enddate; private Date endDate;
private Short status; private Status status;
private UserInfo creationUser; private UserInfo creationUser;
@ -96,28 +116,28 @@ public class Project implements DataModel<eu.eudat.entities.Project>{
this.definition = definition; this.definition = definition;
} }
public Date getStartdate() { public Date getStartDate() {
return startdate; return startDate;
} }
public void setStartdate(Date startdate) { public void setStartDate(Date startDate) {
this.startdate = startdate; this.startDate = startDate;
} }
public Date getEnddate() { public Date getEndDate() {
return enddate; return endDate;
} }
public void setEnddate(Date enddate) { public void setEndDate(Date endDate) {
this.enddate = enddate; this.endDate = endDate;
} }
public Short getStatus() { public short getStatus() {
return status; return status.getValue();
} }
public void setStatus(Short status) { public void setStatus(Short status) {
this.status = status; this.status = Status.fromInteger(status);
} }
public UserInfo getCreationUser() { public UserInfo getCreationUser() {
@ -160,9 +180,9 @@ public class Project implements DataModel<eu.eudat.entities.Project>{
this.reference = entity.getReference(); this.reference = entity.getReference();
this.uri = entity.getUri(); this.uri = entity.getUri();
this.definition = entity.getDefinition(); this.definition = entity.getDefinition();
this.startdate = entity.getStartdate(); this.startDate = entity.getStartdate();
this.enddate = entity.getEnddate(); this.endDate = entity.getEnddate();
this.status = entity.getStatus(); this.setStatus(entity.getStatus());
this.created = entity.getCreated(); this.created = entity.getCreated();
this.modified = entity.getModified(); this.modified = entity.getModified();
this.description = entity.getDescription(); this.description = entity.getDescription();
@ -178,10 +198,10 @@ public class Project implements DataModel<eu.eudat.entities.Project>{
entity.setReference(this.reference); entity.setReference(this.reference);
entity.setUri(this.uri); entity.setUri(this.uri);
entity.setDefinition(this.definition); entity.setDefinition(this.definition);
entity.setStartdate(this.startdate); entity.setStartdate(this.startDate);
entity.setCreated(this.created == null? new Date():this.created); entity.setCreated(this.created == null? new Date():this.created);
entity.setEnddate(this.enddate); entity.setEnddate(this.endDate);
entity.setStatus(this.status); entity.setStatus(this.status!=null?this.getStatus():1);
entity.setModified(new Date()); entity.setModified(new Date());
entity.setDescription(this.description); entity.setDescription(this.description);
return entity; return entity;

View File

@ -1,10 +1,12 @@
package eu.eudat.security; package eu.eudat.security;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import javax.naming.NameAlreadyBoundException; import javax.naming.NameAlreadyBoundException;
import eu.eudat.models.login.Credentials; import eu.eudat.models.login.Credentials;
import eu.eudat.models.login.LoginInfo;
import eu.eudat.models.security.Principal; import eu.eudat.models.security.Principal;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.AuthenticationProvider;
@ -30,14 +32,18 @@ public class CustomAuthenticationProvider {
@Autowired private GoogleTokenValidator googleTokenValidator; @Autowired private GoogleTokenValidator googleTokenValidator;
@Autowired private NativeTokenValidator nativeTokenValidator; @Autowired private NativeTokenValidator nativeTokenValidator;
public Principal authenticate(Credentials credentials) throws AuthenticationException { public Principal authenticate(LoginInfo credentials) throws AuthenticationException {
String token = credentials.getSecret(); String token = credentials.getTicket();
try { try {
Principal principal = googleTokenValidator.validateToken(token); Principal principal = googleTokenValidator.validateToken(token);
return principal; return principal;
} catch (NonValidTokenException e) { } catch (NonValidTokenException e) {
e.printStackTrace();
System.out.println("Could not validate a user by his token! Reason: " + e.getMessage()); System.out.println("Could not validate a user by his token! Reason: " + e.getMessage());
throw new AuthenticationServiceException("Token validation failed - Not a valid token"); throw new AuthenticationServiceException("Token validation failed - Not a valid token");
} catch (IOException e) {
e.printStackTrace();
throw new AuthenticationServiceException("IO Exeption");
} }
} }
} }

View File

@ -1,18 +1,20 @@
package eu.eudat.security.validators; package eu.eudat.security.validators;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.security.GeneralSecurityException; import java.security.GeneralSecurityException;
import java.security.Principal; import java.security.Principal;
import java.util.*; import java.util.*;
import com.google.api.client.googleapis.auth.oauth2.*;
import eu.eudat.dao.entities.security.CredentialDao; import eu.eudat.dao.entities.security.CredentialDao;
import eu.eudat.dao.entities.security.UserTokenDao;
import eu.eudat.entities.Credential; import eu.eudat.entities.Credential;
import eu.eudat.entities.UserToken; import eu.eudat.entities.UserToken;
import eu.eudat.models.login.LoginInfo;
import eu.eudat.services.AuthenticationService; import eu.eudat.services.AuthenticationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload; import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload;
import com.google.api.client.http.HttpTransport; import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.http.javanet.NetHttpTransport;
@ -24,6 +26,8 @@ import eu.eudat.exceptions.NonValidTokenException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import static com.sun.org.apache.xalan.internal.xsltc.compiler.Constants.REDIRECT_URI;
@Component @Component
public class GoogleTokenValidator implements TokenValidator { public class GoogleTokenValidator implements TokenValidator {
@ -33,43 +37,38 @@ public class GoogleTokenValidator implements TokenValidator {
@Autowired private UserInfoDao userInfoDao; @Autowired private UserInfoDao userInfoDao;
@Autowired private CredentialDao credentialDao; @Autowired private CredentialDao credentialDao;
@Autowired private AuthenticationService authenticationService; @Autowired private AuthenticationService authenticationService;
private static final List<String> clientIDs = Arrays.asList( @Autowired private UserTokenDao userTokenDao;
"1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com",
"1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com"
);
private GoogleIdTokenVerifier verifier = null; private GoogleTokenResponse verifyUser(String authCode) throws IOException {
GoogleTokenResponse tokenResponse =
public GoogleTokenValidator() { new GoogleAuthorizationCodeTokenRequest(
verifier = new GoogleIdTokenVerifier.Builder(transport, jacksonFactory) new NetHttpTransport(),
.setAudience(clientIDs) JacksonFactory.getDefaultInstance(),
// Or, if multiple clients access the backend: "https://www.googleapis.com/oauth2/v4/token",
//.setAudience(Arrays.asList(CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3)) "524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com",
.build(); "IQjhbYdExPIsjy37mOfB103F",
authCode,
"postmessage") // Specify the same redirect URI that you use with your web
// app. If you don't have a web version of your app, you can
// specify an empty string.
.execute();
return tokenResponse;
} }
private String getAccessToken(GoogleTokenResponse response){
return response.getAccessToken();
}
private GoogleIdToken getUser(GoogleTokenResponse response) throws IOException {
return response.parseIdToken();
}
@Override @Override
public eu.eudat.models.security.Principal validateToken(String token) throws NonValidTokenException { public eu.eudat.models.security.Principal validateToken(String authCode) throws NonValidTokenException, IOException {
GoogleIdToken idToken = null; GoogleTokenResponse tokenResponse = this.verifyUser(authCode);
try { String token = getAccessToken(tokenResponse);
idToken = verifier.verify(token); GoogleIdToken idToken = getUser(tokenResponse);
}
catch(GeneralSecurityException ex) {
throw new NonValidTokenException("Token is not valid -> "+ex.getMessage());
}
catch(IOException ex) {
throw new NonValidTokenException("Could not verify token -> "+ex.getMessage());
}
catch(IllegalArgumentException ex) {
throw new NonValidTokenException("Could not verify token");
}
if(idToken == null) {
throw new NonValidTokenException("Not a valid token");
}
Payload payload = idToken.getPayload(); Payload payload = idToken.getPayload();
@ -78,12 +77,13 @@ public class GoogleTokenValidator implements TokenValidator {
Credential credential = new Credential(); Credential credential = new Credential();
credential.setCreationTime(new Date()); credential.setCreationTime(new Date());
credential.setId(UUID.randomUUID()); credential.setId(UUID.randomUUID());
credential.setStatus(1);
credential.setLastUpdateTime(new Date()); credential.setLastUpdateTime(new Date());
credential.setProvider(1); credential.setProvider(1);
credential.setSecret(token); credential.setSecret(token);
credential.setPublicValue(userInfo.getName()); credential.setPublicValue(userInfo.getName());
credential.setUserInfo(userInfo); credential.setUserInfo(userInfo);
credentialDao.create(credential);
if(userInfo == null) { //means not existing in db, so create one if(userInfo == null) { //means not existing in db, so create one
userInfo = new UserInfo(); userInfo = new UserInfo();
userInfo.setName((String)payload.get("name")); userInfo.setName((String)payload.get("name"));
@ -99,6 +99,7 @@ public class GoogleTokenValidator implements TokenValidator {
else { else {
userInfo.setLastloggedin(new Date()); userInfo.setLastloggedin(new Date());
Set<Credential> credentials = userInfo.getCredentials(); Set<Credential> credentials = userInfo.getCredentials();
if(credentials.contains(credential))credentials.remove(credential);
credentials.add(credential); credentials.add(credential);
userInfo = userInfoDao.update(userInfo); userInfo = userInfoDao.update(userInfo);
} }
@ -107,13 +108,20 @@ public class GoogleTokenValidator implements TokenValidator {
userToken.setUser(userInfo); userToken.setUser(userInfo);
userToken.setIssuedAt(new Date()); userToken.setIssuedAt(new Date());
userToken.setToken(UUID.randomUUID()); userToken.setToken(UUID.randomUUID());
userToken.setExpiresAt(new Date()); userToken.setExpiresAt(addADay(new Date()));
userTokenDao.create(userToken);
return authenticationService.Touch(userToken.getToken()); return authenticationService.Touch(userToken.getToken());
} }
private Date addADay(Date date){
Date dt = new Date();
Calendar c = Calendar.getInstance();
c.setTime(dt);
c.add(Calendar.DATE, 1);
dt = c.getTime();
return dt;
}

View File

@ -4,8 +4,10 @@ import eu.eudat.entities.UserInfo;
import eu.eudat.exceptions.NonValidTokenException; import eu.eudat.exceptions.NonValidTokenException;
import eu.eudat.models.security.Principal; import eu.eudat.models.security.Principal;
import java.io.IOException;
public interface TokenValidator { public interface TokenValidator {
public Principal validateToken(String token) throws NonValidTokenException; public Principal validateToken(String token) throws NonValidTokenException, IOException;
} }

View File

@ -16,7 +16,7 @@ import java.util.UUID;
/** /**
* Created by ikalyvas on 12/15/2017. * Created by ikalyvas on 12/15/2017.
*/ */
@Service @Service("authenticationService ")
public class AuthenticationService { public class AuthenticationService {
@Autowired @Autowired
UserTokenDao userTokenDao; UserTokenDao userTokenDao;

View File

@ -654,7 +654,6 @@
"requires": { "requires": {
"anymatch": "1.3.2", "anymatch": "1.3.2",
"async-each": "1.0.1", "async-each": "1.0.1",
"fsevents": "1.1.3",
"glob-parent": "2.0.0", "glob-parent": "2.0.0",
"inherits": "2.0.3", "inherits": "2.0.3",
"is-binary-path": "1.0.1", "is-binary-path": "1.0.1",
@ -1703,7 +1702,6 @@
"requires": { "requires": {
"anymatch": "1.3.2", "anymatch": "1.3.2",
"async-each": "1.0.1", "async-each": "1.0.1",
"fsevents": "1.1.3",
"glob-parent": "2.0.0", "glob-parent": "2.0.0",
"inherits": "2.0.3", "inherits": "2.0.3",
"is-binary-path": "1.0.1", "is-binary-path": "1.0.1",
@ -3697,910 +3695,6 @@
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true "dev": true
}, },
"fsevents": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz",
"integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==",
"dev": true,
"optional": true,
"requires": {
"nan": "2.8.0",
"node-pre-gyp": "0.6.39"
},
"dependencies": {
"abbrev": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
},
"ajv": {
"version": "4.11.8",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"co": "4.6.0",
"json-stable-stringify": "1.0.1"
}
},
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
},
"aproba": {
"version": "1.1.1",
"bundled": true,
"dev": true,
"optional": true
},
"are-we-there-yet": {
"version": "1.1.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"delegates": "1.0.0",
"readable-stream": "2.2.9"
}
},
"asn1": {
"version": "0.2.3",
"bundled": true,
"dev": true,
"optional": true
},
"assert-plus": {
"version": "0.2.0",
"bundled": true,
"dev": true,
"optional": true
},
"asynckit": {
"version": "0.4.0",
"bundled": true,
"dev": true,
"optional": true
},
"aws-sign2": {
"version": "0.6.0",
"bundled": true,
"dev": true,
"optional": true
},
"aws4": {
"version": "1.6.0",
"bundled": true,
"dev": true,
"optional": true
},
"balanced-match": {
"version": "0.4.2",
"bundled": true,
"dev": true
},
"bcrypt-pbkdf": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"tweetnacl": "0.14.5"
}
},
"block-stream": {
"version": "0.0.9",
"bundled": true,
"dev": true,
"requires": {
"inherits": "2.0.3"
}
},
"boom": {
"version": "2.10.1",
"bundled": true,
"dev": true,
"requires": {
"hoek": "2.16.3"
}
},
"brace-expansion": {
"version": "1.1.7",
"bundled": true,
"dev": true,
"requires": {
"balanced-match": "0.4.2",
"concat-map": "0.0.1"
}
},
"buffer-shims": {
"version": "1.0.0",
"bundled": true,
"dev": true
},
"caseless": {
"version": "0.12.0",
"bundled": true,
"dev": true,
"optional": true
},
"co": {
"version": "4.6.0",
"bundled": true,
"dev": true,
"optional": true
},
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
},
"combined-stream": {
"version": "1.0.5",
"bundled": true,
"dev": true,
"requires": {
"delayed-stream": "1.0.0"
}
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
},
"core-util-is": {
"version": "1.0.2",
"bundled": true,
"dev": true
},
"cryptiles": {
"version": "2.0.5",
"bundled": true,
"dev": true,
"requires": {
"boom": "2.10.1"
}
},
"dashdash": {
"version": "1.14.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"assert-plus": "1.0.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
}
}
},
"debug": {
"version": "2.6.8",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ms": "2.0.0"
}
},
"deep-extend": {
"version": "0.4.2",
"bundled": true,
"dev": true,
"optional": true
},
"delayed-stream": {
"version": "1.0.0",
"bundled": true,
"dev": true
},
"delegates": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"detect-libc": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"ecc-jsbn": {
"version": "0.1.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"jsbn": "0.1.1"
}
},
"extend": {
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"extsprintf": {
"version": "1.0.2",
"bundled": true,
"dev": true
},
"forever-agent": {
"version": "0.6.1",
"bundled": true,
"dev": true,
"optional": true
},
"form-data": {
"version": "2.1.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"asynckit": "0.4.0",
"combined-stream": "1.0.5",
"mime-types": "2.1.15"
}
},
"fs.realpath": {
"version": "1.0.0",
"bundled": true,
"dev": true
},
"fstream": {
"version": "1.0.11",
"bundled": true,
"dev": true,
"requires": {
"graceful-fs": "4.1.11",
"inherits": "2.0.3",
"mkdirp": "0.5.1",
"rimraf": "2.6.1"
}
},
"fstream-ignore": {
"version": "1.0.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"fstream": "1.0.11",
"inherits": "2.0.3",
"minimatch": "3.0.4"
}
},
"gauge": {
"version": "2.7.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"aproba": "1.1.1",
"console-control-strings": "1.1.0",
"has-unicode": "2.0.1",
"object-assign": "4.1.1",
"signal-exit": "3.0.2",
"string-width": "1.0.2",
"strip-ansi": "3.0.1",
"wide-align": "1.1.2"
}
},
"getpass": {
"version": "0.1.7",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"assert-plus": "1.0.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
}
}
},
"glob": {
"version": "7.1.2",
"bundled": true,
"dev": true,
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
}
},
"graceful-fs": {
"version": "4.1.11",
"bundled": true,
"dev": true
},
"har-schema": {
"version": "1.0.5",
"bundled": true,
"dev": true,
"optional": true
},
"har-validator": {
"version": "4.2.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ajv": "4.11.8",
"har-schema": "1.0.5"
}
},
"has-unicode": {
"version": "2.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"hawk": {
"version": "3.1.3",
"bundled": true,
"dev": true,
"requires": {
"boom": "2.10.1",
"cryptiles": "2.0.5",
"hoek": "2.16.3",
"sntp": "1.0.9"
}
},
"hoek": {
"version": "2.16.3",
"bundled": true,
"dev": true
},
"http-signature": {
"version": "1.1.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"assert-plus": "0.2.0",
"jsprim": "1.4.0",
"sshpk": "1.13.0"
}
},
"inflight": {
"version": "1.0.6",
"bundled": true,
"dev": true,
"requires": {
"once": "1.4.0",
"wrappy": "1.0.2"
}
},
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
},
"ini": {
"version": "1.3.4",
"bundled": true,
"dev": true,
"optional": true
},
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"requires": {
"number-is-nan": "1.0.1"
}
},
"is-typedarray": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"isarray": {
"version": "1.0.0",
"bundled": true,
"dev": true
},
"isstream": {
"version": "0.1.2",
"bundled": true,
"dev": true,
"optional": true
},
"jodid25519": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"jsbn": "0.1.1"
}
},
"jsbn": {
"version": "0.1.1",
"bundled": true,
"dev": true,
"optional": true
},
"json-schema": {
"version": "0.2.3",
"bundled": true,
"dev": true,
"optional": true
},
"json-stable-stringify": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"jsonify": "0.0.0"
}
},
"json-stringify-safe": {
"version": "5.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"jsonify": {
"version": "0.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"jsprim": {
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"assert-plus": "1.0.0",
"extsprintf": "1.0.2",
"json-schema": "0.2.3",
"verror": "1.3.6"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
}
}
},
"mime-db": {
"version": "1.27.0",
"bundled": true,
"dev": true
},
"mime-types": {
"version": "2.1.15",
"bundled": true,
"dev": true,
"requires": {
"mime-db": "1.27.0"
}
},
"minimatch": {
"version": "3.0.4",
"bundled": true,
"dev": true,
"requires": {
"brace-expansion": "1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"dev": true,
"requires": {
"minimist": "0.0.8"
}
},
"ms": {
"version": "2.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"node-pre-gyp": {
"version": "0.6.39",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"detect-libc": "1.0.2",
"hawk": "3.1.3",
"mkdirp": "0.5.1",
"nopt": "4.0.1",
"npmlog": "4.1.0",
"rc": "1.2.1",
"request": "2.81.0",
"rimraf": "2.6.1",
"semver": "5.3.0",
"tar": "2.2.1",
"tar-pack": "3.4.0"
}
},
"nopt": {
"version": "4.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"abbrev": "1.1.0",
"osenv": "0.1.4"
}
},
"npmlog": {
"version": "4.1.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"are-we-there-yet": "1.1.4",
"console-control-strings": "1.1.0",
"gauge": "2.7.4",
"set-blocking": "2.0.0"
}
},
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
},
"oauth-sign": {
"version": "0.8.2",
"bundled": true,
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
"bundled": true,
"dev": true,
"optional": true
},
"once": {
"version": "1.4.0",
"bundled": true,
"dev": true,
"requires": {
"wrappy": "1.0.2"
}
},
"os-homedir": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"os-tmpdir": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"osenv": {
"version": "0.1.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"os-homedir": "1.0.2",
"os-tmpdir": "1.0.2"
}
},
"path-is-absolute": {
"version": "1.0.1",
"bundled": true,
"dev": true
},
"performance-now": {
"version": "0.2.0",
"bundled": true,
"dev": true,
"optional": true
},
"process-nextick-args": {
"version": "1.0.7",
"bundled": true,
"dev": true
},
"punycode": {
"version": "1.4.1",
"bundled": true,
"dev": true,
"optional": true
},
"qs": {
"version": "6.4.0",
"bundled": true,
"dev": true,
"optional": true
},
"rc": {
"version": "1.2.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"deep-extend": "0.4.2",
"ini": "1.3.4",
"minimist": "1.2.0",
"strip-json-comments": "2.0.1"
},
"dependencies": {
"minimist": {
"version": "1.2.0",
"bundled": true,
"dev": true,
"optional": true
}
}
},
"readable-stream": {
"version": "2.2.9",
"bundled": true,
"dev": true,
"requires": {
"buffer-shims": "1.0.0",
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "1.0.0",
"process-nextick-args": "1.0.7",
"string_decoder": "1.0.1",
"util-deprecate": "1.0.2"
}
},
"request": {
"version": "2.81.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"aws-sign2": "0.6.0",
"aws4": "1.6.0",
"caseless": "0.12.0",
"combined-stream": "1.0.5",
"extend": "3.0.1",
"forever-agent": "0.6.1",
"form-data": "2.1.4",
"har-validator": "4.2.1",
"hawk": "3.1.3",
"http-signature": "1.1.1",
"is-typedarray": "1.0.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"mime-types": "2.1.15",
"oauth-sign": "0.8.2",
"performance-now": "0.2.0",
"qs": "6.4.0",
"safe-buffer": "5.0.1",
"stringstream": "0.0.5",
"tough-cookie": "2.3.2",
"tunnel-agent": "0.6.0",
"uuid": "3.0.1"
}
},
"rimraf": {
"version": "2.6.1",
"bundled": true,
"dev": true,
"requires": {
"glob": "7.1.2"
}
},
"safe-buffer": {
"version": "5.0.1",
"bundled": true,
"dev": true
},
"semver": {
"version": "5.3.0",
"bundled": true,
"dev": true,
"optional": true
},
"set-blocking": {
"version": "2.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"signal-exit": {
"version": "3.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"sntp": {
"version": "1.0.9",
"bundled": true,
"dev": true,
"requires": {
"hoek": "2.16.3"
}
},
"sshpk": {
"version": "1.13.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"asn1": "0.2.3",
"assert-plus": "1.0.0",
"bcrypt-pbkdf": "1.0.1",
"dashdash": "1.14.1",
"ecc-jsbn": "0.1.1",
"getpass": "0.1.7",
"jodid25519": "1.0.2",
"jsbn": "0.1.1",
"tweetnacl": "0.14.5"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
}
}
},
"string-width": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"requires": {
"code-point-at": "1.1.0",
"is-fullwidth-code-point": "1.0.0",
"strip-ansi": "3.0.1"
}
},
"string_decoder": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"requires": {
"safe-buffer": "5.0.1"
}
},
"stringstream": {
"version": "0.0.5",
"bundled": true,
"dev": true,
"optional": true
},
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
"dev": true,
"requires": {
"ansi-regex": "2.1.1"
}
},
"strip-json-comments": {
"version": "2.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"tar": {
"version": "2.2.1",
"bundled": true,
"dev": true,
"requires": {
"block-stream": "0.0.9",
"fstream": "1.0.11",
"inherits": "2.0.3"
}
},
"tar-pack": {
"version": "3.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"debug": "2.6.8",
"fstream": "1.0.11",
"fstream-ignore": "1.0.5",
"once": "1.4.0",
"readable-stream": "2.2.9",
"rimraf": "2.6.1",
"tar": "2.2.1",
"uid-number": "0.0.6"
}
},
"tough-cookie": {
"version": "2.3.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"punycode": "1.4.1"
}
},
"tunnel-agent": {
"version": "0.6.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "5.0.1"
}
},
"tweetnacl": {
"version": "0.14.5",
"bundled": true,
"dev": true,
"optional": true
},
"uid-number": {
"version": "0.0.6",
"bundled": true,
"dev": true,
"optional": true
},
"util-deprecate": {
"version": "1.0.2",
"bundled": true,
"dev": true
},
"uuid": {
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"verror": {
"version": "1.3.6",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"extsprintf": "1.0.2"
}
},
"wide-align": {
"version": "1.1.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"string-width": "1.0.2"
}
},
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
}
}
},
"fstream": { "fstream": {
"version": "1.0.11", "version": "1.0.11",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",

View File

@ -1,7 +1,6 @@
import { Component, OnInit, ViewEncapsulation} from '@angular/core'; import { Component, OnInit, ViewEncapsulation} from '@angular/core';
import { ServerService } from './services/server.service'; import { ServerService } from './services/server.service';
import { JsonObjest } from '../app/entities/JsonObject.class'; import { JsonObjest } from '../app/entities/JsonObject.class';
import { TokenService, TokenProvider } from './services/login/token.service';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute, NavigationExtras } from '@angular/router'; import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute, NavigationExtras } from '@angular/router';
import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component'; import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component';
import {BreadcrumbModule,MenuItem} from 'primeng/primeng'; import {BreadcrumbModule,MenuItem} from 'primeng/primeng';
@ -32,7 +31,7 @@ export class AppComponent implements OnInit {
constructor(private tokenService : TokenService, private router: Router, private route: ActivatedRoute, private translate: TranslateService) { constructor( private router: Router, private route: ActivatedRoute, private translate: TranslateService) {
// this language will be used as a fallback when a translation isn't found in the current language // this language will be used as a fallback when a translation isn't found in the current language
translate.setDefaultLang('en'); translate.setDefaultLang('en');
// the lang to use, if the lang isn't available, it will use the current loader to get them // the lang to use, if the lang isn't available, it will use the current loader to get them
@ -63,7 +62,6 @@ export class AppComponent implements OnInit {
} }
logout(){ logout(){
this.tokenService.logout();
} }

View File

@ -39,7 +39,6 @@ import { DynamicFormComponent } from './form/dynamic-form.component';
import { DynamicFormFieldComponent } from './form/dynamic-fields/dynamic-form-field.component'; import { DynamicFormFieldComponent } from './form/dynamic-fields/dynamic-form-field.component';
import { ServerService } from './services/server.service'; import { ServerService } from './services/server.service';
import { GlobalVariables } from './services/global-variables.service'; import { GlobalVariables } from './services/global-variables.service';
import { TokenService, TokenProvider } from './services/login/token.service';
import { LocalStorageService } from 'ngx-webstorage'; import { LocalStorageService } from 'ngx-webstorage';
import { DynamicFormGroupComponent } from './form/dynamic-form-group/dynamic-form-group.component'; import { DynamicFormGroupComponent } from './form/dynamic-form-group/dynamic-form-group.component';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
@ -56,7 +55,6 @@ import { PDFService } from './services/transformers/pdf.service';
import { TabModule } from './tabs/tab.module'; import { TabModule } from './tabs/tab.module';
import { AngularDraggableModule } from 'angular2-draggable'; import { AngularDraggableModule } from 'angular2-draggable';
import { NativeLoginService } from './services/login/native-login.service';
import { GooggleSignInComponent } from './login/googgle-sign-in/googgle-sign-in.component'; import { GooggleSignInComponent } from './login/googgle-sign-in/googgle-sign-in.component';
import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component'; import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component';
import { NguiAutoCompleteModule } from '@ngui/auto-complete'; import { NguiAutoCompleteModule } from '@ngui/auto-complete';
@ -195,8 +193,8 @@ import { FigurecardComponent } from './shared/components/figurecard/figurecard.c
useClass: GlobalInterceptor, useClass: GlobalInterceptor,
multi: true, multi: true,
}, },
ServerService, VisibilityRulesService, PaginationService, GlobalVariables, AuthGuard, TokenService, ServerService, VisibilityRulesService, PaginationService, GlobalVariables, AuthGuard,
LocalStorageService, RestBase, EestoreService, NativeLoginService, PDFService, LocalStorageService, RestBase, EestoreService, PDFService,
AuthService,DashboardService,DatasetService, AuthService,DashboardService,DatasetService,
BaseHttpService BaseHttpService
], ],

View File

@ -63,9 +63,9 @@ export class AutocompleteRemoteComponent implements OnInit/* , ControlValueAcces
this.serverService.getThroughProxy(this.field.data.url, query).subscribe( this.serverService.getThroughProxy(this.field.data.url, query).subscribe(
response => { response => {
this.values.length = 0; this.values.length = 0;
response.data.forEach(element => { /* response.data.forEach(element => {
this.values.push(element.attributes.name); this.values.push(element.attributes.name);
}); }); */
}, },
error => { error => {
console.log(error); console.log(error);

View File

@ -14,7 +14,6 @@ import 'rxjs/add/operator/switchMap';
//import { FieldBase } from '../../app/form/fields/field-base'; //import { FieldBase } from '../../app/form/fields/field-base';
import { FieldControlService } from '../../app/services/field-control.service'; import { FieldControlService } from '../../app/services/field-control.service';
import { ServerService } from '../../app/services/server.service'; import { ServerService } from '../../app/services/server.service';
import { TokenService, TokenProvider } from '../services/login/token.service';
import { ModalComponent } from '../modal/modal.component'; import { ModalComponent } from '../modal/modal.component';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
@ -35,7 +34,6 @@ var flatten = require('flat');
// import * as scroll from '../../assets/jquery.scrollTo.min.js'; // import * as scroll from '../../assets/jquery.scrollTo.min.js';
import '../../assets/custom.js';
declare function simple_notifier(type: string, title: string, message: string): any; declare function simple_notifier(type: string, title: string, message: string): any;
@ -71,7 +69,7 @@ export class DynamicFormComponent implements OnInit {
private fragment: string; private fragment: string;
constructor(private serverService: ServerService, private router: Router, private pdfService: PDFService, constructor(private serverService: ServerService, private router: Router, private pdfService: PDFService,
private _location: Location, private route: ActivatedRoute, private tokenService: TokenService private _location: Location, private route: ActivatedRoute
, private visibilityRulesService: VisibilityRulesService , private visibilityRulesService: VisibilityRulesService
) { ) {
this.datasetId = route.snapshot.params['id']; this.datasetId = route.snapshot.params['id'];
@ -85,7 +83,7 @@ export class DynamicFormComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.serverService.getSingleDataset(this.datasetId).subscribe( this.serverService.getSingleDataset(this.datasetId).subscribe(
response => { (response:any) => {
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel); this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel);
this.pages = this.getPages(this.dataModel); this.pages = this.getPages(this.dataModel);
this.createPagination(); this.createPagination();

View File

@ -1,20 +1,17 @@
import { AuthService } from '../services/auth/auth.service';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { TokenService, TokenProvider } from '../services/login/token.service';
@Injectable() @Injectable()
export class AuthGuard implements CanActivate { export class AuthGuard implements CanActivate {
constructor(private router: Router, private tokenService: TokenService) { } constructor(private auth: AuthService, private router: Router) { }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { let url: string = state.url;
if (!this.auth.current()) {
if(this.tokenService.isLoggedIn() == true){ this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: url } });
return true; return false;
} }
// not logged in so redirect to login page with the return url return true;
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }});
return false;
} }
} }

View File

@ -2,7 +2,7 @@
<table class="table"> <table class="table">
<tbody> <tbody>
<tr align="center"> <tr align="center">
<div class="g-signin2" id="googleBtn"></div> <button id="signinButton" (click)="signIn()">Sign in with Google</button>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -1,12 +1,15 @@
import { AuthService } from '../../services/auth/auth.service';
import { HttpClient } from '@angular/common/http';
import { Component, OnInit, ElementRef, AfterViewInit, VERSION, Injectable } from '@angular/core'; import { Component, OnInit, ElementRef, AfterViewInit, VERSION, Injectable } from '@angular/core';
import { TokenService, TokenProvider } from '../../services/login/token.service'; import { Router, ActivatedRoute, Params } from "@angular/router";
import {Router} from '@angular/router'; import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
import { TranslateService } from "@ngx-translate/core";
declare const gapi: any; declare const gapi: any;
declare var $ :any; declare var auth2 :any;
import '../../../assets/custom.js';
declare function simple_notifier(type: string, title: string, message:string): any; declare function simple_notifier(type: string, title: string, message:string): any;
@Component({ @Component({
@ -17,10 +20,9 @@ declare function simple_notifier(type: string, title: string, message:string): a
export class GooggleSignInComponent implements OnInit, Injectable { export class GooggleSignInComponent implements OnInit, Injectable {
constructor(private element: ElementRef, private router : Router,private authService:AuthService,private route:ActivatedRoute,
constructor(private element: ElementRef, private tokenService : TokenService, private router : Router) { public snackBar: MatSnackBar,public language: TranslateService
) { }
}
ngOnInit() { ngOnInit() {
@ -29,64 +31,54 @@ export class GooggleSignInComponent implements OnInit, Injectable {
initiateExternalProviders(){ initiateExternalProviders(){
var clientId = '1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com';
var scope = [
'profile',
'email'
].join(' ');
if(gapi.auth2 == undefined){
gapi.load('auth2', () => { // if(gapi.auth2 == undefined){
gapi.auth2.init({ // gapi.load('auth2', () => {
client_id: clientId,
cookiepolicy: 'single_host_origin',
scope: scope
}).then(()=>this.renderButton());
}); // this.auth2 = gapi.auth2.getAuthInstance({
// client_id: clientId,
// })
// });
}else{ // }else{
gapi.auth2.init({ // this.auth2=gapi.auth2.getAuthInstance({
client_id: clientId, // client_id: clientId,
cookiepolicy: 'single_host_origin', // })}
scope: scope
}).then(()=>this.renderButton()); }
public signIn() {
auth2.grantOfflineAccess().then((authResult)=>this.signInCallback(authResult))
}
signInCallback(authResult){
if (authResult['code']) {
this.authService.login({ticket:authResult['code'],service:"google"}).subscribe(
res => this.onLogInSuccess(res),
error => this.onLogInError(error)
)
} }
} }
public onLogInSuccess(logoutMessage: any) {
this.route.queryParams.subscribe((params: Params) => {
let redirectUrl = params['returnUrl'] ? params['returnUrl'] : '/';
this.router.navigate([redirectUrl]);
})
}
renderButton() { public onLogInError(errorMessage: string) {
console.log(errorMessage);
gapi.signin2.render('googleBtn'); this.snackBar.openFromComponent(SnackBarNotificationComponent, {
var buttonElement = this.element.nativeElement.querySelector('#googleBtn'); data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGIN', language: this.language },
if(buttonElement)this.attachSignin(buttonElement); duration: 3000,
extraClasses: ['snackbar-warning']
} })
}
public attachSignin(element) {
gapi.auth2.getAuthInstance().attachClickHandler(element, {},
(googleUser) => {
//simple_notifier("success",null,"Successful login");
let profile = googleUser.getBasicProfile();
this.tokenService.login(googleUser.getAuthResponse().id_token, TokenProvider.google, profile.getName(), profile.getEmail());
},
function (error) {
//simple_notifier("danger",null,"Failed to login");
console.log(JSON.stringify(error, undefined, 2));
}
);
}
} }

View File

@ -1,12 +1,9 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { NativeLoginService } from '../../services/login/native-login.service';
import { TokenService, TokenProvider } from '../../services/login/token.service';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {MenuItem} from 'primeng/primeng'; import {MenuItem} from 'primeng/primeng';
declare const gapi: any; declare const gapi: any;
import '../../../assets/custom.js';
declare function simple_notifier(type: string, title: string, message:string): any; declare function simple_notifier(type: string, title: string, message:string): any;
@Component({ @Component({
@ -22,7 +19,7 @@ export class MainSignInComponent implements OnInit {
creds : any = {"username":"","password":""}; creds : any = {"username":"","password":""};
constructor( private fb: FormBuilder, private nativeLogin : NativeLoginService, private tokenService : TokenService, private router : Router) { constructor( private fb: FormBuilder, private router : Router) {
} }
@ -39,27 +36,12 @@ export class MainSignInComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.createForm(); this.createForm();
if(this.tokenService.isLoggedIn()){
this.router.navigate(['/welcome'], { queryParams: { /*returnUrl: this.state.url*/ }});
}
} }
login(){ login(){
//login using the credentials //login using the credentials
this.nativeLogin.login(this.creds.username, this.creds.password).subscribe(
response => {
simple_notifier("success",null,"Successful login");
this.tokenService.login(response['token'], TokenProvider.native, this.creds.username, response['email']);
this.router.navigate(['/welcome'], { queryParams: { /*returnUrl: this.state.url*/ }});
},
err => {
simple_notifier("danger",null,"Failed to login");
}
);
} }

View File

@ -65,7 +65,7 @@ export class ModalComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.serverService.listDmpsLabelID().subscribe( this.serverService.listDmpsLabelID().subscribe(
response => { (response:any) => {
console.log("response"); console.log("response");
console.log(response); console.log(response);
//let params = new Param(); //let params = new Param();

View File

@ -1,13 +1,12 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse, HttpErrorResponse} from '@angular/common/http'; import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse, HttpErrorResponse} from '@angular/common/http';
import { TokenService, TokenProvider } from './login/token.service';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
@Injectable() @Injectable()
export class GlobalInterceptor implements HttpInterceptor { export class GlobalInterceptor implements HttpInterceptor {
constructor(public tokenService: TokenService, private router : Router) {} constructor( private router : Router) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
@ -21,7 +20,6 @@ export class GlobalInterceptor implements HttpInterceptor {
if (err instanceof HttpErrorResponse) { if (err instanceof HttpErrorResponse) {
if (err.status === 401) { if (err.status === 401) {
console.log("Received an unauthorized... redirecting to login page"); console.log("Received an unauthorized... redirecting to login page");
this.tokenService.logout();
this.router.navigate(['/login'], { queryParams: { /*returnUrl: this.state.url*/ }}); this.router.navigate(['/login'], { queryParams: { /*returnUrl: this.state.url*/ }});
} }
} }

View File

@ -1,31 +0,0 @@
import { Injectable, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { TokenService, TokenProvider } from '../login/token.service'
import { HttpClient , HttpHeaders, HttpParams} from '@angular/common/http';
import {RestBase} from '../rest-base';
@Injectable()
export class NativeLoginService implements OnInit {
constructor(private restBase: RestBase) {
}
ngOnInit(){
}
login(username, password){
var credentials = {"username": username, "password":password};
return this.restBase.login("nativeLogin", credentials);
}
}

View File

@ -1,110 +0,0 @@
import { Injectable, Inject} from '@angular/core';
import { Observable } from 'rxjs';
import {LocalStorageService} from 'ngx-webstorage';
import {Router} from '@angular/router';
import 'rxjs/add/operator/map';
import { DOCUMENT } from '@angular/platform-browser';
declare var jQuery : any;
import '../../../assets/custom.js';
declare function sign_out_google(): any;
@Injectable()
export class TokenService {
constructor (private storage : LocalStorageService, @Inject(DOCUMENT) private document, private router : Router) {
//var csrfToken : string = jQuery(document).find('meta[name="csrf-token"]').attr('content');
//this.setCSRFToken(csrfToken);
}
/*
getCSRFToken() : string{
return this.storage.retrieve('csrf-token');
}
setCSRFToken(csrfToken : string){
this.storage.store('csrf-token',csrfToken);
}
*/
getProvider() : TokenProvider {
return this.storage.retrieve('provider');
}
setProvider(provider : TokenProvider){
this.storage.store('provider',provider);
}
getToken() : string{
return this.storage.retrieve('token');
}
setToken(token : string){
this.storage.store('token',token);
}
isLoggedIn(){
return this.storage.retrieve('loggedIn');
}
setLoggedIn(boolStatus){
this.storage.store('loggedIn',boolStatus);
}
getEmail(){
return this.storage.retrieve('email');
}
setEmail(email){
this.storage.store('email',email);
}
getUsername(){
return this.storage.retrieve('username');
}
setUsername(username){
this.storage.store('username',username);
}
login(token: string, provider: TokenProvider, username: string, email: string){
this.setLoggedIn(true);
this.setToken(token);
this.setProvider(provider);
this.setUsername(username);
this.setEmail(email);
window.location.reload();
}
logout(){
//set the log out actions here
this.setLoggedIn(false);
this.setEmail(null);
this.setUsername(null);
this.setToken(null);
if(this.getProvider() == TokenProvider.google){
sign_out_google();
}
this.setProvider(null);
this.router.navigate(['/login'], { queryParams: { /*returnUrl: this.state.url*/ }});
//window.location.reload();
}
}
export enum TokenProvider {
native,
google
}

View File

@ -1,5 +1,4 @@
import { HttpClient , HttpHeaders, HttpParams } from '@angular/common/http'; import { HttpClient , HttpHeaders, HttpParams } from '@angular/common/http';
import { TokenService, TokenProvider } from './login/token.service'
import 'rxjs/Rx'; import 'rxjs/Rx';
@ -9,9 +8,9 @@ export class RestBase {
xml2jsonOBJ: any; xml2jsonOBJ: any;
static get parameters() { return [HttpClient, TokenService] } static get parameters() { return [HttpClient] }
constructor(public http : HttpClient, public tokenService : TokenService) { constructor(public http : HttpClient) {
this.xml2jsonOBJ = new X2JS(); this.xml2jsonOBJ = new X2JS();
} }
@ -65,7 +64,7 @@ export class RestBase {
} }
private createOptions(parameters : any){ private createOptions(parameters : any){
var token = this.tokenService.getToken(); /* var token = this.tokenService.getToken();
var provider: TokenProvider = this.tokenService.getProvider(); var provider: TokenProvider = this.tokenService.getProvider();
var params = new HttpParams(); var params = new HttpParams();
@ -81,8 +80,8 @@ export class RestBase {
headers = new HttpHeaders().set('Content-Type', 'application/json').set("google-token", token); headers = new HttpHeaders().set('Content-Type', 'application/json').set("google-token", token);
if(provider == TokenProvider.native) if(provider == TokenProvider.native)
headers = new HttpHeaders().set('Content-Type', 'application/json').set("native-token", token); headers = new HttpHeaders().set('Content-Type', 'application/json').set("native-token", token);
let options = { params: params, headers: headers }; let options = { params: params, headers: headers }; */
return options; return null;
} }

View File

@ -0,0 +1 @@
<h2>{{message}}</h2>

View File

@ -0,0 +1,49 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Component, Input } from "@angular/core";
import { AuthService } from "../core/services/auth.service";
import { ActivatedRoute, Router } from "@angular/router";
var UnauthorizedComponent = (function () {
function UnauthorizedComponent(authService, route, router) {
this.authService = authService;
this.route = route;
this.router = router;
}
UnauthorizedComponent.prototype.ngAfterViewInit = function () {
var _this = this;
var returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
var principal = this.authService.current();
if (!principal) {
this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } });
}
else {
this.authService.me().subscribe(function (principal) {
if (!principal)
_this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } });
}, function (err) { return console.error('An error occurred', err); });
}
};
return UnauthorizedComponent;
}());
__decorate([
Input(),
__metadata("design:type", String)
], UnauthorizedComponent.prototype, "message", void 0);
UnauthorizedComponent = __decorate([
Component({
selector: 'unauthorized-component',
templateUrl: './unauthorized.component.html'
}),
__metadata("design:paramtypes", [AuthService,
ActivatedRoute,
Router])
], UnauthorizedComponent);
export { UnauthorizedComponent };
//# sourceMappingURL=unauthorized.component.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"unauthorized.component.js","sourceRoot":"","sources":["unauthorized.component.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAMzD,IAAa,qBAAqB;IAG9B,+BACY,WAAwB,EACxB,KAAqB,EACrB,MAAc;QAFd,gBAAW,GAAX,WAAW,CAAa;QACxB,UAAK,GAAL,KAAK,CAAgB;QACrB,WAAM,GAAN,MAAM,CAAQ;IACtB,CAAC;IAEL,+CAAe,GAAf;QAAA,iBAaC;QAZG,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC;QACpE,IAAI,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3C,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,CAAC,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,SAAS,CAC3B,UAAA,SAAS;gBACL,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBAAC,KAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;YAChG,CAAC,EACD,UAAA,GAAG,IAAI,OAAA,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,EAAvC,CAAuC,CAAC,CAAC;QACxD,CAAC;IACL,CAAC;IACL,4BAAC;AAAD,CAAC,AAvBD,IAuBC;AArBG;IADC,KAAK,EAAE;;sDACe;AAFd,qBAAqB;IAJjC,SAAS,CAAC;QACP,QAAQ,EAAE,wBAAwB;QAClC,WAAW,EAAE,+BAA+B;KAC/C,CAAC;qCAK2B,WAAW;QACjB,cAAc;QACb,MAAM;GANjB,qBAAqB,CAuBjC;SAvBY,qBAAqB"}

View File

@ -0,0 +1,32 @@
import { AuthService } from '../services/auth/auth.service';
import { Component, Input } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
@Component({
selector: 'unauthorized-component',
templateUrl: './unauthorized.component.html'
})
export class UnauthorizedComponent {
@Input()
public message: string;
constructor(
private authService: AuthService,
private route: ActivatedRoute,
private router: Router
) { }
ngAfterViewInit() {
let returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
let principal = this.authService.current();
if (!principal) {
this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } });
}
else {
this.authService.me().subscribe(
principal => {
if (!principal) this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } });
},
err => console.error('An error occurred', err));
}
}
}

View File

@ -0,0 +1,37 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { UnauthorizedComponent } from './unauthorized.component';
import { UnauthorizedRoutes } from './unauthorized.routes';
import { SharedModule } from '../shared/shared.module';
var UnauthorizedModule = (function () {
function UnauthorizedModule() {
}
return UnauthorizedModule;
}());
UnauthorizedModule = __decorate([
NgModule({
imports: [
CommonModule,
FormsModule,
HttpClientModule,
UnauthorizedRoutes,
SharedModule
],
declarations: [
UnauthorizedComponent
],
exports: [
UnauthorizedComponent
]
})
], UnauthorizedModule);
export { UnauthorizedModule };
//# sourceMappingURL=unauthorized.module.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"unauthorized.module.js","sourceRoot":"","sources":["unauthorized.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAmBtD,IAAa,kBAAkB;IAA/B;IAAkC,CAAC;IAAD,yBAAC;AAAD,CAAC,AAAnC,IAAmC;AAAtB,kBAAkB;IAlB9B,QAAQ,CAAC;QACN,OAAO,EAAE;YACL,YAAY;YACZ,WAAW;YACX,gBAAgB;YAChB,kBAAkB;YAClB,YAAY;SACf;QAED,YAAY,EAAE;YACV,qBAAqB;SACxB;QAED,OAAO,EAAE;YACL,qBAAqB;SACxB;KACJ,CAAC;GAEW,kBAAkB,CAAI;SAAtB,kBAAkB"}

View File

@ -0,0 +1,27 @@
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { UnauthorizedComponent } from './unauthorized.component';
import { UnauthorizedRoutes } from './unauthorized.routes';
import { SharedModule } from '../shared/shared.module'
@NgModule({
imports: [
CommonModule,
FormsModule,
HttpClientModule,
UnauthorizedRoutes,
SharedModule
],
declarations: [
UnauthorizedComponent
],
exports: [
UnauthorizedComponent
]
})
export class UnauthorizedModule { }

View File

@ -0,0 +1,7 @@
import { RouterModule } from '@angular/router';
import { UnauthorizedComponent } from './unauthorized.component';
var routes = [
{ path: '', component: UnauthorizedComponent }
];
export var UnauthorizedRoutes = RouterModule.forChild(routes);
//# sourceMappingURL=unauthorized.routes.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"unauthorized.routes.js","sourceRoot":"","sources":["unauthorized.routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAU,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,IAAM,MAAM,GAAW;IACnB,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE;CACjD,CAAC;AAEF,MAAM,CAAC,IAAM,kBAAkB,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC"}

View File

@ -0,0 +1,9 @@
import { RouterModule, Routes } from '@angular/router';
import { UnauthorizedComponent } from './unauthorized.component';
const routes: Routes = [
{ path: '', component: UnauthorizedComponent }
];
export const UnauthorizedRoutes = RouterModule.forChild(routes);

View File

@ -39,7 +39,7 @@ export class DmpDetailedComponent implements OnInit {
if(this.dmp.previous != null && this.dmp.previous != ""){ if(this.dmp.previous != null && this.dmp.previous != ""){
this.serverService.getDmpHistory(this.dmp.id).subscribe( this.serverService.getDmpHistory(this.dmp.id).subscribe(
response => { response => {
this.previousDMPs = response; //this.previousDMPs = response;
}, },
error => { error => {
console.log("Could not get previous DMPs (history)"); console.log("Could not get previous DMPs (history)");

View File

@ -30,7 +30,7 @@ export class ProjectDetailedComponent implements OnInit {
let projectid = params.projectid; let projectid = params.projectid;
this.serverService.getProject(projectid).subscribe( this.serverService.getProject(projectid).subscribe(
response => { (response:any) => {
this.project = response; this.project = response;
$('#project-details-modal').modal('show'); $('#project-details-modal').modal('show');
//get also projects of dmp (there's a problem with the List<> serialization on server - side) //get also projects of dmp (there's a problem with the List<> serialization on server - side)
@ -66,7 +66,7 @@ export class ProjectDetailedComponent implements OnInit {
this.users.clear(); this.users.clear();
for(var i=0;i<project.dmps.length;i++){ for(var i=0;i<project.dmps.length;i++){
debugger; debugger;
const user = await this.serverService.getUserByID(project.dmps[i].creator).toPromise(); const user:any = await this.serverService.getUserByID(project.dmps[i].creator).toPromise();
this.users.set(project.dmps[i].creator, user.name); this.users.set(project.dmps[i].creator, user.name);
} }
} }
@ -78,7 +78,7 @@ export class ProjectDetailedComponent implements OnInit {
project.dmps.forEach(dmp => { project.dmps.forEach(dmp => {
if(!this.users.has(dmp.creator)){ if(!this.users.has(dmp.creator)){
this.serverService.getUserByID(dmp.creator).subscribe( this.serverService.getUserByID(dmp.creator).subscribe(
user => { (user:any) => {
this.users.set(dmp.creator, user.name); this.users.set(dmp.creator, user.name);
}, },
error => { error => {

View File

@ -1,6 +1,5 @@
<!doctype html> <!doctype html>
<html lang="en"> <html itemscope itemtype="http://schema.org/Article">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
@ -9,7 +8,6 @@
<meta name="csrf-token" content="2c64def7de30197c40276fe1a7ea874ca8871f70be7d7dc3305465a4d5c565e4"> <meta name="csrf-token" content="2c64def7de30197c40276fe1a7ea874ca8871f70be7d7dc3305465a4d5c565e4">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
<meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- <!--
@ -33,8 +31,12 @@
<!-- Nice BS notifications --> <!-- Nice BS notifications -->
<script src="assets/bootstrap-notify.min.js"></script> <script src="assets/bootstrap-notify.min.js"></script>
<!-- that's google sign in library --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
<script src="https://apis.google.com/js/platform.js"></script>
</script>
<script src="https://apis.google.com/js/client:platform.js?onload=start" async defer>
</script>
<!-- font-awesome css --> <!-- font-awesome css -->
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
@ -47,15 +49,24 @@
<!-- my custom global code and css --> <!-- my custom global code and css -->
<link rel="stylesheet" type="text/css" href="assets/custom.css"> <link rel="stylesheet" type="text/css" href="assets/custom.css">
<script src="assets/custom.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head> </head>
<script>
var auth2;
function start() {
gapi.load('auth2', function() {
auth2 = gapi.auth2.init({
client_id: "524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com",
scope: "email"
});
});
}
</script>
<body> <body>
<app-root ></app-root> <app-root></app-root>
</body> </body>
</html> </html>