@Override
public String execute(Connection<?> connection) {
final Object api = connection.getApi();
Assert.notNull(api, "'api' should never be null");
if (api instanceof Github) {
Github github = (Github) api;
String login = github.getUserOperations().getUserProfile().getLogin();
LOG.info("Got from API : {}", login);
if (configProperties.getAdmins().contains(login)) {
registerUser(login, Arrays.asList(ROLE_ADMIN));
return login;
} else if (configProperties.getUsers().contains(login)) {
registerUser(login, Arrays.asList(ROLE_USER));
return login;
} else if (isTeamMember(login, github)) {
registerUser(login, Arrays.asList(ROLE_USER));
return login;
} else if (configProperties.isAllowAll() ){
registerUser(login, Arrays.asList(ROLE_USER));
return login;
}
} else {
logger.warn("Expected connection of type 'github', but got another : {}", connection.getKey().getProviderId());
}
return null;
}