Wednesday, April 25, 2012

Add basic authendication for Jetty

1. In web.xml, it needs to add this
This config indicates that all resources need ROLE api to access.

2. In the jetty folder, find start.ini and make sure the line like this is not commented. Of course to make this realm config right.
3. Go into your etc/jetty-example.xml to make the xml similar like this

          hw xxx Realm

4. Go into your etc/ file to set up realm configuration.

Also these two links are very helpful. Recently I found another problem with realm with jetty 8.1.7. When setup as above, the browser does not popup the authentication window but keep reporting error "This web page has a redirect loop" by Chrome. After a struggling by comparing the jetty xml files I found the issue was caused by this section in contenxts/test.xml


Just comment out this section, the issue was solved.

Quit ssh with out killing running process

Since I need to keep start.jar of jetty running on EC2. I need to quit the ssh without killing the current running jetty process. There is a tool called "screen" can do this easily.

Follow the steps below
sudo java -jar start.jar
ctrl+a and then ctrl+d
4.quit ssh.