Table of Contents

Installation of CzechIdM - Windows

We presume that the server is prepared as described in Server preparation - Windows.

This tutorial shows how to install full production-ready version of CzechIdM on standard software setup (java, postgreSQL, Tomcat, Apache httpd). If you are looking for a demo installation please see Getting Started.

Create DB user and database in PostgreSQL

Open a PSQL binary from the Start menu (for the OpenSCG PostgreSQL) or fire-up the cmd terminal and run psql.exe -U postgres (for the EnterpriseDB PostgreSQL). A windows-cmd-like window should appear with a prompt. Create a db user and a database for CzechIdM.

CREATE USER czechidm PASSWORD '*****';
 
-- Choose appropriate collation and create database.
-- with english collation (we expect the default windows installation with cp1250/cp1252 and "English_United States" collation).
CREATE DATABASE "czechidm" WITH OWNER 'czechidm' ENCODING 'UTF8' template 'template0';
-- with czech collation
CREATE DATABASE "czechidm" WITH OWNER 'czechidm' ENCODING 'UTF8' LC_COLLATE = 'czech_czech' LC_CTYPE = 'czech_czech' template 'template0';

Use the pgAdmin or PSQL to test the database connection under the czechidm user.

JDBC driver installation

Download the PostgreSQL JDBC driver from the this URL and move it to the C:\Program Files\Apache Software Foundation\Tomcat 8.5\lib\ directory.

Configure environment properties. Select application profile

Run the Monitor Tomcat application from the Start menu. Configure following settings:

Change Tomat logging properties

In order to set-up log rotation we need stop logging to stdout and start logging to catalina.log .

Make these changes in file C:\Program Files\Apache Software Foundation\Tomcat 8.5\conf\logging.properties: Comment out console handler. We don't want tomcat to log to stdout or stderr.

handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler
#handlers =  java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.AsyncFileHandler
#.handlers = java.util.logging.ConsoleHandler,

#java.util.logging.ConsoleHandler.level = FINE
#java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter

In 1catalina file handler change log level to "INFO" and prefix from "catalina" to "tomcat". Also set property rotable to "false". Tomcat write to this file only when starting or shutting down.

#1catalina.org.apache.juli.AsyncFileHandler.level = FINE
#1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
1catalina.org.apache.juli.AsyncFileHandler.level = INFO
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = tomcat
1catalina.org.apache.juli.AsyncFileHandler.rotatable = false
1catalina.org.apache.juli.AsyncFileHandler.suffix = .log

Create CzechIdM configuration folders

In CzechIdM, you can store all deployment-specific configuration (i.e. database credentials) outside the war file. This is a configure-once approach which greatly simplifies future deployments.

Create the directory structure:

C:\CzechIdM
C:\CzechIdM\etc
C:\CzechIdM\lib
C:\CzechIdM\backup
C:\CzechIdM\data

Create SSL truststore

Open the Git Bash and navigate to the /c/czechidm/etc. Then create fake certificate which will be, for this time, the only certificate in the truststore.

openssl genrsa -out fakecert.key
# if the following command fails, remove the parameter -subj and supply the values interactively
openssl req -new -key fakecert.key -out fakecert.csr -subj "/C=CZ/ST=Czech Republic/L=Prague/O=BCV/CN=CzechIdM placeholder cert"
openssl x509 -req -in fakecert.csr -signkey fakecert.key -days 1 -sha256 -out fakecert.crt
keytool -importcert -file fakecert.crt -alias placeholder-cert -keystore truststore.jks
    Enter keystore password:  ENTER SOME PASSWORD HERE AND REMEMBER IT FOR LATER
    Re-enter new password:
    ...
    Trust this certificate? [no]:  yes
    Certificate was added to keystore
 
rm fakecert.key fakecert.csr fakecert.crt

Then adjust Tomcat configuration - the JAVA_OPTS - as you did before. Add path to the truststore -Djavax.net.ssl.trustStore=C:/CzechIdM/etc/truststore.jks and truststore password -Djavax.net.ssl.trustStorePassword=THE PASSWORD YOU ENTERED WHEN CREATING KEYSTORE.

Save the configuration and restart the Tomcat for changes to take effect.

Create CzechIdM configuration

Now we will create configuration files the CzechIdM will use.

Code snippets in this chapter can be mostly copy-pasted or (but please read through whole chapter to be aware of setting you have to adjust). Configuring the CzechIdM is about altering four or five lines altogether.

Adjust database configuration

If you followed this howto, the only thing you should need to adjust is a spring.datasource.password propetry. Set it to the password for czechidm user in PostgreSQL. If necessary, adjust other database connection properties…

spring.datasource.url=jdbc:postgresql://localhost:5432/czechidm
spring.datasource.username=czechidm
spring.datasource.password=********** TODO *********
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.validationQuery=SELECT 1
spring.datasource.test-on-borrow=true

Generate JWT token

Set value of the idm.sec.security.jwt.secret.token property as is described in the template file:

# Generate JWT token security string as "cat /dev/urandom | tr -dc 'a-z0-9' | head -c VALUE" where VALUE can be from 1 to 255.
# We recommend the VALUE to be at least 25.
idm.sec.security.jwt.secret.token=********** TODO *********

Local confidential storage

Local confidential storage is encrypted by AES algoritm. Read more. Confidential storage is encrypted by a key found in secret.key file you already created.

There are two properties in application-production.properties that influence the confidential storage:

On Windows, you have to use separate file secret.key.
CzechIdM doesn't contain any default key for crypt confidential storage. Please define it before you start using the IdM.

Confidential storage uses AES/CBC/PKCS5Padding (more info) algorithm which operates with 128bit or 256bit key.

Attachment store

In CzechIdM, users can sometimes add attachments (say, attach *.jpeg photo to their employee card request). Those files are stored in the attachment store. With the following property, you can configure, where the store is. If you used sample property file, the store is by-default located under C:\CzechIdM\data.

# attachments will be stored under this path.
# new directories for attachment will be created in this folder (permissions has to be added)
# System.getProperty("user.home")/idm_data will be used if no path is given
idm.sec.core.attachment.storagePath=c:/czechidm/data

Environment

If you install CzechIdM in multiple environments (typically test and production), you can display a label in the navigation bar which will tell the users in which environment they work. The default value "production" doesn't display any label. Set the value to test to display the label marking the Test environment.

# Application stage (development, test, production (default))
idm.pub.app.stage=production

Deploy the CzechIdM

CzechIdM is deployed as a WAR archive.

Change default admin password

In the fresh CzechIdM installation, there is one user identity - admin with password admin. Right after you install the application, go to https://yourserver.tld/idm and change the default password.

Configure IdM

Follow some final configuration steps: Installation of CzechIdM - Final steps.