2017-12-15 00:01:26 +01:00
|
|
|
package eu.eudat.security.validators;
|
2017-10-13 17:08:49 +02:00
|
|
|
|
2017-12-15 17:57:41 +01:00
|
|
|
import eu.eudat.models.security.Principal;
|
2017-10-13 17:08:49 +02:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
import eu.eudat.dao.entities.UserInfoDao;
|
|
|
|
import eu.eudat.entities.UserInfo;
|
|
|
|
import eu.eudat.exceptions.NonValidTokenException;
|
|
|
|
import eu.eudat.security.TokenSessionManager;
|
|
|
|
import org.springframework.stereotype.Component;
|
2017-10-13 17:08:49 +02:00
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
@Component
|
2017-10-13 17:08:49 +02:00
|
|
|
public class NativeTokenValidator implements TokenValidator {
|
|
|
|
|
|
|
|
@Autowired private TokenSessionManager tokenSessionManager;
|
2017-10-20 12:03:55 +02:00
|
|
|
@Autowired private UserInfoDao userInfoDao;
|
2017-10-13 17:08:49 +02:00
|
|
|
|
|
|
|
@Override
|
2017-12-15 17:57:41 +01:00
|
|
|
public Principal validateToken(String token) throws NonValidTokenException {
|
2017-10-13 17:08:49 +02:00
|
|
|
String tokenUser = tokenSessionManager.getUser(token);
|
|
|
|
if(tokenUser==null || tokenUser.isEmpty())
|
2017-12-15 00:01:26 +01:00
|
|
|
throw new NonValidTokenException("Login session has expired! Need to eu.eudat.login again!");
|
2017-12-15 17:57:41 +01:00
|
|
|
return new Principal();
|
2017-10-13 17:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|