46,79 €
Create modular scalable enterprise-grade applications with JBoss Enterprise Application Platform 7
The ideal target audience for this book is Java System Administrators who already have some experience with JBoss EAP and who now want explore in depth creating Enterprise grade apps with the latest JBoss EAP version.
The JBoss Enterprise Application Platform (EAP) has been one of the most popular tools for Java developers to create modular, cloud-ready, and modern applications. It has achieved a reputation for architectural excellence and technical savvy, making it a solid and efficient environment for delivering your applications.
The book will first introduce application server configuration and the management instruments that can be used to control the application server. Next, the focus will shift to enterprise solutions such as clustering, load balancing, and data caching; this will be the core of the book. We will also discuss services provided by the application server, such as database connectivity and logging. We focus on real-world example configurations and how to avoid common mistakes. Finally, we will implement the knowledge gained so far in terms of Docker containers and cloud availability using RedHat's OpenShift.
If you are a Java developer who wants to level-up to modern day Java web development with the latest Java EE 7 and JBoss EAP 7, this book is the ideal solution for you. It addresses (in a clear and simple way) proof-of-concept scenarios such as clustering and cloud and container configurations, and explains how to solve common issues.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 359
Veröffentlichungsjahr: 2016
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: August 2016
Production reference: 1300816
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78646-363-0
www.packtpub.com
Authors
Francesco Marchioni
Luigi Fugaro
Copy Editor
Safis Editing
Reviewer
Mauro Vocale
Project Coordinator
Devanshi Joshi
Commissioning Editor
Amarabha Banerjee
Proofreader
Safis Editing
Acquisition Editor
Reshma Raman
Indexer
Rekha Nair
Content Development Editor
Samantha Gonsalves
Graphics
Jason Monteiro
Technical Editor
Jayesh Sonawane
Production Coordinator
Melwyn D'sa
Francesco Marchioni is a Red Hat Certified JBoss Administrator (RHCJA) and Sun Certified Enterprise Architect working at Red Hat in Rome, Italy. He started learning Java in 1997, and since then he has followed the path to the newest Application Program Interfaces released by Sun. In 2000, he joined the JBoss community when the application server was running the 2.X release.
He has spent years as a software consultant, where he has envisioned many successful software migrations from vendor platforms to open source products, such as JBoss AS, fulfilling the tight budget requirements of current times.
Over the last 10 years, he has authored many technical articles for OReilly Media and ran an IT portal focused on JBoss products (http://www.mastertheboss.com).
He has authored multiple books for Packt Publishing such as JBoss AS 5 Development (http://www.packtpub.com/jboss-as-5-development/book), JBoss AS 5 Performance Tuning (http://www.packtpub.com/jboss-5-performance-tuning/book), JBoss AS 7 Configuration Deployment Administration (http://www.packtpub.com/jboss-as-7-configuration-deployment-administration/book), JBoss 7 Development (https://www.packtpub.com/application-development/jboss-7-development), and MongoDB Java Developers ( https://www.packtpub.com/application-development/mongodb-java-developers).
I would like to express my gratitude to the many people who helped me write this book and assisted in editing and proofreading. So, in strict alphabetical order, I'd like to thank Alessandro Arrichiello, who shared his valuable experience on the Red Hat infrastructure and gave the installation chapter a deep cut. Many thanks to the engineers at Red Hat who provided helpful insights on the new server release, in particular Josef Cacek for the awesome Kerberos stuff published on GitHub and Pedro Igor Silva for the elytron bits. A warm thanks to Luigi Fugaro, who launched the idea of writing this book together along with a nice cup of espresso and scaled this wall with me. This book would not be complete without the careful reviews of Mauro Vocale, who shared a valuable amount of his time to help us on it. And last but not least, thanks to Samantha Gonsalves, our content editor from Packt Publishing, for her patience and professionalism demonstrated in this bleeding-edge project.
Luigi Fugaro had his first encounter with computers back in the early 80s when he was still a kid. He started with a Commodore Vic-20, passing through a Sinclair, a Commodore 64, and an Atari ST 1040, where he spent days and nights giving breath mints to Otis. Then he took a big jump to a 486DX2 66MHz and started programming in Pascal and Basic.
In 1998, he started his career as a webmaster doing HTML, JavaScript, Applets, and some graphics with Paint Shop Pro. He then switched to Delphi, Visual Basic, and finally, started working on Java projects.
While working on Java, he met a lot of people who helped him get more and more hard and soft skills. Luigi has been developing in Java, all kinds of web applications, dealing with both backend and frontend frameworks, for various system integrators.
During his years in Red Hat, Luigi met extraordinary people, both for personal and professional reasons, who believed in him and helped him in his carrier.
He is still working with Red Hat, where he can count on a wide group of highly talented people who help him daily. He would like to mention all of them, but a few of them need special recognition: Ugo, Grande Marinelli, Nonno, Mr. Bernacchi, Frank, 3A, Vocal, eljeko, Scardy, Rinaldo (don’t mind the order).
He has authored WildFly Cookbook by Packt Publishing.
A special thanks goes to the content editor, Samantha Gonsalves, who helped me a lot with her talent and patience.
A very very big THANK YOU goes to my friend and colleague, Mauro Vocale, for his precious work of reviewing and testing all the technical aspects of the book!
Mauro Vocale was born on March 25, 1980 in Venaria Reale, Italy.
He started working on Java and Linux OS in 2001, and he is currently working with Red Hat, which gives him the opportunity to interact with some open source communities.
He is certified Oracle Master Java SE Developer and Oracle Web Component and EJB Developer for JEE 6 also over the last 10 years he worked as a Java consultant to tried to spread the open source technologies and the idea of free software.
I would like to thank my wife, Silvia, for her help and support during the challenge of my work, and my beautiful children, Alessio and Fabrizio.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
Yesterday I was a writer. Today I'm a writer. Tomorrow I'll probably still be a writer. Sigh! There's so little hope for advancement in this world.
--Francesco Marchioni (inspired by C.Schultz's masterpiece)I’d like to dedicate this book to my Dad, who passed away this year. I’d also like to dedicate this book to my daughter Giada, the love of my life.
--Luigi FugaroJBoss Application Server has been, de facto, the open source platform to provision enterprise Java applications. The commercial platform that supported the release of the application server is JBoss Enterprise Application Platform (JBoss EAP), which has just hit its 7th release.
This release contains the advanced features developed for the upstream project—now called WildFly Application Server (currently at version 10)—such as the newly designed web subsystem, Undertow, which uses the latest non-blocking I/O features of Java to provide improved scalability and performance. Undertow also supports the latest standards for web applications, such as HTTP/2, HTTP Upgrade, and WebSockets.
Another change in the application server platform is the messaging subsystem, which is now based on the unified messaging technology for Red Hat products, called Apache ActiveMQ Artemis. Active MQ Artemis enables customers to exchange messages between JBoss EAP 6 and 7, while preserving the performance, scalability, and reliability of the EAP 6's HornetQ.
JBoss EAP 7 also features several significant management updates by giving administrators the ability to see and manage the configuration of JBoss EAP servers offline, or using the new server suspend mode to gracefully shut down the servers only after completing the in-flight transactions.
The preceding list is a non-exhaustive collection of features that will be discussed throughout this book, which will guide you through the core aspects of the Enterprise server, focusing on practical use cases and describing how to solve common issues.
Chapter 1, Installation and Configuration, introduces you to the application server platform and provides details about the installation, available server modes, and the management instruments (Web console and CLI).
Chapter 2, The CLI Management Tool, describes how you can configure and manage your JBoss EAP 7 platform using the CLI, using its auto completion feature, offline mode, and script files.
Chapter 3, Managing EAP in Domain Mode, goes in depth with the application server management using the domain mode, showing how to design advanced domain configurations and handle disaster and recovery scenarios.
Chapter 4, Deploying Applications, explains the different ways you can deploy your applications. Either by CLI, Web console, or filesystem, all a deployment's life cycle is managed by the platform itself and for both standalone and domain mode.
Chapter 5, Load Balancing, is about balancing requests to EAP 7 servers from a Web frontend layer.
Chapter 6, Clustering EAP 7, goes in depth to support and better configure your environment by providing a fault tolerant system with failover capabilities.
Chapter 7, Logging, provides a comprehensive description of the logging services available in the application server, teaching you how to build a scalable logging system.
Chapter 8, Configuring Database Connectivity, explains how to configure a datasource using the CLI. Adding a JDBC driver, defining a connection pool, choosing between an XA and a non-XA Datasource, and hardening the configuration is all described in depth.
Chapter 9, Configuring EAP 7 for Java EE Applications, describes how to configure the services needed for server-side applications through the application server subsystems.
Chapter 10, Messaging Administration, goes in detail about message-oriented middleware and how the JBoss EAP 7 platform can help rely on Apache Artemis as its default implementation.
Chapter 11, Securing the Application Server, discusses securing the application server infrastructure, including the applications running on top of it.
Chapter 12, New Security Features of EAP 7, is a preview of the upcoming security features available in the EAP 7.1 release and how to centralize security concerns of Web applications with the Red Hat Single Sign-On (SSO) server.
Chapter 13, Using EAP 7 with Docker, shows how to use the Docker technology to provision EAP 7 in the Enterprise.
Chapter 14, Running EAP 7 on the Cloud Using OpenShift, shows how applications leverage the new Red Hat PaaS (based on Docker and Kubernetes) to scale automatically and in any environment.
To fully benefit from this book, you first need a PC, possibly running a Linux-like system, with at least 4 GB of RAM and around 10 GB of free disk space. Also, an Internet connection is a must.
From a software point of view, you will need JDK 8 and, of course, JBoss EAP 7.x. Furthermore, you should install Git and Maven.
Java system administrators, developers, and application testers will benefit from this book. You are not expected to have accumulated a lot of experience on the earlier versions of the application server, though you must know the basic concepts of the Java and Linux operating system.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from https://github.com/mjbeap7 or from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/MasteringJBossEnterpriseApplicationPlatform7_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at [email protected] with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.
Red Hat JBoss Enterprise Application Platform 7.0 ( JBoss EAP 7) is a middleware platform built on open standards and compliant with the Java EE 7 specification.
It is derived from the upstream project Wildfly 10 and provides ready-to-use features such as high-availability clustering, messaging, and distributed caching.
JBoss EAP 7 is designed with a modular structure that allows on-demand services, thus greatly improving startup speed. Thanks to its web based management console and its powerful Command Line Interface (CLI), editing XML configuration files is unnecessary (and is even discouraged!). The CLI also adds the ability to script and automate management tasks. Internally, JBoss EAP includes APIs and development frameworks for quickly developing fast, secure, and scalable Java EE applications compliant with the Java EE 7 specification.
The first part of this book will let you conquer the management instruments and the EAP 7 domain configuration. When you have completed all green bars, we will concentrate on advanced topics, showing the improvements from the earlier release of the server.
As far as this chapter is concerned, we will now have a quick tour of its technology covering these topics:
If you are arriving from a JBoss EAP 6 environment you will be eager to know about the highlights of the new platform. Broadly speaking, the changes encompass both the server administration area and the Java Enterprise APIs that can help to provide applications on it. We will start by introducing the new administrative features and then we will briefly mention the API highlights.
The administrative features are described as follows:
* 8080 for applications with JNDI and EJB multiplexed
* 9990 for management, for both HTTP/JSON and native API
Support for HTTP/2: The new web server architecture supports the new version of the HTTP protocol, named HTTP/2. HTTP/2 aims to reduce latency and make efficient use of the TCP connection by means of binary framing, request/response multiplexing, header compression (HPACK) and more.New life cycle modes: It is now possible to suspend and resume the execution of the application server. This allows active sessions/requests/in-flight-txs to complete and can be used for a graceful server shutdown scenario.Enhanced server management: The administration web console has been revamped with a new graphical layout and new availabilities such as the Datasource wizard that will let you quickly create database connections with a few touches.ArtemisMQ Messaging Broker: In the new server version, the messaging broker has changed to ArtemisMQ which is directly derived from the former HornetQ. Former HornetQ clients will be supported out of the box, while offering compatibility to Apache's ActiveMQ 5.0 clients as well.ORB Switch: The new version of the application server has switched to OpenJDK ORB which provides better interoperability with other vendors compared with the earlier JacORB implementation.The Java EE 7 API highlights are related to the the Java EE 7 (JSR 342) specification is an umbrella specification which encompasses 33 single specifications. There have been brand new technologies and improvements of existing ones.
Here is a short list of Java EE 7 drivers:
JSR-352 batch applications for the Java platform, featuring a new API for an XML-based job specification language and a runtime API.JSR-236 concurrency utilities for JavaEE, providing a simple and standard API for using multiple threads from Java Enterprise components.JSR-353 Java API for JSON Processing (JSON-P). This API can be used to parse, transform, and query JSON data.JSR-356 WebSockets support, featuring a full-duplex communication channel between the client and the server by means of simple annotations and life cycle callbacks.Besides the new additions, some updates have been released to existing services. The most notable ones are as follows:
Installing the application server can be done in several ways. For the purpose of learning we will start with the basic unzipping installation which will produce a vanilla installation ready to be used. In real-world scenarios with dozens of customized installations to be completed, you will probably want to learn some advanced installation tactics. Don't worry, we have been trained for it and you will be too in a while.
The first one we will detail is also the simplest, which merely requires unzipping a file. The JBoss EAP 7 ZIP file is available from the Red Hat Customer Portal. This method of installation is platform-independent and requires the following steps:
JBoss EAP 7 is now downloaded to your target machine, ready for installation. Execute the following command in order to unzip the archive:
unzip jboss-eap-7.0.0.zipNow you can test that the installation was successful by executing the standalone.sh shell script (Windows users will launch the standalone.cmd equivalent).
cd jboss-eap-7.0cd bin$ ./standalone.shWhen to use ZIP installation:
The ZIP installation can be used for developers or simple environments where it's just fine to provide a basic default installation of the server, with all the configuration and libraries in the standard folders. Therefore, it's not the best choice for large enterprise systems where you want to automate and customize installations.
This method of installation is peculiar of JBoss EAP and can be a practical solution if you want to manage your application ecosystem through Red Hat Packet Manager (RPM) archives.
Installing JBoss EAP 7 via RPM requires a subscription to the official Red Hat's repositories. You can either subscribe to the current JBoss EAP channel or a minor channel that provides a specific minor release and all applicable patches. This allows you to maintain the same minor version of JBoss EAP 7, while still staying current with high severity and security patches.
Let's see in practice how the installation can be done on a RHEL 7 operating system. First of all, we have to register our brand new server to the Red Hat Network (RHN), using our credentials (username/password) for accessing to all needed subscriptions.
The command will ask for username or password, or in case we've planned to use an internal RH Satellite 6 system, we can use a preconfigured Activation Key as an option:
# subscription-manager registerAfter a successful registration we need to figure out to which Pool we need to attach for downloading the EAP 7 packages. We can use the subscription-manager list command followed by the less one for searching through multiple subscriptions:
# subscription-manager list --available|lessSubscription Name: Client SKUProvides: Oracle Java (for RHEL Server) - AUS Oracle Java (for RHEL Client) Red Hat Enterprise Linux 7 High Availability Red Hat Enterprise Linux High Availability Red Hat EUCJP Support (for RHEL Server) Red Hat Enterprise Linux for Power Red Hat Enterprise Linux EUS Compute Node Red Hat Enterprise Linux for Power, big endian - Red Hat OpenShift Enterprise JBoss EAP add-on Oracle Java (for RHEL Server) - Extended Update dotNET on RHEL Beta (for RHEL Server) Red Hat Enterprise Linux Load Balancer JBoss Enterprise Web Server JBoss Enterprise Application Platform - ELS . . . . . . . . . . . . . . . . . . .As soon as we find the right subscription (you should choose something like: JBoss Enterprise Application Platform) we have to take note of the pool ID and run the following:
# subscription-manager attach --pool 844aff014485be8a85f8d058bf198144After that we can explore the available repositories:
# subscription-manager repos --listWe won't list here all the available repositories which is quite large; however, you have to enable only EAP, RHEL7 base rpms, extras, and optional repository, and disable all the others with the following command:
# subscription-manager repos --disable="*" --enable jb-eap-7.0- for-rhel-7-server-rpms --enable rhel-7-server-rpms --enable rhel-7-server-extras-rpms --enable rhel-7-server-optional-rpmsYou can verify that the process worked as expected by simply running the following:
# yum repolistThe list should look like this:
Loaded plugins: search-disabled-reposrepo id name !jb-eap-7.0-for-rhel-7-server-rpms/7Server/x86_64 (RPMs)!rhel-7-server-extras-rpms/x86_64 (RPMs)!rhel-7-server-optional-rpms/7Server/x86_64 (RPMs)!rhel-7-server-rpms/7Server/x86_64 (RPMs)repolist: 19,727Complete the installation by executing the following:
# yum groupinstall jboss-eap7When to use RPM installation:
The RPM installation makes things a lot easier in terms of installation because you can use all the tools that know how to deal with RPMs, and upgrading is simpler because you can use yum to do it, especially for security errata. The JBoss RPMs put things where many RHEL system administrators would expect them: config files under /etc, content and libraries under /var, and so on.
Most of the downsides come from being forced to do things the way RHN/RPMs want to do them. You cannot install multiple version of JBoss in parallel, which may not be an issue if you spin up a new VM per instance, but can be for some people. It is also difficult to install non-current versions, since you either need to manually specify the versions of several hundred packages or use satellite with a date cutoff on a custom cloned channel to hide any packages from newer releases.
The JBoss EAP 7 installer archive is also available from the Red Hat Customer Portal (https://access.redhat.com). The .jar archive can be used to run either the graphical or text-based installers.
In order to complete the JAR installation, follow these steps:
We will not detail the single steps of the installation which are quite intuitive and covered by the EAP installation guide. Rather we would like to stress that the installer produces an XML script; you can reuse it for multiple installations, as you can see from the following picture:
If you open the generated XML file, then you can pinpoint some custom elements in the installation:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <AutomatedInstallation langpack="eng"> <productName>EAP</productName> <productVersion>7.0.0</productVersion> <com.izforge.izpack.panels.HTMLLicencePanel id="HTMLLicencePanel"/> <com.izforge.izpack.panels.TargetPanel id="DirectoryPanel"> <installpath>/home/francesco/EAP-7.0.0</installpath> . . . . . </AutomatedInstallation>Then you can repeat the installation with the following command:
java -jar jboss-eap-7.0.0-installer.jar -xml yourxmlWe would recommend using the JAR installer for medium to large sized environments where you have some common defaults for networks, database connectivity, or security settings. Another advantage of this approach is that it can be used for any operating system as it's completely Java based.
Downloading the source code can be used if you need low-level details about the single modules of the application server. Once you have downloaded the jboss-eap-7.0.0-src.zip file, unzip it to your disk at first. Next you can build the server in two ways:
Change to the bin directory after a successful build:
$ cd build/target/jboss-eap/binVerify that the application server boots successfully:
$ ./standalone.shThe amount of installation options for EAP could well deserve one or more chapters; however, that would take us away from the scope of this book. We will just mention Ansible, which is an excellent configuration management and provisioning tool that uses SSH to perform administrative tasks on your machines. This has the evident advantage that nothing needs to be installed on the machines you are targeting as Ansible only runs on your main control machine, which could even be your laptop!
The steps used by Ansible to provision and configure machines are described in a kind of template called Playbooks, which are Ansible's configuration, deployment, and orchestration language.
You can find a large list of example Playbooks in the Ansible documentation, available at http://docs.ansible.com/ansible . Besides this, for testing purposes we have provided a sample EAP 7 playbook which is attached to the sources of this book. (Read the instructions contained in the README.txt file packaged in ansible.zip.)
Besides this, if you want a user interface for your provisioning activities, Ansible Tower is a web-based solution that makes Ansible even more easy to use for IT teams of all kinds. It's designed to be the hub for all of your automation tasks.
The scripts for starting the server are contained in the JBOSS_HOME/bin folder:
An equivalent BAT file is also included for Windows users.
In order to check that your installation was successful, execute one of the startup scripts:
$ ./standalone.shNext surf to localhost:8080 and check the welcome page of the application server:
Stopping the application server can be done in several ways. Sending an interrupt signal (Ctrl + C) will interrupt the server abruptly, so it's not a recommended option.
So it is sending a kill -9 signal from the terminal against the application server process which is an extreme option to be used when the application server is not responsive through management channels.
The recommended approach is to connect through the Command Line Interface and execute the shutdown command:
Two things to know!
The first one is that if you don't provide any parameter to the connect command, it will use the defaults contained in the jboss-cli.xml that will attempt to connect to localhost on port 9990.
Next, if you are connecting to a remote host controller, a username/password challenge will be prompted. See the next section (Basic server administration) to learn how to create a management user.
Once the installation has been completed, it's about time to complete some basic administration tasks. The most obvious one involves creating one or more users for managing your platform. Out of the box, a script called add-user.sh is provided along with your installation. The purpose of this script is to manage two different types of user:
Important notice!
The add-user script uses a very simple file-based mechanism to store the users' information. This can be acceptable for basic security requirements. Real-world scenarios, however, would need to use more appropriate security polices as detailed in Chapter 11, Securing the Application Server, of this book.
You can execute the add-user script both in an interactive way and in an automatic way.
In order to execute the add-user script in an interactive way, just execute it as follows and provide the requested information:
$ ./add.user.shWhat type of user do you wish to add? a) Management User (mgmt-users.properties) b) Application User (application-users.properties)(a): aEnter the details of the new user to add.Using realm 'ManagementRealm' as discovered from the existing property files.Username : administrator1. . . . .Password : Re-enter Password : What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]: About to add user 'administrator1' for realm 'ManagementRealm'Is this correct yes/no? yesTo represent the user add the following to the server- identities definition <secret value="UGFzc3dvcmQxIQ==" />We have removed some negligible information from the output so that you can focus on the required arguments of the script. The previous information can be filled in also in a non- interactive way by providing the username with the -u parameter, the password with the -p, and the group (if needed) with -g. You can discriminate between management users and application users with the -m and -a parameters.
Here is how to create a management user:
$ ./add-user.sh -m -u administrator1 -p Securepassword1!Once you have created the management user, you can verify that the login correctly lets you through the management console, which is available at http://localhost:9990.
On the other hand, here is the shell script to create an application user belonging to the guest group:
$ ./add-user.sh -a -u demouser -p Securepassword1! -g guestBeware that creating users in a non-interactive way exposes your user/password information across the shell history system process table if you are a Linux user.
Once you have created your users the following files (contained in the configuration folder of your server base directory) will be updated:
-rw-rw-r--. 1 francesco francesco 711 Oct 26 06:13 application-roles.properties-rw-------. 1 francesco francesco 935 Oct 26 06:13 application-users.properties-rw-rw-r--. 1 francesco francesco 646 Nov 24 16:11 mgmt- groups.properties-rw-------. 1 francesco francesco 1111 Nov 24 16:11 mgmt- users.propertiesThe application-roles.properties holds the list of roles granted to application users. The file application-users.properties contains the list of application users and their hashed passwords. Conversely, mgmt-groups.properties contains the list of roles granted to management users and mgmt-users.properties holds the management users and their hash passwords. As a final note, the password contained in *-users.properties files is in hash using this format:
username=HEX( MD5( username ':' realm ':' password))How to recover the password
Being an MD5 based hash means that the password is not reversible. On the other hand, consider that most hashes are also non-unique; rather, they're unique enough, so a collision is highly improbable, but still possible.
JBoss EAP provides two operating modes for the servers: the standalone mode and the domain mode. A standalone server is a Java process which is governed by a single management point using a configuration file. A domain server, on the other hand, is a group of Java processes which are managed through a single point called the Domain Controller and its configuration file.
