Revision: 262
http://sourceforge.net/p/beeframework/code/262
Author: m_plomer
Date: 2014-10-18 05:40:51 +0000 (Sat, 18 Oct 2014)
Log Message:
-----------
- some more namespacing
Modified Paths:
--------------
trunk/framework/Bee/Security/Helper.php
Modified: trunk/framework/Bee/Security/Helper.php
===================================================================
--- trunk/framework/Bee/Security/Helper.php 2014-10-18 05:11:17 UTC (rev 261)
+++ trunk/framework/Bee/Security/Helper.php 2014-10-18 05:40:51 UTC (rev 262)
@@ -1,5 +1,4 @@
<?php
-namespace Bee\Security;
/*
* Copyright 2008-2014 the original author or authors.
*
@@ -15,117 +14,122 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-use Bee\Security\Context\SecurityContextHolder;
-use Bee\Security\Exception\AuthenticationException;
+namespace Bee\Security {
+ use Bee\Security\Context\SecurityContextHolder;
+ use Bee\Security\Exception\AuthenticationException;
-/**
- * Class Helper
- * @package Bee\Security
- */
-class Helper {
-
/**
- * @var IAccessDecisionManager
+ * Class Helper
+ * @package Bee\Security
*/
- private static $accessDecisionManager;
+ class Helper {
- /**
- * @var IAfterInvocationManager
- */
- private static $afterInvocationProviderManager;
+ /**
+ * @var IAccessDecisionManager
+ */
+ private static $accessDecisionManager;
- /**
- * @var IUserDetailsService
- */
- private static $userDetailsService;
+ /**
+ * @var IAfterInvocationManager
+ */
+ private static $afterInvocationProviderManager;
- public static function construct(IAccessDecisionManager $accessDecisionManager = null,
- IAfterInvocationManager $afterInvocationProviderManager = null,
- IUserDetailsService $userDetailsService = null) {
- self::$accessDecisionManager = $accessDecisionManager;
- self::$afterInvocationProviderManager = $afterInvocationProviderManager;
- self::$userDetailsService = $userDetailsService;
- }
+ /**
+ * @var IUserDetailsService
+ */
+ private static $userDetailsService;
- /**
- * @return bool
- */
- public static function isAuthenticated() {
- $auth = SecurityContextHolder::getContext()->getAuthentication();
- return is_null($auth) ? false : $auth->isAuthenticated();
- }
+ public static function construct(IAccessDecisionManager $accessDecisionManager = null,
+ IAfterInvocationManager $afterInvocationProviderManager = null,
+ IUserDetailsService $userDetailsService = null) {
+ self::$accessDecisionManager = $accessDecisionManager;
+ self::$afterInvocationProviderManager = $afterInvocationProviderManager;
+ self::$userDetailsService = $userDetailsService;
+ }
- /**
- * @return array
- */
- public static function getRoles() {
- $auth = SecurityContextHolder::getContext()->getAuthentication();
- if (is_null($auth) || !$auth->isAuthenticated()) {
- return array();
+ /**
+ * @return bool
+ */
+ public static function isAuthenticated() {
+ $auth = SecurityContextHolder::getContext()->getAuthentication();
+ return is_null($auth) ? false : $auth->isAuthenticated();
}
- return (array_keys($auth->getAuthorities()));
- }
- /**
- * @param $role
- * @return bool
- * @throws AuthenticationException
- */
- public static function checkRole($role) {
- self::$accessDecisionManager->decide(
- self::getAuthIfAuthenticated(), null,
- new ConfigAttributeDefinition($role)
- );
- return true;
- }
+ /**
+ * @return array
+ */
+ public static function getRoles() {
+ $auth = SecurityContextHolder::getContext()->getAuthentication();
+ if (is_null($auth) || !$auth->isAuthenticated()) {
+ return array();
+ }
+ return (array_keys($auth->getAuthorities()));
+ }
- /**
- * @param $configAttribute
- * @param null $secureObject
- * @return bool
- * @throws AuthenticationException
- */
- public static function checkAccess($configAttribute, $secureObject = null) {
- self::$accessDecisionManager->decide(
- self::getAuthIfAuthenticated(), $secureObject,
- new ConfigAttributeDefinition($configAttribute)
- );
- return true;
- }
+ /**
+ * @param $role
+ * @return bool
+ * @throws AuthenticationException
+ */
+ public static function checkRole($role) {
+ self::$accessDecisionManager->decide(
+ self::getAuthIfAuthenticated(), null,
+ new ConfigAttributeDefinition($role)
+ );
+ return true;
+ }
- /**
- * @param $configAttribute
- * @param null $secureObject
- * @param null $returnedObject
- * @return mixed
- * @throws AuthenticationException
- */
- public static function checkResultAccess($configAttribute, $secureObject = null, $returnedObject = null) {
- return self::$afterInvocationProviderManager->decide(
- self::getAuthIfAuthenticated(), $secureObject,
- new ConfigAttributeDefinition($configAttribute), $returnedObject
- );
- }
+ /**
+ * @param $configAttribute
+ * @param null $secureObject
+ * @return bool
+ * @throws AuthenticationException
+ */
+ public static function checkAccess($configAttribute, $secureObject = null) {
+ self::$accessDecisionManager->decide(
+ self::getAuthIfAuthenticated(), $secureObject,
+ new ConfigAttributeDefinition($configAttribute)
+ );
+ return true;
+ }
- /**
- * @return mixed
- */
- public static function getPrincipal() {
- return self::getAuthIfAuthenticated()->getPrincipal();
- }
+ /**
+ * @param $configAttribute
+ * @param null $secureObject
+ * @param null $returnedObject
+ * @return mixed
+ * @throws AuthenticationException
+ */
+ public static function checkResultAccess($configAttribute, $secureObject = null, $returnedObject = null) {
+ return self::$afterInvocationProviderManager->decide(
+ self::getAuthIfAuthenticated(), $secureObject,
+ new ConfigAttributeDefinition($configAttribute), $returnedObject
+ );
+ }
- /**
- * @return IAuthentication
- * @throws AuthenticationException
- */
- private static function getAuthIfAuthenticated() {
- $auth = SecurityContextHolder::getContext()->getAuthentication();
- if (is_null($auth) || !$auth->isAuthenticated()) {
- throw new AuthenticationException('Not authenticated');
+ /**
+ * @return mixed
+ */
+ public static function getPrincipal() {
+ return self::getAuthIfAuthenticated()->getPrincipal();
}
- return $auth;
+
+ /**
+ * @return IAuthentication
+ * @throws AuthenticationException
+ */
+ private static function getAuthIfAuthenticated() {
+ $auth = SecurityContextHolder::getContext()->getAuthentication();
+ if (is_null($auth) || !$auth->isAuthenticated()) {
+ throw new AuthenticationException('Not authenticated');
+ }
+ return $auth;
+ }
}
+
}
-class SEC extends Helper {
-}
\ No newline at end of file
+namespace {
+ class SEC extends Bee\Security\Helper {
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|