private URI callbackToUri(String callbackParameter) throws IOException, OAuthProblemException {
if (callbackParameter.equals("oob")) {
return null;
}
URI callback;
try {
callback = new URI(callbackParameter);
} catch (URISyntaxException e) {
log.error("Unable to parse callback URI '%s'", callbackParameter);
OAuthProblemException problem = new OAuthProblemException(PARAMETER_REJECTED);
problem.setParameter(OAUTH_PARAMETERS_REJECTED, OAUTH_CALLBACK);
problem.setParameter(OAUTH_PROBLEM_ADVICE, String.format(INVALID_CALLBACK_ADVICE, callbackParameter));
throw problem;
}
if (!ServiceProviderToken.isValidCallback(callback)) {
log.error("Invalid callback URI '%s'", callbackParameter);
OAuthProblemException problem = new OAuthProblemException(PARAMETER_REJECTED);
problem.setParameter(OAUTH_PARAMETERS_REJECTED, OAUTH_CALLBACK);
problem.setParameter(OAUTH_PROBLEM_ADVICE, String.format(INVALID_CALLBACK_ADVICE, callbackParameter));
throw problem;
}
return callback;
}
}