当前位置: 首页>>代码示例>>PHP>>正文


PHP Model\SecurityIdentityInterface类代码示例

本文整理汇总了PHP中Symfony\Component\Security\Acl\Model\SecurityIdentityInterface的典型用法代码示例。如果您正苦于以下问题:PHP SecurityIdentityInterface类的具体用法?PHP SecurityIdentityInterface怎么用?PHP SecurityIdentityInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SecurityIdentityInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: equals

 /**
  * {@inheritDoc}
  */
 public function equals(SecurityIdentityInterface $sid)
 {
     if (!$sid instanceof UserSecurityIdentity) {
         return false;
     }
     return $this->username === $sid->getUsername() && $this->class === $sid->getClass();
 }
开发者ID:notbrain,项目名称:symfony,代码行数:10,代码来源:UserSecurityIdentity.php

示例2: equals

 /**
  * {@inheritdoc}
  */
 public function equals(SecurityIdentityInterface $sid)
 {
     if (!$sid instanceof JournalRoleSecurityIdentity) {
         return false;
     }
     return $this->role === $sid->getRole() && (int) $this->journal === (int) $sid->getJournal();
 }
开发者ID:necatikartal,项目名称:ojs,代码行数:10,代码来源:JournalRoleSecurityIdentity.php

示例3: equals

 /**
  * {@inheritDoc}
  */
 public function equals(SecurityIdentityInterface $sid)
 {
     if (!$sid instanceof RoleSecurityIdentity) {
         return false;
     }
     return $this->role === $sid->getRole();
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:10,代码来源:RoleSecurityIdentity.php

示例4: equals

 /**
  * {@inheritdoc}
  */
 public function equals(SecurityIdentityInterface $sid)
 {
     if (!$sid instanceof self) {
         return false;
     }
     return $this->id === $sid->getId() && $this->class === $sid->getClass();
 }
开发者ID:kstupak,项目名称:platform,代码行数:10,代码来源:BusinessUnitSecurityIdentity.php

示例5: revokeMask

 /**
  * @param $entity
  * @param $mask
  * @param SecurityIdentityInterface $securityIdentity
  * @return $this
  */
 public function revokeMask($entity, $mask, SecurityIdentityInterface $securityIdentity)
 {
     $acl = $this->getAcl($entity);
     $aces = $acl->getObjectAces();
     foreach ($aces as $index => $ace) {
         if ($securityIdentity->equals($ace->getSecurityIdentity())) {
             $this->removeMask($index, $acl, $ace, $mask);
         }
     }
     $this->aclProvider->updateAcl($acl);
     return $this;
 }
开发者ID:GTheron,项目名称:RestBundle,代码行数:18,代码来源:AuthorizationManager.php

示例6: fromAclIdentity

 /**
  * Transform a given ACL security identity into a SecurityIdentity model.
  *
  * If there is no model entry given, a new one will be created and saved to the database.
  *
  * @throws \InvalidArgumentException
  *
  * @param \Symfony\Component\Security\Acl\Model\SecurityIdentityInterface $aclIdentity
  * @param \PropelPDO                                                      $con
  *
  * @return \Propel\PropelBundle\Model\Acl\SecurityIdentity
  */
 public static function fromAclIdentity(SecurityIdentityInterface $aclIdentity, \PropelPDO $con = null)
 {
     if ($aclIdentity instanceof UserSecurityIdentity) {
         $identifier = $aclIdentity->getClass() . '-' . $aclIdentity->getUsername();
         $username = true;
     } elseif ($aclIdentity instanceof RoleSecurityIdentity) {
         $identifier = $aclIdentity->getRole();
         $username = false;
     } else {
         throw new \InvalidArgumentException('The ACL identity must either be an instance of UserSecurityIdentity or RoleSecurityIdentity.');
     }
     $obj = SecurityIdentityQuery::create()->filterByIdentifier($identifier)->filterByUsername($username)->findOneOrCreate($con);
     if ($obj->isNew()) {
         $obj->save($con);
     }
     return $obj;
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:29,代码来源:SecurityIdentity.php

示例7: getUpdateSecurityIdentitySql

 /**
  * Constructs the SQL for updating a security identity.
  *
  * @param SecurityIdentityInterface $sid
  * @param string $oldName
  * @throws \InvalidArgumentException
  * @return string
  */
 protected function getUpdateSecurityIdentitySql(SecurityIdentityInterface $sid, $oldName)
 {
     if ($sid instanceof UserSecurityIdentity) {
         if ($sid->getUsername() == $oldName) {
             throw new \InvalidArgumentException('There are no changes.');
         }
         $oldIdentifier = $sid->getClass() . '-' . $oldName;
         $newIdentifier = $sid->getClass() . '-' . $sid->getUsername();
         $username = true;
     } elseif ($sid instanceof RoleSecurityIdentity) {
         if ($sid->getRole() == $oldName) {
             throw new \InvalidArgumentException('There are no changes.');
         }
         $oldIdentifier = $oldName;
         $newIdentifier = $sid->getRole();
         $username = false;
     } else {
         throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity, or RoleSecurityIdentity.');
     }
     return sprintf('UPDATE %s SET identifier = %s WHERE identifier = %s AND username = %s', $this->options['sid_table_name'], $this->connection->quote($newIdentifier), $this->connection->quote($oldIdentifier), $this->connection->getDatabasePlatform()->convertBooleans($username));
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:29,代码来源:MutableAclProvider.php

示例8: getFormattedName

 /**
  * @param SecurityIdentityInterface $sid
  *
  * @return string
  */
 protected function getFormattedName(SecurityIdentityInterface $sid)
 {
     if ($sid instanceof UserSecurityIdentity && $sid->getUsername()) {
         $user = $this->manager->getRepository('OroUserBundle:User')->findOneBy(['username' => $sid->getUsername()]);
         if ($user) {
             return $this->nameFormatter->format($user);
         }
     } elseif ($sid instanceof BusinessUnitSecurityIdentity) {
         $businessUnit = $this->manager->getRepository('OroOrganizationBundle:BusinessUnit')->find($sid->getId());
         if ($businessUnit) {
             return $businessUnit->getName();
         }
     }
     return '';
 }
开发者ID:kstupak,项目名称:platform,代码行数:20,代码来源:OroSecurityExtension.php

示例9: getInsertSecurityIdentitySql

 /**
  * Constructs the SQL for inserting a security identity.
  *
  * @param SecurityIdentityInterface $sid
  *
  * @throws \InvalidArgumentException
  *
  * @return string
  */
 protected function getInsertSecurityIdentitySql(SecurityIdentityInterface $sid)
 {
     if ($sid instanceof UserSecurityIdentity) {
         $identifier = $sid->getClass() . '-' . $sid->getUsername();
         $username = true;
     } elseif ($sid instanceof RoleSecurityIdentity) {
         $identifier = $sid->getRole();
         $username = false;
     } elseif ($sid instanceof JournalRoleSecurityIdentity) {
         $identifier = $sid->getIdentifier();
         $username = false;
     } else {
         throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity, JournalRoleSecurityIdentity or RoleSecurityIdentity.');
     }
     return sprintf('INSERT INTO %s (identifier, username) VALUES (%s, %s)', $this->options['sid_table_name'], $this->connection->quote($identifier), $this->connection->getDatabasePlatform()->convertBooleans($username));
 }
开发者ID:beyzakokcan,项目名称:ojs,代码行数:25,代码来源:MutableAclProvider.php

示例10: getSecurityIdentityQuery

 /**
  * Create an array of the security identity for inserting in the document
  *
  * @param SecurityIdentityInterface $sid
  * @throws \InvalidArgumentException
  * @return array
  */
 protected function getSecurityIdentityQuery(SecurityIdentityInterface $sid)
 {
     if ($sid instanceof UserSecurityIdentity) {
         return array('username' => $sid->getUsername(), 'class' => $sid->getClass());
     } else {
         if ($sid instanceof RoleSecurityIdentity) {
             return array('role' => $sid->getRole());
         } else {
             throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity, or RoleSecurityIdentity.');
         }
     }
 }
开发者ID:Cobrowser,项目名称:MongoDBAclBundle,代码行数:19,代码来源:MutableAclProvider.php

示例11: getSecurityIdentifier

 /**
  * Get Security Identifier and Username flag to create SQL queries
  *
  * @param SecurityIdentityInterface $sid
  *
  * @throws \InvalidArgumentException
  *
  * @return array
  */
 protected function getSecurityIdentifier(SecurityIdentityInterface $sid)
 {
     if ($sid instanceof UserSecurityIdentity) {
         return [$sid->getClass() . '-' . $sid->getUsername(), true];
     } elseif ($sid instanceof RoleSecurityIdentity) {
         return [$sid->getRole(), false];
     } elseif ($sid instanceof BusinessUnitSecurityIdentity) {
         return [$sid->getClass() . '-' . $sid->getId(), false];
     } else {
         throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity or RoleSecurityIdentity' . ' or BusinessUnitSecurityIdentity.');
     }
 }
开发者ID:kstupak,项目名称:platform,代码行数:21,代码来源:MutableAclProvider.php

示例12: getSidSqlRestriction

 /**
  * Constructs sql restriction based on sid specified as array and fills list
  * of used sql params to be bind in prepared statement
  *
  * @param SecurityIdentityInterface $sid            sid
  * @param array                     &$valuesForBind list of params to be bind
  *
  * @return string
  */
 private function getSidSqlRestriction(SecurityIdentityInterface $sid, &$valuesForBind)
 {
     if ($sid instanceof UserSecurityIdentity) {
         $identifier = $sid->getClass() . '-' . $sid->getUsername();
         $isUsername = true;
     } elseif ($sid instanceof RoleSecurityIdentity) {
         $identifier = $sid->getRole();
         $isUsername = false;
     } else {
         throw new InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity, or RoleSecurityIdentity.');
     }
     $sidSqlRestriction = sprintf("INNER JOIN %s s ON e.security_identity_id = s.id AND s.identifier = :identifier AND s.username = :username", $this->options['sid_table_name']);
     $valuesForBind['identifier'] = ['value' => $identifier, 'type' => PDO::PARAM_STR];
     $valuesForBind['username'] = ['value' => $isUsername, 'type' => PDO::PARAM_BOOL];
     return $sidSqlRestriction;
 }
开发者ID:GlobalTradingTechnologies,项目名称:reverse-search-acl,代码行数:25,代码来源:ReverseSearchAclProvider.php

示例13: getSecurityIdentityId

 /**
  * @param SecurityIdentityInterface $sid
  *
  * @return mixed
  */
 protected function getSecurityIdentityId(SecurityIdentityInterface $sid)
 {
     if ($sid instanceof UserSecurityIdentity) {
         $identifier = $sid->getClass() . '-' . $sid->getUsername();
         $username = true;
     } elseif ($sid instanceof RoleSecurityIdentity) {
         //skip Role SID because we didn't share records for Role
         return null;
     } elseif ($sid instanceof BusinessUnitSecurityIdentity) {
         $identifier = $sid->getClass() . '-' . $sid->getId();
         $username = false;
     } else {
         throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity or RoleSecurityIdentity ' . 'or BusinessUnitSecurityIdentity.');
     }
     return $this->getObjectManager()->getRepository('OroSecurityBundle:AclSecurityIdentity')->findOneBy(['identifier' => $identifier, 'username' => $username]);
 }
开发者ID:kstupak,项目名称:platform,代码行数:21,代码来源:OwnershipConditionDataBuilder.php

示例14: getSelectSecurityIdentityIdSql

 /**
  * Constructs the SQL for selecting the primary key of a security identity.
  *
  * @param SecurityIdentityInterface $sid
  * @throws \InvalidArgumentException
  * @return string
  */
 protected function getSelectSecurityIdentityIdSql(SecurityIdentityInterface $sid)
 {
     if ($sid instanceof UserSecurityIdentity) {
         $identifier = $sid->getClass() . '-' . $sid->getUsername();
         $username = true;
     } elseif ($sid instanceof RoleSecurityIdentity) {
         $identifier = $sid->getRole();
         $username = false;
     } else {
         throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity, or RoleSecurityIdentity.');
     }
     return sprintf('SELECT id FROM %s WHERE identifier = %s AND username = %s', $this->options['sid_table_name'], $this->connection->quote($identifier), $this->connection->getDatabasePlatform()->convertBooleans($username));
 }
开发者ID:rcastardo,项目名称:symfony,代码行数:20,代码来源:MutableAclProvider.php

示例15: revoke

 /**
  * @param ObjectIdentityInterface   $objectIdentity
  * @param SecurityIdentityInterface $securityIdentity
  * @param string|string[]           $permissions
  * @param string                    $type
  * @param null|string               $field
  */
 protected function revoke(ObjectIdentityInterface $objectIdentity, SecurityIdentityInterface $securityIdentity, $permissions, $type, $field = null)
 {
     if (null === ($acl = $this->findAcl($objectIdentity))) {
         return;
     }
     $index = false;
     $oldMask = 0;
     /** @var Entry $ace */
     foreach ($acl->{$this->resolveAceMethod('get', $type, $field)}($field) as $k => $ace) {
         if ($securityIdentity->equals($ace->getSecurityIdentity())) {
             $index = $k;
             $oldMask = $ace->getMask();
             continue;
         }
     }
     if (false !== $index) {
         $maskBuilder = $this->permissionMap->getMaskBuilder();
         $maskBuilder->set($oldMask);
         foreach ((array) $permissions as $permission) {
             $maskBuilder->remove($permission);
         }
         if (null === $field) {
             $acl->{$this->resolveAceMethod('update', $type)}($index, $maskBuilder->get());
         } else {
             $acl->{$this->resolveAceMethod('update', $type, $field)}($index, $field, $maskBuilder->get());
         }
     }
     $this->aclProvider->updateAcl($acl);
 }
开发者ID:dragosprotung,项目名称:AclBundle,代码行数:36,代码来源:AclManager.php


注:本文中的Symfony\Component\Security\Acl\Model\SecurityIdentityInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。