本文整理汇总了PHP中Authenticator::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP Authenticator::authenticate方法的具体用法?PHP Authenticator::authenticate怎么用?PHP Authenticator::authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authenticator
的用法示例。
在下文中一共展示了Authenticator::authenticate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test11RetrieveConceptFiletrStatus
public function test11RetrieveConceptFiletrStatus()
{
// Use API to search for concept and filter on status
// todo: test additionele zoek parameters
print "\n" . "Test: get concept via filters";
$client = Authenticator::authenticate();
//prepare and send request
$uri = BASE_URI_ . '/public/api/find-concepts?q=prefLabel:' . CONCEPT_prefLabel . '&status:' . CONCEPT_status_forfilter . '&tenant:' . TENANT . '&inScheme:' . CONCEPT_schema_forfilter;
print "\n fileterd request's uri: " . $uri;
$client->setUri($uri);
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$client->SetHeaders(array('Accept' => 'text/html,application/xhtml+xml,application/xml', 'Content-Type' => 'application/xml', 'Accept-Language' => 'nl,en-US,en', 'Accept-Encoding' => 'gzip, deflate', 'Connection' => 'keep-alive'));
$response = $client->request(Zend_Http_Client::GET);
// analyse respond
if ($response->getStatus() != 200) {
print "\n " . $response->getMessage();
}
print "\n Response Headers: ";
var_dump($response->getHeaders());
$this->AssertEquals(200, $response->getStatus());
$namespaces = array("rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "skos" => "http://www.w3.org/2004/02/skos/core#", "openskos" => "http://openskos.org/xmlns/openskos.xsd");
print "\n\n\n Response Body: ";
var_dump($response->getBody());
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$dom->registerXpathNamespaces($namespaces);
$elem = $dom->queryXpath('/rdf:RDF');
$this->assertEquals($elem->current()->nodeType, XML_ELEMENT_NODE, 'The root node of the response is not an element');
$resDescr = $dom->queryXpath('/rdf:RDF/rdf:Description');
$resStatus = $dom->queryXpath('/rdf:RDF/rdf:Description/openskos:status');
$this->assertEquals(1, $resDescr->count());
$this->assertEquals($resDescr->count(), $resStatus->count(), "Not all result concepts have status field. ");
}
示例2: test11RetrieveConceptFiletrStatus
public function test11RetrieveConceptFiletrStatus()
{
// Use API to search for concept and filter on status
// todo: test additionele zoek parameters
print "\n" . "Test: get concept via filters";
$client = Authenticator::authenticate();
//prepare and send request
$uri = BASE_URI_ . '/public/api/find-concepts?q=prefLabel:' . CONCEPT_prefLabel . '&status:' . CONCEPT_status_forfilter . '&tenant:' . TENANT . '&inScheme:' . CONCEPT_schema_forfilter;
print "\n filtered request's uri: " . $uri . "\n";
$client->setUri($uri);
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$client->SetHeaders(array('Accept' => 'text/html,application/xhtml+xml,application/xml', 'Content-Type' => 'application/xml', 'Accept-Language' => 'nl,en-US,en', 'Accept-Encoding' => 'gzip, deflate', 'Connection' => 'keep-alive'));
$response = $client->request(Zend_Http_Client::GET);
// analyse respond
print "\n get status: " . $response->getMessage() . "\n";
$this->AssertEquals(200, $response->getStatus());
$namespaces = array("rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "skos" => "http://www.w3.org/2004/02/skos/core#", "openskos" => "http://openskos.org/xmlns/openskos.xsd");
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$dom->registerXpathNamespaces($namespaces);
$elem = $dom->queryXpath('/rdf:RDF');
$this->assertEquals(XML_ELEMENT_NODE, $elem->current()->nodeType, 'The root node of the response is not an element');
$this->assertEquals(1, $elem->current()->getAttribute("openskos:numFound"));
$resDescr = $dom->queryXpath('/rdf:RDF/rdf:Description');
$i = 0;
$l = $resDescr->count();
$resDescr->rewind();
while ($i < $l) {
$labels = $resDescr->current()->getElementsByTagName("altLabel");
//print "\n val:" . $labels ->item(0) ->textContent;
$randomn = rand(0, 4096);
$labels->item(0)->nodeValue = "test-1-" . $randomn;
$doc = $resDescr->current()->ownerDocument;
$xml = $doc->saveXML();
var_dump($xml);
// try $newdom isntead of $dom, which can be corrupted
//$dom = new DOMDocument('1.0', 'utf-8');
//$rdf = $dom -> createElement("rdf:RDF");
//$dom ->importNode($newDescr, TRUE);// appendChild($rdf);
//$rdf ->appendChild($newDescr);
//$xml = $dom->saveXML();
//var_dump($xml);
$client->setUri(BASE_URI_ . "/public/api/concept?");
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$response = $client->setEncType('text/xml')->setRawData($xml)->setParameterGet('tenant', TENANT)->setParameterGet('collection', COLLECTION_1_code)->setParameterGet('key', API_KEY)->request(Zend_Http_Client::PUT);
print "\n Update response message: " . $response->getMessage();
$this->AssertEquals(200, $response->getStatus(), 'Update request returned worng status code');
$resDescr->next();
$i++;
}
}
示例3: setUpBeforeClass
public static function setUpBeforeClass()
{
self::$client = Authenticator::authenticate();
// create a test concept
$randomn = rand(0, 2048);
self::$prefLabel = 'testPrefLable_' . $randomn;
self::$altLabel = 'testAltLable_' . $randomn;
self::$hiddenLabel = 'testHiddenLable_' . $randomn;
self::$notation = 'test-xxx-' . $randomn;
self::$uuid = uniqid();
self::$about = BASE_URI_ . CONCEPT_collection . "/" . self::$notation;
$xml = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:openskos="http://openskos.org/xmlns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmi="http://dublincore.org/documents/dcmi-terms/#">' . '<rdf:Description rdf:about="' . self::$about . '">' . '<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>' . '<skos:prefLabel xml:lang="nl">' . self::$prefLabel . '</skos:prefLabel>' . '<skos:altLabel xml:lang="nl">' . self::$altLabel . '</skos:altLabel>' . '<skos:hiddenLabel xml:lang="nl">' . self::$hiddenLabel . '</skos:hiddenLabel>' . '<openskos:set rdf:resource="' . BASE_URI_ . CONCEPT_collection . '"/>' . '<openskos:uuid>' . self::$uuid . '</openskos:uuid>' . '<skos:notation>' . self::$notation . '</skos:notation>' . '<skos:inScheme rdf:resource="http://data.beeldengeluid.nl/gtaa/Onderwerpen"/>' . '<skos:topConceptOf rdf:resource="http://data.beeldengeluid.nl/gtaa/Onderwerpen"/>' . '<skos:definition xml:lang="nl">testje (voor def ingevoegd)</skos:definition>' . '</rdf:Description>' . '</rdf:RDF>';
self::$response0 = RequestResponse::CreateConceptRequest(self::$client, $xml, "false");
//var_dump(self::$response0->getBody());
print "\n Creation status: " . self::$response0->getStatus() . "\n";
}
示例4: testCollectionsRDFXML
public function testCollectionsRDFXML()
{
print "\n" . "Test: get collection. ";
$client = Authenticator::authenticate();
//prepare and send request
$client->setUri(BASE_URI_ . '/public/api/collections/' . COLLECTION_1_tenant . ":" . COLLECTION_1_code . '.rdf');
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$client->SetHeaders(array('Accept' => 'text/html,application/xhtml+xml,application/xml', 'Content-Type' => 'text/xml', 'Accept-Language' => 'nl,en-US,en', 'Accept-Encoding' => 'gzip, deflate', 'Connection' => 'keep-alive'));
$response = $client->request(Zend_Http_Client::GET);
// analyse respond
if ($response->getStatus() != 200) {
print "\n " . $response->getMessage();
}
$this->AssertEquals(200, $response->getStatus());
$this->assertionsForXMLRDFCollection($response);
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
self::$client = Authenticator::authenticate();
// create a test concept
$randomn = rand(0, 2048);
self::$prefLabel = 'testImportPrefLable_' . $randomn;
self::$notation = 'test-import-' . $randomn;
print "\n " . self::$notation . "\n";
self::$uuid = uniqid();
self::$about = BASE_URI_ . CONCEPT_collection . "/" . self::$notation;
self::$creator = CREATOR;
$xml = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:openskos="http://openskos.org/xmlns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:ns0="http://dublincore.org/documents/dcmi-terms/#">' . '<rdf:Description rdf:about="' . self::$about . '">' . '<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>' . '<skos:notation>' . self::$notation . '</skos:notation>' . '<skos:inScheme rdf:resource="http://hdl.handle.net/11148/CCR_P-DialogueActs_1bb8b49f-7260-6731-6479-408c29cead73"/>' . '<skos:inScheme rdf:resource="http://hdl.handle.net/11148/CCR_P-LexicalSemantics_0d519a3c-85a6-ea17-d93c-8b89339ffc88"/>' . '<skos:inScheme rdf:resource="http://hdl.handle.net/11148/CCR_P-Metadata_deedbe7e-9a1d-4388-2857-ad0daaf06793"/>' . '<skos:inScheme rdf:resource="http://hdl.handle.net/11148/CCR_P-Morphosyntax_c99c78ee-1425-c8f3-33e3-fe2a4b2ec7ca"/>' . '<skos:inScheme rdf:resource="http://hdl.handle.net/11148/CCR_P-SemanticContentRepresentation_37ab80c4-cf9f-18dd-c319-e6554b1d9462"/>' . '<skos:inScheme rdf:resource="http://hdl.handle.net/11148/CCR_P-Syntax_ba63dab1-103c-f8ee-81c3-f32a101e5c96"/>' . '<skos:inScheme rdf:resource="http://hdl.handle.net/11148/CCR_P-Terminology_bf8fdd3f-0075-bca2-ae35-1070be98f856"/>' . '<skos:inScheme rdf:resource="http://hdl.handle.net/11148/CCR_P-Translation_d8214c27-7c8f-9d05-e6ca-ea8fdc922a1c"/>' . '<skos:topConceptOf rdf:resource="http://hdl.handle.net/11148/CCR_P-Metadata_deedbe7e-9a1d-4388-2857-ad0daaf06793"/>' . '<skos:topConceptOf rdf:resource="http://hdl.handle.net/11148/CCR_P-Terminology_bf8fdd3f-0075-bca2-ae35-1070be98f856"/>' . '<skos:topConceptOf rdf:resource="http://hdl.handle.net/11148/CCR_P-Morphosyntax_c99c78ee-1425-c8f3-33e3-fe2a4b2ec7ca"/>' . '<skos:topConceptOf rdf:resource="http://hdl.handle.net/11148/CCR_P-SemanticContentRepresentation_37ab80c4-cf9f-18dd-c319-e6554b1d9462"/>' . '<skos:topConceptOf rdf:resource="http://hdl.handle.net/11148/CCR_P-Syntax_ba63dab1-103c-f8ee-81c3-f32a101e5c96"/>' . '<skos:topConceptOf rdf:resource="http://hdl.handle.net/11148/CCR_P-LexicalSemantics_0d519a3c-85a6-ea17-d93c-8b89339ffc88"/>' . '<skos:topConceptOf rdf:resource="http://hdl.handle.net/11148/CCR_P-DialogueActs_1bb8b49f-7260-6731-6479-408c29cead73"/>' . '<skos:topConceptOf rdf:resource="http://hdl.handle.net/11148/CCR_P-Translation_d8214c27-7c8f-9d05-e6ca-ea8fdc922a1c"/>' . '<skos:prefLabel xml:lang="nl">' . self::$prefLabel . '</skos:prefLabel>' . '<openskos:uuid>' . self::$uuid . '</openskos:uuid>' . '<skos:scopeNote xml:lang="nl">A text corpus may be limited according to aspects of subject fields, size or time, e.g. mathematical texts, certain periodicals from 1986 onwards. It is used as source material for further linguistic analysis or terminology work. (source: ISO 1087-2, 2.7)</skos:scopeNote>' . '<skos:definition xml:lang="nl">A systematic collection of machine-readable texts or parts of text prepared, coded and stored according to predefined rules. (source: ISO 1087-2, 2.7)</skos:definition>' . '</rdf:Description>' . '</rdf:RDF>';
self::$boundaryNumeric = '36374246216810994721943965972';
$part1 = 'Content-Disposition: form-data; name="MAX_FILE_SIZE"
10485760';
$part2 = 'Content-Disposition: form-data; name="xml"; filename="tttt.xml"
Content-Type: text/xml
' . $xml;
$part3 = 'Content-Disposition: form-data; name="status"
candidate';
$part4 = 'Content-Disposition: form-data; name="ignoreIncomingStatus"
0';
$part5 = 'Content-Disposition: form-data; name="lang"
en';
$part6 = 'Content-Disposition: form-data; name="toBeChecked"
0';
$part7 = 'Content-Disposition: form-data; name="purge"
0';
$part8 = 'Content-Disposition: form-data; name="onlyNewConcepts"
0';
$part9 = 'Content-Disposition: form-data; name="submit"
Submit';
$boundary = "--" . self::$boundaryNumeric;
$boundaryLn = $boundary . "\n";
$lnBoundaryLn = "\n" . $boundaryLn;
self::$postData = $boundaryLn . $part1 . $lnBoundaryLn . $part2 . $lnBoundaryLn . $part3 . $lnBoundaryLn . $part4 . $lnBoundaryLn . $part5 . $lnBoundaryLn . $part6 . $lnBoundaryLn . $part7 . $lnBoundaryLn . $part8 . $lnBoundaryLn . $part9 . "\n" . $boundary . "--";
}
示例6: testAuthenticate
public function testAuthenticate()
{
// Construct
$a = new Authenticator(self::TEST_SECRET);
$date = new \DateTime();
$random = self::TEST_RANDOM;
$hash = $a->createAuthentication($random, $date);
// Test
$this->assertTrue($a->authenticate($date, $random, $hash));
}
示例7: login
public function login(array $data, Form $form)
{
Authenticator::authenticate($data, $this);
// Do something with $data
//LoginForm::
}
示例8: testExport
public function testExport()
{
$clientI = Authenticator::authenticate();
//importing
$responseImport = $this->importFromRawData($clientI, 'default');
print "\n Preparing test, step 1: make import job response: " . $responseImport->getStatus();
$sendjob = exec(PHP_JOBS_PROCESS);
print "\n Preparing test, step 2: sent import job. \n";
print "\n" . "Testing export ... ";
$client = Authenticator::authenticate();
$conceptIdJson = $this->retrieveConceptIdFromNotation($client, $this->notationg, 'application/json');
$conceptId = json_decode($conceptIdJson);
$docs = $conceptId->response->docs;
$uuid = $docs[0]->uuid;
print "\n Fresh concept id: ";
var_dump($uuid);
print "\n ";
// exporting test concept
$fileName = 'export_' . $uuid;
print "\n If the data are big, they should be written to " . $fileName;
print "\n Otherwise they are exported as stream in the response's body. \n";
$response = $this->exportConcept($client, $uuid, $fileName);
print "\n Export response status: " . $response->GetStatus();
print "\n Export response message: " . $response->GetMessage();
// retrieving the data from the exported file
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->GetBody());
// comparing test xml with the data from the xml from the file
// Asserting
// Assert - 1
$results1 = $dom->query('skos:notation');
$this->AssertEquals(1, count($results1));
$this->AssertEquals($this->notationg, $results1->current()->nodeValue);
// Assert - 2
$results2 = $dom->query('skos:inScheme');
$this->AssertEquals(8, count($results2));
$i = 0;
foreach ($results2 as $result) {
$i++;
$this->assertStringStartsWith(HANDLE_CCR_PREFIX, $result->getAttribute('rdf:resource'), "The {$i}-th attribute does not start with " . HANDLE_CCR_PREFIX);
}
}
示例9: Authenticator
<?php
$auth = new Authenticator();
$res = $auth->authenticate($_POST);
if ($res['auth']) {
Session::instance()->login($_POST['username']);
LittleDropsOfCode::instance()->setPage('home');
} else {
LittleDropsOfCode::instance()->setPage('login');
}
示例10: Authenticator
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
require_once '../scriptsPHP/DAO/Connection.php';
require_once './utilidades/Authenticator.php';
header("Content-Type: text/html");
$authenticator = new Authenticator("Tirate una autenticacion papa", "No vas a pasar ni en pedo, puto");
$authenticator->setUser("jose");
$authenticator->setPassword("1234");
$authenticator->authenticate(TRUE, TRUE);
$conexionObject = new Connection("localhost", "matias", "", "diccionario");
$conexion = $conexionObject->getConnection();
$conexion = $conexionObject->getConnection();
$query = "select * from palabra";
$resultSet = $conexion->query($query);
while ($currentRow = mysqli_fetch_assoc($resultSet)) {
echo $currentRow["palabra"] . " - ";
echo "<br><br>";
}
$conexionObject->closeConnection();
示例11: test10CreateConceptWithoutUriButWithNotationUniquePrefLabel
public function test10CreateConceptWithoutUriButWithNotationUniquePrefLabel()
{
// Create a concept without Uri (no rdf:about), but with notation. prefLabel is unique.
print "\n\n test10 ... \n";
$client = Authenticator::authenticate();
$randomn = rand(0, 4092);
$prefLabel = 'testPrefLable_' . $randomn;
$dateSubmitted = date(DateTime::ISO8601);
$xml = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:dcterms="http://purl.org/dc/terms/" > ' . '<rdf:Description>' . '<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>' . '<dcterms:creator>Test</dcterms:creator>' . '<skos:prefLabel xml:lang="nl">' . $prefLabel . '</skos:prefLabel>' . '<dcterms:dateSubmitted>' . $dateSubmitted . '</dcterms:dateSubmitted>' . '<skos:inScheme rdf:resource="http://data.beeldengeluid.nl/gtaa/GeografischeNamen"/>' . '<skos:notation>1</skos:notation>' . '</rdf:Description>' . '</rdf:RDF>';
$client->setUri(BASE_URI_ . "/public/api/concept?");
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$response = $client->setEncType('text/xml')->setRawData($xml)->setParameterGet('tenant', TENANT)->setParameterGet('collection', COLLECTION_1_code)->setParameterGet('key', API_KEY)->setParameterGet('autoGenerateIdentifiers', 'true')->request('POST');
if ($response->isSuccessful()) {
print "\n Concept created \n";
var_dump($response->getBody());
} else {
print "\n Failed to create concept (header) : " . $response->getHeader('X-Error-Msg');
print "\n Message: " . $response->getMessage();
}
$this->AssertEquals(400, $response->getStatus());
}
示例12: is_ajax
<?php
include_once "../gb_conf.php";
include_once "Authenticator.php";
function is_ajax()
{
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
if (is_ajax()) {
$username = $_POST["username"];
$password = $_POST["password"];
if (isset($username) && isset($password)) {
$results = Authenticator::authenticate($username, $password);
$hash = $results[0]["hash"];
if (password_verify($password, $hash)) {
session_start();
$_SESSION["uid"] = $results[0]["_id"];
echo json_encode($results[0]["_id"]);
} else {
echo json_encode("fail");
}
}
}