Get resource list from OpenAM

134 views Asked by At

We are using OpenAM (Forcibly 12) and its Policy Decision for ACL. How can we get list of resources (Uri+verb) though REST API or Client SDK? We have added some complementary REST using SDK, and we are able to add resource list as well.

1

There are 1 answers

0
Ritesh Roushan On BEST ANSWER

using following IP you can get complete data

Get    -  http://youurl/openam/xacml/policies
Header -  "iplanetDirectoryPro" = "Token value"

After that you need to filter "resources" with respect to "application".

function get_resources() {
    $resources = array();
    if(isset($_SESSION['OpenAmSession']['sso_token']) || !empty($_SESSION['OpenAmSession']['sso_token'])) {
        $curl = new Curl();
        $curl->setHeader('iPlanetDirectoryPro', $_SESSION['OpenAmSession']['sso_token']);
        $curl->setHeader('Content-Type', 'application/json');
        $curl->post(OPENAM_BASEURL.'/json/policies?_action=evaluate', array(
                            'resources' => array("your URL"),
                            'application' => 'Application Name',
        ));
        if ($curl->error) {
            //echo $curl->error_message;
        } else {
            if(isset($curl->response[0]->attributes->resources)) {
                $resources = $curl->response[0]->attributes->resources; 
            }
        }
    }
    return $resources;
}