D
David Thielen
Hi;
I have the following method:
public static InputStream loadResource(String filename, int location)
throws IOException
{
if ((filename == null) || (filename.length() == 0))
return null;
if ((location & (THREAD | APP_CLASS | SYSTEM_CLASS)) != 0)
{
System.IO.Stream stream =
Class.ToType(SystemWrapper.class).get_Assembly().GetManifestResourceStream(filename);
if (stream != null)
return new JavaInputStream(stream);
}
// file
if ((location & FILE) != 0) {
File file = new File(filename);
if (file.exists()) {
if (log.isInfoEnabled())
log.info("Loading resource file: " + new
File(filename).getAbsolutePath());
return new FileInputStream(file);
}
}
// url last
if ((location & URL) != 0) {
try {
URL url = new URL(filename);
if (log.isInfoEnabled())
log.info("Loading resource file: " + new
File(filename).getAbsolutePath());
return url.openStream();
} catch (MalformedURLException mue) {
// nothing
}
}
return null;
}
And it's permissions demanded are:
<Method Sig="class InputStream loadResource(string , int )">
<Demand>
<PermissionSet version="1"
class="System.Security.PermissionSet">
<IPermission version="1"
class="System.Security.Permissions.EnvironmentPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Read="UserName" />
<IPermission version="1"
class="System.Security.Permissions.FileIOPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Unrestricted="true" />
<IPermission version="1"
class="System.Security.Permissions.ReflectionPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Flags="MemberAccess" />
<IPermission version="1"
class="System.Security.Permissions.RegistryPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Unrestricted="true" />
<IPermission version="1"
class="System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Flags="UnmanagedCode, ControlThread, ControlEvidence" />
<IPermission version="1"
class="System.Security.Permissions.KeyContainerPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Unrestricted="true" />
</PermissionSet>
</Demand>
<Sandbox>
<PermissionSet version="1"
class="System.Security.PermissionSet" Unrestricted="true" />
</Sandbox>
</Method>
However, all of the above permissions are not required to run our program.
In most cases the GetManifestResourceStream is the only part used. How do I
set this to say that these requests are optional not required?
I hope it's not having to go set permissions on each method throughout our
code because that would take weeks.
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
I have the following method:
public static InputStream loadResource(String filename, int location)
throws IOException
{
if ((filename == null) || (filename.length() == 0))
return null;
if ((location & (THREAD | APP_CLASS | SYSTEM_CLASS)) != 0)
{
System.IO.Stream stream =
Class.ToType(SystemWrapper.class).get_Assembly().GetManifestResourceStream(filename);
if (stream != null)
return new JavaInputStream(stream);
}
// file
if ((location & FILE) != 0) {
File file = new File(filename);
if (file.exists()) {
if (log.isInfoEnabled())
log.info("Loading resource file: " + new
File(filename).getAbsolutePath());
return new FileInputStream(file);
}
}
// url last
if ((location & URL) != 0) {
try {
URL url = new URL(filename);
if (log.isInfoEnabled())
log.info("Loading resource file: " + new
File(filename).getAbsolutePath());
return url.openStream();
} catch (MalformedURLException mue) {
// nothing
}
}
return null;
}
And it's permissions demanded are:
<Method Sig="class InputStream loadResource(string , int )">
<Demand>
<PermissionSet version="1"
class="System.Security.PermissionSet">
<IPermission version="1"
class="System.Security.Permissions.EnvironmentPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Read="UserName" />
<IPermission version="1"
class="System.Security.Permissions.FileIOPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Unrestricted="true" />
<IPermission version="1"
class="System.Security.Permissions.ReflectionPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Flags="MemberAccess" />
<IPermission version="1"
class="System.Security.Permissions.RegistryPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Unrestricted="true" />
<IPermission version="1"
class="System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Flags="UnmanagedCode, ControlThread, ControlEvidence" />
<IPermission version="1"
class="System.Security.Permissions.KeyContainerPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Unrestricted="true" />
</PermissionSet>
</Demand>
<Sandbox>
<PermissionSet version="1"
class="System.Security.PermissionSet" Unrestricted="true" />
</Sandbox>
</Method>
However, all of the above permissions are not required to run our program.
In most cases the GetManifestResourceStream is the only part used. How do I
set this to say that these requests are optional not required?
I hope it's not having to go set permissions on each method throughout our
code because that would take weeks.
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm