Introduction

The AccessManager component has been redeveloped to use the XACML standard for access control policies definitions and authorization requests and responses. The access control model is the same Role Based Access Control. The Access Manager server is an independent application that receives request via TCP network connections from clients and responds in the same way. It is implemented in Java using the Sun's XACML implementation. This version uses a LDAP database to store the users' roles and local XML files to store the access control policies.

Client API

In order to interrogate the Access Manager server, the clients can use the provided API. Currently, the API is available in C++ and Java implementations.

Java API

Following is an example of an request authorization to access a PMG specific resource for a start or terminate action using the Java API:

import am.client.ServerInterrogator;
import am.util.AMException;
import am.xacml.context.impl.PMGResource;

public class ServerInterrogatorTest {
	public static void main(String[] args){
		
		// instantiate a server interrogator object
		ServerInterrogator srv = new ServerInterrogator();
		
		try {
			// define the resource to request the access authorization for
			PMGResource respmg = new PMGResource("ANY:PROCESS");
			// set the action to be performed on the resource and that has to be authorized
			respmg.setStartAction();
			
			// get the authorization result and the reason of the decision
			System.out.println("PMG AUTHORIZATION REQUEST RESULT:" + srv.isAuthorizationGranted(respmg) + 
					" STATUS:" + srv.getStatusMessage());
		} catch (AMException e) {
			System.err.println(e.getMessage());
		}
	}
}			
The environment variables needed by the Java client API are:
	TDAQ_AM_AUTHORIZATION 		- enable or disabled the Access Manager authorization in C++ API. Valid values are 'on' and 'off'
	TDAQ_AM_SERVER_HOST   		- the hostname where Access Manager server is running
	TDAQ_AM_SERVER_PORT   		- the port number on which the Access Manager server is listening
	TDAQ_AM_LOGS_DIR      		- the log directory where the log files are written
	TDAQ_AM_CLIENT_LOG_LEVEL 	- the log level. Can be one of the following:
	        NONE            - no logs at all
	        NORMAL          - log the errors and warnings
	        VERBOSE         - log the information messages
	        VERY_VERBOSE    - log the configuration messages
	        DEBUG           - log the debug messages
	        ALL             - log all the messages		
		

C++ API

Following is an example of an request authorization to access a PMG specific resource for a start or terminate action using the C++ API:

#include <AccessManager/util/ErsIssues.h>
#include <AccessManager/xacml/impl/PMGResource.h>
#include <AccessManager/client/ServerInterrogator.h>

using namespace std;
	
int main() {
	
	daq::am::PMGResource pmgRes("process_binary_path", "hostname", "arg1 arg2");
	pmgRes.setStartAction();

		
	daq::am::ServerInterrogator si;
	
	bool allowed;
	try{
		allowed = si.isAuthorizationGranted(pmgRes);
		if (allowed){
			cout << "permission: ALLOWED" << endl;
		} else {
			cout << "permission: DENIED" << endl;
		}
		cout << "Status Message=" << si.getStatusMessage() << endl;
		
	} catch (daq::am::ServerInterrogationIssue& ex){
		ers::error(ex);
	} catch (...) {
		ERS_ERROR("Can not decode the response! "); 
		throw;
	}

	return 0;
}
The environment variables needed by the C++ client API are:
	TDAQ_AM_AUTHORIZATION 		- enable or disabled the Access Manager authorization in C++ API. Valid values are 'on' and 'off'
	TDAQ_AM_SERVER_HOST   		- the hostname where Access Manager server is running
	TDAQ_AM_SERVER_PORT   		- the port number on which the Access Manager server is listening
	TDAQ_ERS_DEBUG_LEVEL     	- the ERS debug level. Should be a positive number
		

Scripts

There are available a set of Access Manager scripts to start/stop the server, generate the policies, run some client tests using the Java and C++ API, and roles manipulations. Following are the help screens of each script showing the list of arguments to be passed to them.

amPAP

Run the AM's Policy Access Point to generate the policies into files.
Usage: amPAP [-d LDAP_host] [-b LDAP_basedn] [-P policies_path] [-L log_dir] [-l log_level] [-h]
  -d the LDAP server name
     Default is [atd-ldap.cern.ch]
  -b the LDAP base DN
     Default is [ou=tdaq,ou=atlas,o=cern,c=ch]
  -P the policies directory where the XACML policy files are stored
     Default is [/home-users/mleahu/am/installed/share/bin/../data/AccessManager/policies/]
  -L the log directory where the log files are written
     Default is [/home-users/mleahu/logs/]
  -l the log level. Can be one of the following:
        NONE            - no logs at all
        NORMAL          - log the errors and warnings
        VERBOSE         - log the information messages
        VERY_VERBOSE    - log the configuration messages
        DEBUG           - log the debug messages
        ALL             - log all the messages
     Default is [NORMAL]
  -h this info

amServer

Start or stops the Access Manager server.
Usage: amServer [-p port] [-d LDAP_host] [-b LDAP_basedn] [-P policies_path] [-L log_dir] [-l log_level] [-h] 
  -p the port number on which the server will listen for requests
     Default is [20000]
  -d the LDAP server name
     Default is [atd-ldap.cern.ch]
  -b the LDAP base DN
     Default is [ou=tdaq,ou=atlas,o=cern,c=ch]
  -P the policies directory where the XACML policy files are stored
     Default is [/home-users/mleahu/am/installed/share/bin/../data/AccessManager/policies/]
  -L the log directory where the log files are written
     Default is [/home-users/mleahu/logs/]
  -l the log level. Can be one of the following:
        NONE            - no logs at all
        NORMAL          - log the errors and warnings
        VERBOSE         - log the information messages
        VERY_VERBOSE    - log the configuration messages
        DEBUG           - log the debug messages
        ALL             - log all the messages
     Default is [NORMAL]
  -h this info

amServerInterrogatorCTest

Run the AM's Server Interrogator implementation using the C++ API.
Usage: amServerInterrogatorCTest [-a ] [-s server_host] [-p server_port] [-l log_level] [-h]
  -a enable or disabled the Access Manager authorization in C++ API. Valid values are 'on' and 'off'
     Default is [on]
  -s the hostname where Access Manager server is running
     Default is [pcatd11]
  -p the port number on which the Access Manager server is listening
     Default is [20000]
  -l the ERS debug level. Should be a positive number
     Default is [0]
  -h this info

amServerInterrogatorJTest

Run the AM's Server Interrogator implementation using the Java API and Junit testing framework.
Usage: amServerInterrogatorJTest [-a ] [-s server_host] [-p server_port] [-L log_dir] [-l log_level] [-h]
  -a enable or disabled the Access Manager authorization in Java API. Valid values are 'on' and 'off'
     Default is [on]
  -s the hostname where Access Manager server is running
     Default is [pcatd11]
  -p the port number on which the Access Manager server is listening
     Default is [20000]
  -L the log directory where the log files are written
     Default is [/home-users/mleahu/logs/]
  -l the log level. Can be one of the following:
        NONE            - no logs at all
        NORMAL          - log the errors and warnings
        VERBOSE         - log the information messages
        VERY_VERBOSE    - log the configuration messages
        DEBUG           - log the debug messages
        ALL             - log all the messages
     Default is [NORMAL]
  -h this info

Access Manager shell scripts

These scripts may require extra privileges to manipulate users roles so that only AM administrators are able to add and revoke roles.

amRoles
Access Manager shell interface for roles manipulation

Usage: amRoles [-a|-r|-e|-d roleid] [-s|-S ] [-u username] [-m userBindDN] [-M] [-p password] [-l ldapserver] [-b basedn] [-h] [-v]
  -a assign the  to the 
  -r revoke the  for the 
  -e enable the  for the 
  -d disable the  for the 
    DO NOT ADD/REMOVE/ENABLE/DISABLE ROLES IN THE SAME TIME!
  -s show the roles assigned to the user
  -S show the roles assigned and enabled to the user
  -u user name; default is the current user [mleahu]
  -m authenticate as  to the LDAP server; default is 
  -M authenticate as [cn=Manager] to the LDAP server
  -p password to bind to the LDAP server
  -l use this ldapserver;       default is [atd-ldap.cern.ch]
  -b use this basedn;           default is [ou=tdaq,ou=atlas,o=cern,c=ch]
  -v verbose mode
  -h this info
amAdminDumpRoles
Dump the roles from LDAP

Usage: amAdminDumpRoles  [-l ldapserver] [-b basedn] [-v] [-h]
  -l use this ldapserver;default is [atd-ldap.cern.ch]
  -b use this basedn;default is [ou=tdaq,ou=atlas,o=cern,c=ch]
  -v verbose mode
  -h this info
amAdminUpdateRoles
Update the roles assignment in LDAP using the 'amRoles' script.
IMPORTANT: The 'amRoles' should be in the path!.

Usage: amAdminUpdateRoles [-f inputfile] [-r]
  -f input file with 'username: role1 role2' on each line
  -r refresh the roles, i.e. revokes all the roles before new assignment
  -h this info