Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. /**
  2. * {@inheritdoc}
  3. */
  4. public function vote(TokenInterface $token, $object, array $attributes)
  5. {
  6. $result = VoterInterface::ACCESS_ABSTAIN;
  7. foreach ($attributes as $attribute) {
  8. if (!$this->supportsAttribute($attribute)) {
  9. continue;
  10. }
  11.  
  12. $result = VoterInterface::ACCESS_DENIED;
  13.  
  14. if (self::IS_AUTHENTICATED_FULLY === $attribute
  15. && $this->authenticationTrustResolver->isFullFledged($token)) {
  16. return VoterInterface::ACCESS_GRANTED;
  17. }
  18.  
  19. if (self::IS_AUTHENTICATED_REMEMBERED === $attribute
  20. && ($this->authenticationTrustResolver->isRememberMe($token)
  21. || $this->authenticationTrustResolver->isFullFledged($token))) {
  22. return VoterInterface::ACCESS_GRANTED;
  23. }
  24.  
  25. if (self::IS_AUTHENTICATED_ANONYMOUSLY === $attribute
  26. && ($this->authenticationTrustResolver->isAnonymous($token)
  27. || $this->authenticationTrustResolver->isRememberMe($token)
  28. || $this->authenticationTrustResolver->isFullFledged($token))) {
  29. return VoterInterface::ACCESS_GRANTED;
  30. }
  31. }
  32.  
  33. return $result;
  34. }
  35.  
  36. public function isAuthenticated()
  37. {
  38. $securityContext = $this->container->get('security.context');
  39. return $securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED');
  40. }
  41.  
  42. if (isAuthenticated()) {
  43. throw $this->createNotFoundException('This page does not exist');
  44. }
  45.  
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function vote(TokenInterface $token, $object, array $attributes)
  50. {
  51. $result = VoterInterface::ACCESS_ABSTAIN;
  52. foreach ($attributes as $attribute) {
  53. if (!$this->supportsAttribute($attribute)) {
  54. continue;
  55. }
  56.  
  57. $result = VoterInterface::ACCESS_DENIED;
  58.  
  59. if (self::IS_AUTHENTICATED_FULLY === $attribute
  60. && $this->authenticationTrustResolver->isFullFledged($token)) {
  61. return VoterInterface::ACCESS_GRANTED;
  62. }
  63.  
  64. if (self::IS_AUTHENTICATED_REMEMBERED === $attribute
  65. && $this->authenticationTrustResolver->isRememberMe($token)) {
  66. return VoterInterface::ACCESS_GRANTED;
  67. }
  68.  
  69. if (self::IS_AUTHENTICATED_ANONYMOUSLY === $attribute
  70. && $this->authenticationTrustResolver->isAnonymous($token)) {
  71. return VoterInterface::ACCESS_GRANTED;
  72. }
  73. }
  74.  
  75. return $result;
  76. }
  77.  
  78. pp_security.apikey_authenticated_voter:
  79. class: %pp_security.apikey_authenticated_voter.class%
  80. arguments:
  81. - "@security.authentication.trust_resolver"
  82. public: false
  83. tags:
  84. - { name: security.voter }
  85.  
  86. security:
  87. access_decision_manager:
  88. strategy: unanimous
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement