Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prevent javascript from accessing all methods of the class by the nashorn? #129

Open
NanyangWorker opened this issue Jul 23, 2022 · 6 comments
Labels

Comments

@NanyangWorker
Copy link

Generally,javascript can access the class in the java application by the nashorn,but some public method should not be expose to javascript.How to prevent javascript from accessing all public methods of the class by the nashorn?

@mxro
Copy link
Collaborator

mxro commented Jul 25, 2022

Thank you for your question!

I don't think there is an easy way to give per-method access. Could you create a new class XYZProxy add the class you want to call the methods on as a private variable and then add to XYZProxy the methods you would like to expose?

@mxro mxro added the question label Jul 25, 2022
@NanyangWorker
Copy link
Author

Thank you for your answer!

@NanyangWorker
Copy link
Author

I should be able to create it;But some method in parent class is exposed to javascript;Such as wait() method;

@NanyangWorker
Copy link
Author

I think some methods such as wait()、notify(),are exposed to javascript is not security.Thread safety issues may arise.Thank you for your attention.

@mxro
Copy link
Collaborator

mxro commented Jul 27, 2022

Ah good point! The sandbox does not provide any methods as far as I remember to prevent access to those!

If you do find a way, please let me know & we may be able to add that into the sandbox!

@NanyangWorker
Copy link
Author

Well,I'll try my best.I'll let you know if I have a good idea.Thank you for you attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants