Welcome to JavaRanch.
Yes, this can be done with Java, but an applet is not the right place to do it, and it needs to be done before the PDF is served to the client.
The excellent iText library can apply security to an existing PDF. My post
in this thread shows a relevant code excerpt that uses iText.
I'll move this post to the Other Open Source project forum where iText is discussed.