Skip to main content

AppClassloader ClassCastException

1 reply [Last post]
jduxbury
Offline
Joined: 2010-06-08
Points: 0

When running the following code (I think this is where the issue occurs) in AppClassLoader:

// Initialize the ProtectionDomain used for all application files
Policy policy = Policy.getPolicy();
PermissionCollection perms = ((PolicyImpl) policy).createApplicationPermissions(cs);

I am seeing a ClassCastException:

Java_java_net_SocketOutputStream_socketWrite0: length = 255
16380 [pool-1] DEBUG http.HttpFileSys - HttpFileSys.getFileDataPriv() -- Content length = 8649
Java_java_net_PlainSocketImpl_socketAvailable: fd =rio, avai,lale = 848
Java_java_net_PlainSocketImpl_socketAvailable: fd = 4e, available = 0
Java_java_net_PlainSocketImpl_socketAvailable: fd = 4e, available = 0
16424 [pool-1] DEBUG application.XletApp - Could not exec org.cablelabs.impl.manager.application.XletApp$5@abe1bc6f
java.lang.ClassCastException: sun.security.provider.PolicyFile
at org.cablelabs.impl.manager.application.AppClassLoader.(Unknown Source)
at org.cablelabs.impl.manager.application.AppClassLoader.(Unknown Source)
at org.cablelabs.impl.managAppapplication.Ap157ntext.loang:nkdApn Source),boat =tr.c,vielabs.imp3,panorir.a150icaseDn.X/VOAp
pp/,clausPank=[]nclaurce)
at org.cablelabs.impl.manager.application.XletApp$Returnable.run(Unknown Source)
at org.cablelabs.impl.manager.application.AbstractCallerContext$2.run(Unknown Source)
at org.cablelabs.impl.manager.application.AbstractCallerContext$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Compiled Method)(Unknown Source)
at org.cablelabs.impl.manager.application.AbstractCallerContext.runAsContextSamePriority(Unknown Source)
at org.cablelabs.impl.manager.application.AbstractCallerContext.runAsContext(Unknown Source)
at org.cablelabs.impl.manager.application.XletApp$Rerernapis.doit(Un
1wn Source)
aBUGrg.cablelabs.imesDmanager.application.XletA IMdoLApp(Unknown Source)
at org.cablelabs.impl.manager.application.XletApp.handleAutpriart(Unkn5,b SoDire)CMAat o83/calaslabth=mpcr-anagiceapplicatta
-.Apredcatl],$SasseChe=ce.rcoxUnma.wn entrce)
atparg.cablelabs.impl.manager.aablication.WorklasaScrrenDUnknoed=Source)
at org.cablelabs.impl.manager.application.AbstractCallerContext$2.run(Unknown Source)
at org.cablelabs.impl.manager.application.AbstractCallerContext$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Compiled Method)(Unknown Source)
at org.cablelabs.impl.manager.application.AbstractCallerContext.runAsContextSamePriority(Unknown Source)
at omplcablelate.impl.manager.application.AbstractCallerContext.runAsContext(Unknown Source)
at org.cablelabs.impl.manager.application.ContextTask.run(Unknown Source)
at org.cablelabs.impl.manager.application.DemandExecQueue$DemandTask.run(Unknown Source)
at org.cablelabs.impl.manager.application.WorkerTask.run(Unknown Source)
at org.cablelabs.impl.manager.application.ThreadPool$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at java.lang.Thread.startup(Unknown Source)

I noticed has been added as of 1.1.4. What's to say that the call to Policy.getPolicy() should return a PolicyImpl as opposed to the sun.security.provider.PolicyFile specified in the java.security file? I don't see any overrides for this call anywhere. I need some help piecing this together.

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
greg80303
Offline
Joined: 2008-07-03
Points: 0

There can be only one Policy implementation at a time. In our case, that is the org.cablelabs.impl.security.PolicyImpl class that implements the application security policy mandated by the OCAP specification.

Unless you are using a modified version of the stack, I'm not sure how you could ever get Policy.getPolicy() to return something other than PolicyImpl. In org.cablelabs.impl.ocap.OcapMain.startApps(), right before starting any applications, we initialize security by calling securitySetup() on the registered OcapSecurityManager. In both implementations of OcapSecurityManager (org.cablelabs.impl.manager.security.OcapSecurityImpl and org.cablelabs.impl.manager.security.NoAccessControl) we call Policy.setPolicy() with an instance of PolicyImpl. If any calls are being made by your VM to set the policy based on the values in the policy file, it should be overwritten by the code I just mentioned.

You should step through this initialization sequence on your system and ensure that you see these calls being made.

G