eclipse-ee4j / tyrus

Tyrus
Other
112 stars 36 forks source link

Support for running websocket client inside sandbox Java applet #508

Open glassfishrobot opened 10 years ago

glassfishrobot commented 10 years ago

Tyrus websocket client doesn't function out of the box within sandbox applet due to its restrictions and security limitations. There were 2 major problems with the existing code base: access to system properties (restricted in sandbox except for few specific Java properties, see http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/properties.html) and some Java reflections code that behaves differently in Sandbox applet than in a standalone application.

Below is the list of changes we've implemented to resolve the issue in Tyrus project (Grizzly project has a much bigger list):

1. /containers/grizzly-client/src/main/java/org/glassfish/tyrus/container/grizzly/client/GrizzlyClientSocket.java Made conditional access to system properties (when having no access - in sandbox applet, use predefined default). Also made conditional access to proxy settings (not allowed in sandbox).

2. /core/src/main/java/org/glassfish/tyrus/core/ReflectionHelper.java getParameterizedClassArguments method behaves differently in sandbox and in standalone application. Specifically, p.genericInterface is never instance of ParameterizedType (Java reflection getGeneric... methods do not return the correct type in sandbox for typed classes; for example, in standalone application we get MyClass.InnerClass while in sandbox we get only MyClass.InnerClass only). As a workaround resolution, we hard coded specific org.glassfish.tyrus.core.coder.X classes instead of dynamic resolution.

Probably the solution we've implemented is not the best so it is just a hint on what should be fixed and where.

Environment

WildFly 8.1.0 application server, sandbox Java applet that uses Tyrus websocket client.

Affected Versions

[1.6]

glassfishrobot commented 6 years ago
glassfishrobot commented 10 years ago

@glassfishrobot Commented Reported by mark30000

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA TYRUS-331