简体   繁体   中英

How do you password protect static content in JBoss 3 with Jetty 4?

I have a login app which relies on webtoken and cookies, and a few other apps running in jboss. I also have static content mostly PDF files under apache2 which are listed in a static page as links, which can be accessed directly without credentials. I'm trying to password protect these content, and willing to move them somewhere in my jboss. So that If I try to access the url to a specific PDF file, and I'm not logged in, I shoud be redirect to login. If I'm logged in i should be able to see the PDF file opened in my browser.

Spec: jboss-3.2.7 jetty-4.2.24 sar

I solved it by adding a filter with authentication and filter mapping with url pattern in WEB-INF web.xml.

<filter>
 <filter-name>filter1</filter-name>
 <filter-class>com.shojib.filter1</filter-class>
</filter>
<filter-mapping>
 <filter-name>filter1</filter-name>
 <url-pattern>/htdocs/*</url-pattern>
</filter-mapping>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM