this.codec = codecInitializer.getCodec();
}
@Override
public User findUserByOAuthProviderUsername(OAuthProviderType oauthProviderType, String oauthProviderUsername) {
UserHandler userHandler = orgService.getUserHandler();
// TODO: Ugly, but it's used due to OrganizationService API limitations because it doesn't allow to find user by unique userProfile attribute
try {
Method m = userHandler.getClass().getDeclaredMethod("findUserByUniqueAttribute", String.class, String.class);
return (User)m.invoke(userHandler, oauthProviderType.getUserNameAttrName(), oauthProviderUsername);
} catch (NoSuchMethodException e) {
String error = "Method findUserByUniqueAttribute(String, String) is not available on userHandler object " + userHandler +
"of class " + userHandler.getClass();
log.error(error);
throw new OAuthException(OAuthExceptionCode.PERSISTENCE_ERROR, error, e);
} catch (Exception e) {
throw new OAuthException(OAuthExceptionCode.PERSISTENCE_ERROR, e);
}