*/
public Object lookup(String role, Context c) throws ServiceException
{
if (c == null)
{
throw new ServiceException(role, "Unable to pass null context");
}
Object o = lookupFManager(role);
if ((o instanceof KeelContextualizable))
{
try
{
((KeelContextualizable) o).setKeelContext(c);
}
catch (ContextException e)
{
throw new ServiceException(role, e.getMessage());
}
}
if (o instanceof Securable)
{
AuthorizationManager am = ((Securable) o).getAuthorizationManager();
if (am == null)
{
throw new ServiceException(role,
"Authorization Manager was not setup properly, this is a container setup problem");
}
try
{
if (! am.allowed(o, c))
{
throw new SecurityException("Service '" + role + "' Not Authorized");
}
}
catch (AuthorizationException e)
{
throw new ServiceException(role, "Error authorizing service " + role + " - " + e.toString());
}
}
return o;
}