Java Development with NetBeans and Maven: Part 3

Overview

Since the Maven can integrate to the other system, such as “Issue Tracker“, “Version Control System“, especially the “Repository Manager“, which we will deploy our artifact for sharing to our team. All those target system is usually protected. We must provide the “security information / credential” such as user id and password for accessing it.

Normally we can declare the “security information /credential” inside the “Project POM File” (pom.xml). Please consider, in the real world development environment, they are many people joining the same project. The “Project POM File” (pom.xml) is also shared, too. If we decide to store that security information /credential” at the “Project POM File” (pom.xml). We may face a difficult if everyone keep updating the “Project POM File” (pom.xml) over and over. It would be nice that we can link the personal information, such as the security information /credential“, to the

Project POM File” (pom.xml).

Declare Our Own Information

You may have seen it berfore, The “settings.xml“. Please refer to my previous post, about the “Maven Repository Manager“, the “Artifactory” which can manage the repository and artifact for us. We use the “settings.xml” to notify “Maven” that it should connect to our “Maven Repository Manager“, the “Artifactory” instead of connect to the remote repository in the internet.

Inside the <profile> tag, we can declare a <properties> tag. The element inside this tag can be named any as we need. e.g. <userId>, and we can refer it in the “Project POM File” (pom.xml) by the ${MY_VARIABLE}, e.g. ${userId}. Pleases see further information here.

The we can declare our own “security information /credential” such as <issueUserId>, <issuePassword>,<vcsUserId>, <vcsPassword> and so on, so that we achieve configure our own “security information /credential“.

<profiles>
    <profile>
        ..........
        <id>artifactory</id>
        <properties>
            <svnUser>user1</svnUser>
            <svnPassword>password</svnPassword>
            <bugzillaUser>user2</bugzillaUser>
            <bugzillaPassword>password</bugzillaPassword>
        </properties>
    </profile>
</profiles>

Special Feature for the Maven Repository Manager

We can declare our credential for accessing the “Maven Repository Manager“, please note the “Maven Repository Manager” usually anonymous downloading, but not for deploying.

<servers>
    <server>
        <id>The Reference Id</id>
        <username>User</username>
        <password>password</password>
        <filePermissions>777</filePermissions>
        <directoryPermissions>777</directoryPermissions>
        <!--
        <privateKey>${user.home}/.ssh/id_dsa</privateKey>
        <passphrase>some_passphrase</passphrase>
        <filePermissions>664</filePermissions>
        <directoryPermissions>775</directoryPermissions>
        <configuration></configuration>
        -->
    </server>
</servers>

The password encryption

It can be done by following this document. I will intoduce you an overview.

Create Master Password

Create the master passowrd
mvn –encrypt-master-password <password>

Store it for future referencing

Please create a file named “settings-security.xml” at <USER_HOME>/.m2 and put the following content into it.

<settingsSecurity>
  <master>Master Password</master>
</settingsSecurity>

Encrypt The Password

Create the master passowrd
mvn –encrypt-password <password>

Please copy the encrypted password and paste to the “settings.xml“, the <server> tag.

The Artifactory

If the security is enable for the “Artifactory“, we can not use the “clear password“, or take it to encrypt with the master password. The “Artifactory” encrypted value is required. The step for picking that vaule is as following: –

  1. Please log in to “Maven Repository Manager“, the “Artifactory“.
  2. Go to your profile page by clicking the name displayed at the top-right of the screen.
  3. Enter your current password and press “Unlock” button.
  4. The encrypted password will be displayed at the “Encrypted Password” text box.
  5. Copy the whole displayed value, including the {DESede} or other.
  6. You can use this value at the “settings.xml“, the <server> tag.
  7. You can also “double encrypt” by using the maven encryption, too.

Summary

At the moment we can declare our own information at the “settings.xml” and link it to the “Project POM File” (pom.xml). We also understand the special feature for the “Maven Repository Manager“, the password encryption, including the specific for the “Artifactory“.

Next I will make use of these to integrate with Version Control System, Issue Tracker, especially to create a report and maven site. Please stay tuned as always.

About Charlee Chitsuk

I've been working as a software developer since 1998. At the moment I focus on system integration including with SOA and Enterprise Security Solution.

Posted on November 12, 2010, in Artifactory, Java SE, Maven and tagged , , . Bookmark the permalink. 1 Comment.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: