getLogger().info("No mandatory redirect URI provided");
return;
}
// Check that clientID and redirURI match
Client client = clients.findById(clientId);
getLogger().info("Client = " + client);
if (client == null) {
// client = clients.createClient(clientId, redirUri);
sendError(sessionId, OAuthError.INVALID_CLIENT,
params.getFirstValue(STATE),
"Need to register the client : " + clientId, null);
getLogger().info("Need to register the client : " + clientId);
return;
}
getLogger().info(
"Compare client redir:provided redir = "
+ client.getRedirectUri() + ":" + redirUri);
if (!redirUri.startsWith(client.getRedirectUri())) {
sendError(sessionId, OAuthError.REDIRECT_URI_MISMATCH,
params.getFirstValue(STATE),
"Callback URI does not match.", null);
getLogger().info("Callback URI does not match.");
return;
}
// Set the real redir URI since it might be longer then the entered one
// Cookie or OpenID
if (session != null && session.getScopeOwner() != null) {
if (flow.equals(ResponseType.token)
|| flow.equals(ResponseType.code)) {
String[] requestedScopes = parseScope(params
.getFirstValue(SCOPE));
for (String scope : requestedScopes) {
getLogger().info("Requested scopes = " + scope);
}
session.setClient(client);
session.setAuthFlow(flow);
session.setRequestedScope(requestedScopes);
// Dynamic URL- we know that the base is same
// Might be used to allow more fine grained path or query params
if (!redirUri.equals(client.getRedirectUri())) {
session.setDynamicCallbackURI(redirUri);
getLogger().info(
"OAuth2 set dynamic callback = " + redirUri);
}