Setting ExternalServiceInfo when application

This commit is contained in:
Luca Frosini 2022-03-29 14:59:36 +02:00
parent 0286521cfe
commit 4617573a26
1 changed files with 6 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import java.util.concurrent.TimeUnit;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.authorization.library.provider.ClientInfo;
import org.gcube.common.authorization.library.provider.ExternalServiceInfo;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.common.authorization.library.utils.Caller;
import org.gcube.common.authorization.utils.clientid.RenewalProvider;
@ -131,7 +132,11 @@ public class JWTSecret extends Secret {
public ClientInfo getClientInfo() throws Exception {
if(clientInfo==null) {
User user = getUser();
clientInfo = new UserInfo(user.getUsername(), new ArrayList<>(user.getRoles()), user.getEmail(), user.getGivenName(), user.getFamilyName());
if(user.isApplication()) {
clientInfo = new ExternalServiceInfo(user.getUsername(), "UNKNOWN");
}else {
clientInfo = new UserInfo(user.getUsername(), new ArrayList<>(user.getRoles()), user.getEmail(), user.getGivenName(), user.getFamilyName());
}
}
return clientInfo;
}