src/ServiceBus/Internal/WrapTokenManager.php
public function getAccessToken($targetUri)
    {
        Validate::isString($targetUri, '$targetUri');

        $this->_sweepExpiredTokens();
        $scopeUri = $this->_createScopeUri($targetUri);

        if (array_key_exists($scopeUri, $this->_activeTokens)) {
            $activeToken = $this->_activeTokens[$scopeUri];

            return $activeToken->getWrapAccessTokenResult()->getAccessToken();
        }

        $wrapAccessTokenResult = $this->_wrapRestProxy->wrapAccessToken(
            $this->_wrapUri,
            $this->_wrapName,
            $this->_wrapPassword,
            $scopeUri
        );

        $expirationDateTime = new \DateTime('now');
        $expiresIn = intval($wrapAccessTokenResult->getExpiresIn() / 2);
        $expirationDateTime = $expirationDateTime->add(
            new \DateInterval('PT'.$expiresIn.'S')
        );

        $acquiredActiveToken = new ActiveToken($wrapAccessTokenResult);
        $acquiredActiveToken->setExpirationDateTime($expirationDateTime);
        $this->_activeTokens[$scopeUri] = $acquiredActiveToken;

        return $wrapAccessTokenResult->getAccessToken();
    }
public function getAccessToken($targetUri)
    {
        Validate::isString($targetUri, '$targetUri');

        $this->_sweepExpiredTokens();
        $scopeUri = $this->_createScopeUri($targetUri);

        if (array_key_exists($scopeUri, $this->_activeTokens)) {
            $activeToken = $this->_activeTokens[$scopeUri];

            return $activeToken->getWrapAccessTokenResult()->getAccessToken();
        }

        $wrapAccessTokenResult = $this->_wrapRestProxy->wrapAccessToken(
            $this->_wrapUri,
            $this->_wrapName,
            $this->_wrapPassword,
            $scopeUri
        );

        $expirationDateTime = new \DateTime('now');
        $expiresIn = intval($wrapAccessTokenResult->getExpiresIn() / 2);
        $expirationDateTime = $expirationDateTime->add(
            new \DateInterval('PT'.$expiresIn.'S')
        );

        $acquiredActiveToken = new ActiveToken($wrapAccessTokenResult);
        $acquiredActiveToken->setExpirationDateTime($expirationDateTime);
        $this->_activeTokens[$scopeUri] = $acquiredActiveToken;

        return $wrapAccessTokenResult->getAccessToken();
    }
public function getAccessToken ( $ targetUri ) { Validate :: isString ( $ targetUri , '$targetUri' ) ; $ this -> _sweepExpiredTokens ( ) ; $ scopeUri = $ this -> _createScopeUri ( $ targetUri ) ; if ( array_key_exists ( $ scopeUri , $ this -> _activeTokens ) ) { $ activeToken = $ this -> _activeTokens [ $ scopeUri ] ; return $ activeToken -> getWrapAccessTokenResult ( ) -> getAccessToken ( ) ; } $ wrapAccessTokenResult = $ this -> _wrapRestProxy -> wrapAccessToken ( $ this -> _wrapUri , $ this -> _wrapName , $ this -> _wrapPassword , $ scopeUri ) ; $ expirationDateTime = new \ DateTime ( 'now' ) ; $ expiresIn = intval ( $ wrapAccessTokenResult -> getExpiresIn ( ) / 2 ) ; $ expirationDateTime = $ expirationDateTime -> add ( new \ DateInterval ( 'PT' . $ expiresIn . 'S' ) ) ; $ acquiredActiveToken = new ActiveToken ( $ wrapAccessTokenResult ) ; $ acquiredActiveToken -> setExpirationDateTime ( $ expirationDateTime ) ; $ this -> _activeTokens [ $ scopeUri ] = $ acquiredActiveToken ; return $ wrapAccessTokenResult -> getAccessToken ( ) ; }
Gets WRAP access token with specified target Uri.

@param string $targetUri The target Uri of the WRAP access Token

@return string
Gets WRAP access token with specified target Uri .