Create a login and registration system in Apache Geronimo, part 1th

Source: Internet
Author: User
Tags contains gz file ibm db2 mail requires zip

Create login and registration systems in Apache Geronimo, part 1th using Java EE declarative security and Geronimo's built-in Derby database

Brief introduction

In addition to being completely compatible with Java EE, open source, and packaged Apache licenses, Geronimo's best thing is its extreme modularity. Its core is compact, allowing a framework like Apache Derby to be added to the kernel or removed from the kernel via a Geronimo Bean (GBean). In fact, Derby is built into Geronimo by default, so Derby and Geronimo are a good combination for Geronimo applications. In my previous article "Restricting Directory Access in Apache Geronimo" (developerworks,2005 November), you used two property files to hold user and password information. This approach requires that you manually enter the user ID and password into these two property files. This two-part article series is certified in a different way, by querying the built-in Derby database for Geronimo. This not only allows you to save user name and password information, but also allows you to save other personal and identity information about the user, such as e-mail addresses. As the business expands, this form of database authentication becomes more important, which obviously benefits the customers of our virtual Web Apps company.

In this article, you will also use Derby to save information other than user names and passwords. A simple login system will be created using the sqlloginmodule of Geronimo, and users can access and log on to the system with declarative security based on the form's authentication and Java EE. User names, passwords, and other information are saved in a Derby database that is built into Geronimo, and a table contains mappings of user names to groups.

This article teaches how to create and initialize these tables in Geronimo's built-in Derby database. The new table contains the initial login data used by the test application, Sqlloginmodule connects to the database, gets the username and password information. Security is implemented through a database deployment plan that specifies database drivers, connection URLs, and SQL in other databases.

Part 2nd expands the simple login system created in this article to implement a registration system where visitors can register and access the system immediately. This is done by creating a Java servlet, Servelet allows users to enter personal information and login information, and saves the information in a built-in Derby database.

Begin

This article uses the Milestone 5 (M5) version of Geronimo and assumes that the reader does not have the knowledge of Geronimo. To use Geronimo, Java 1.4.2_08 (or above) is required, but before 1.5, it can be obtained from Sun's Web site.

After you have installed the Java code, download the Geronimo M5 from Apache. You can select. zip (Windows or Linux) or. tar.gz (Linux) files. When the download is complete, all you need to do is unzip the. zip or. tar.gz file, and then you can start the server.

You need some. jar files for the SQL login module to work. They include IBM Db2®java database Connector (JDBC) generic drivers. Please download them from IBM. Unzip the. zip file obtained from IBM. Now put the two files Db2jcc.jar and Db2jar_license_c.jar in the Lib directory in the <geronimo-install-dir>/repository/of the Geronimo installation The Org.apache.derby/jars directory.

This article also requires Apache Ant, because it helps simplify the process of creating a. War file. Please download Ant from Apache. After you have extracted Ant, add the <ant-install-dir>/bin directory to the path.

Derby: Setting up the database

To understand the concepts covered in this article, a simple application is implemented (see the Readme file in the compressed source code, which is available in the Downloads section), demonstrating the use of Java EE Declarative Security and Geronimo's built-in Derby database access system to achieve login. You can use the Geronimo console to set up users and group tables. User tables contain user names, passwords, e-mail messages, and other user-specific information that you want to add. The Group table holds information about groups of users. Later, Geronimo queries these tables for the user name and password required for the authenticated logon session and gets the group that the user belongs to. Geronimo then matches this information with the information that is allowed to be accessed and denies or allows access accordingly.

Log on to the Geronimo console

First, you create the database directly in the Geronimo console. The console allows you to view server status and error/message logs and, of course, perform database management.

Open the Web browser and point to http://localhost:8080/console/. Enter the default user name System and password manager for Geronimo to log on (see Figure 1).

Figure 1. Log on to the Geronimo console

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.