this.oauthCodec = oauthCodec;
}
@Override
public void preSave(UserProfile userProfile, boolean isNew) throws Exception {
UserProfile foundUserProfile = userProfileHandler.findUserProfileByName(userProfile.getUserName());
if(foundUserProfile == null) {
foundUserProfile = userProfileHandler.createUserProfileInstance(userProfile.getUserName());
}
for (OAuthProviderType opt : oauthProviderTypeRegistry.getEnabledOAuthProviders()) {
String oauthProviderUsername = userProfile.getAttribute(opt.getUserNameAttrName());
String foundOauthProviderUsername = foundUserProfile.getAttribute(opt.getUserNameAttrName());
// This means that oauthUsername has been changed. We may need to invalidate current accessToken as well
if (!Safe.equals(oauthProviderUsername, foundOauthProviderUsername)) {
OAuthProviderProcessor processor = opt.getOauthProviderProcessor();
Object currentAccessToken = processor.getAccessTokenFromUserProfile(userProfile, oauthCodec);