本文整理汇总了PHP中Repository::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::authenticate方法的具体用法?PHP Repository::authenticate怎么用?PHP Repository::authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository::authenticate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAuthenticate
/**
* This method should handle any authentication and report back to the subject
*
* @access public
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object $response Authentication response object
* @return boolean
* @since 1.5
*/
function onAuthenticate($credentials, $options, &$response)
{
// This file is needed to use the Repository class
require_once dirname(__FILE__) . '/alfresco-php-library/Repository.php';
// Get the URL of the Alfresco repository as a parameter of the plugin
$plugin =& JPluginHelper::getPlugin('authentication', 'joosco');
$pluginParams = new JParameter($plugin->params);
// Set the variables
$repositoryUrl = $pluginParams->get('alf-url');
$userName = $credentials['username'];
$password = $credentials['password'];
// Connect to the repository
$repository = new Repository($repositoryUrl);
$ticket = null;
try {
// Try to create a ticket
$ticket = $repository->authenticate($userName, $password);
// If the ticket fails, it means that the username and/or password are wrong
$_SESSION["ticket"] = $ticket;
$response->status = JAUTHENTICATE_STATUS_SUCCESS;
// There's no way to get the Alfresco name or email address of the user
// The only thing to do is wait for an update of the Alfresco PHP API
$response->username = $credentials['username'];
$response->email = $credentials['username'] . "@alfresco.user";
$response->fullname = $credentials['username'];
} catch (Exception $e) {
// Wrong username or password creates an exception
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Authentication failed';
}
}
示例2: testCreateSession
public function testCreateSession()
{
$repository = new Repository();
$ticket = $repository->authenticate("admin", "admin");
$session = $repository->createSession($ticket);
$this->assertNotNull($session);
$this->assertEquals("http://localhost:8080/alfresco/api", $session->repository->connectionUrl);
$this->assertEquals($ticket, $session->ticket);
// TODO for now if no ticket is provided a null session is returned
$session2 = $repository->createSession();
$this->assertNull($session2);
}
示例3: getConnection
protected function getConnection()
{
if ($this->alfresco == null) {
if (!empty($this->alfrescoUrl)) {
$repository = new Repository($this->alfrescoUrl);
try {
$ticket = $repository->authenticate($this->alfrescoUser, $this->alfrescoPass);
} catch (Exception $e) {
za()->log()->err("Failed authenticating to Alfresco");
return;
}
$this->alfresco = $repository->createSession($ticket);
$this->spacesStore = new SpacesStore($this->alfresco);
}
}
return $this->alfresco;
}
示例4: Repository
*
* Note: any changes to this file should be uploaded to the wiki
*/
// Include the required Alfresco PHP API objects
if (isset($_SERVER["ALF_AVAILABLE"]) == false) {
require_once "Alfresco/Service/Repository.php";
require_once "Alfresco/Service/Session.php";
require_once "Alfresco/Service/SpacesStore.php";
}
// Specify the connection details
$repositoryUrl = "http://localhost:8080/alfresco/api";
$userName = "admin";
$password = "admin";
// Authenticate the user and create a session
$repository = new Repository($repositoryUrl);
$ticket = $repository->authenticate($userName, $password);
$session = $repository->createSession($ticket);
// Create a reference to the 'SpacesStore'
$spacesStore = new SpacesStore($session);
// Use a serach to get the content node we are updating
$nodes = $session->query($spacesStore, "PATH:\"app:company_home/app:guest_home/cm:Alfresco-Tutorial.pdf\"");
$contentNode = $nodes[0];
// Update the property if the form has been posted with the correct details
if (isset($_REQUEST["update"]) == true) {
// Set the updated title and decription values
$contentNode->cm_title = $_REQUEST["title"];
$contentNode->cm_description = $_REQUEST["description"];
// Save the session. This ensures that the updates are presisted back to the repository.
// If this save call is not made the changes made will be lost when the session object is destroyed.
$session->save();
}
示例5: connect
/**
* Connect to an external Alfresco DMS repository.
*
* In the event of any error the object paramter '$errormsg' will be set
* to an approriate value.
*
* @uses $USER
* @param string $username The username to authenticate with.
* @param string $password The password to authenticate with.
* @return bool True on sucess, False otherwise.
*/
function connect($username, $password) {
global $USER;
if (ELIS_FILES_DEBUG_TRACE) mtrace('connect(' . $username . ', ' . $password . ')');
$this->errormsg = '';
if (empty($username) || empty($password)) {
$this->errormsg = get_string('usernameorpasswordempty', 'repository_elisfiles');
return false;
}
/// Create the session
$repository = new Repository($this->get_repourl());
$ticket = null;
if (!isset($USER->alfresoSession)) {
$ticket = $repository->authenticate($username, $password);
$USER->alfrescoTicket = $ticket;
$USER->alfrescoLogin = time();
}
return true;
}
示例6: Repository
// Get the login details
$username = null;
if (isset($_REQUEST["loginForm:user-name"]) == true) {
$username = $_REQUEST["loginForm:user-name"];
}
$password = null;
if (isset($_REQUEST["loginForm:user-password"]) == true) {
$password = $_REQUEST["loginForm:user-password"];
}
// Set a null failure message
$failure = null;
if ($username != null && $password != null) {
try {
// Try and create a ticket
$alfRepository = new Repository();
$ticket = $alfRepository->authenticate($username, $password);
if (isset($ticket) == true) {
// Redirect to the index page with the ticket information
$url = "/alfresco/php/wiki/index.php?alfTicket=" . $ticket . "&alfUser=" . $username;
if ($title != null) {
$url .= "&title=" . $title;
}
header("Location: " . $url);
exit;
}
} catch (Exception $e) {
// Need to indicate that the login failed
$failure = "Login to MediaWiki failed, please try again.";
}
}
}