Register the frontend user as aspect

@param Context $context
@param AbstractUserAuthentication $user
493907
protected function setFrontendUserAspect(Context $context, AbstractUserAuthentication $user)
    {
        $context->setAspect('frontend.user', GeneralUtility::makeInstance(UserAspect::class, $user));
    }
305106
@Transactional
	public OAuthSessionContextEntity create(final UserEntity user, final OAuthServiceEntity service, final String scope)
	{
		// Create a new context
		OAuthSessionContextEntity entity = get(user.getId(), service.getId(), scope);

		// No active context exists, we must create one
		if (entity == null)
		{
			entity = new OAuthSessionContextEntity();

			entity.setUser(user);
			entity.setScope(StringUtils.trimToEmpty(scope));
			entity.setService(service);
			entity.setActive(true);

			entity.setId(save(entity));
		}

		return entity;
	}
826130
public function handleLogin(UserEntity $user)
    {
        $accessToken = new AccessToken($this->tokenStorage, $this->tokenStorage);
        $token = $accessToken->createAccessToken('', $user->getId(), null, true);

        return $token;
    }
1090176
public function authenticate(SecurityContextInterface &$context) {

        $token = $this->generateEmptyToken($this->getSession());

        try {
            $this->userAuthenticationProvider->loadClientByCredentials($token->getClient()->getCredentials());
        } catch (ClientCredentialsNotFoundException $e) {

            $this->logger->addAlert('Client not found ' . $e->getMessage());
            throw $e;
        }

        //validate the client, if good then add to the context
        if (true) {
            $context->setToken($token);
        }
    }
863178
public function encryptUserData(AbstractUser $user)
    {
        // data (we use short syntax to reduce the size of the cookie or session)
        $data = [
            // username
            'u'  => $user->getUsername(),
            // valid until
            'vu' => time() + $this->getTokenTtl(),
            // auth provider driver
            'ap' => $user->getAuthProviderName(),
            // user provider driver
            'up' => $user->getUserProviderName()
        ];

        // build and add token to $data
        $token = $this->getCrypt()->encrypt($this->jsonEncode($data), $this->getEncryptionKey());
        $token = urlencode(rtrim($token, '='));

        return $token;
    }
1062948
public function registerUser(BaseUser $user, $source = self::SOURCE_TYPE_WEBSITE)
    {
        $user->setRoles(["ROLE_USER"])
            ->setSource($source)
            ->setEnabled(true);

        $this->saveUserWithPlainPassword($user);

        $this->dispatcher->dispatch(self::REGISTER_EVENT, new UserEvent($user));

        return $user;
    }
1103805
protected function _beforeSend(DispatcherContext $context)
    {
        foreach($this->__authenticator_queue as $authenticator)
        {
            if($authenticator->challengeResponse($context) === true) {
                break;
            }
        }
    }
449349
public function challengeResponse(DispatcherContext $context)
    {
        $response = $context->getResponse();

        //The response MUST include a WWW-Authenticate header field.
        if($response->getStatusCode() == HttpResponse::UNAUTHORIZED) {
            $response->headers->set('Www-Authenticate', ucfirst($this->getScheme()).' realm="'.$this->getRealm().'"', false);
        }
    }
89508
protected static function export_data($context, $user) {
        if (!$context) {
            return;
        }
        $contextdata = helper::get_context_data($context, $user);
        helper::export_context_files($context, $user);
        writer::with_context($context)->export_data([], $contextdata);
    }
1333760
public static RenderingContext user(final ApplicationInfo appInfo) {
        final UserImpl user2 = new UserImpl();
        user2.setUsername("User");
        user2.setFirstname("Ursula");
        user2.setLastname("User");
        user2.clearRoles();
        user2.addRole("USER");
        return new RenderingContext(user2, appInfo, new CalendarProviderStub());
    }
520229
public function sendRegisteredEmailMessage($user)
    {
        $templateName = 'CoreBundle:Email:registration.email.html.twig';
        $contractPath = null;
        $context = array(
            'user' => $user
        );

        $this->sendMessage(
                    $templateName, 
                    $context, 
                    $this->twigGlobal->getParameter('admin_email'), 
                    $user->getEmail()
//                    $contractPath
                    );
    }
1051477
public function authenticateRequest(DispatcherContext $context)
    {
        if($token = $this->getToken())
        {
            if($token->verify($this->getSecret()))
            {
                $user = $token->getSubject();
                $data = (array) $token->getClaim('user');

                //Ensure the token is not expired
                if($this->_check_expire)
                {
                    if(!$token->getExpireTime() || $token->isExpired()) {
                        throw new ControllerExceptionRequestNotAuthenticated('Token Expired');
                    }
                }

                //Ensure the token is not too old
                if($this->_check_age)
                {
                    if (!$token->getIssueTime() || $token->getAge() > $this->_max_age) {
                        throw new ControllerExceptionRequestNotAuthenticated('Token Expired');
                    }
                }
                //Ensure the user exists
                if($this->_check_user)
                {
                    //Ensure we have a username
                    if(empty($user)) {
                        throw new ControllerExceptionRequestNotAuthenticated('Invalid User');
                    }

                    if($this->getObject('user.provider')->getUser($user)->getId() == 0) {
                        throw new ControllerExceptionRequestNotAuthenticated('User Not Found');
                    }
                }

                //Login the user
                return $this->loginUser($user, $data);
            }
            else throw new ControllerExceptionRequestNotAuthenticated('Invalid Token');
        }
    }
1225291
public function saveUserToken(AbstractUser $user)
    {
        return $this->httpCookie()->save($this->getTokenName(), $this->encryptUserData($user), $this->getTokenTtl());
    }
817555
private function loginUser(UserInterface $user, $request)
    {
        $token = new UsernamePasswordToken($user, null, 'admin', $user->getRoles());
        $this->get('security.token_storage')->setToken($token); //now the user is logged in

        //now dispatch the login event
        $event = new InteractiveLoginEvent($request, $token);
        $this->get('event_dispatcher')->dispatch('security.interactive_login', $event);
    }
324198
public function verifyResumeAuthorization(DeliveryExecutionInterface $deliveryExecution, User $user)
    {
        foreach ($this->getProviders() as $provider) {
            $provider->verifyResumeAuthorization($deliveryExecution, $user);
        }
        $this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger(new DeliveryExecutionVerified($deliveryExecution));
    }
793093
public function register( $context = null ) {
		if ( ! $this->is_needed() ) {
			return;
		}

		\shortcode_ui_register_for_shortcode(
			$this->shortcode_tag,
			$this->config
		);
	}
1278295
public static function delete_data_for_all_users_in_context(\context $context) {
        // Only delete data for a user context.
        if ($context->contextlevel == CONTEXT_USER) {
            static::delete_user_data($context->instanceid, $context);
        }
    }