[Beeframework-svn] SF.net SVN: beeframework:[204] trunk/framework/Bee
Brought to you by:
b_hartmann,
m_plomer
From: <m_p...@us...> - 2014-08-29 16:47:33
|
Revision: 204 http://sourceforge.net/p/beeframework/code/204 Author: m_plomer Date: 2014-08-29 16:47:25 +0000 (Fri, 29 Aug 2014) Log Message: ----------- - ported latest auth fixes from 0.9 branch to trunk Modified Paths: -------------- trunk/framework/Bee/MVC/View/JsonService.php trunk/framework/Bee/Security/AbstractAuthenticationManager.php trunk/framework/Bee/Security/AbstractAuthenticationToken.php trunk/framework/Bee/Security/IAuthentication.php trunk/framework/Bee/Security/IAuthenticationProvider.php trunk/framework/Bee/Security/Provider/AbstractUserDetailsAuthentication.php trunk/framework/Bee/Security/Provider/AnonymousAuthentication.php trunk/framework/Bee/Security/Provider/DaoAuthentication.php trunk/framework/Bee/Security/Provider/Manager.php trunk/framework/Bee/Security/UsernamePasswordAuthenticationToken.php Modified: trunk/framework/Bee/MVC/View/JsonService.php =================================================================== --- trunk/framework/Bee/MVC/View/JsonService.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/MVC/View/JsonService.php 2014-08-29 16:47:25 UTC (rev 204) @@ -33,5 +33,3 @@ echo json_encode(Bee_MVC_Model::getModelValues()); } } - -?> \ No newline at end of file Modified: trunk/framework/Bee/Security/AbstractAuthenticationManager.php =================================================================== --- trunk/framework/Bee/Security/AbstractAuthenticationManager.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/Security/AbstractAuthenticationManager.php 2014-08-29 16:47:25 UTC (rev 204) @@ -20,14 +20,14 @@ /** * Enter description here... * - * @var booelan + * @var boolean */ private $clearExtraInformation; public final function authenticate(Bee_Security_IAuthentication $authentication) { try { return $this->doAuthentication($authentication); - } catch (Bee_Security_AuthenticationException $e) { + } catch (Bee_Security_Exception_Authentication $e) { $e->setAuthentication($authentication); if ($this->clearExtraInformation) { @@ -43,7 +43,7 @@ * * @param Bee_Security_IAuthentication $authentication * - * @throws Bee_Security_AuthenticationException + * @throws Bee_Security_Exception_Authentication */ protected abstract function doAuthentication(Bee_Security_IAuthentication $authentication); @@ -60,5 +60,4 @@ $this->clearExtraInformation = $clearExtraInformation; } -} -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Security/AbstractAuthenticationToken.php =================================================================== --- trunk/framework/Bee/Security/AbstractAuthenticationToken.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/Security/AbstractAuthenticationToken.php 2014-08-29 16:47:25 UTC (rev 204) @@ -79,6 +79,4 @@ } return $principal; } - -} -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Security/IAuthentication.php =================================================================== --- trunk/framework/Bee/Security/IAuthentication.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/Security/IAuthentication.php 2014-08-29 16:47:25 UTC (rev 204) @@ -73,5 +73,9 @@ * @return void */ function setAuthenticated($authenticated); -} -?> \ No newline at end of file + + /** + * @return string + */ + function getName(); +} \ No newline at end of file Modified: trunk/framework/Bee/Security/IAuthenticationProvider.php =================================================================== --- trunk/framework/Bee/Security/IAuthenticationProvider.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/Security/IAuthenticationProvider.php 2014-08-29 16:47:25 UTC (rev 204) @@ -31,7 +31,7 @@ * <code>Authentication</code> object. In such a case, the next <code>AuthenticationProvider</code> that * supports the presented <code>Authentication</code> class will be tried. * - * @throws Bee_Security_AuthenticationException if authentication fails. + * @throws Bee_Security_Exception_Authentication if authentication fails. */ function authenticate(Bee_Security_IAuthentication $authentication); @@ -43,4 +43,3 @@ */ function supports($authenticationClass); } -?> \ No newline at end of file Modified: trunk/framework/Bee/Security/Provider/AbstractUserDetailsAuthentication.php =================================================================== --- trunk/framework/Bee/Security/Provider/AbstractUserDetailsAuthentication.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/Security/Provider/AbstractUserDetailsAuthentication.php 2014-08-29 16:47:25 UTC (rev 204) @@ -41,7 +41,7 @@ * @param Bee_Security_IUserDetails $userDetails * @param Bee_Security_UsernamePasswordAuthenticationToken $authentication * - * @throws Bee_Security_AuthenticationException + * @throws Bee_Security_Exception_Authentication */ protected abstract function additionalAuthenticationChecks(Bee_Security_IUserDetails $userDetails, Bee_Security_UsernamePasswordAuthenticationToken $authentication); @@ -67,12 +67,17 @@ } } - /** - * Enter description here... - * - * @param Bee_Security_IAuthentication $authentication - * @return Bee_Security_IAuthentication - */ + /** + * Enter description here... + * + * @param Bee_Security_IAuthentication $authentication + * @throws Bee_Security_Exception_AccountStatus + * @throws Bee_Security_Exception_Authentication + * @throws Bee_Security_Exception_BadCredentials + * @throws Bee_Security_Exception_UsernameNotFound + * @throws Exception + * @return Bee_Security_IAuthentication + */ public final function authenticate(Bee_Security_IAuthentication $authentication) { Bee_Utils_Assert::isInstanceOf('Bee_Security_UsernamePasswordAuthenticationToken', $authentication, 'Only UsernamePasswordAuthenticationToken is supported'); @@ -109,7 +114,7 @@ if ($cacheWasUsed) { // There was a problem, so try again after checking // we're using latest data (ie not from the cache) - $cacheWasUsed = false; +// $cacheWasUsed = false; $user = $this->retrieveUser($username, $authentication); $this->additionalAuthenticationChecks($user, $authentication); } else { @@ -138,12 +143,12 @@ * <p>Subclasses will usually store the original credentials the user supplied (not salted or encoded * passwords) in the returned <code>Bee_Security_IAuthentication</code> object.</p> * - * @param principal that should be the principal in the returned object (defined by the {@link + * @param mixed $principal that should be the principal in the returned object (defined by the {@link * #isForcePrincipalAsString()} method) - * @param authentication that was presented to the provider for validation - * @param user that was loaded by the implementation + * @param Bee_Security_IAuthentication $authentication that was presented to the provider for validation + * @param Bee_Security_IUserDetails $user that was loaded by the implementation * - * @return the successful authentication token + * @return Bee_Security_UsernamePasswordAuthenticationToken the successful authentication token */ protected function createSuccessAuthentication($principal, Bee_Security_IAuthentication $authentication, Bee_Security_IUserDetails $user) { // Ensure we return the original credentials the user supplied, @@ -231,6 +236,4 @@ public function setForcePrincipalAsString($forcePrincipalAsString) { $this->forcePrincipalAsString = $forcePrincipalAsString; } - } -?> \ No newline at end of file Modified: trunk/framework/Bee/Security/Provider/AnonymousAuthentication.php =================================================================== --- trunk/framework/Bee/Security/Provider/AnonymousAuthentication.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/Security/Provider/AnonymousAuthentication.php 2014-08-29 16:47:25 UTC (rev 204) @@ -22,7 +22,6 @@ * Time: 9:10:57 PM * To change this template use File | Settings | File Templates. */ - class Bee_Security_Provider_AnonymousAuthentication implements Bee_Security_IAuthenticationProvider { private $key; @@ -33,6 +32,7 @@ if (!$this->supports($authentication)) { return null; } + /** @var Bee_Security_AnonymousAuthenticationToken $authentication */ if (hash('md5', $this->key) != $authentication->getKeyHash()) { throw new Bee_Security_Exception_BadCredentials('The presented AnonymousAuthenticationToken does not contain the expected key'); @@ -53,4 +53,3 @@ return Bee_Utils_Types::isAssignable($authenticationClass, 'Bee_Security_AnonymousAuthenticationToken'); } } -?> \ No newline at end of file Modified: trunk/framework/Bee/Security/Provider/DaoAuthentication.php =================================================================== --- trunk/framework/Bee/Security/Provider/DaoAuthentication.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/Security/Provider/DaoAuthentication.php 2014-08-29 16:47:25 UTC (rev 204) @@ -137,4 +137,3 @@ $this->userDetailsService = $userDetailsService; } } -?> \ No newline at end of file Modified: trunk/framework/Bee/Security/Provider/Manager.php =================================================================== --- trunk/framework/Bee/Security/Provider/Manager.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/Security/Provider/Manager.php 2014-08-29 16:47:25 UTC (rev 204) @@ -28,7 +28,7 @@ /** * Enter description here... * - * @var array + * @var Bee_Security_IAuthenticationProvider[] */ private $providers = array(); @@ -128,5 +128,4 @@ public final function setSessionController(Bee_Security_Concurrent_ISessionController $sessionController) { $this->sessionController = $sessionController; } -} -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Security/UsernamePasswordAuthenticationToken.php =================================================================== --- trunk/framework/Bee/Security/UsernamePasswordAuthenticationToken.php 2014-08-29 16:30:19 UTC (rev 203) +++ trunk/framework/Bee/Security/UsernamePasswordAuthenticationToken.php 2014-08-29 16:47:25 UTC (rev 204) @@ -20,42 +20,42 @@ * */ class Bee_Security_UsernamePasswordAuthenticationToken extends Bee_Security_AbstractAuthenticationToken { - - private $credentials; - private $principal; - - /** - * Enter description here... - * - * @param mixed $principal - * @param mixed $credentials - * @param Bee_Security_IGrantedAuthority[] $authorities - */ - public function __construct($principal, $credentials, $authorities = null) { - parent::__construct($authorities); - $this->principal = $principal; - $this->credentials = $credentials; - parent::setAuthenticated(!is_null($authorities) ? true : false); - } - + private $credentials; + + private $principal; + + /** + * Enter description here... + * + * @param mixed $principal + * @param mixed $credentials + * @param Bee_Security_IGrantedAuthority[] $authorities + */ + public function __construct($principal, $credentials, $authorities = null) { + parent::__construct($authorities); + $this->principal = $principal; + $this->credentials = $credentials; + + parent::setAuthenticated(!is_null($authorities) ? true : false); + } + public function getPrincipal() { return $this->principal; } - + public function getCredentials() { return $this->credentials; } - + public function setAuthenticated($authenticated) { - if ($authenticated) { - throw new Exception("Cannot set this token to trusted - use constructor containing granted authority[]s instead"); - } - parent::setAuthenticated(false); + if ($authenticated) { + throw new Exception("Cannot set this token to trusted - use constructor containing granted authority[]s instead"); + } + parent::setAuthenticated(false); } - public function __toString() { - return 'Bee_Security_UsernamePasswordAuthenticationToken['.$this->principal.']'; - } -} -?> \ No newline at end of file + public function __toString() { + return 'Bee_Security_UsernamePasswordAuthenticationToken[' . $this->principal . ']'; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |