30 lines
879 B
Java
30 lines
879 B
Java
package eu.eudat.security.validators;
|
|
|
|
import eu.eudat.models.security.Principal;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
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;
|
|
|
|
@Component
|
|
public class NativeTokenValidator implements TokenValidator {
|
|
|
|
@Autowired private TokenSessionManager tokenSessionManager;
|
|
@Autowired private UserInfoDao userInfoDao;
|
|
|
|
@Override
|
|
public Principal validateToken(String token) throws NonValidTokenException {
|
|
String tokenUser = tokenSessionManager.getUser(token);
|
|
if(tokenUser==null || tokenUser.isEmpty())
|
|
throw new NonValidTokenException("Login session has expired! Need to eu.eudat.login again!");
|
|
return new Principal();
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|