*/
public final class SecurityActivator implements BundleActivator
{
public synchronized void start(BundleContext context) throws Exception
{
PermissionAdminImpl pai = null;
SecureAction action = new SecureAction();
Permissions permissions = new Permissions(context, action);
File tmp = context.getDataFile("security" + File.separator + "tmp");
if ((tmp == null) || (!tmp.isDirectory() && !tmp.mkdirs()))
{
throw new IOException("Can't create tmp dir.");
}
// TODO: log something if we can not clean-up the tmp dir
File[] old = tmp.listFiles();
if (old != null)
{
for (int i = 0; i < old.length; i++)
{
old[i].delete();
}
}
if ("TRUE".equalsIgnoreCase(getProperty(context,
SecurityConstants.ENABLE_PERMISSIONADMIN_PROP,
SecurityConstants.ENABLE_PERMISSIONADMIN_VALUE)))
{
File cache = context.getDataFile("security" + File.separator
+ "pa.txt");
if ((cache == null) || (!cache.isFile() && !cache.createNewFile()))
{
throw new IOException("Can't create cache file");
}
pai = new PermissionAdminImpl(permissions, new PropertiesCache(
cache, tmp, action));
}
ConditionalPermissionAdminImpl cpai = null;