Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace RD\RpcBase\Security\Authentication\Token;
- use TYPO3\FLOW3\Annotations as FLOW3;
- /**
- *
- */
- class UsernamePasswordRPC extends \TYPO3\FLOW3\Security\Authentication\Token\AbstractToken {
- /**
- * @var \RD\RpcBase\Resource\RpcRequest
- */
- protected $rpcRequest;
- /**
- * The username/password credentials
- * @var array
- * @FLOW3\Transient
- */
- protected $credentials = array('username' => '', 'password' => '');
- /**
- * Initializes the object
- *
- * @return void
- */
- public function initializeObject() {
- $entryPoint = new \RD\RpcBase\Security\Authentication\EntryPoint\RPCCall();
- $this->setAuthenticationEntryPoint($entryPoint);
- }
- /**
- * Updates the username and password credentials from the HTTP authorization header.
- * Sets the authentication status to AUTHENTICATION_NEEDED, if the header has been
- * sent, to NO_CREDENTIALS_GIVEN if no authorization header was there.
- *
- * @param \TYPO3\FLOW3\Http\Request $request The current action request
- * @return void
- */
- public function updateCredentials(\TYPO3\FLOW3\Http\Request $request) {
- $this->rpcRequest = new \RD\RpcBase\Resource\RpcRequest(file_get_contents('php://input'));
- if (isset($this->rpcRequest->getCurrentParams()->username) && isset($this->rpcRequest->getCurrentParams()->password)) {
- $this->credentials['username'] = $this->rpcRequest->getCurrentParams()->username;
- $this->credentials['password'] = $this->rpcRequest->getCurrentParams()->password;
- $this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED);
- }
- }
- /**
- * Returns a string representation of the token for logging purposes.
- *
- * @return string The username credential
- */
- public function __toString() {
- return 'Username: "' . $this->credentials['username'] . '"';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement