PersistentFactory pf = null;
if (ue.getGroups().size() == 0)
{
throw new AuthorizationException("User '" + ue.getLoginName() + "' is not a member of any groups");
}
try
{
pf = getPersistentFactory();
Persistent serviceSecurity = pf.create("component-security.instancesecurity");
serviceSecurity.setBypassAuthorizationManager(bypassAm);
/* Iterate through all the groups that this principal is a member of */
String oneGroup = null;
for (Iterator j = ue.getGroups().iterator(); j.hasNext();)
{
oneGroup = (String) j.next();
serviceSecurity.clear();
serviceSecurity.setField("component", getComponentName(o.getService()));
serviceSecurity.setField("groupname", oneGroup);
serviceSecurity.setField("instance", instanceName);
if (log.isDebugEnabled())
{
log.debug("Looking for " + serviceSecurity.toString());
}
if (serviceSecurity.find())
{
if (operationCode.equals("*"))
{
return true;
}
if (serviceSecurity.getFieldString("allowedoperations").indexOf(operationCode) > 0)
{
return true;
}
if (serviceSecurity.getFieldString("allowedoperations").equals("*"))
{
return true;
}
}
}
}
catch (PersistenceException pe)
{
log.error("Database error checking authorization", pe);
throw new AuthorizationException(pe);
}
catch (AuthorizationException ae)
{
log.error("Authorization error while checking authorization", ae);
throw new AuthorizationException(ae);
}
finally
{
releaseService(pf);