User Tools

Site Tools


developers:examples:java:tomcat-hello-world

This is an old revision of the document!


Tomcat Hello World application

The installation package contains a sample web application “Hello World” that serves as an example of ADUCID® technology integration. The installation DVD contains source files of the sample application.

Try it out

Get sources and binaries on GitHub

Prerequisites

Preliminary condition must be fulfilled to be sure that sample application is fully working:

  • PEIG must be running (Client’s side of ADUCID®)
  • There must be valid ADUCID® approved identity with personal factor on ADUCID Server Kit

Installation

To install the web application, follow these steps:

  1. Ask the user administrator to add a loginName attribute, jsmith value for example, to your profile. Potentially also ask role administrator for the role, demo application works with RegAdmin and UserAdmin roles, on figure 7-1 jsmith has RegAdmin role only.
  2. Configure Aducid Authenticator as per instructions in section 4.2.
  3. Rename supplied sample web application “Hello World” from aducid-tomcat-webapp-[version].war to aducid-tomcat-webapp.war.
  4. Load the sample web application into Tomcat, specifically to $TOMCAT_HOME/webapps folder
  5. Run Tomcat, so that the installed sample web application unpacks.
  6. Stop Tomcat.
  7. Set application configuration parameters in the file $TOMCAT_HOME/webapps/aducid-tomcat-webapp/WEB-INF/classes/config.properties:
    • appName—the application name shown on the log out page
    • loginPage—link to the log in page, used from the error and log out page
    • refreshAfterErrorPage—link to a page where the user can go if an error occurs
  8. Run Tomcat.

After installation, sample application is accessible on address:

http://[ip_address_of_your_container]:[port_of_your_container]/aducid-tomcat-webapp

For example on address:

http://10.20.29.189:8080/aducid-tomcat-webapp

In case of installing on Linux OS, consider also iptables settings.

The web application you have just installed contains two JSP pages.

/unsecured.jsp - this page is freely accessible.

/web/secured.jsp - this page is protected by the “RegAdmin” and “UserAdmin” roles.

<font 11.0pt/11;;inherit;;inherit>If both the application and Tomcat are configured properly, the /web/secured.jsp page will be accessible. Accessibility of individual sections depends on the role assigned.</font>

Troubleshooting

If the result of authentication process is not according previous figure check following:

  • PEIG is active – indicator is green
  • There is valid ADUCID® approved identity with personal factor on ADUCID Server Kit

Appendix A

The appendix shows the relevant part of the web.xml descriptor.

<security-constraint>
    <web-resource-collection>
        <web-resource-name>secured resources</web-resource-name>
        <url-pattern>/web/*</url-pattern>
        <url-pattern>/authCheck</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>RegAdmin</role-name>
        <role-name>UserAdmin</role-name>
    </auth-constraint>
</security-constraint>
<login-config>
    <auth-method>ADUCID</auth-method>
</login-config>
<security-role>
    <role-name>RegAdmin</role-name>
</security-role>
<security-role>
    <role-name>UserAdmin</role-name>
</security-role>

Appendix B

Example of log4j.properties settings

log4j.rootCategory=INFO, CONSOLE

log4j.logger.com.aducid.tomcat=DEBUG

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout

log4j.appender.CONSOLE.layout.ConversionPattern=[%p] [%c] %m%n
developers/examples/java/tomcat-hello-world.1564653985.txt.gz · Last modified: 2019/08/01 10:06 by tjotov