本文整理汇总了PHP中Credentials类的典型用法代码示例。如果您正苦于以下问题:PHP Credentials类的具体用法?PHP Credentials怎么用?PHP Credentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Credentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCredentials
public function testCredentials()
{
$credentials = new Credentials(self::MERCHANT, self::PRIVATE_KEY, new Md5Algorithm(), self::ENCRYPTION_PROTOCOL);
$this->assertEquals(self::MERCHANT, $credentials->getMerchantPosId());
$this->assertEquals(self::PRIVATE_KEY, $credentials->getPrivateKey());
$this->assertEquals(self::ENCRYPTION_PROTOCOL, $credentials->getEncryptionProtocols());
$this->assertInstanceOf('\\Team3\\PayU\\SignatureCalculator\\Encoder\\Algorithms\\AlgorithmInterface', $credentials->getSignatureAlgorithm());
}
示例2: tryLogin
public function tryLogin(Credentials $userCredentials, UserArray $users)
{
//First check to make sure the user is not already logged in (this is also checked in controller, but I prefer to check in all places to minimize errors)
if (!$this->isUserLoggedIn()) {
//If input matches any saved user, return true (successful login attempt) and save in session variable as 'logged in'
if ($users->getUserByName($userCredentials->getUserName()) != null && password_verify($userCredentials->getUserPassword(), $users->getUserByName($userCredentials->getUserName())->getPassword())) {
$_SESSION['LoggedIn'] = $userCredentials->getUserName();
return true;
}
}
//In all other cases, return false
return false;
}
示例3: testHstore
/**
* Install hstore
* /usr/share/postgresql/contrib # cat hstore.sql | psql -U pgsql -d onphp
**/
public function testHstore()
{
foreach (DBTestPool::me()->getPool() as $connector => $db) {
DBPool::me()->setDefault($db);
$properties = array('age' => '23', 'weight' => 80, 'comment' => null);
$user = TestUser::create()->setCity($moscow = TestCity::create()->setName('Moscow'))->setCredentials(Credentials::create()->setNickname('fake')->setPassword(sha1('passwd')))->setLastLogin(Timestamp::create(time()))->setRegistered(Timestamp::create(time())->modify('-1 day'))->setProperties(Hstore::make($properties));
$moscow = TestCity::dao()->add($moscow);
$user = TestUser::dao()->add($user);
Cache::me()->clean();
TestUser::dao()->dropIdentityMap();
$user = TestUser::dao()->getById('1');
$this->assertInstanceOf('Hstore', $user->getProperties());
$this->assertEquals($properties, $user->getProperties()->getList());
$form = TestUser::proto()->makeForm();
$form->get('properties')->setFormMapping(array(Primitive::string('age'), Primitive::integer('weight'), Primitive::string('comment')));
$form->import(array('id' => $user->getId()));
$this->assertNotNull($form->getValue('id'));
$object = $user;
FormUtils::object2form($object, $form);
$this->assertInstanceOf('Hstore', $form->getValue('properties'));
$this->assertEquals(array_filter($properties), $form->getValue('properties')->getList());
$subform = $form->get('properties')->getInnerForm();
$this->assertEquals($subform->getValue('age'), '23');
$this->assertEquals($subform->getValue('weight'), 80);
$this->assertNull($subform->getValue('comment'));
$user = new TestUser();
FormUtils::form2object($form, $user, false);
$this->assertEquals($user->getProperties()->getList(), array_filter($properties));
}
}
示例4: __construct
/**
* Constructs a Credentials object for Users (making requests on behalf of a user).
*
* @param string $consumerKey Twitter Application Consumer Key
* @param string $consumerSecret Twitter Application Consumer Secret
* @param string|null $callbackUrl Twitter Application Callback URL
* @param string|null $accessToken Twitter Access Token
* @param string|null $accessTokenSecret Twitter Access Token Secret
*/
public function __construct($consumerKey, $consumerSecret, $callbackUrl = null, $accessToken = null, $accessTokenSecret = null)
{
parent::__construct($consumerKey, $consumerSecret);
$this->accessToken = $accessToken;
$this->accessTokenSecret = $accessTokenSecret;
$this->callbackUrl = $callbackUrl;
}
示例5: it_should_provide_a_basic_authentication_token
/**
* @test
* @covers ::fromUsernameAndPassword
* @covers ::basicAuthentication
*/
public function it_should_provide_a_basic_authentication_token()
{
$username = 'mike';
$password = 'itworks';
$credentials = Credentials::fromUsernameAndPassword($username, $password);
$this->assertSame('bWlrZTppdHdvcmtz', $credentials->basicAuthentication());
}
示例6: testMakeDefault
public function testMakeDefault()
{
$cred = $this->credentials('testUser');
$cred->makeDefault($this->users('testUser')->id, 'email');
$defaults = $cred->getDefaultCredentials(true);
$default = Credentials::model()->findDefault($this->users('testUser')->id, 'email');
$this->assertEquals($cred->id, $default->id, 'Failed asserting proper function of set-as-default method.');
}
示例7: login
/**
*
* Authenticates the user using the supplied credentials.
* If workspace is recognized as the name of an existing workspace in the repository and authorization to access that workspace is granted, then a new Session object is returned.
* If authentication or authorization for the specified workspace fails, a LoginException is thrown.
* If workspace is not recognized, a NoSuchWorkspaceException is thrown.
* @param Credentials $credentials the credentials of the user.
* @param string $workspace the name of the workspace.
* @return Session a valid session for the user to access the repository.
*
*/
public static function login(Credentials $credentials, $workspace)
{
if (!file_exists($_SERVER['PCR'] . "/config/{$workspace}.xml")) {
throw new NoSuchWorkspaceException($workspace);
}
$config = simplexml_load_file($_SERVER['PCR'] . "/config/{$workspace}.xml");
$persistenceManager = (string) $config->persistenceManager;
if (!file_exists($_SERVER['PCR'] . "/PMs/{$persistenceManager}.php")) {
throw new RepositoryException("persistence manager does not exist for workspace: {$workspace}=>{$persistenceManager}");
}
require_once $_SERVER['PCR'] . "/PMs/{$persistenceManager}.php";
$pm = new $persistenceManager($credentials, $workspace, $config);
if (!$pm->isLive()) {
throw new LoginException("workspace=>{$workspace}, persistenceManager=>{$persistenceManager}, userID=>" . $credentials->getUserID());
}
Log4PCR::access("workspace=>{$workspace}, persistenceManager=>{$persistenceManager}, userID=>" . $credentials->getUserID());
return new Session($pm);
}
示例8: testSubaccountDoesntExist
public function testSubaccountDoesntExist()
{
$creds = Credentials::get();
$client = new GSC_Client($creds["merchantId"]);
$client->login($creds["email"], $creds["password"]);
$errors = $client->getAccount("1");
$errors = $errors->getErrors();
$error = $errors[0];
$this->assertEquals('ResourceNotFoundException', $error->getCode());
}
示例9: __construct
public function __construct(Credentials $credentials, $workspace, $config)
{
$link = @mysql_connect($config->server, $credentials->getUserID(), $credentials->getPassword(), 1);
if (mysql_stat($link) !== null) {
if (!mysql_select_db($workspace, $link)) {
$sql = "CREATE DATABASE {$workspace}";
if (mysql_query($sql, $link)) {
mysql_select_db($workspace, $link);
$sql = "CREATE TABLE c (p text NOT NULL,\n\t\t\t\t\t\t\t\tn text NOT NULL,\n\t\t\t\t\t\t\t\tv text NOT NULL,\n\t\t\t\t\t\t\t\tKEY INDEX1 (p (1000)),\n\t\t\t\t\t\t\t\tKEY INDEX2 (p (850), n (150)),\n\t\t\t\t\t\t\t\tKEY INDEX3 (p (550), n (150), v (300)),\n\t\t\t\t\t\t\t\tKEY INDEX4 (v (1000)))\n\t\t\t\t\t\t\t\tENGINE = MyISAM DEFAULT CHARSET = latin1";
mysql_query($sql, $link);
} else {
throw new RepositoryException("in MySQL, cannot create workspace: {$workspace}");
}
}
$this->credentials = $credentials;
$this->workspace = $workspace;
$this->config = $config;
$this->link = $link;
$this->isLive = true;
}
}
示例10: testCount
public function testCount()
{
foreach (DBTestPool::me()->getPool() as $db) {
DBPool::me()->setDefault($db);
$this->getDBCreator()->fillDB();
$count = TestUser::dao()->getTotalCount();
$this->assertGreaterThan(1, $count);
$city = TestCity::create()->setId(1);
$newUser = TestUser::create()->setCity($city)->setCredentials(Credentials::create()->setNickname('newuser')->setPassword(sha1('newuser')))->setLastLogin(Timestamp::create(time()))->setRegistered(Timestamp::create(time()));
TestUser::dao()->add($newUser);
$newCount = TestUser::dao()->getTotalCount();
$this->assertEquals($count + 1, $newCount);
}
}
示例11: testIpAddressProperty
public function testIpAddressProperty()
{
foreach (DBTestPool::me()->getPool() as $db) {
DBPool::me()->setDefault($db);
$city = TestCity::create()->setName('Khimki');
TestCity::dao()->add($city);
$userWithIp = TestUser::create()->setCredentials(Credentials::create()->setNickName('postgreser')->setPassword(sha1('postgreser')))->setLastLogin(Timestamp::makeNow())->setRegistered(Timestamp::makeNow())->setCity($city)->setIp(IpAddress::create('127.0.0.1'));
TestUser::dao()->add($userWithIp);
$this->assertTrue($userWithIp->getId() >= 1);
$this->assertTrue($userWithIp->getIp() instanceof IpAddress);
$plainIp = DBPool::me()->getByDao(TestUser::dao())->queryColumn(OSQL::select()->get('ip')->from(TestUser::dao()->getTable())->where(Expression::eq('id', $userWithIp->getId())));
$this->assertEquals($plainIp[0], $userWithIp->getIp()->toString());
$count = Criteria::create(TestUser::dao())->add(Expression::eq('ip', IpAddress::create('127.0.0.1')))->addProjection(Projection::count('*', 'count'))->getCustom('count');
$this->assertEquals($count, 1);
}
}
示例12: paramRules
public function paramRules()
{
if (Yii::app()->isInSession) {
$credOptsDict = Credentials::getCredentialOptions(null, true);
$credOpts = $credOptsDict['credentials'];
$selectedOpt = $credOptsDict['selectedOption'];
foreach ($credOpts as $key => $val) {
if ($key == $selectedOpt) {
$credOpts = array($key => $val) + $credOpts;
// move to beginning of array
break;
}
}
} else {
$credOpts = array();
}
return array_merge(parent::paramRules(), array('title' => Yii::t('studio', $this->title), 'info' => Yii::t('studio', $this->info), 'options' => array(array('name' => 'from', 'label' => Yii::t('studio', 'Send As:'), 'type' => 'dropdown', 'options' => $credOpts))));
}
示例13: actionTwitterIntegration
public function actionTwitterIntegration()
{
$credId = Yii::app()->settings->twitterCredentialsId;
if ($credId && ($cred = Credentials::model()->findByPk($credId))) {
$params = array('id' => $credId);
} else {
$params = array('class' => 'TwitterApp');
}
$url = Yii::app()->createUrl('/profile/createUpdateCredentials', $params);
$this->redirect($url);
}
示例14: getSigningKey
/**
* @return string
*/
protected function getSigningKey()
{
$signingKey = rawurlencode($this->credentials->getConsumerSecret()) . '&';
if ($this->tokenSecret !== null) {
$signingKey .= rawurlencode($this->tokenSecret);
}
return $signingKey;
}
示例15: toArray
/**
* @param bool $includeNull = false
* @return array
*/
public function toArray($includeNull = false)
{
$array = parent::toArray($includeNull);
if ($this->credentials) {
$array['token'] = $this->credentials->getToken();
}
return $array;
}