{
throw new RuntimeException(e);
}
for (String res : scope.keySet())
{
Resource resource = identityManager.getResource(realm, res);
html.append("<tr><td><b>Resource: </b>").append(resource.getName()).append("</td><td><b>Roles:</b>");
ScopeMapping mapping = identityManager.getScopeMapping(realm, resource, client);
for (String role : scope.get(res))
{
html.append(" ").append(role);
if (!mapping.getRoles().contains(role))
{
return Response.ok("<h1>Security Alert</h1><p>Known client not authorized for the requested scope.</p>").type("text/html").build();
}
}
html.append("</td></tr>");
}
html.append("</table><p>To Authorize, please login below</p>");
}
else
{
ScopeMapping mapping = identityManager.getScopeMapping(realm, client);
if (mapping != null && mapping.getRoles().contains("login"))
{
html.append("<h1>Login For ").append(realm.getName()).append(" Realm</h1>");
if (validationError != null)
{
try
{
Thread.sleep(1000); // put in a delay
}
catch (InterruptedException e)
{
throw new RuntimeException(e);
}
html.append("<p/><p><b>").append(validationError).append("</b></p>");
}
}
else
{
html.append("<h1>Grant Request For ").append(realm.getName()).append(" Realm</h1>");
if (validationError != null)
{
try
{
Thread.sleep(1000); // put in a delay
}
catch (InterruptedException e)
{
throw new RuntimeException(e);
}
html.append("<p/><p><b>").append(validationError).append("</b></p>");
}
SkeletonKeyScope scope = new SkeletonKeyScope();
List<Resource> resources = identityManager.getResources(realm);
boolean found = false;
for (Resource resource : resources)
{
ScopeMapping resourceScope = identityManager.getScopeMapping(realm, resource, client);
if (resourceScope == null) continue;
if (resourceScope.getRoles().size() == 0) continue;
if (!found)
{
found = true;
html.append("<p>A Third Party is requesting access to the following resources</p>");
html.append("<table>");
}
html.append("<tr><td><b>Resource: </b>").append(resource.getName()).append("</td><td><b>Roles:</b>");
// todo add description of role
for (String role : resourceScope.getRoles())
{
html.append(" ").append(role);
scope.add(resource.getName(), role);
}
}
if (!found)
{
return Response.ok("<h1>Security Alert</h1><p>Known client not authorized to access this realm.</p>").type("text/html").build();