ArgUtil.notNull(new Object[] { fullPath, permission }, new String[] { "fullPath", "permission" },
"grantPermission(java.security.Principal, java.security.Permission)");
Collection internalPermissions = new ArrayList();
InternalPrincipal internalPrincipal = getInternalPrincipal(fullPath);
if (null == internalPrincipal)
{
if ( principal instanceof UserPrincipal )
{
throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(principal.getName()));
}
else if ( principal instanceof RolePrincipal )
{
throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(principal.getName()));
}
// must/should be GroupPrincipal
throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(principal.getName()));
}
InternalPermission internalPermission = getInternalPermission(permission);
if (null == internalPermission)
{
throw new SecurityException(SecurityException.PERMISSION_DOES_NOT_EXIST.create(permission.getName()));
}
if (null != internalPrincipal.getPermissions())
{
internalPermissions.addAll(internalPrincipal.getPermissions());
}
if (!internalPermissions.contains(internalPermission))
{
internalPermissions.add(internalPermission);
}
// clear the whole ThreadLocal permissions cache
permissionsCache.set(null);
try
{
internalPrincipal.setModifiedDate(new Timestamp(System.currentTimeMillis()));
internalPrincipal.setPermissions(internalPermissions);
getPersistenceBrokerTemplate().store(internalPrincipal);
}
catch (Exception e)
{