@EXT\Route("/{badge}/assertion", name="apiv2_badge-class_assertion")
@EXT\Method("GET")
@EXT\ParamConverter("badge", class="ClarolineOpenBadgeBundle:BadgeClass", options={"mapping": {"badge": "uuid"}})

@return JsonResponse
761894
public function getAssertionsAction(Request $request, BadgeClass $badge)
    {
        return new JsonResponse(
            $this->finder->search(Assertion::class, array_merge(
                $request->query->all(),
                ['hiddenFilters' => ['badge' => $badge->getUuid(), 'revoked' => false]]
            ))
        );
    }
721941
public function cgetAction()
    {
        /** @var WebspaceManagerInterface $webspaceManager */
        $webspaceManager = $this->get('sulu_core.webspace.webspace_manager');

        $localizations = [];
        $locales = [];

        /** @var Webspace $webspace */
        foreach ($webspaceManager->getWebspaceCollection() as $webspace) {
            $i = 0;
            foreach ($webspace->getAllLocalizations() as $localization) {
                if (!in_array($localization->getLocale(), $locales)) {
                    $locales[] = $localization->getLocale();
                    $localizations[] = [
                        'localization' => $localization->getLocale(),
                        'name' => $localization->getLocale(Localization::DASH),
                        'id' => $i++,
                    ];
                }
            }
        }

        $data = [
            '_embedded' => $localizations,
            'total' => count($localizations),
        ];

        return new JsonResponse($data);
    }
157192
public function deserialize($data, BadgeClass $badge = null, array $options = [])
    {
        $this->sipe('name', 'setName', $data, $badge);
        $this->sipe('description', 'setDescription', $data, $badge);
        $this->sipe('criteria', 'setCriteria', $data, $badge);
        $this->sipe('duration', 'setDurationValidation', $data, $badge);
        $this->sipe('issuingMode', 'setIssuingMode', $data, $badge);

        if (isset($data['issuer'])) {
            $badge->setIssuer($this->om->getObject($data['issuer'], Organization::class));
        }

        if (isset($data['image']) && isset($data['image']['id'])) {
            $thumbnail = $this->om->getObject($data['image'], PublicFile::class);
            $badge->setImage($data['image']['url']);
            $this->fileUt->createFileUse(
                $thumbnail,
                BadgeClass::class,
                $badge->getUuid()
            );
        }

        if (isset($data['workspace']) && isset($data['workspace']['id'])) {
            $workspace = $this->om->getRepository(Workspace::class)->find($data['workspace']['id']);
            $badge->setWorkspace($workspace);
            //main orga maybe instead ? this is fishy
            $badge->setIssuer($workspace->getOrganizations()[0]);
        }

        if (isset($data['tags'])) {
            if (is_string($data['tags'])) {
                $this->deserializeTags($badge, explode(',', $data['tags']));
            } else {
                $this->deserializeTags($badge, $data['tags']);
            }
        }

        if (isset($data['allowedUsers'])) {
            $allowed = [];
            foreach ($data['allowedUsers'] as $user) {
                $allowed[] = $this->om->getObject($user, User::class);
            }
            $badge->setAllowedIssuers($allowed);
        }

        if (isset($data['allowedGroups'])) {
            $allowed = [];
            foreach ($data['allowedGroups'] as $group) {
                $allowed[] = $this->om->getObject($group, Group::class);
            }
            $badge->setAllowedIssuersGroups($allowed);
        }

        return $badge;
    }
109899
protected function getTokenData() {
    $result = null;

    $request = ObjectFactory::getInstance('request');
    $token = $request->hasHeader(self::TOKEN_HEADER) ?
        trim(str_replace(self::AUTH_TYPE, '', $request->getHeader(self::TOKEN_HEADER))) : $this->token;
    if ($token !== null) {
      $jwt = (new Parser())->parse((string)$token);

      // validate
      $data = new ValidationData();
      $data->setIssuer($this->getTokenIssuer());
      if ($jwt->validate($data) && $jwt->verify($this->getTokenSigner(), $this->key)) {
        $result = $jwt->getClaims();
      }
    }
    return $result;
  }
48102
public function token()
    {
        try {
            $response = $this->oauthServer->respondToAccessTokenRequest($this->request, new Response());

            $this->pruneTokens();

            return $response;
        } catch (\Exception $e) {
            // Rethrow the exception
            throw $e;
        }
    }
1247486
public function get($userId, $badgeId, $optParams = array()) {
      $params = array('userId' => $userId, 'badgeId' => $badgeId);
      $params = array_merge($params, $optParams);
      $data = $this->__call('get', array($params));
      if ($this->useObjects()) {
        return new Badge($data);
      } else {
        return $data;
      }
    }
1365206
public function authenticateAction()
    {
        if ($this->zfcUserAuthentication()->getAuthService()->hasIdentity()) {
            return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }
        $adapter = $this->zfcUserAuthentication()->getAuthAdapter();
        $redirect = $this->params()->fromPost('redirect', $this->params()->fromQuery('redirect', false));
        
        $routeLoginAdmin = $this->params()->fromPost('routeLoginAdmin', $this->params()->fromQuery('routeLoginAdmin', false));

        $result = $adapter->prepareForAuthentication($this->getRequest());

        // Return early if an adapter returned a response
        if ($result instanceof Response) {
            return $result;
        }

        $auth = $this->zfcUserAuthentication()->getAuthService()->authenticate($adapter);

        if (!$auth->isValid()) {
            $this->flashMessenger()->setNamespace('zfcuser-login-form')->addMessage($this->failedLoginMessage);
            $adapter->resetAdapters();

            if (!empty($routeLoginAdmin)) {
                return $this->redirect()->toUrl($routeLoginAdmin);
            }

            return $this->redirect()->toUrl(
                $this->url()->fromRoute('frontend/zfcuser/login')
                . ($redirect ? '?redirect='.$redirect : '')
            );
        }

        $user = $this->zfcUserAuthentication()->getIdentity();
        $this->getEventManager()->trigger('login.post', $this, array('user' => $user));

        if ($this->getOptions()->getUseRedirectParameterIfPresent() && $redirect) {
            return $this->redirect()->toUrl($redirect);
        }

        return $this->redirect()->toUrl(
            $this->url()->fromRoute(
                $this->getOptions()->getLoginRedirectRoute()
            )
        );
    }
234216
public function getOAuth()
    {
        if ($this->oauthResponse instanceof InstagramOAuth) {
            return $this->oauthResponse;
        }

        $accessToken = new stdClass;
        $accessToken->access_token = null;

        $this->oauthResponse = new InstagramOAuth($accessToken);

        return $this->oauthResponse;
    }
659780
public function getBearerToken()
    {
        $this->response = $this->twitter->oauth2_token();

        if ($this->responseOk()) {
            return $this->response->access_token;
        }

        $this->triggerError("Unable to get bearer token.", $this->response);
    }
1097875
function newService()
    {
        # Check Debug Mode:

        if ( $this->debugMode )
            // Mock Debug Mode
            return new AssertDebugTokenAction($this->debugToken);


        if ($this->tokenAssertion)
            $assertion = $this->tokenAssertion;

        else throw new \RuntimeException('Token Assertion Provider Not Injected.');

        $assertAction = new AssertTokenAction($assertion);
        return $assertAction;
    }
110459
public function authenticate()
    {
        $e = $this->getEvent();

        $result = new Result(
            $e->getCode(),
            $e->getIdentity(),
            $e->getMessages()
        );

        $this->resetAdapters();

        return $result;
    }
331802
function assertTokenParams()
    {
        # Assert Params

        if ( null === $this->getClientId() || null === $this->getClientSecret() )
            throw new exMissingGrantRequestParams('Request Param "client_id" & "client_secret" must Set.');

        if ( null === $this->getToken() && null === $this->getRefreshToken() )
            throw new exMissingGrantRequestParams('Request Param "token" or "refresh_token" must Set.');


        # Build Request Params

        $params = $this->__toArray();
        return $params;
    }
719686
private function getToken()
    {
        $vars = array(
            'method' => 'auth.getToken',
            'api_key' => $this->apiKey
        );

        $sig = $this->apiSig($this->apiSecret, $vars);
        $vars['api_sig'] = $sig;

        if ($call = $this->apiGetCall($vars)) {
            $this->token = $call->token;
        } else {
            return false;
        }
    }
779927
public function getDepartment(){
	    if (!$this->access_token && !$this->checkAuth()) return false;
	    $result = $this->http_get(self::API_URL_PREFIX.self::DEPARTMENT_LIST_URL.'access_token='.$this->access_token);
	    if ($result)
	    {
	        $json = json_decode($result,true);
	        if (!$json || !empty($json['errcode'])) {
	            $this->errCode = $json['errcode'];
	            $this->errMsg = $json['errmsg'];
	            return false;
	        }
	        return $json;
	    }
	    return false;
	}
914661
public function getBadgeAction(BadgeClass $badge)
    {
        return new JsonResponse($this->serializer->serialize($badge, [Options::ENFORCE_OPEN_BADGE_JSON]));
    }
1095621
public function assertResponseBodyIsAnEmptyJsonArray() {
        $this->requireResponse();

        try {
            Assertion::same(
                [],
                $body = $this->getResponseBodyArray(),
                sprintf('Expected response body to be an empty JSON array, got "%s".', json_encode($body, JSON_PRETTY_PRINT))
            );
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
691645
public function build()
    {
        $params = [
            'badge' => $this->badge,
            'alert' => $this->alert,
            'sound' => $this->sound,
            'category' => $this->category,
            'expiry' => $this->expiryDate ? $this->expiryDate->format('c') : null,
            'custom_uri' => $this->uri,
            'message_variation_id' => $this->messageVariationId,
            'asset_url' => $this->assetUrl,
            'asset_file_type' => $this->assetFileType,
        ];

        if (!empty($this->extra)) {
            $params['extra'] = $this->extra;
        }

        return array_filter($params, function ($param) {
            return $param !== null;
        });
    }