Fixes bug on fetching user of Configurable Provider. (Issue #183)

This commit is contained in:
gkolokythas 2019-11-14 13:33:53 +02:00
parent 5285c1a3a6
commit 893547aee3
4 changed files with 12 additions and 6 deletions

View File

@ -35,7 +35,9 @@ public class ConfigurableProviderCustomProviderImpl implements ConfigurableProvi
Map<String, Object> values = template.postForObject(accessTokenUrl, request, Map.class);
ConfigurableProviderResponseToken responseToken = new ConfigurableProviderResponseToken();
responseToken.setAccessToken((String) values.get(access_token));
responseToken.setExpiresIn((Integer) values.get(expires_in));
if (expires_in != null && !expires_in.isEmpty()) {
responseToken.setExpiresIn((Integer) values.get(expires_in));
}
return responseToken;
}

View File

@ -31,9 +31,12 @@ public class ConfigurableProviderUser {
}
ConfigurableProviderUser getConfigurableProviderUser(Map data, ConfigurableProviderUserSettings user) {
this.id = (String) data.get(user.getId());
this.name = (String) data.get(user.getName());
this.email = (String) data.get(user.getEmail());
if (user.getId() != null && !user.getId().isEmpty())
this.id = (String) data.get(user.getId());
if (user.getName() != null && !user.getName().isEmpty())
this.name = (String) data.get(user.getName());
if (user.getEmail() != null && !user.getEmail().isEmpty())
this.email = (String) data.get(user.getEmail());
return this;
}
}

View File

@ -15,6 +15,7 @@ import eu.eudat.models.data.loginprovider.LoginProviderUser;
import eu.eudat.models.data.security.Principal;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.stream.Collectors;
@Component("configurableProviderTokenValidator")
@ -38,7 +39,7 @@ public class ConfigurableProviderTokenValidator implements TokenValidator {
}
@Override
public Principal validateToken(LoginInfo credentials) throws NullEmailException {
String configurableLoginId = (String) credentials.getData();
String configurableLoginId = ((Map) credentials.getData()).get("configurableLoginId").toString();
ConfigurableProvider configurableProvider = getConfigurableProviderFromId(configurableLoginId);
ConfigurableProviderUser configurableUser = this.configurableProvider.getUser(credentials.getTicket(), configurableProvider.getUser());
LoginProviderUser user = new LoginProviderUser();

View File

@ -17,7 +17,7 @@
"id": "sub",
"name": "name",
"email": "email",
"user_info_endpoint": ""
"user_info_url": ""
},
"oauthUrl": "/authorize",
"scope": "email",