本文整理汇总了PHP中EngineBlock_ApplicationSingleton::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP EngineBlock_ApplicationSingleton::getInstance方法的具体用法?PHP EngineBlock_ApplicationSingleton::getInstance怎么用?PHP EngineBlock_ApplicationSingleton::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EngineBlock_ApplicationSingleton
的用法示例。
在下文中一共展示了EngineBlock_ApplicationSingleton::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction($url)
{
$this->setNoRender();
// let shindig do the rendering
set_include_path(ENGINEBLOCK_FOLDER_SHINDIG . PATH_SEPARATOR . get_include_path());
include_once 'src/common/Config.php';
include_once 'src/common/File.php';
// You can't inject a Config, so force it to try loading
// and ignore errors from config file not being there :(
global $shindigConfig;
$shindigConfig = array();
@Config::setConfig(array('allow_plaintext_token' => true, 'person_service' => 'EngineBlock_Shindig_DataService', 'activity_service' => 'EngineBlock_Shindig_DataService', 'group_service' => 'EngineBlock_Shindig_DataService'));
spl_autoload_register(array(get_class($this), 'shindigAutoLoad'));
// Shindig expects urls to be moiunted on /social/rest so we enforce that.
$_SERVER['REQUEST_URI'] = '/social/rest/' . $url;
// We only support JSON
$_SERVER['CONTENT_TYPE'] = 'application/json';
// Shindig wants a security token, but interface F in coin is auth-less so we fake one.
$_REQUEST["st"] = $_GET["st"] = $_POST["st"] = "o:v:a:d:u:m:c";
$requestMethod = EngineBlock_ApplicationSingleton::getInstance()->getHttpRequest()->getMethod();
$methodName = 'do' . ucfirst(strtolower($requestMethod));
$servletInstance = new DataServiceServlet();
if (is_callable(array($servletInstance, $methodName))) {
$servletInstance->{$methodName}();
} else {
echo "Invalid method";
// @todo Error out
}
}
示例2: serve
/**
* Handle the forwarding of the user to the proper IdP0 after the WAYF screen.
*
* @param string $serviceName
* @throws EngineBlock_Corto_Module_Services_Exception
* @throws EngineBlock_Exception
* @throws EngineBlock_Corto_Module_Services_SessionLostException
*/
public function serve($serviceName)
{
$selectedIdp = urldecode($_REQUEST['idp']);
if (!$selectedIdp) {
throw new EngineBlock_Corto_Module_Services_Exception('No IdP selected after WAYF');
}
// Retrieve the request from the session.
$id = $_POST['ID'];
if (!$id) {
throw new EngineBlock_Exception('Missing ID for AuthnRequest after WAYF', EngineBlock_Exception::CODE_NOTICE);
}
$authnRequestRepository = new EngineBlock_Saml2_AuthnRequestSessionRepository($this->_server->getSessionLog());
$request = $authnRequestRepository->findRequestById($id);
if (!$request) {
throw new EngineBlock_Corto_Module_Services_SessionLostException('Session lost after WAYF');
}
// Flush log if SP or IdP has additional logging enabled
$sp = $this->_server->getRepository()->fetchServiceProviderByEntityId($request->getIssuer());
$idp = $this->_server->getRepository()->fetchIdentityProviderByEntityId($selectedIdp);
if (EngineBlock_SamlHelper::doRemoteEntitiesRequireAdditionalLogging(array($sp, $idp))) {
$application = EngineBlock_ApplicationSingleton::getInstance();
$application->flushLog('Activated additional logging for the SP or IdP');
$log = $application->getLogInstance();
$log->info('Raw HTTP request', array('http_request' => (string) $application->getHttpRequest()));
}
$this->_server->sendAuthenticationRequest($request, $selectedIdp);
}
示例3: metadataAction
public function metadataAction()
{
$this->setNoRender();
$request = EngineBlock_ApplicationSingleton::getInstance()->getHttpRequest();
$entityId = $request->getQueryParameter("entityid");
$gadgetUrl = $request->getQueryParameter('gadgeturl');
// If we were only handed a gadget url, no entity id, lookup the Service Provider entity id
if ($gadgetUrl && !$entityId) {
$identifiers = $this->_getRegistry()->findIdentifiersByMetadata('coin:gadgetbaseurl', $gadgetUrl);
if (count($identifiers) > 1) {
EngineBlock_ApplicationSingleton::getLog()->warn("Multiple identifiers found for gadgetbaseurl: '{$gadgetUrl}'");
throw new EngineBlock_Exception('Multiple identifiers found for gadgetbaseurl');
}
if (count($identifiers) === 0) {
EngineBlock_ApplicationSingleton::getInstance()->getLog()->warn("No Entity Id found for gadgetbaseurl '{$gadgetUrl}'");
$this->_getResponse()->setHeader('Content-Type', 'application/json');
$this->_getResponse()->setBody(json_encode(new stdClass()));
return;
}
$entityId = $identifiers[0];
}
if (!$entityId) {
throw new EngineBlock_Exception('No entity id provided to get metadata for?!');
}
if (isset($_REQUEST["keys"])) {
$result = $this->_getRegistry()->getMetaDataForKeys($entityId, explode(",", $_REQUEST["keys"]));
} else {
$result = $this->_getRegistry()->getMetadata($entityId);
}
$result['entityId'] = $entityId;
$this->_getResponse()->setHeader('Content-Type', 'application/json');
$this->_getResponse()->setBody(json_encode($result));
}
示例4: validate
/**
* Validate the license information
*
* @param string $userId
* @param array $spMetadata
* @param array $idpMetadata
* @return string
*/
public function validate($userId, array $spMetadata, array $idpMetadata)
{
if (!$this->_active) {
return EngineBlock_LicenseEngine_ValidationManager::LICENSE_UNKNOWN;
}
$client = new Zend_Http_Client($this->_url);
$client->setConfig(array('timeout' => 15));
try {
$client->setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/json; charset=utf-8')->setParameterGet('userId', urlencode($userId))->setParameterGet('serviceProviderEntityId', urlencode($spMetadata['EntityId']))->setParameterGet('identityProviderEntityId', urlencode($idpMetadata['EntityId']))->request('GET');
$body = $client->getLastResponse()->getBody();
$response = json_decode($body, true);
$status = $response['status'];
} catch (Exception $exception) {
$additionalInfo = new EngineBlock_Log_Message_AdditionalInfo($userId, $idpMetadata['EntityId'], $spMetadata['EntityId'], $exception->getTraceAsString());
EngineBlock_ApplicationSingleton::getLog()->error("Could not connect to License Manager" . $exception->getMessage(), $additionalInfo);
return EngineBlock_LicenseEngine_ValidationManager::LICENSE_UNKNOWN;
}
if ($status['returnUrl']) {
$currentResponse = EngineBlock_ApplicationSingleton::getInstance()->getHttpResponse();
$currentResponse->setRedirectUrl($status['returnUrl']);
$currentResponse->send();
exit;
} else {
if ($status['licenseStatus']) {
return $status['licenseStatus'];
} else {
return EngineBlock_LicenseEngine_ValidationManager::LICENSE_UNKNOWN;
}
}
}
示例5: _getAccessToken
protected function _getAccessToken($conf, $subjectId, $requireNew)
{
$cache = EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getApplicationCache();
if (!$requireNew && $cache instanceof Zend_Cache_Backend_Apc) {
$accessToken = $cache->load(self::ACCESS_TOKEN_KEY);
if ($accessToken) {
return $accessToken;
}
}
// for example https://api.dev.surfconext.nl/v1/oauth2/token
$baseUrl = $this->_ensureTrailingSlash($conf->baseUrl) . 'v1/oauth2/token';
$client = new Zend_Http_Client($baseUrl);
try {
$response = $client->setConfig(array('timeout' => 15))->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED)->setAuth($conf->key, $conf->secret)->setParameterPost('grant_type', 'client_credentials')->request(Zend_Http_Client::POST);
$result = json_decode($response->getBody(), true);
if (isset($result['access_token'])) {
$accessToken = $result['access_token'];
if ($cache instanceof Zend_Cache_Backend_Apc) {
$cache->save($accessToken, self::ACCESS_TOKEN_KEY);
}
return $accessToken;
}
throw new EngineBlock_VirtualOrganization_AccessTokenNotGrantedException('AccessToken not granted for EB as SP. Check SR and the Group Provider endpoint log.');
} catch (Exception $exception) {
$additionalInfo = EngineBlock_Log_Message_AdditionalInfo::create()->setUserId($subjectId)->setDetails($exception->getTraceAsString());
EngineBlock_ApplicationSingleton::getLog()->error("Error in connecting to API(s) for access token grant" . $exception->getMessage(), array('additional_info' => $additionalInfo->toArray()));
throw new EngineBlock_VirtualOrganization_AccessTokenNotGrantedException('AccessToken not granted for EB as SP. Check SR and the Group Provider endpoint log', EngineBlock_Exception::CODE_ALERT, $exception);
}
}
示例6: tearDown
public function tearDown()
{
if (!$this->_originalConfig) {
return true;
}
EngineBlock_ApplicationSingleton::getInstance()->setConfiguration($this->_originalConfig);
}
示例7: setup
public function setup()
{
$this->proxyServerMock = $this->mockProxyServer();
$diContainer = EngineBlock_ApplicationSingleton::getInstance()->getDiContainer();
$this->xmlConverterMock = $this->mockXmlConverter($diContainer[EngineBlock_Application_DiContainer::XML_CONVERTER]);
$this->consentFactoryMock = $diContainer[EngineBlock_Application_DiContainer::CONSENT_FACTORY];
$this->consentMock = $this->mockConsent();
}
示例8: _setIsMember
protected function _setIsMember()
{
if (!isset($this->_responseAttributes[static::URN_IS_MEMBER_OF])) {
$this->_responseAttributes[static::URN_IS_MEMBER_OF] = array();
}
$configuration = EngineBlock_ApplicationSingleton::getInstance()->getConfiguration();
$this->_responseAttributes[static::URN_IS_MEMBER_OF][] = $configuration->addgueststatus->guestqualifier;
}
示例9: displayAction
public function displayAction($exception)
{
$this->_getResponse()->setStatus(500, 'Internal Server Error');
$application = EngineBlock_ApplicationSingleton::getInstance();
if ($application->getConfigurationValue('debug', false)) {
$this->exception = $exception;
}
}
示例10: _getUserDirectory
protected function _getUserDirectory()
{
if ($this->_userDirectory == NULL) {
$ldapConfig = EngineBlock_ApplicationSingleton::getInstance()->getConfiguration()->ldap;
$this->_userDirectory = new EngineBlock_UserDirectory($ldapConfig);
}
return $this->_userDirectory;
}
示例11: execute
public function execute()
{
$metadataRepository = EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getMetadataRepository();
$allowedIdpEntityIds = $metadataRepository->findAllowedIdpEntityIdsForSp($this->_serviceProvider);
if (!in_array($this->_identityProvider->entityId, $allowedIdpEntityIds)) {
throw new EngineBlock_Corto_Exception_InvalidConnection("Disallowed response by SP configuration. " . "Response from IdP '{$this->_identityProvider->entityId}' to SP '{$this->_serviceProvider->entityId}'");
}
}
示例12: indexAction
public function indexAction()
{
$this->previewOnly = $this->_getRequest()->getQueryParameter('preview') ? true : false;
$deprovisionEngine = new EngineBlock_Deprovisioning();
$this->deprovisionPreview = $deprovisionEngine->deprovision($this->previewOnly);
$this->deprovisionConfig = EngineBlock_ApplicationSingleton::getInstance()->getConfiguration()->cron->deprovision;
$this->_redirectToController("Index");
}
示例13: displayAction
public function displayAction($exception)
{
header('HTTP/1.1 500 Internal Server Error', true, 500);
$application = EngineBlock_ApplicationSingleton::getInstance();
if ($application->getConfigurationValue('debug', false)) {
$this->exception = $exception;
}
}
示例14: testItAddsANonEmptyStringToTheRecord
public function testItAddsANonEmptyStringToTheRecord()
{
// Assert the log ID is bootstrapped.
$logId = EngineBlock_ApplicationSingleton::getInstance()->getLogRequestId();
$this->assertInternalType('string', $logId);
$this->assertNotEmpty($logId);
$processor = new EngineBlock_Log_Monolog_Processor_RequestIdProcessor();
$record = $processor(array('extra' => array()));
$this->assertEquals($logId, $record['extra']['request_id'], 'Appended log request ID and bootstrapped log request ID do not match');
}
示例15: execute
public function execute()
{
if (!$this->_collabPersonId) {
throw new EngineBlock_Corto_Filter_Command_Exception_PreconditionFailed('Missing collabPersonId');
}
$config = EngineBlock_ApplicationSingleton::getInstance()->getConfiguration();
$licenseEngine = new EngineBlock_LicenseEngine_ValidationManager($config);
$licenseCode = $licenseEngine->validate($this->_collabPersonId, $this->_spMetadata, $this->_idpMetadata);
$this->_responseAttributes[EngineBlock_LicenseEngine_ValidationManager::LICENSE_SAML_ATTRIBUTE] = array($licenseCode);
}