protected function exec($path)
 {
     $json = file_get_contents($path);
     $this->json_input = json_decode($json, true);
     $auth = isset($this->json_input['authority']) ? $this->json_input['authority'] : ['name' => "John Smith", 'mbox' => "mailto:test@learninglocker.co.uk", 'objectType' => "Agent"];
     $manager = new xAPIValidation();
     return $manager->runValidation($this->json_input, $auth);
 }
Ejemplo n.º 2
0
 protected function validateValue($name, $value, $type)
 {
     $validator = new XApiValidator();
     $validator->checkTypes($name, $value, $type, 'params');
     if ($validator->getStatus() !== 'passed') {
         throw new Exceptions\Exception(implode(',', $validator->getErrors()));
     }
 }
Ejemplo n.º 3
0
        return Redirect::guest('/');
    }
});
/*
|--------------------------------------------------------------------------
| Submit statement via basic http authentication
|--------------------------------------------------------------------------
|
| Login in once using key / secret to store statements or retrieve statements.
|
*/
Route::filter('auth.statement', function ($route, $request) {
    $method = Request::server('REQUEST_METHOD');
    if ($method !== "OPTIONS") {
        // Validates authorization header.
        $auth_validator = new XApiValidator();
        $authorization = LockerRequest::header('Authorization');
        if ($authorization !== null && strpos($authorization, 'Basic') === 0) {
            $authorization = gettype($authorization) === 'string' ? substr($authorization, 6) : false;
            $auth_validator->checkTypes('auth', $authorization, 'base64', 'headers');
            if ($auth_validator->getStatus() === 'failed') {
                throw new Exceptions\Validation($auth_validator->getErrors());
            }
        } else {
            if ($authorization !== null && strpos($authorization, 'Bearer') === 0) {
                $bridgedRequest = OAuth2\HttpFoundationBridge\Request::createFromRequest(Request::instance());
                $bridgedResponse = new OAuth2\HttpFoundationBridge\Response();
                if (!App::make('oauth2')->verifyResourceRequest($bridgedRequest, $bridgedResponse)) {
                    throw new Exceptions\Exception('Unauthorized request.', $bridgedResponse->getStatusCode());
                }
            } else {