[[ux_configuration]]
Configuration of UNICORE/X
--------------------------

Overview of the main configuration options
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

UNICORE/X is a fairly complex software which has many interfaces to other UNICORE components
and configuration options. This section tries to give an overview of what can 
and should be configured. The detailed configuration guide follows in the next sections.

==== Mandatory configuration

 - Certificates and basic security: UNICORE uses X.509 certificates for all servers. 
For UNICORE/X these are configured in the wsrflite.xml config file

 - Attribute sources: to map clients (i.e. X.509 certificates) to local attributes such as 
user name, groups and role, various attribute sources are available. For details,
consult xref:use_aip[].

 - Backend / target system access: to access a resource manager like SGE or Torque, the
UNICORE TSI needs to be installed and UNICORE/X needs to be configured accordingly. Please
consult xref:ux_xnjs[].

UNICORE/X has several sub-components. These are configured using
several config files residing in the CONF directory, see 
xref:ux_install[] for the location of the CONF directory.

Config file overview
~~~~~~~~~~~~~~~~~~~~

The following table indicates the main configuration files. Depending on
configuration and installed extensions, some of these files may not be present, or
more files may be present.

UNICORE/X watches some most configuration files for changes, and tries to reconfigure 
if they are modified, at least where possible. This is indicated in the
"dynamically reloaded" column.
are indicated.

.UNICORE/X configuration files
[options="header"]
|===============================
|config file        | usage					| dynamically reloaded
|startup.properties |Java settings (e.g. memory), lib/log/conf directories    | no
|uas.config	    |General settings, startup behaviour, storages, AIP setup    | yes
|wsrflite.xml	    |Services to be deployed, SSL settings, Web server settings|yes
|simpleidb	    |Backend, installed applications, resources|yes
|xnjs.xml	    |Back end properties | no 
|xnjs_legacy.xml    |Back end properties preconfigured for the Perl TSI| no
|logging.properties |logging levels, logfiles and their properties|yes
|xacml2Policies/*.xml | Access control policy for securing the web services|yes, via xacml2.config (do 'touch xacml2.config' to trigger) 
|xacml2.config	    |Configure the XACML2 access control component|yes
|vo.config          |Configure the use of UVOS (optional attribute source) | no
|simpleuudb         |A file mapping user DNs to local attributes (optional attribute source) |yes
|jmxremote.password |Access control file for remote monitoring using the Java management extensions (JMX)  | no
|===============================

Settings for the UNICORE/X process (e.g. memory)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The properties controlling the Java virtual machine running the
UNICORE/X process are configured in
  
  - UNIX: the CONF/startup.properties configuration file
  
  - Windows: the "CONF\\wrapper.conf" configuration file
  

These properties include settings for maximum memory, and also the properties
for configuring JMX, see xref:ux_admin[] for more on JMX.  

General
  
Config file formats
~~~~~~~~~~~~~~~~~~~

UNICORE/X uses two different formats for configuration. 
  
==== Java properties

    - Each property can be assigned a value using the syntax "name=value"
  
    - Please do not quote values, as the quotes will be interpreted as part of the value

    - Comment lines are started by the "#" 
  
    - Multiline values are possible by ending lines with "\", e.g.
  
-------
      name=value1 \
      value2
-------
   
In this example the value of the "name" property will be "value1 value2".
    

==== XML

Various XML dialects are being used, so please refer to the example files distributed with
UNICORE for more information on the syntax. In general XML is a bit unfriendly to edit, and
it is rather easy to introduce typos. 

[NOTE]
============
It is advisable to run a tool such as 'xmllint' after editing XML files to check for
typos
============


UNICORE/X container configuration overview
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following table gives an overview of the basic settings for a
UNICORE/X server. These can be set in uas.config or wsrflite.xml. Many
of the settings (e.g. security) will be explained in more detail in
separate sections.

include::containerProperties.txt[]

Integration of UNICORE/X into a UNICORE infrastructure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Since UNICORE/X is the central component, it is interfaced to other 
parts of the UNICORE architecture, i.e. the Gateway and (optionally) 
a Registry.

==== Gateway

The gateway address is hard-coded into CONF/wsrflite.xml, using
the "container.baseurl" property:

-------------------------
  <property name="container.baseurl"
            value="https://Gateway_HOST:Gateway_PORT/SITENAME/services"/>
-------------------------

where Gateway_HOST and Gateway_PORT are the host and port of the
gateway, and SITENAME is the UNICORE/X site name. The gateway address
MUST be accessible from the UNICORE/X node!

On the gateway side, the UNICORE/X address can be hard-coded as well,
using an entry SITENAME=address in the connections.properties file
pointing to the network address of the UNICORE/X container. In some
scenarios, it is convenient to auto-register with a gateway. This can be
enabled using the +container.security.gateway.*+ Please check the
gateway manual on how to configure the autoregistration on the gateway
side.


==== Registry

It is possible to configure UNICORE/X to contact one or more 
external or "global" Registries in order to publish information on crucial services
there. Most of the following properties deal with the automatic discovery 
and/or manual setup of the external registries being used.

For example

-------------------------
container.externalregistry.use=true
container.externalregistry.url=https://host1:8080/REGISTRY/services/Registry?res=default_registry
container.externalregistry.url2=https://host2:8080/BACKUP/services/Registry?res=default_registry
-------------------------

==== Unity

If you want to support certificate-less end user access via Unity,
you have to configure UNICORE/X to trust one or more Unity servers.
This is done using the +container.security.trustedAssertionIssuers+ 
property. This configures a truststore containing the certificates of
all trusted Unity servers (NOT the CA certificates).

For example, to configure a directory containing the trusted certificates
in PEM format:

-------------------------
  <!-- configure trusted Unity certificates -->
  <property name="container.security.trustedAssertionIssuers.type" 
            value="directory" />
  <property name="container.security.trustedAssertionIssuers.directoryLocations.1" 
            value="conf/unity/unity.pem" />
-------------------------

All the usual options for configuring truststores are available here, 
as well, as described in Section [[use-authtrust]].

[NOTE]
==========
To enable certificate-less end user access, you will also need to disable
client-authentication in the Gateway, please refer to the Gateway manual.
==========

Startup code
~~~~~~~~~~~~

In order to provide a flexible initialization process for UNICORE/X,
there is a set of properties named "container.onstartup.*". The
value(s) of this property consists of a whitespace separated list of
java classes which must be implementing the "Runnable" interface. Many
extensions for UNICORE/X rely on an entry in this property to
initialise themselves.
  

.Startup code
[options="header"]
|=============================
| class name			   	    | description | usage
|de.fzj.unicore.uas.util.DefaultOnStartup   | initialises the job management system and the "local" registry; should usually be run on startup | normal UNICORE/X servers 
|de.fzj.unicore.bes.util.BESOnStartup   | initialises the OGSA-BES job management system | UNICORE/X servers that expose BES services
|de.fzj.unicore.cisprovider.impl.InitOnStartup | sets up the CIS infoprovider | UNICORE/X servers that want to provide information in GLUE2 format or want to be visible in the CIS
|com.intel.gpe.gridbeans.PublishGridBeanService |if available, publishes the GridBeanService to the registry | UNICORE/X servers that host a Gridbean service
|de.fzj.unicore.uas.util.CreateSMSOnStartup |creates and deploys a single instance of the SMS that is shared between users, named default_storage| if a shared storage is required
|============================


Security
~~~~~~~~
  
==== Overview

Security is a complex issue, and many options exist. On a high level, the following items
need to be configured.
   
   - SSL setup (keystore and truststore settings for securing the basic communication between components)

   - Attribute sources configuration which assign an authorisation role, UNIX login, group and other properties to 
   Grid users. UNICORE knows several attribute sources which can be combined using various combining algorithms. 
   These are configured in the uas.config file. Due to the complexity, the description of the 
   configuration options can be found in xref:use_aip[].
    
   - Access control setup (controlling in detail who can do what on which services). Again, several options exist, 
   which are described in xref:use_pdp[].
  
   - Message level security (message signatures). UNICORE can be configured (and is so by default) to require digital 
   signatures on important messages (like job submissions or file exports). When enabled UNICORE guarantees non-repudiation,
   i.e. the client can not deny that it invoked the operation. Check the table below for the option allowing to 
   disable this feature to have a bit better performance.


[[use-secref]]
==== General security options

This table presents all security related options, except credential and truststore settings
which are described in the subsequent section.

include::use-ref-security.txt[]

:leveloffset: 2

[[use-authtrust]]
include::sec-authtrustcfg.txt[]

:leveloffset: 0


Configuring the XNJS and TSI
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Information on the configuration of the XNJS and TSI backend can be found in xref:ux_xnjs[].

Configuring storages on TargetSystem instances
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Each TargetSystem instance can have one or more storages attached to it. Note that this 
is different case from the shared storage (the one created with CreateSMSOnStartup hook)
which is not attached to any particular TargetSystem. The practical difference is that to use 
storages attached to a TargetSystem, a user must first create one.
    
By default, NO storages are created.

For example, to allows users access their home directory on the target system, 
you need to add a storage. This is done using configuration entries in uas.config.

include::tss-smsProperties.txt[]

Here, "N" stands for an identifier (e.g. 1,2, 3, ...) to distinguish the storages. For example, 
to configure three storages (Home, one named TEMP pointing to "/tmp" and the other named DEISA_HOME 
pointing to "$DEISA_HOME") you would add the following configuration entries in uas.config:

-------------------
coreServices.targetsystem.storage.0.name=Home
coreServices.targetsystem.storage.0.type=HOME

coreServices.targetsystem.storage.1.name=TEMP
coreServices.targetsystem.storage.1.type=FIXEDPATH
coreServices.targetsystem.storage.1.path=/tmp
coreServices.targetsystem.storage.1.protocols=UFTP BFT

coreServices.targetsystem.storage.2.name=DEISA_HOME
coreServices.targetsystem.storage.2.type=VARIABLE
coreServices.targetsystem.storage.2.path=$DEISA_HOMES

# example for a custom SMS implementation (e.g. for Hadoop or iRODS)
coreServices.targetsystem.storage.3.name=IRODS
coreServices.targetsystem.storage.3.type=CUSTOM
coreServices.targetsystem.storage.3.path=/
coreServices.targetsystem.storage.3.class=my.custom.sms.ImplementationClass
-------------------

Note that you can optionally control the file transfer protocols that should be enabled for each storage.

Some storage protocols require additional software to be
installed. For instance, the UNICORE File Transfer Protocol (UFTP)
requires the UFTPD to be available and configured on the system. 


==== Controlling target system's storage resources

By default storage resource names (used in storage address) are formed from
the owning user's xlogin and the storage type name, e.g. "someuser-Home". This is quite useful 
as users can write a URL of the storage without prior searching for its address.
However if the site's user mapping configuration maps more than one grid certificate to the same
xlogin, then this solution is not acceptable: only the first user connecting would be able to access
her/his storage. This is because resource owners are expressed as grid user names (certificate DNs) and not xlogins.
To have unique, but dynamically created and non user friendly names of storages 
(and solve the problem of non-unique DN mappings) set this option in uas.config:

------------------
coreServices.targetsystem.uniqueStorageIds=true
------------------

Configuring the StorageFactory service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The StorageFactory service allows clients to dynamically create storage instances.
These can have different types, for example you could have storages on a normal
filesystem, and other storages on an Apache Hadoop cluster.

The basic property controls which storage types are supported

----------------
coreServices.sms.enabledFactories=TYPE1 TYPE2 ...
----------------

Each supported storage type is configured using a set of properties

include::smf-smsProperties.txt[]

For example

----------------
coreServices.sms.factory.TYPE1.description=GPFS file system
coreServices.sms.factory.TYPE1.fixedpath=GPFS file system
coreServices.sms.factory.TYPE1.path=/mnt/gpfs/unicore/unicorex-1/storage-factory
coreServices.sms.factory.TYPE1.protocols=UFTP BFT

# if this is set to true, the directory corresponding to a storage instance will
# be deleted when the instance is destroyed. Defaults to "true"
coreServices.sms.factory.TYPE1.cleanup=true
----------------

The "path" parameter determines the base directory used for the storage instances 
(i.e. on the backend), and the unique ID of the storage will be appended automatically.

The "cleanup" parameter controls whether the storage directory will be deleted when the storage
is destroyed. 

The normal storage properties (see the previous section) are also accepted: "protocols",
"type", "class", "filterFiles" etc.

If you have a custom storage type, an additional "class" parameter defines the
Java class name to use (as in normal SMS case). For example:

----------------------
coreServices.sms.factory.TYPE1.type=CUSTOM
coreServices.sms.factory.TYPE1.class=de.fzj.unicore.uas.hadoop.SMSHadoopImpl
----------------------

HTTP proxy, timeout and web server settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The UNICORE Services Environment container has a number of settings related to 
the web server and to the HTTPClient library used for outgoing HTTP(s) calls.

The server options are shown in the following table.

include::sec-ref-jettyProperties.txt[]


The client options are the following

include::sec-ref-clientProperties.txt[]
 

  
  
