893 lines
37 KiB
HTML
893 lines
37 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="google-site-verification" content="CPhbjooaiTdROm7Vs4E7kuHZvBfkeLUtonGgcVUbTL8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="description" content="">
|
|
<meta name="author" content="">
|
|
<link rel="shortcut icon" href="ico/favicon.ico">
|
|
|
|
<title>Strolch: Tutorial</title>
|
|
|
|
<!-- Bootstrap core CSS -->
|
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
|
|
|
<!-- Custom styles for this template -->
|
|
<link href="css/custom.css" rel="stylesheet">
|
|
|
|
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --><!--[if lt IE 9]>
|
|
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
|
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script><![endif]-->
|
|
</head>
|
|
<body>
|
|
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
|
<div class="container">
|
|
<div class="navbar-header">
|
|
<a class="navbar-brand" href="index.html">Strolch</a>
|
|
</div>
|
|
<div class="collapse navbar-collapse">
|
|
<ul class="nav navbar-nav">
|
|
<li><a href="index.html">Overview</a></li>
|
|
<li><a href="api.html">API</a></li>
|
|
<li><a href="documentation.html">Documentation</a></li>
|
|
<li class="active"><a href="tutorial.html">Tutorial</a></li>
|
|
<li><a href="downloads.html">Downloads</a></li>
|
|
<li><a href="development.html">Development</a></li>
|
|
<li><a href="blog.html">Blog</a></li>
|
|
</ul>
|
|
</div>
|
|
<!--/.nav-collapse -->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
|
|
<div class="page-header">
|
|
<h1 class="page-title">Tutorial: Configuration</h1>
|
|
|
|
<p class="lead page-description">Configure the runtime</p>
|
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
<a href="tutorial.html" class="pull-left">Previous: Start</a><a href="tutorial-model.html" class="pull-right">Next:
|
|
Model</a>
|
|
<br><br>
|
|
|
|
<p>Let's start by creating a new Apache Maven project. We'll need a POM with the proper dependencies. We expect
|
|
you to be familiar with Apache Maven, so we'll just show you a working POM file:</p>
|
|
|
|
<b>pom.xml</b>
|
|
<pre class="pre-scrollable">
|
|
<?xml version="1.0"?>
|
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
<modelVersion>4.0.0</modelVersion>
|
|
|
|
<groupId>li.strolch</groupId>
|
|
<artifactId>strolch-bookshop</artifactId>
|
|
<version>0.1.0-SNAPSHOT</version>
|
|
<packaging>war</packaging>
|
|
|
|
<name>strolch-bookshop</name>
|
|
<description>Bookshop built on Strolch</description>
|
|
<inceptionYear>2017</inceptionYear>
|
|
|
|
<properties>
|
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
|
|
<buildTimestamp>${maven.build.timestamp}</buildTimestamp>
|
|
|
|
<jdk.version>1.8</jdk.version>
|
|
|
|
<jersey.version>2.25.1</jersey.version>
|
|
<slf4j.version>1.7.25</slf4j.version>
|
|
<logback.version>1.2.3</logback.version>
|
|
<petitparser.version>2.1.0</petitparser.version>
|
|
<hikaricp.version>2.7.1</hikaricp.version>
|
|
<postgresql.version>42.1.4</postgresql.version>
|
|
<gson.version>2.8.2</gson.version>
|
|
<annotation.version>1.3.1</annotation.version>
|
|
<javaxmail.version>1.6.0</javaxmail.version>
|
|
<serverlet.version>3.1.0</serverlet.version>
|
|
<jaxrs.api.version>2.1</jaxrs.api.version>
|
|
|
|
<junit.version>4.12</junit.version>
|
|
<hamcrest.version>1.3</hamcrest.version>
|
|
<mockito.version>2.0.8-beta</mockito.version>
|
|
|
|
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
|
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
|
|
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
|
<maven-war-plugin.version>3.1.0</maven-war-plugin.version>
|
|
|
|
<strolch.version>1.6.0-SNAPSHOT</strolch.version>
|
|
|
|
<warFinalName>bookshop</warFinalName>
|
|
<m2eclipse.wtp.contextRoot>${warFinalName}</m2eclipse.wtp.contextRoot>
|
|
</properties>
|
|
|
|
<dependencies>
|
|
|
|
<!-- base -->
|
|
<dependency>
|
|
<groupId>org.slf4j</groupId>
|
|
<artifactId>slf4j-api</artifactId>
|
|
<version>${slf4j.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>ch.qos.logback</groupId>
|
|
<artifactId>logback-classic</artifactId>
|
|
<version>${logback.version}</version>
|
|
<scope>runtime</scope>
|
|
</dependency>
|
|
|
|
<!-- strolch -->
|
|
<dependency>
|
|
<groupId>li.strolch</groupId>
|
|
<artifactId>li.strolch.utils</artifactId>
|
|
<version>${strolch.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>li.strolch</groupId>
|
|
<artifactId>li.strolch.privilege</artifactId>
|
|
<version>${strolch.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>li.strolch</groupId>
|
|
<artifactId>li.strolch.model</artifactId>
|
|
<version>${strolch.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>li.strolch</groupId>
|
|
<artifactId>li.strolch.agent</artifactId>
|
|
<version>${strolch.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>li.strolch</groupId>
|
|
<artifactId>li.strolch.rest</artifactId>
|
|
<version>${strolch.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>li.strolch</groupId>
|
|
<artifactId>li.strolch.service</artifactId>
|
|
<version>${strolch.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>li.strolch</groupId>
|
|
<artifactId>li.strolch.testbase</artifactId>
|
|
<version>${strolch.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
|
|
<!-- utils -->
|
|
<dependency>
|
|
<groupId>com.google.code.gson</groupId>
|
|
<artifactId>gson</artifactId>
|
|
<version>${gson.version}</version>
|
|
</dependency>
|
|
|
|
<!-- web -->
|
|
<dependency>
|
|
<groupId>javax.servlet</groupId>
|
|
<artifactId>javax.servlet-api</artifactId>
|
|
<version>${serverlet.version}</version>
|
|
<scope>provided</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>javax.ws.rs</groupId>
|
|
<artifactId>javax.ws.rs-api</artifactId>
|
|
<version>${jaxrs.api.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.glassfish.jersey.core</groupId>
|
|
<artifactId>jersey-common</artifactId>
|
|
<version>${jersey.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.glassfish.jersey.core</groupId>
|
|
<artifactId>jersey-server</artifactId>
|
|
<version>${jersey.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.glassfish.jersey.containers</groupId>
|
|
<artifactId>jersey-container-servlet</artifactId>
|
|
<version>${jersey.version}</version>
|
|
</dependency>
|
|
|
|
<!-- testing -->
|
|
<dependency>
|
|
<groupId>junit</groupId>
|
|
<artifactId>junit</artifactId>
|
|
<version>${junit.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.hamcrest</groupId>
|
|
<artifactId>hamcrest-core</artifactId>
|
|
<version>${hamcrest.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.hamcrest</groupId>
|
|
<artifactId>hamcrest-library</artifactId>
|
|
<version>${hamcrest.version}</version>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
</dependencies>
|
|
|
|
<build>
|
|
<resources>
|
|
<!-- filter properties files, and copy the rest -->
|
|
<resource>
|
|
<directory>src/main/resources</directory>
|
|
<filtering>true</filtering>
|
|
<includes>
|
|
<include>**/*.properties</include>
|
|
</includes>
|
|
</resource>
|
|
<resource>
|
|
<directory>src/main/resources</directory>
|
|
<filtering>false</filtering>
|
|
<excludes>
|
|
<exclude>**/*.properties</exclude>
|
|
</excludes>
|
|
</resource>
|
|
</resources>
|
|
|
|
<plugins>
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-compiler-plugin</artifactId>
|
|
<version>${maven-compiler-plugin.version}</version>
|
|
<configuration>
|
|
<source>${jdk.version}</source>
|
|
<target>${jdk.version}</target>
|
|
</configuration>
|
|
</plugin>
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-war-plugin</artifactId>
|
|
<version>${maven-war-plugin.version}</version>
|
|
<configuration>
|
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
|
<warName>${warFinalName}</warName>
|
|
</configuration>
|
|
</plugin>
|
|
</plugins>
|
|
</build>
|
|
|
|
<profiles>
|
|
<!-- active when building on eitch's machines -->
|
|
<profile>
|
|
<id>m2e.eitchpc</id>
|
|
<activation>
|
|
<property>
|
|
<name>user.name</name>
|
|
<value>eitch</value>
|
|
</property>
|
|
<os>
|
|
<family>unix</family>
|
|
</os>
|
|
</activation>
|
|
<properties>
|
|
<strolch.env>dev.eitchpc</strolch.env>
|
|
</properties>
|
|
</profile>
|
|
</profiles>
|
|
</project>
|
|
</pre>
|
|
|
|
<p>Now we need the rest of the directory structure:</p>
|
|
|
|
<pre class="pre-scrollable">
|
|
../strolch-bookshop/
|
|
- src/main/java/
|
|
- li/strolch/bookshop/
|
|
- <!-- java classes -->
|
|
- src/main/resources/
|
|
- ENV.properties
|
|
- appVersion.properties
|
|
- logback.xml
|
|
- src/main/webapp/WEB-INF/
|
|
- StrolchBootstrap.xml
|
|
- runtime
|
|
- config/
|
|
- PrivilegeConfig.xml
|
|
- PrivilegeRoles.xml
|
|
- PrivilegeUsers.xml
|
|
- StrolchConfiguration.xml
|
|
- StrolchPolicies.xml
|
|
- data/
|
|
- StrolchModel.xsd
|
|
- defaultModel.xml
|
|
- templates.xml
|
|
- temp/
|
|
</pre>
|
|
|
|
<p>A few notes to the resource files:</p>
|
|
<ul>
|
|
<li>The <code>ENV.properties</code> file is filtered by maven and the environment to load is written in it
|
|
using the environment variable strolch.env.
|
|
</li>
|
|
<li>The <code>appVersion.properties</code> file is also filtered by maven and allows to reflect on the
|
|
version of this app at runtime.
|
|
</li>
|
|
<li>The <code>logback.xml</code> file configures logging using SLF4j and Logback.</li>
|
|
</ul>
|
|
|
|
<p>The <code>StrolchBootstrap.xml</code> file is used to configure Strolch's environment and root directory. For
|
|
a webapp it can be annoying to store Strolch's configuration inside the webapp, which is why we can define an
|
|
absolute path where the configuration is kept. In the following example we keep it in the root of the
|
|
sources:</p>
|
|
<pre class="pre-scrollable">
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<StrolchBootstrap>
|
|
<env id="dev.eitchpc" default="true">
|
|
<root>/home/eitch/src/git/strolch-bookshop/runtime</root>
|
|
<environment>dev</environment>
|
|
</env>
|
|
</StrolchBootstrap>
|
|
</pre>
|
|
|
|
<p>Here we define two environments, but the both redefine the environment to dev. This is because we want this
|
|
app to start on two different machines with different user home directories. See the profiles in the POM as
|
|
to how these environments are activated using a environment property strolch.env.</p>
|
|
|
|
<p>In this next step we'll create Strolch's configuration at the location we defined in the StrolchBootstrap.xml
|
|
file. Strolch's configuration contains of three directories: config, data and temp. config contains static
|
|
files which usually aren't changed, data contains model files in XML format and temp is used at runtime for
|
|
any temporary files, e.g. storing active sessions.</p>
|
|
|
|
<p>The configuration as well as the model has been described on Strolch's documentation web page, we'll just
|
|
provide you with the files for the bookshop:</p>
|
|
|
|
<b>PrivilegeConfig.xml</b>
|
|
<pre class="pre-scrollable">
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<Privilege>
|
|
<Container>
|
|
<Parameters>
|
|
<!-- parameters for the container itself -->
|
|
<Parameter name="secretKey" value="45f251ce-d51f-4624-990a-8dcd5b181f0e"/>
|
|
<Parameter name="secretSalt" value="4770a32d-1512-4891-9a63-362504932500"/>
|
|
<Parameter name="persistSessions" value="true"/>
|
|
<Parameter name="autoPersistOnUserChangesData" value="false"/>
|
|
<Parameter name="privilegeConflictResolution" value="MERGE"/>
|
|
</Parameters>
|
|
<EncryptionHandler class="li.strolch.privilege.handler.DefaultEncryptionHandler">
|
|
<Parameters>
|
|
<Parameter name="hashAlgorithm" value="PBKDF2WithHmacSHA512"/>
|
|
<Parameter name="hashIterations" value="10000"/>
|
|
<Parameter name="hashKeyLength" value="256"/>
|
|
</Parameters>
|
|
</EncryptionHandler>
|
|
<PersistenceHandler class="li.strolch.privilege.handler.XmlPersistenceHandler">
|
|
<Parameters>
|
|
<Parameter name="usersXmlFile" value="PrivilegeUsers.xml"/>
|
|
<Parameter name="rolesXmlFile" value="PrivilegeRoles.xml"/>
|
|
</Parameters>
|
|
</PersistenceHandler>
|
|
<UserChallengeHandler class="li.strolch.privilege.handler.MailUserChallengeHandler">
|
|
</UserChallengeHandler>
|
|
</Container>
|
|
<Policies>
|
|
<Policy name="DefaultPrivilege" class="li.strolch.privilege.policy.DefaultPrivilege"/>
|
|
<Policy name="RoleAccessPrivilege" class="li.strolch.privilege.policy.RoleAccessPrivilege"/>
|
|
<Policy name="UserAccessPrivilege" class="li.strolch.privilege.policy.UserAccessPrivilege"/>
|
|
<Policy name="UserSessionAccessPrivilege" class="li.strolch.privilege.policy.UsernameFromCertificatePrivilege"/>
|
|
</Policies>
|
|
</Privilege>
|
|
</pre>
|
|
|
|
<b>PrivilegeRoles.xml</b>
|
|
<pre class="pre-scrollable">
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<Roles>
|
|
<Role name="User">
|
|
<Privilege name="li.strolch.service.api.Service" policy="DefaultPrivilege">
|
|
</Privilege>
|
|
|
|
<Privilege name="li.strolch.search.StrolchSearch" policy="DefaultPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
<Allow>li.strolch.bookshop.search.BookSearch</Allow>
|
|
</Privilege>
|
|
|
|
<Privilege name="GetResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="GetOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="GetActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="AddResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="AddOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="AddActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="UpdateResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="UpdateOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="UpdateActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="RemoveResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="RemoveOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="RemoveActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
</Role>
|
|
<Role name="UserPrivileges">
|
|
<Privilege name="PrivilegeSetUserLocale" policy="UserAccessPrivilege" />
|
|
<Privilege name="PrivilegeSetUserPassword" policy="UserAccessPrivilege" />
|
|
</Role>
|
|
|
|
<!--
|
|
Internal
|
|
-->
|
|
<Role name="StrolchAdmin">
|
|
<Privilege name="li.strolch.service.api.Service" policy="DefaultPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
|
|
<Privilege name="li.strolch.search.StrolchSearch" policy="DefaultPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
|
|
<Privilege name="GetResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="GetOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="GetActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="AddResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="AddOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="AddActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="UpdateResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="UpdateOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="UpdateActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="RemoveResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="RemoveOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="RemoveActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
|
|
<Privilege name="PrivilegeAddUser" policy="UserAccessPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="PrivilegeSetUserPassword" policy="UserAccessPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
</Role>
|
|
|
|
<Role name="agent">
|
|
<Privilege name="li.strolch.privilege.handler.SystemAction" policy="DefaultPrivilege">
|
|
<Allow>li.strolch.runtime.privilege.StrolchSystemAction</Allow>
|
|
<Allow>li.strolch.runtime.privilege.StrolchSystemActionWithResult</Allow>
|
|
<Allow>li.strolch.persistence.postgresql.PostgreSqlSchemaInitializer</Allow>
|
|
</Privilege>
|
|
|
|
<Privilege name="li.strolch.service.api.Service" policy="DefaultPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
|
|
<Privilege name="li.strolch.model.query.StrolchQuery" policy="DefaultPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="li.strolch.search.StrolchSearch" policy="DefaultPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
|
|
<Privilege name="GetResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="GetOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="GetActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="AddResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="AddOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="AddActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="UpdateResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="UpdateOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="UpdateActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="RemoveResource" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="RemoveOrder" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="RemoveActivity" policy="ModelPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
|
|
<Privilege name="PrivilegeAction" policy="DefaultPrivilege">
|
|
<Allow>Persist</Allow>
|
|
<Allow>PersistSessions</Allow>
|
|
<Allow>GetCertificates</Allow>
|
|
</Privilege>
|
|
<Privilege name="PrivilegeAddUser" policy="UserAccessPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="PrivilegeModifyUser" policy="UserAccessPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
<Privilege name="PrivilegeGetUser" policy="UserAccessPrivilege">
|
|
<AllAllowed>true</AllAllowed>
|
|
</Privilege>
|
|
</Role>
|
|
|
|
</Roles>
|
|
</pre>
|
|
|
|
<b>PrivilegeUsers.xml</b>
|
|
<pre class="pre-scrollable">
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<Users>
|
|
<User userId="U10" username="jill" password="8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918">
|
|
<Firstname>Jill</Firstname>
|
|
<Lastname>Someone</Lastname>
|
|
<State>ENABLED</State>
|
|
<Locale>en-GB</Locale>
|
|
<Roles>
|
|
<Role>User</Role>
|
|
<Role>UserPrivileges</Role>
|
|
</Roles>
|
|
<Properties>
|
|
<Property name="email" value="eitch+jill@eitchnet.ch" />
|
|
</Properties>
|
|
</User>
|
|
|
|
<User userId="U01" username="admin" password="8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918">
|
|
<Firstname>Jill</Firstname>
|
|
<Lastname>Someone</Lastname>
|
|
<State>ENABLED</State>
|
|
<Locale>en-GB</Locale>
|
|
<Roles>
|
|
<Role>StrolchAdmin</Role>
|
|
<Role>UserPrivileges</Role>
|
|
</Roles>
|
|
<Properties>
|
|
<Property name="email" value="eitch+admin@eitchnet.ch" />
|
|
</Properties>
|
|
</User>
|
|
|
|
<!--
|
|
Internal
|
|
-->
|
|
<User userId="S01" username="agent">
|
|
<State>SYSTEM</State>
|
|
<Roles>
|
|
<Role>agent</Role>
|
|
</Roles>
|
|
</User>
|
|
|
|
</Users>
|
|
</pre>
|
|
|
|
<b>StrolchConfiguration.xml</b>
|
|
<pre class="pre-scrollable">
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<StrolchConfiguration>
|
|
<env id="global">
|
|
<Runtime>
|
|
<applicationName>Bookshop</applicationName>
|
|
<Properties>
|
|
<locale>en</locale>
|
|
<verbose>true</verbose>
|
|
</Properties>
|
|
</Runtime>
|
|
|
|
<Component>
|
|
<name>PrivilegeHandler</name>
|
|
<api>li.strolch.runtime.privilege.PrivilegeHandler</api>
|
|
<impl>li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler</impl>
|
|
<Properties>
|
|
<privilegeConfigFile>PrivilegeConfig.xml</privilegeConfigFile>
|
|
</Properties>
|
|
</Component>
|
|
|
|
<Component>
|
|
<name>RealmHandler</name>
|
|
<api>li.strolch.agent.api.RealmHandler</api>
|
|
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
|
|
<depends>PrivilegeHandler</depends>
|
|
<Properties>
|
|
<realms>defaultRealm</realms>
|
|
|
|
<dataStoreMode>TRANSIENT</dataStoreMode>
|
|
<dataStoreFile>defaultModel.xml</dataStoreFile>
|
|
<enableObserverUpdates>true</enableObserverUpdates>
|
|
</Properties>
|
|
</Component>
|
|
|
|
<Component>
|
|
<name>ServiceHandler</name>
|
|
<api>li.strolch.service.api.ServiceHandler</api>
|
|
<impl>li.strolch.service.api.DefaultServiceHandler</impl>
|
|
<depends>RealmHandler</depends>
|
|
<depends>PrivilegeHandler</depends>
|
|
<Properties>
|
|
<verbose>true</verbose>
|
|
</Properties>
|
|
</Component>
|
|
|
|
<Component>
|
|
<name>PolicyHandler</name>
|
|
<api>li.strolch.policy.PolicyHandler</api>
|
|
<impl>li.strolch.policy.DefaultPolicyHandler</impl>
|
|
<Properties>
|
|
<readPolicyFile>true</readPolicyFile>
|
|
</Properties>
|
|
</Component>
|
|
|
|
<Component>
|
|
<name>ExecutionHandler</name>
|
|
<api>li.strolch.execution.ExecutionHandler</api>
|
|
<impl>li.strolch.execution.EventBasedExecutionHandler</impl>
|
|
<depends>RealmHandler</depends>
|
|
<depends>PrivilegeHandler</depends>
|
|
</Component>
|
|
|
|
<Component>
|
|
<name>RestfulHandler</name>
|
|
<api>li.strolch.rest.RestfulStrolchComponent</api>
|
|
<impl>li.strolch.rest.RestfulStrolchComponent</impl>
|
|
<depends>SessionHandler</depends>
|
|
<Properties>
|
|
<secureCookie>false</secureCookie>
|
|
<restLogging>false</restLogging>
|
|
<restLoggingEntity>false</restLoggingEntity>
|
|
<restTracing>ALL</restTracing>
|
|
</Properties>
|
|
</Component>
|
|
<Component>
|
|
<name>SessionHandler</name>
|
|
<api>li.strolch.rest.StrolchSessionHandler</api>
|
|
<impl>li.strolch.rest.DefaultStrolchSessionHandler</impl>
|
|
<depends>PrivilegeHandler</depends>
|
|
<Properties>
|
|
<session.ttl.minutes>30</session.ttl.minutes>
|
|
<session.reload>true</session.reload>
|
|
</Properties>
|
|
</Component>
|
|
|
|
<Component>
|
|
<name>MailHandler</name>
|
|
<api>li.strolch.handler.mail.MailHandler</api>
|
|
<impl>li.strolch.handler.mail.SmtpMailHandler</impl>
|
|
<Properties>
|
|
<fromAddr>relayer@eitchnet.ch</fromAddr>
|
|
<fromName>Susi</fromName>
|
|
<overrideRecipients>IPSC Test <eitch@eitchnet.ch></overrideRecipients>
|
|
<recipientWhitelist>eitch@eitchnet.ch</recipientWhitelist>
|
|
<username>test</username>
|
|
<password>test</password>
|
|
<auth>true</auth>
|
|
<startTls>true</startTls>
|
|
<host>smtp.gmail.com</host>
|
|
<port>587</port>
|
|
</Properties>
|
|
</Component>
|
|
|
|
</env>
|
|
|
|
<env id="dev">
|
|
<!-- overrides go here -->
|
|
</env>
|
|
|
|
</StrolchConfiguration>
|
|
</pre>
|
|
|
|
<b>StrolchPolicies.xml</b>
|
|
<pre class="pre-scrollable">
|
|
<StrolchPolicies>
|
|
<PolicyType Type="ExecutionPolicy" Api="li.strolch.execution.policy.ExecutionPolicy">
|
|
<Policy Key="DurationExecution" Class="li.strolch.execution.policy.DurationExecution" />
|
|
<Policy Key="ReservationExection" Class="li.strolch.execution.policy.ReservationExection" />
|
|
</PolicyType>
|
|
<PolicyType Type="ConfirmationPolicy" Api="li.strolch.execution.policy.ConfirmationPolicy">
|
|
<Policy Key="DefaultConfirmation" Class="li.strolch.execution.policy.ConfirmationPolicy" />
|
|
</PolicyType>
|
|
<PolicyType Type="ActivityArchivalPolicy" Api="li.strolch.execution.policy.ActivityArchivalPolicy">
|
|
<Policy Key="DefaultActivityArchival" Class="li.strolch.execution.policy.ActivityArchivalPolicy" />
|
|
</PolicyType>
|
|
</StrolchPolicies>
|
|
</pre>
|
|
|
|
<p>A few notes on the configuration:</p>
|
|
<ul>
|
|
<li>Note how there are three users. Jill is a user with currently no privileges as it's role definition is
|
|
empty. Admin can do everything, and the agent user is a system user which can also do everything.
|
|
</li>
|
|
<li>There is one realm defined in the <code>RealmHandler</code> component which references the <code>defaultModel.xml</code>
|
|
file in the data directory. This file then includes the currently still empty <code>templates.xml</code>
|
|
file.
|
|
</li>
|
|
<li>We have defined a global environment, but are using the dev environment. The dev environment includes
|
|
the definitions in the global environment.
|
|
</li>
|
|
<li>In <code>PrivilegeConfig.xml</code> we have enabled persistence of sessions, so you will be needing the
|
|
unlimited JCE libraries for your JVM and when you restart the server, you don't need to log back in, if
|
|
your session is still alive.
|
|
</li>
|
|
<li>In <code>PrivilegeRoles.xml</code> there seems to be a lot of boilerplate. One thing about a highly
|
|
configurable system is that sometimes the configuration is bigger. In this case we have opted to have
|
|
the configuration shown and not use default values which you don't see, so that privilege acces is
|
|
clearly seen.
|
|
</li>
|
|
</ul>
|
|
|
|
<p>Your project is now ready to be imported into your favourite IDE. We have used both IntelliJ and Eclipse so
|
|
this is up to you.</p>
|
|
|
|
Now that we have a configuration, it is time to have Strolch started when the WAR is deployed and started. In
|
|
your IDE create a new class as follows:</p>
|
|
|
|
<b>StartupListener.java</b>
|
|
<pre class="pre-scrollable">
|
|
package li.strolch.bookshop.web;
|
|
|
|
import javax.servlet.ServletContextEvent;
|
|
import javax.servlet.ServletContextListener;
|
|
import javax.servlet.annotation.WebListener;
|
|
import java.io.InputStream;
|
|
|
|
import li.strolch.agent.api.StrolchAgent;
|
|
import li.strolch.agent.api.StrolchBootstrapper;
|
|
import li.strolch.utils.helper.StringHelper;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@WebListener
|
|
public class StartupListener implements ServletContextListener {
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(StartupListener.class);
|
|
private static final String APP_NAME = "Bookshop";
|
|
|
|
private StrolchAgent agent;
|
|
|
|
@Override
|
|
public void contextInitialized(ServletContextEvent sce) {
|
|
|
|
logger.info("Starting " + APP_NAME + "...");
|
|
long start = System.currentTimeMillis();
|
|
try {
|
|
String boostrapFileName = "/WEB-INF/" + StrolchBootstrapper.FILE_BOOTSTRAP;
|
|
InputStream bootstrapFile = sce.getServletContext().getResourceAsStream(boostrapFileName);
|
|
StrolchBootstrapper bootstrapper = new StrolchBootstrapper(StartupListener.class);
|
|
this.agent = bootstrapper.setupByBoostrapFile(StartupListener.class, bootstrapFile);
|
|
this.agent.initialize();
|
|
this.agent.start();
|
|
} catch (Throwable e) {
|
|
logger.error("Failed to start " + APP_NAME + " due to: " + e.getMessage(), e);
|
|
throw e;
|
|
}
|
|
|
|
long took = System.currentTimeMillis() - start;
|
|
logger.info("Started " + APP_NAME + " in " + (StringHelper.formatMillisecondsDuration(took)));
|
|
}
|
|
|
|
@Override
|
|
public void contextDestroyed(ServletContextEvent sce) {
|
|
if (this.agent != null) {
|
|
logger.info("Destroying " + APP_NAME + "...");
|
|
try {
|
|
this.agent.stop();
|
|
this.agent.destroy();
|
|
} catch (Throwable e) {
|
|
logger.error("Failed to stop " + APP_NAME + " due to: " + e.getMessage(), e);
|
|
throw e;
|
|
}
|
|
}
|
|
logger.info("Destroyed " + APP_NAME);
|
|
}
|
|
}
|
|
</pre>
|
|
|
|
<p>Now configure your IDE to start the web project, and then once it has started, you should see the following
|
|
in the logs:</p>
|
|
<pre class="pre-scrollable">
|
|
Bookshop:dev All 8 Strolch Components started. Took 44ms. Strolch is now ready to be used. Have fun =))
|
|
</pre>
|
|
|
|
<p>This log tells us the name of the app as defined in the StrolchConfiguration.xml file as well as which
|
|
environment was loaded. Further we can see that 8 components were configured and started.</p>
|
|
|
|
<p>This concludes the initial setup of a new Strolch project. We can now go ahead and start building the
|
|
business logic.</p>
|
|
|
|
<!-- content here -->
|
|
|
|
<a href="tutorial.html" class="pull-left">Previous: Start</a><a href="tutorial-model.html" class="pull-right">Next:
|
|
Model</a>
|
|
|
|
</div>
|
|
<!-- /.content -->
|
|
|
|
<div id="footer">
|
|
<div class="container">
|
|
<p class="text-muted">© Strolch / <a href="mailto:eitch@eitchnet.ch">Robert von Burg</a> / Hosting by
|
|
<a href="http://www.eitchnet.ch">eitchnet.ch</a></p>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<!-- /.container -->
|
|
|
|
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
|
<!-- Include all compiled plugins (below), or include individual xsd as needed -->
|
|
<script src="js/bootstrap.min.js"></script>
|
|
|
|
<!-- Piwik -->
|
|
<script type="text/javascript">
|
|
var _paq = _paq || [];
|
|
_paq.push(['trackPageView']);
|
|
_paq.push(['enableLinkTracking']);
|
|
(function () {
|
|
var u = (("https:" == document.location.protocol) ? "https" : "http") + "://piwik.eitchnet.ch/";
|
|
_paq.push(['setTrackerUrl', u + 'piwik.php']);
|
|
_paq.push(['setSiteId', 2]);
|
|
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
|
|
g.type = 'text/javascript';
|
|
g.defer = true;
|
|
g.async = true;
|
|
g.src = u + 'piwik.js';
|
|
s.parentNode.insertBefore(g, s);
|
|
})();
|
|
</script>
|
|
<noscript><p><img src="http://piwik.eitchnet.ch/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
|
|
<!-- End Piwik Code -->
|
|
|
|
</body>
|
|
</html>
|