all groups > vj# > january 2004 >
You're in the

vj#

group:

What code access security permisssions does vjslib need?


What code access security permisssions does vjslib need? Teo Lachev
1/29/2004 5:13:10 PM
vj#:
Hi,

I have a J# class library which I call from Reporting Services. Inside the
RS configuraration file I defined a custom code access group, as follows:
<CodeGroup class="UnionCodeGroup" version="1"
PermissionSetName="FullTrust" Name="OpenForecastCodeGroup">
<IMembershipCondition class="UrlMembershipCondition" version="1"
Url="C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\ReportServer\bin\OpenForecast.dll"/>
</CodeGroup>

The call fails with the exception below. What set of permissions does the J#
library need to execute successfully? I ran PermView but got no results.

Exception: System.Security.SecurityException: Request for the permission of
type com.ms.vjsharp.util.VJSPermission, vjslib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a failed.
at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken,
CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames,
Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap,
StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at java.lang.System.getProperty(String key, String def)
at java.lang.System.getProperty(String key)
at net.sourceforge.openforecast.DataSet.ToString() in
C:\Books\RS\Code\OpenForecast\DataSet.java:line 384
at System.Diagnostics.TraceListener.WriteLine(Object o)
at System.Diagnostics.TraceInternal.WriteLine(Object value)
at System.Diagnostics.Trace.WriteLine(Object value)
at AWC.RS.Library.RsLibrary.GetForecastedSet(Double[] dataSet, Int32
numberForecastedPoints) in c:\books\rs\code\awrslibrary\rslibrary.cs:line 43
at CustomCodeProxy.GetValue(Int32 productCategoryID, DateTime orderDate,
Double sales, Parameters reportParameters, TextBox txtRange)

--
Teo Lachev


Re: What code access security permisssions does vjslib need? Teo Lachev
1/29/2004 5:57:30 PM
Thank you. The J# library doesn't make any external calls. It just allocates
arrays and performs math calculations. Both assemblies are installed
locally. Inoticed that the vsjlib calls down to native Windows APIs which
might be causing the problem.




[quoted text, click to view]

Re: What code access security permisssions does vjslib need? mikegreonline NO[at]SPAM microsoft.com
1/29/2004 11:19:24 PM
Teo,

How is your J# code getting called. I see that in your code group you use a
URL as the membership condition. I'm thinking that maybe that membership
condition is not getting satisfied because of how the J# code is getting
loaded and executed. Please explain how this code is getting called.

Thanks,

Michael Green
Microsoft Developer Support
Re: What code access security permisssions does vjslib need? Lars-Inge Tønnessen
1/29/2004 11:50:12 PM
Take a look at this msdn doc:

http://msdn.microsoft.com/library/en-us/dv_vjsharp/html/vjgrfSecuritySemanticsForApplicationsWrittenInVisualJNET.asp

Maybe your classes access other classes with more security than FullTrust?

--
Regards,
Lars-Inge Tonnessen
http://emailme.larsinge.com
http://www.larsinge.com

Re: What code access security permisssions does vjslib need? Lars-Inge Tønnessen
1/30/2004 12:05:07 AM

Try to see if you can find anything in the "Contol Panel" + "Admin Tools" +
"Microsoft .NET Framework Configuration" + "Runtime Security Policy".

--
Regards,
Lars-Inge Tonnessen
http://emailme.larsinge.com
http://www.larsinge.com

RE: What code access security permisssions does vjslib need? mikegreonline NO[at]SPAM microsoft.com
2/10/2004 7:25:16 PM
You might want to take a look at the ‘Using Strong-Named Assemblies’ topic
in SQL Reporting Services BOL. The following is an excerpt from that topic
which may be useful.

Using the AllowPartiallyTrustedCallersAttribute
You can use the AllowPartiallyTrustedCallersAttribute to allow strong-named
assemblies to be called by Report Designer or the report server in report
expressions. If a custom assembly that you or a third-party create is
strong-named, using the AllowPartiallyTrustedCallersAttribute is the
recommended way in which strong-named assemblies can be incorporated into
your reports.

Security Note Before deploying an assembly that contains the
AllowPartiallyTrustedCallersAttribute to your report server, you should
review what operations and resources its public members can access. Always
perform a security review before deploying custom assemblies to your report
server.

I hope this is helpful,

Michael Green
Microsoft Developer Support
--------------------
| From: "Teo Lachev" <teo@online.hp.com>
| Subject: What code access security permisssions does vjslib need?
| Date: Thu, 29 Jan 2004 17:13:10 -0500
| Lines: 43
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <OanzVUr5DHA.2300@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.vjsharp
| NNTP-Posting-Host: 209.101.193.66
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.vjsharp:5272
| X-Tomcat-NG: microsoft.public.dotnet.vjsharp
|
| Hi,
|
| I have a J# class library which I call from Reporting Services. Inside the
| RS configuraration file I defined a custom code access group, as follows:
| <CodeGroup class="UnionCodeGroup" version="1"
| PermissionSetName="FullTrust" Name="OpenForecastCodeGroup">
| <IMembershipCondition class="UrlMembershipCondition" version="1"
| Url="C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
| Services\ReportServer\bin\OpenForecast.dll"/>
| </CodeGroup>
|
| The call fails with the exception below. What set of permissions does the
J#
| library need to execute successfully? I ran PermView but got no results.
|
| Exception: System.Security.SecurityException: Request for the permission
of
| type com.ms.vjsharp.util.VJSPermission, vjslib, Version=1.0.5000.0,
| Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a failed.
| at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
| grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
| PermissionToken permToken)
| at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
permToken,
| CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames,
| Int32 unrestrictedOverride)
| at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
cap,
| StackCrawlMark& stackMark)
| at System.Security.CodeAccessPermission.Demand()
| at java.lang.System.getProperty(String key, String def)
| at java.lang.System.getProperty(String key)
| at net.sourceforge.openforecast.DataSet.ToString() in
| C:\Books\RS\Code\OpenForecast\DataSet.java:line 384
| at System.Diagnostics.TraceListener.WriteLine(Object o)
| at System.Diagnostics.TraceInternal.WriteLine(Object value)
| at System.Diagnostics.Trace.WriteLine(Object value)
| at AWC.RS.Library.RsLibrary.GetForecastedSet(Double[] dataSet, Int32
| numberForecastedPoints) in c:\books\rs\code\awrslibrary\rslibrary.cs:line
43
| at CustomCodeProxy.GetValue(Int32 productCategoryID, DateTime orderDate,
| Double sales, Parameters reportParameters, TextBox txtRange)
|
| --
| Teo Lachev
|
|
|
|
Re: What code access security permisssions does vjslib need? Teo Lachev
2/10/2004 9:55:47 PM
Michael,

Are you saying that I need to convert my C# and J# assemblies to
strong-named assemblies?




[quoted text, click to view]

Re: What code access security permisssions does vjslib need? mikegreonline NO[at]SPAM microsoft.com
2/11/2004 6:50:08 PM
There are a couple of things to know here:

First off J# code currently is not able to be called from partially trusted
code (i.e. anything that does not have full trust).
Secondly in order to for your code to be called from Reporting Services
your assemblies they must be marked with the AllowPartiallyTrustedCallers
and be strong named.

So you won't be able to call J# assemblies from Reporting Services (even if
there is a C# assembly in between).

There is no "conversion" involved in strong naming an assembly. All you
need to do is generate a key pair with the sn.exe tool and then use the
[assembly: AssemblyKeyFile("")] directive to specify your key pair (.snk
file).

I hope this is helpful,

Michael Green
Microsoft Developer Support
Re: What code access security permisssions does vjslib need? Lars-Inge Tønnessen
2/11/2004 8:20:33 PM

What about using a Remoting.net layer from C# to J# ?

--
Regards,
Lars-Inge Tonnessen
http://emailme.larsinge.com
http://www.larsinge.com


[quoted text, click to view]

Re: What code access security permisssions does vjslib need? Teo Lachev
2/12/2004 12:59:21 PM
Michael,

Thanks for perservering. Reporting Services does allow calling
"weekly"-named assemblies. Anyway, I tried the strong-named approach and
AllowPartiallyTrustedCaller attribute to no avail. The exception now is:

Exception: System.TypeInitializationException: The type initializer for
"java.lang.System" threw an exception. ---> java.lang.UnsatisfiedLinkError:
?
--- End of inner exception stack trace ---
at java.lang.System.arraycopy(Object src, Int32 src_position, Object dst,
Int32 dst_position, Int32 length)
at java.util.ArrayList.add(Int32 ix, Object e)
at java.util.ArrayList.add(Object e)
at net.sourceforge.openforecast.DataSet.add(DataPoint dataPoint) in
C:\Books\RS\Code\OpenForecast\DataSet.java:line 125
at AWC.RS.Library.RsLibrary.GetForecastedSet(Double[] dataSet, Int32
numberForecastedPoints) in c:\books\rs\code\awrslibrary\rslibrary.cs:line 39
at CustomCodeProxy.GetValue(Int32 productCategoryID, DateTime orderDate,
Double sales, Parameters reportParameters, TextBox txtRange)


If I replace the java library with C# assembly (which I don't want to do),
the calls completes successfully even if both assemblies are weekly-named.
What is UnsatisfiedLinkError?

Regards,

Teo

[quoted text, click to view]

Re: What code access security permisssions does vjslib need? Teo Lachev
2/12/2004 2:45:00 PM
After adding UnmanagedCode permission, now the error message is bit more
informative:

Exception: System.TypeInitializationException: The type initializer for
"java.lang.System" threw an exception. ---> java.lang.UnsatisfiedLinkError:
Unable to load DLL (vjsnativ).
--- End of inner exception stack trace ---
at java.lang.System.arraycopy(Object src, Int32 src_position, Object dst,
Int32 dst_position, Int32 length)
at java.util.ArrayList.add(Int32 ix, Object e)
at java.util.ArrayList.add(Object e)
at net.sourceforge.openforecast.DataSet.add(DataPoint dataPoint) in
C:\Books\RS\Code\OpenForecast\DataSet.java:line 125
at AWC.RS.Library.RsLibrary.GetForecastedSet(Double[] dataSet, Int32
numberForecastedPoints) in c:\books\rs\code\awrslibrary\rslibrary.cs:line 39
at CustomCodeProxy.GetValue(Int32 productCategoryID, DateTime orderDate,
Double sales, Parameters reportParameters, TextBox txtRange)

Which begs the same question. What permissions does vjsnativ need so I can
assert it in my J# code?

[quoted text, click to view]

Re: What code access security permisssions does vjslib need? Teo Lachev
2/12/2004 3:28:24 PM
Getting closer. After some more trials and errors I get now:

Exception: System.Security.SecurityException: Request for the permission of
type com.ms.vjsharp.util.VJSPermission, vjslib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a failed.
at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken,
CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames,
Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap,
StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at java.lang.System.getProperty(String key, String def)
at java.lang.System.getProperty(String key)
at net.sourceforge.openforecast.DataSet.ToString() in
C:\Books\RS\Code\OpenForecast\DataSet.java:line 384
at System.Diagnostics.TraceListener.WriteLine(Object o)
at System.Diagnostics.TraceInternal.WriteLine(Object value)
at System.Diagnostics.Trace.WriteLine(Object value)
at AWC.RS.Library.RsLibrary.GetForecastedSet(Double[] dataSet, Int32
numberForecastedPoints) in c:\books\rs\code\awrslibrary\rslibrary.cs:line 45
at CustomCodeProxy.GetValue(Int32 productCategoryID, DateTime orderDate,
Double sales, Parameters reportParameters, TextBox txtRange)

How shoud I declare the VJSPermission in the configuration file? This is
what I tried but it doesn't work:

<SecurityClass Name="VJSPermission"
Description="com.ms.vjsharp.util.VJSPermission, vjslib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

<PermissionSet

class="NamedPermissionSet"

version="1"

Unrestricted="true"

Name="MyPermissionSet">

<IPermission

class="VJSPermission"

version="1"

Flags="FullTrust"

/>

</PermissionSet>

Then,

<CodeGroup class="UnionCodeGroup" version="1"
PermissionSetName="MyPermissionSet" Name="OpenForecast">

<IMembershipCondition class="UrlMembershipCondition" version="1"
Url="C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\ReportServer\bin\OpenForecast.dll"/>

</CodeGroup>





[quoted text, click to view]

Re: What code access security permisssions does vjslib need? Teo Lachev
2/12/2004 3:47:28 PM
I wasn't able to figure it out but removing the Diagnostic.Trace.WriteLine
calls seems to fix the problem. Those calls were outputting some custom
structures by iterating through their elements. Now the report works with
only FullTrust permissions to both binaries.

Thanks for all of your help Michael and Lars.

Regards,

Teo




[quoted text, click to view]

AddThis Social Bookmark Button