Example #1
0
 * limitations under the License.
 */
require_once 'vendor/autoload.php';
echo date("Y-m-d H:i:s") . " :: starting Janus entity aclDump\n";
try {
    $configFile = __DIR__ . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini";
    $config = \fkooman\Config\Config::fromIniFile($configFile);
    // data directory
    $exportDir = $config->s('output')->l('exportDir', true);
    // REQ
    $aclDir = $config->s('output')->l('aclDir', true);
    // REQ
    $timezone = $config->l('timezone', false, "Europe/Amsterdam");
    date_default_timezone_set($timezone);
    $inputFile = $exportDir . DIRECTORY_SEPARATOR . "export.json";
    $exportData = @file_get_contents($inputFile);
    if (false === $exportData) {
        throw new Exception(sprintf("unable to read JSON file '%s' from disk", $inputFile));
    }
    $entities = json_decode($exportData, true);
    $aclResolve = new SURFnet\janus\acl\Resolve($entities);
    $aclDump = array("saml20-idp" => $aclResolve->idpAclDump(true), "saml20-sp" => $aclResolve->spAclDump(true));
    $outputFile = $aclDir . DIRECTORY_SEPARATOR . "acl.json";
    if (false === @file_put_contents($outputFile, json_encode($aclDump))) {
        throw new Exception(sprintf("unable to write JSON file '%s' to disk", $outputFile));
    }
} catch (Exception $e) {
    echo sprintf("ERROR: %s", $e->getMessage());
    die(PHP_EOL);
}
echo date("Y-m-d H:i:s") . " :: entity aclDump done\n";