The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Maven Note: Securing a temporary Jetty instance in the jetty-maven-plugin

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ryan Ransford

Posts: 71
Nickname: rdransfo
Registered: Jul, 2008

Ryan Ransford is a Java developer working in the enterprise looking to make the world a better place
Maven Note: Securing a temporary Jetty instance in the jetty-maven-plugin Posted: Mar 31, 2011 9:48 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by Ryan Ransford.
Original Post: Maven Note: Securing a temporary Jetty instance in the jetty-maven-plugin
Feed Title: Active-Active Configuration
Feed URL: http://active-active.blogspot.com/feeds/posts/default
Feed Description: Active-Active Configuration is a blog about making my place in the enterprise world better. This blog is primarily focused on Java articles, but be prepared to be challenged by posts about dynamic languages, agile tools, and the lighter side of geek culture.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by Ryan Ransford
Latest Posts From Active-Active Configuration

Advertisement

One of my tasks for the current iteration was to add security constraints to the J2EE web service that we are currently developing. This is the easy part. Simply define the appropriate security-constraint, login-config, and security-role elements in the project's web.xml.

web.xml

... ... deny unauthorized users global / /* AUTHORIZED_USER CONFIDENTIAL BASIC APP authorized user for application AUTHORIZED_USER ]]>

From the above, you can see that I defined an expected role, AUTHORIZED_USER, an expected realm for http basic authentication, APP, and a set of resources, / and /*, which can only be accessed through SSL by a user who is a member of the AUTHORIZED_USER role. This is the easy part and should work for most application servers which are worth their salt.

Enter jetty-maven-plugin

This project is already using the jetty-maven-plugin to run a test instance of the application. I thought it would be a good idea to make sure that the security on the localhost instance for testing would work in the same manner as the WebSphere server to which the application is to be deployed. This would help me to ensure that I, as a lazy programmer, would not have to change the functional tests (SoapUI) between localhost and dev.

By default, the jetty instance created by executing mvn jetty:run-war does not include a user realm for defining users and groups, a login service for handling attempted logins, or even the capability for handling SSL connections. In order to bring these components into the localhost instance, I had to make some changes to the configuration of my project's jetty-maven-plugin. First, the changes for enabling the user realm and login service.

pom.xml (version 1)

jetty-maven-plugin 7.3.0.v20110203 ... APP ${project.build.directory}/test-classes/jetty-users.properties APP ${project.build.directory}/test-classes/jetty-users.properties ... ... ... ]]>

/src/test/resources/jetty-users.properties

Using the keytool-maven-plugin for generating a certificate for SSL

In order to enable server authentication, the Jetty instance needs to have access to a server certificate to be sent out in the SSL handshake. I did some investigation and found that there was a plugin, keytool-maven-plugin, which would allow you to automate self-signed certificate generation in the maven execution. I modified the project's pom as follows:

pom.xml (version 2)

keytool-maven-plugin generate-resources clean clean generate-resources genkey genkey ${project.build.directory}/jetty-ssl.keystore cn=active-active.blogspot.com jetty6 jetty6 jetty6 RSA ... ... ... ]]>

Adding SSL support to Jetty

Now, we have a way for the client to authenticate itself, a realm for assigning that client's roles, and a keystore. We just need to tell Jetty how to expose an SSL port to the world.

pom.xml (version 3)

jetty-maven-plugin 7.3.0.v20110203 ... 8080 60000 8443 60000 ${project.build.directory}/jetty-ssl.keystore jetty6 jetty6 ... ... ... ... ]]>

A big thank-you to mrhaki and his article Configure Maven Jetty Plugin for SSL Communication for the assist.

Read: Maven Note: Securing a temporary Jetty instance in the jetty-maven-plugin

Topic: Bliki: MediaServer Previous Topic   Next Topic Topic: Dojo Retrospectives

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use