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);
Object foundAccessToken = processor.getAccessTokenFromUserProfile(foundUserProfile, oauthCodec);
// In this case, we need to remove existing accessToken
if (currentAccessToken != null && currentAccessToken.equals(foundAccessToken)) {
if (log.isTraceEnabled()) {
log.trace("Removing accessToken for oauthProvider=" + opt + ", username=" + userProfile.getUserName());
}
processor.removeAccessTokenFromUserProfile(userProfile);
}
}
}
}