/**
  * @return array
  */
 public function getAllActiveExtensions()
 {
     $extensions = ServerExtension::where('active', '=', true)->get();
     $res = array();
     foreach ($extensions as $extension) {
         $class_name = $extension->extension_class;
         if (empty($class_name)) {
             continue;
         }
         $class = new ReflectionClass($class_name);
         $constructor = $class->getConstructor();
         $constructor_params = $constructor->getParameters();
         $deps = array();
         foreach ($constructor_params as $constructor_param) {
             $param_class = $constructor_param->getClass();
             $name = $constructor_param->getName();
             if (is_null($param_class)) {
                 array_push($deps, $extension->{$name});
             } else {
                 $service = ServiceLocator::getInstance()->getService($param_class->getName());
                 array_push($deps, $service);
             }
         }
         $implementation = $class->newInstanceArgs($deps);
         array_push($res, $implementation);
     }
     return $res;
 }
 /**
  * @param OpenIdMessage $message
  * @return null|SessionAssociationDHStrategy|SessionAssociationUnencryptedStrategy
  */
 public static function buildSessionAssociationStrategy(OpenIdMessage $message)
 {
     $association_service = ServiceLocator::getInstance()->getService(OpenIdServiceCatalog::AssociationService);
     $configuration_service = ServiceLocator::getInstance()->getService(UtilsServiceCatalog::ServerConfigurationService);
     $log_service = ServiceLocator::getInstance()->getService(UtilsServiceCatalog::LogService);
     if (OpenIdDHAssociationSessionRequest::IsOpenIdDHAssociationSessionRequest($message)) {
         return new SessionAssociationDHStrategy(new OpenIdDHAssociationSessionRequest($message), $association_service, $configuration_service, $log_service);
     }
     if (OpenIdAssociationSessionRequest::IsOpenIdAssociationSessionRequest($message)) {
         return new SessionAssociationUnencryptedStrategy(new OpenIdAssociationSessionRequest($message), $association_service, $configuration_service, $log_service);
     }
     return null;
 }
 /**
  * @param OpenIdResponse $response
  * @return IHttpResponseStrategy
  * @throws \Exception
  */
 public static function buildStrategy(OpenIdResponse $response)
 {
     $type = $response->getType();
     switch ($type) {
         case OpenIdIndirectResponse::OpenIdIndirectResponse:
             return ServiceLocator::getInstance()->getService(OpenIdIndirectResponse::OpenIdIndirectResponse);
             break;
         case OpenIdDirectResponse::OpenIdDirectResponse:
             return ServiceLocator::getInstance()->getService(OpenIdDirectResponse::OpenIdDirectResponse);
             break;
         default:
             throw new \Exception("Invalid OpenId response Type");
             break;
     }
 }
示例#4
0
        $authentication_service = ServiceLocator::getInstance()->getService(UtilsServiceCatalog::AuthenticationService);
        $client_service = ServiceLocator::getInstance()->getService(OAuth2ServiceCatalog::ClientService);
        $client_id = $route->getParameter('id');
        $client = $client_service->getClientByIdentifier($client_id);
        $user = $authentication_service->getCurrentUser();
        if (is_null($client) || intval($client->getUserId()) !== intval($user->getId())) {
            throw new Exception('invalid client id for current user');
        }
    } catch (Exception $ex) {
        Log::error($ex);
        return Response::json(array('error' => 'operation not allowed.'), 400);
    }
});
Route::filter('is.current.user', function ($route, $request) {
    try {
        $authentication_service = ServiceLocator::getInstance()->getService(UtilsServiceCatalog::AuthenticationService);
        $used_id = Input::get('user_id', null);
        if (is_null($used_id)) {
            $used_id = Input::get('id', null);
        }
        if (is_null($used_id)) {
            $used_id = $route->getParameter('user_id');
        }
        if (is_null($used_id)) {
            $used_id = $route->getParameter('id');
        }
        $user = $authentication_service->getCurrentUser();
        if (is_null($used_id) || intval($used_id) !== intval($user->getId())) {
            throw new Exception(sprintf('user id %s does not match with current user id %s', $used_id, $user->getId()));
        }
    } catch (Exception $ex) {
示例#5
0
    }
});
App::error(function (InvalidOpenIdMessageException $exception, $code) {
    Log::error($exception);
    if (!App::runningInConsole()) {
        $checkpoint_service = ServiceLocator::getInstance()->getService(UtilsServiceCatalog::CheckPointService);
        if ($checkpoint_service) {
            $checkpoint_service->trackException($exception);
        }
        return View::make('404');
    }
});
App::error(function (InvalidOAuth2Request $exception, $code) {
    Log::error($exception);
    if (!App::runningInConsole()) {
        $checkpoint_service = ServiceLocator::getInstance()->getService(UtilsServiceCatalog::CheckPointService);
        if ($checkpoint_service) {
            $checkpoint_service->trackException($exception);
        }
        return View::make('404');
    }
});
/*
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
| The "down" Artisan command gives you the ability to put an application
| into maintenance mode. Here, you will define what is displayed back
| to the user if maintenace mode is in effect for this application.
|