Skip to content
This repository was archived by the owner on Jul 11, 2018. It is now read-only.

AM Check entitlement

Remold edited this page Jul 31, 2015 · 1 revision
<?php
 
// Enter the entitlement value that needs to be checked
$entitlementRequired = 'urn:surf.nl:everett.nl:entitlement:allowed';
 
// Check if the entitlement is present
$entitlementFound = false;
if (isset($attributes) and ($attributes !== FALSE)) {
    if (!empty($attributes['urn:mace:dir:attribute-def:eduPersonEntitlement'])) {
        foreach ($attributes['urn:mace:dir:attribute-def:eduPersonEntitlement'] as $entitlementValue) {
 
            if ($entitlementValue === $entitlementRequired) {
                $entitlementFound = true;
            }
        }
    }
}
// When the entitlement is not found, generate a OpenConext error
// The Title and Description of the error can be modified and should be entered in English (en) and Dutch (nl)
// It is not possible to use HTML code, so for example it is not possibility to use a link
if (!$entitlementFound) {
    $amFout = new EngineBlock_Attributes_Manipulator_CustomException("AM_ERROR Entitlement not found", EngineBlock_Attributes_Manipulator_CustomException::CODE_NOTICE);
    $amFout->setFeedbackTitle(array("nl" => "Niet toegestaan", "en" => "Not Allowed"));
    $amFout->setFeedbackDescription(array("en" => "You are not allowed to use this service due to a missing entitlement.",
                                           "nl" => "Toegang tot deze dienst is niet toegestaan vanwege een ontbrekende entitlement."));
    throw $amFout;
}
Clone this wiki locally