[Beeframework-svn] SF.net SVN: beeframework:[282] trunk/framework
Brought to you by:
b_hartmann,
m_plomer
From: <m_p...@us...> - 2015-02-16 08:03:02
|
Revision: 282 http://sourceforge.net/p/beeframework/code/282 Author: m_plomer Date: 2015-02-16 08:02:59 +0000 (Mon, 16 Feb 2015) Log Message: ----------- - Security/Acl: fixed regressions from namespace refactoring - Security/Vote: namespace refactoring Modified Paths: -------------- trunk/framework/Bee/MVC/Controller/Multiaction/AbstractAnnotationBasedResolver.php trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/AnnotationBasedInvocator.php trunk/framework/Bee/Security/Acls/Pdo/AclService.php trunk/framework/Bee/Security/Acls/Pdo/BasicLookupStrategy.php trunk/framework/Bee/Security/Config/Utils.php trunk/framework/Bee/Security/ConfigAttributeDefinition.php trunk/framework/Bee/Security/Transactions/Interceptor/DefaultTransactionAttribute.php trunk/framework/Bee/Security/Transactions/Interceptor/DelegatingTransactionAttribute.php trunk/framework/Bee/Security/Vote/AbstractAclVoter.php trunk/framework/Bee/Security/Vote/AbstractDecisionManager.php trunk/framework/Bee/Security/Vote/AclEntryVoter.php trunk/framework/Bee/Security/Vote/AffirmativeBased.php trunk/framework/Bee/Security/Vote/IAccessDecisionVoter.php trunk/framework/Bee/Security/Vote/RoleVoter.php trunk/framework/acl-default.xml Modified: trunk/framework/Bee/MVC/Controller/Multiaction/AbstractAnnotationBasedResolver.php =================================================================== --- trunk/framework/Bee/MVC/Controller/Multiaction/AbstractAnnotationBasedResolver.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/MVC/Controller/Multiaction/AbstractAnnotationBasedResolver.php 2015-02-16 08:02:59 UTC (rev 282) @@ -134,7 +134,7 @@ $annotations = $method->getAllAnnotations('Bee_MVC_Controller_Multiaction_RequestHandler'); foreach ($annotations as $annotation) { $requestTypeKey = $this->getMethodNameKey($annotation->httpMethod) . - $this->getAjaxTypeKey(filter_var($annotation->ajax, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)); + $this->getAjaxTypeKey(is_null($annotation->ajax) ? null : filter_var($annotation->ajax, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)); if (!array_key_exists($requestTypeKey, $mappings)) { $mappings[$requestTypeKey] = array(); } Modified: trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/AnnotationBasedInvocator.php =================================================================== --- trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/AnnotationBasedInvocator.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/AnnotationBasedInvocator.php 2015-02-16 08:02:59 UTC (rev 282) @@ -86,7 +86,6 @@ public function invokeHandlerMethod(IHttpRequest $request, array $fixedParams = array()) { /** @var MethodInvocation $resolvedMethod */ $resolvedMethod = $this->resolveMethodForRequest($request); - if (is_null($resolvedMethod)) { $resolvedMethod = $this->getDefaultMethodInvocation(); } Modified: trunk/framework/Bee/Security/Acls/Pdo/AclService.php =================================================================== --- trunk/framework/Bee/Security/Acls/Pdo/AclService.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Acls/Pdo/AclService.php 2015-02-16 08:02:59 UTC (rev 282) @@ -167,7 +167,7 @@ // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) $acl = $this->readAclForOid($objectIdentity); - Assert::isInstanceOf('IMutableAcl', $acl, "MutableAcl should have been returned"); + Assert::isInstanceOf('Bee\Security\Acls\IMutableAcl', $acl, "MutableAcl should have been returned"); return $acl; Modified: trunk/framework/Bee/Security/Acls/Pdo/BasicLookupStrategy.php =================================================================== --- trunk/framework/Bee/Security/Acls/Pdo/BasicLookupStrategy.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Acls/Pdo/BasicLookupStrategy.php 2015-02-16 08:02:59 UTC (rev 282) @@ -264,7 +264,7 @@ $resultMap = array(); foreach ($acls as $inputAcl) { - Assert::isInstanceOf('Acl', $inputAcl, 'Map should have contained an AclImpl'); + Assert::isInstanceOf('Bee\Security\Acls\Impl\Acl', $inputAcl, 'Map should have contained an AclImpl'); $result = $this->convert($acls, $inputAcl->getId()); $resultMap[$result->getObjectIdentity()->getIdentifierString()] = $result; Modified: trunk/framework/Bee/Security/Config/Utils.php =================================================================== --- trunk/framework/Bee/Security/Config/Utils.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Config/Utils.php 2015-02-16 08:02:59 UTC (rev 282) @@ -31,7 +31,7 @@ if (!$parserContext->getRegistry()->containsBeanDefinition(Bee_Security_Config_IBeanIds::ACCESS_MANAGER)) { $roleVoter = new GenericBeanDefinition(); - $roleVoter->setBeanClassName('Bee_Security_Vote_RoleVoter'); + $roleVoter->setBeanClassName('Bee\Security\Vote\RoleVoter'); // $authenticatedVoter = new GenericBeanDefinition(); // $authenticatedVoter->setBeanClassName('Bee_Security_Vote_AuthenticatedVoter'); // todo: implement... @@ -41,7 +41,7 @@ $authenticatedVoter*/ ); - $accessMgrBuilder = BeanDefinitionBuilder::rootBeanDefinition('Bee_Security_Vote_AffirmativeBased'); + $accessMgrBuilder = BeanDefinitionBuilder::rootBeanDefinition('Bee\Security\Vote\AffirmativeBased'); $accessMgrBuilder->addPropertyValue('decisionVoters', $defaultVoters); $parserContext->getRegistry()->registerBeanDefinition(Bee_Security_Config_IBeanIds::ACCESS_MANAGER, $accessMgrBuilder->getBeanDefinition()); } Modified: trunk/framework/Bee/Security/ConfigAttributeDefinition.php =================================================================== --- trunk/framework/Bee/Security/ConfigAttributeDefinition.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/ConfigAttributeDefinition.php 2015-02-16 08:02:59 UTC (rev 282) @@ -44,7 +44,7 @@ if(is_string($attr)) { $newList[] = new ConfigAttribute($attr); } else { - Assert::isInstanceOf('IConfigAttribute', $attr, 'List entries must be of type ConfigAttribute'); + Assert::isInstanceOf('Bee\Security\IConfigAttribute', $attr, 'List entries must be of type ConfigAttribute'); $newList[] = $attr; } } Modified: trunk/framework/Bee/Security/Transactions/Interceptor/DefaultTransactionAttribute.php =================================================================== --- trunk/framework/Bee/Security/Transactions/Interceptor/DefaultTransactionAttribute.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Transactions/Interceptor/DefaultTransactionAttribute.php 2015-02-16 08:02:59 UTC (rev 282) @@ -38,4 +38,3 @@ return ($ex instanceof RuntimeException); } } -?> \ No newline at end of file Modified: trunk/framework/Bee/Security/Transactions/Interceptor/DelegatingTransactionAttribute.php =================================================================== --- trunk/framework/Bee/Security/Transactions/Interceptor/DelegatingTransactionAttribute.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Transactions/Interceptor/DelegatingTransactionAttribute.php 2015-02-16 08:02:59 UTC (rev 282) @@ -65,5 +65,4 @@ } -} -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Security/Vote/AbstractAclVoter.php =================================================================== --- trunk/framework/Bee/Security/Vote/AbstractAclVoter.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Vote/AbstractAclVoter.php 2015-02-16 08:02:59 UTC (rev 282) @@ -1,6 +1,7 @@ <?php +namespace Bee\Security\Vote; /* - * Copyright 2008-2010 the original author or authors. + * Copyright 2008-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,20 +18,20 @@ use Bee\Utils\Assert; /** - * Created by IntelliJ IDEA. - * User: mp - * Date: Mar 19, 2010 - * Time: 5:30:14 PM - * To change this template use File | Settings | File Templates. + * Class AbstractAclVoter + * @package Bee\Security\Vote */ +abstract class AbstractAclVoter implements IAccessDecisionVoter { -abstract class Bee_Security_Vote_AbstractAclVoter implements Bee_Security_Vote_IAccessDecisionVoter { - /** * @var string */ private $processDomainObjectClass; + /** + * @param $secureObject + * @return mixed + */ protected function getDomainObjectInstance($secureObject) { // Object[] args; // Class[] params; @@ -57,6 +58,9 @@ // + " did not provide any argument of type: " + processDomainObjectClass); } + /** + * @return string + */ public function getProcessDomainObjectClass() { return $this->processDomainObjectClass; } Modified: trunk/framework/Bee/Security/Vote/AbstractDecisionManager.php =================================================================== --- trunk/framework/Bee/Security/Vote/AbstractDecisionManager.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Vote/AbstractDecisionManager.php 2015-02-16 08:02:59 UTC (rev 282) @@ -1,6 +1,7 @@ <?php +namespace Bee\Security\Vote; /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +21,15 @@ use Bee\Security\IConfigAttribute; use Bee\Utils\Assert; -abstract class Bee_Security_Vote_AbstractDecisionManager implements IAccessDecisionManager, IInitializingBean { +/** + * Class AbstractDecisionManager + * @package Bee\Security\Vote + */ +abstract class AbstractDecisionManager implements IAccessDecisionManager, IInitializingBean { /** * - * @var Bee_Security_Vote_IAccessDecisionVoter[] + * @var IAccessDecisionVoter[] */ private $decisionVoters; @@ -34,10 +39,16 @@ */ private $allowIfAllAbstainDecisions; + /** + * + */ public function afterPropertiesSet() { Assert::isTrue(count($this->decisionVoters) > 0, 'A list of AccessDecisionVoters is required'); } + /** + * @throws AccessDeniedException + */ protected final function checkAllowIfAllAbstainDecisions() { if (!$this->isAllowIfAllAbstainDecisions()) { throw new AccessDeniedException('access_denied'); // @todo: message source @@ -61,17 +72,27 @@ $this->allowIfAllAbstainDecisions = $allowIfAllAbstainDecisions; } + /** + * @return IAccessDecisionVoter[] + */ public function getDecisionVoters() { return $this->decisionVoters; } + /** + * @param IAccessDecisionVoter[]|array $decisionVoters + */ public function setDecisionVoters(array $decisionVoters) { foreach($decisionVoters as $voter) { - Assert::isInstanceOf('Bee_Security_Vote_IAccessDecisionVoter', $voter, 'AccessDecisionVoter ' . get_class($voter) . ' must implement Bee_Security_Vote_IAccessDecisionVoter'); + Assert::isInstanceOf('Bee\Security\Vote\IAccessDecisionVoter', $voter, 'AccessDecisionVoter ' . get_class($voter) . ' must implement Bee\Security\Vote\IAccessDecisionVoter'); } $this->decisionVoters = $decisionVoters; } + /** + * @param IConfigAttribute $configAttribute + * @return bool + */ public function supports(IConfigAttribute $configAttribute) { foreach($this->decisionVoters as $voter) { if($voter->supports($configAttribute)) { @@ -81,6 +102,10 @@ return false; } + /** + * @param string $className + * @return bool + */ public function supportsClass($className) { foreach($this->decisionVoters as $voter) { if(!$voter->supportsClass($className)) { Modified: trunk/framework/Bee/Security/Vote/AclEntryVoter.php =================================================================== --- trunk/framework/Bee/Security/Vote/AclEntryVoter.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Vote/AclEntryVoter.php 2015-02-16 08:02:59 UTC (rev 282) @@ -1,6 +1,7 @@ <?php +namespace Bee\Security\Vote; /* - * Copyright 2008-2010 the original author or authors. + * Copyright 2008-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +28,7 @@ use Bee\Security\IAuthentication; use Bee\Security\IConfigAttribute; use Bee\Utils\Strings; +use Logger; /** * Created by IntelliJ IDEA. @@ -36,7 +38,7 @@ * To change this template use File | Settings | File Templates. */ -class Bee_Security_Vote_AclEntryVoter extends Bee_Security_Vote_AbstractAclVoter { +class Bee_Security_Vote_AclEntryVoter extends AbstractAclVoter { /** * @var Logger @@ -83,6 +85,11 @@ */ private $requirePermission; + /** + * @param IAclService $aclService + * @param $processConfigAttribute + * @param array $requirePermission + */ public function __construct(IAclService $aclService, $processConfigAttribute, array $requirePermission) { @@ -135,13 +142,22 @@ $this->sidRetrievalStrategy = $sidIdentityRetrievalStrategy; } + /** + * @param IConfigAttribute $configAttribute + * @return bool + */ public function supports(IConfigAttribute $configAttribute) { return $configAttribute->getAttribute() == $this->getProcessConfigAttribute(); } + /** + * @param IAuthentication $authentication + * @param mixed $object + * @param ConfigAttributeDefinition $config + * @return int + * @throws GenericSecurityException + */ public function vote(IAuthentication $authentication, $object, ConfigAttributeDefinition $config) { - - foreach($config->getConfigAttributes() as $attr) { if (!$this->supports($attr)) { @@ -216,6 +232,5 @@ // No configuration attribute matched, so abstain return self::ACCESS_ABSTAIN; - } } \ No newline at end of file Modified: trunk/framework/Bee/Security/Vote/AffirmativeBased.php =================================================================== --- trunk/framework/Bee/Security/Vote/AffirmativeBased.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Vote/AffirmativeBased.php 2015-02-16 08:02:59 UTC (rev 282) @@ -1,6 +1,7 @@ <?php +namespace Bee\Security\Vote; /* - * Copyright 2008-2010 the original author or authors. + * Copyright 2008-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +19,20 @@ use Bee\Security\ConfigAttributeDefinition; use Bee\Security\Exception\AccessDeniedException; use Bee\Security\IAuthentication; +use Bee\Security\Vote\IAccessDecisionVoter; -class Bee_Security_Vote_AffirmativeBased extends Bee_Security_Vote_AbstractDecisionManager { +/** + * Class AffirmativeBased + * @package Bee\Security\Vote + */ +class AffirmativeBased extends AbstractDecisionManager { + + /** + * @param IAuthentication $authentication + * @param mixed $object + * @param ConfigAttributeDefinition $configAttributes + * @throws AccessDeniedException + */ public function decide(IAuthentication $authentication, $object, ConfigAttributeDefinition $configAttributes) { $deny = 0; @@ -27,9 +40,9 @@ $result = $voter->vote($authentication, $object, $configAttributes); switch($result) { - case Bee_Security_Vote_IAccessDecisionVoter::ACCESS_GRANTED: + case IAccessDecisionVoter::ACCESS_GRANTED: return; - case Bee_Security_Vote_IAccessDecisionVoter::ACCESS_DENIED: + case IAccessDecisionVoter::ACCESS_DENIED: $deny++; break; default: Modified: trunk/framework/Bee/Security/Vote/IAccessDecisionVoter.php =================================================================== --- trunk/framework/Bee/Security/Vote/IAccessDecisionVoter.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Vote/IAccessDecisionVoter.php 2015-02-16 08:02:59 UTC (rev 282) @@ -1,6 +1,7 @@ <?php +namespace Bee\Security\Vote; /* - * Copyright 2008-2010 the original author or authors. + * Copyright 2008-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +29,7 @@ * </p> * */ -interface Bee_Security_Vote_IAccessDecisionVoter { +interface IAccessDecisionVoter { const ACCESS_GRANTED = 1; const ACCESS_ABSTAIN = 0; Modified: trunk/framework/Bee/Security/Vote/RoleVoter.php =================================================================== --- trunk/framework/Bee/Security/Vote/RoleVoter.php 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/Bee/Security/Vote/RoleVoter.php 2015-02-16 08:02:59 UTC (rev 282) @@ -1,6 +1,7 @@ <?php +namespace Bee\Security\Vote; /* - * Copyright 2008-2010 the original author or authors. + * Copyright 2008-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +45,7 @@ * All comparisons and prefixes are case sensitive. * */ -class Bee_Security_Vote_RoleVoter implements Bee_Security_Vote_IAccessDecisionVoter { +class RoleVoter implements IAccessDecisionVoter { private $rolePrefix = "ROLE_"; @@ -65,14 +66,28 @@ $this->rolePrefix = $rolePrefix; } + /** + * @param IConfigAttribute $configAttribute + * @return bool + */ public function supports(IConfigAttribute $configAttribute) { return Strings::startsWith($configAttribute->getAttribute(), $this->rolePrefix); } + /** + * @param $className + * @return bool + */ public function supportsClass($className) { return true; } + /** + * @param IAuthentication $authentication + * @param mixed $object + * @param ConfigAttributeDefinition $config + * @return int + */ public function vote(IAuthentication $authentication, $object, ConfigAttributeDefinition $config) { $result = self::ACCESS_ABSTAIN; @@ -89,7 +104,11 @@ return $result; } - + + /** + * @param IAuthentication $authentication + * @return string[] + */ protected function extractAuthorities(IAuthentication $authentication) { return $authentication->getAuthorities(); } Modified: trunk/framework/acl-default.xml =================================================================== --- trunk/framework/acl-default.xml 2015-02-12 09:08:08 UTC (rev 281) +++ trunk/framework/acl-default.xml 2015-02-16 08:02:59 UTC (rev 282) @@ -123,10 +123,10 @@ </constructor-arg> </bean> - <bean id="accessDecisionManager" class="Bee_Security_Vote_AffirmativeBased"> + <bean id="accessDecisionManager" class="Bee\Security\Vote\AffirmativeBased"> <property name="decisionVoters"> <array> - <bean class="Bee_Security_Vote_RoleVoter"/> + <bean class="Bee\Security\Vote\RoleVoter"/> <ref bean="aclVoterRead" /> <ref bean="aclVoterWrite" /> <ref bean="aclVoterCreate" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |