{@inheritDoc}

@throws SocialLoginException
963834
@Override
    public PrivateKey getPrivateKey() throws SocialLoginException {
        if (this.sslRefInfo == null) {
            SocialLoginService service = socialLoginServiceRef.getService();
            if (service == null) {
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, "Social login service is not available");
                }
                return null;
            }
            sslRefInfo = createSslRefInfoImpl(service);
        }
        return sslRefInfo.getPrivateKey();
    }
1051192
public function init($consumerKey, $consumerSecret, $oauthToken, $oauthTokenSecret, $bearerToken)
    {
        $this->twitter->setConsumerKey($consumerKey, $consumerSecret);

        if (! is_null($bearerToken)) {
            $this->setBearerToken($bearerToken);
        } elseif (! is_null($oauthToken) && ! is_null($oauthTokenSecret)) {
            $this->setToken($oauthToken, $oauthTokenSecret);
        } elseif ($this->hasSessionToken()) {
            $this->setSessionToken();
        }
    }
739838
public function index()
    {
        //  If already logged out just send them silently on their way
        if (!isLoggedIn()) {
            redirect('/');
        }

        // --------------------------------------------------------------------------

        //  Generate an event for this log in
        create_event('did_log_out');

        // --------------------------------------------------------------------------

        //  Log social media out
        $oSocial = Factory::service('SocialSignOn', 'nails/module-auth');
        $oSocial->logout();

        // --------------------------------------------------------------------------

        //  Log user out
        $oAuthModel = Factory::model('Auth', 'nails/module-auth');
        $oAuthModel->logout();

        // --------------------------------------------------------------------------

        redirect();
    }
854075
public static function logException (LoggerInterface $logger, Exception $exception)
  {
    $logger->error (sprintf ("%s, at %s(%s)", $exception->getMessage (),
      ErrorConsole::shortFileName ($exception->getFile ()), $exception->getLine ()));
  }
741294
public function verify()
	{
		// TODO check structure
		if($this->type != SocialRecord::TYPE_PLATFORM && $this->type != SocialRecord::TYPE_USER && $this->type != SocialRecord::TYPE_PAGE)
			throw new SocialRecordFormatException('invalid type value [' . $this->type . ']');
		
		if(!GID::isValid($this->globalID))
			throw new SocialRecordFormatException('invalid globalID value');
			
		if(!GID::isValid($this->platformGID))
			throw new SocialRecordFormatException('invalid platformGID value');
		
		if(!GID::verifyGID($this->personalPublicKey, $this->salt, $this->globalID))
			throw new SocialRecordFormatException('invalid globalID value');
		
		if(!XSDDateTime::isValid($this->datetime))
			throw new SocialRecordFormatException('invalid date value [' . $this->datetime . ']');
		
		/*if($this->)
			throw new SocialRecordFormatException('invalid value');
		*/
		
		return true;
	}
423421
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('config');
        $config = $config[self::CONFIG_KEY];

        if (is_null($config))
            throw new \RuntimeException(_('Config could not be found!'));

        FacebookSession::setDefaultApplication($config['appId'], $config['secret']);

        try {
            $helper = new FacebookCanvasLoginHelper();
            $session = $helper->getSession();

            $this->setAccessToken($session->getAccessToken());
        } catch (FacebookRequestException $ex) {
            StaticLogger::save($ex->__toString(), 'facebook.log');
        } catch (\Exception $ex) {
            StaticLogger::save($ex->__toString(), 'facebook.log');
        }

        return $session;
    }
1360335
public function beforeCompile(): void
	{
		$builder = $this->getContainerBuilder();

		if ($builder->getByType(User::class) === null) {
			throw new LogicException(sprintf('Service of type "%s" is needed. Please register it.', User::class));
		}

		if ($builder->getByType(EventDispatcherInterface::class) === null) {
			throw new LogicException(sprintf('Service of type "%s" is needed. Please register it.', EventDispatcherInterface::class));
		}

		$user = $builder->getDefinition($builder->getByType(User::class));
		$dispatcher = $builder->getDefinition($builder->getByType(EventDispatcherInterface::class));

		$user->addSetup('?->onLoggedIn[] = function() {?->dispatch(?, new ?(...func_get_args()));}', [
			'@self',
			$dispatcher,
			SecurityEvents::ON_LOGGED_IN,
			new PhpLiteral(LoggedInEvent::class),
		]);
		$user->addSetup('?->onLoggedOut[] = function() {?->dispatch(?, new ?(...func_get_args()));}', [
			'@self',
			$dispatcher,
			SecurityEvents::ON_LOGGED_OUT,
			new PhpLiteral(LoggedOutEvent::class),
		]);
	}
353920
public function boot($graph): NetworkInterface
    {
        switch (true) {
            case (is_a($graph, Graph::class)):
                break;
            case (is_file($graph)):
                $graph = Graph::loadFile($graph);
                break;
            case is_string($graph) && is_file($graph):
                $graph = Graph::loadFile($graph);
                break;
            case (is_string($graph)):
                $graph = Graph::loadString($graph);
                break;
            default:
                throw new InvalidTypeException(
                    "Graph has to be either a Graph object or a compatible definition file/string"
                );
        }

        $graph->on(self::EVENT_ADD, [$this, 'addNode']);
        $graph->on(self::EVENT_REMOVE, [$this, 'removeNode']);
        $graph->on(self::EVENT_ADD_EDGE, [$this, 'addEdge']);
        $graph->on(self::EVENT_REMOVE_EDGE, [$this, 'removeEdge']);

        /** @todo think of caching graphs here, maybe */
        $this->graph = $graph;
        $this->loadGraph($graph);

        return $this;
    }
615181
public function logException($messageException = null, $method = null, $line = null)
    {
        if (self::getConfig('log', 'exception')) {
            $this->logMessage("EXCEPTION", "Exception find : {$messageException} --- " . $this->__toString(), $method, $line);
        }
    }
722673
public static function socialRecordExists($globalID)
	{
		if(!GID::isValid($globalID))
		{
			throw new \Exception('Illegal GID format');
		}
		
		try
		{
			$result = GSLS::getSocialRecord($globalID);
		}
		catch (SocialRecordNotFoundException $e)
		{
			return false;
		}
		
		return true;
	}
966850
public function initSdk() {
    $class_name = '\Facebook\Facebook';

    if (!class_exists($class_name)) {
      throw new SocialApiException(sprintf('The PHP SDK for Facebook could not be found. Class: %s.', $class_name));
    }

    if (!$this->validateConfig($this->settings)) {
      return FALSE;
    }

    $settings = [
      'app_id' => $this->settings->getAppId(),
      'app_secret' => $this->settings->getAppSecret(),
      'default_graph_version' => 'v' . $this->settings->getGraphVersion(),
      'persistent_data_handler' => $this->getDataHandler(),
    ];

    return new $class_name($settings);
  }
1224531
public function setLoggerInstance(LoggerInterface $LogInterface = null)
    {
        $this->oLog = $LogInterface ?? new \Psr\Log\NullLogger();

        return $this;
    }
462463
public function build()
	{
		if($this->displayName == NULL)
			throw new SocialRecordFormatException('SocialRecord: displayName must be specified for instantiation');
		if($this->profileLocation == NULL)
			throw new SocialRecordFormatException('SocialRecord: profileLocation must be specified for instantiation');
		if($this->personalPublicKey == NULL)
			throw new SocialRecordFormatException('SocialRecord: personalPublicKey must be specified for instantiation');
		if($this->accountPublicKey == NULL)
			throw new SocialRecordFormatException('SocialRecord: accountPublicKey must be specified for instantiation');
		if($this->type == NULL)
			throw new SocialRecordFormatException('SocialRecord: type must be specified for instantiation');
		
		if($this->type != SocialRecord::TYPE_PLATFORM && $this->type != SocialRecord::TYPE_USER && $this->type != SocialRecord::TYPE_PAGE)
			throw new SocialRecordFormatException('SocialRecord: Invalid type value [' . $this->type . ']');
		
		if($this->salt == NULL)
			$this->salt = Random::getRandom(SocialRecord::SALT_CHARS/2);
		if($this->datetime == NULL)
			$this->datetime = XSDDateTime::getXSDDateTime();
		if($this->globalID == NULL)
			$this->globalID = GID::createGID($this->personalPublicKey, $this->salt);
		if(!GID::isValid($this->globalID))
			throw new SocialRecordFormatException('SocialRecord: Invalid globalID value [' . $this->globalID . ']');
			
		if($this->platformGID == NULL && $this->type == SocialRecord::TYPE_PLATFORM)
			$this->platformGID = $this->globalID;
		if($this->platformGID == NULL)
			throw new SocialRecordFormatException('SocialRecord: platformGID must be specified for instantiation');
		if(!GID::isValid($this->platformGID))
			throw new SocialRecordFormatException('SocialRecord: Invalid platformGID value [' . $this->platformGID . ']');
		
		if($this->keyRevocationList == NULL)
			$this->keyRevocationList = array();
		if($this->active == NULL)
			$this->active = 1;
		
		return new SocialRecord($this);
	}
336939
public function save(
        $data,
        $locale,
        $id = null,
        $patch = false,
        $flush = true
    ) {
        $username = $this->getProperty($data, 'username');
        $contactId = $this->getProperty($data, 'contactId');
        $contact = $this->getProperty($data, 'contact');
        $email = $this->getProperty($data, 'email');
        $password = $this->getProperty($data, 'password');
        $enabled = $this->getProperty($data, 'enabled');
        $locked = $this->getProperty($data, 'locked');
        $user = null;

        try {
            if ($id) {
                // update user
                $user = $this->userRepository->findUserById($id);
                if (!$user) {
                    throw new EntityNotFoundException($this->userRepository->getClassName(), $id);
                }
                $this->processEmail($user, $email);
            } else {
                // add user
                if (!$this->isValidPassword($password)) {
                    throw new MissingPasswordException();
                }
                /** @var UserInterface $user */
                $user = $this->userRepository->createNew();
                $this->processEmail($user, $email, $contact);
            }

            // check if username is already in database and the current user is not the user with this username
            if (!$patch || null !== $username) {
                if ($user->getUsername() != $username &&
                    !$this->isUsernameUnique($username)
                ) {
                    throw new UsernameNotUniqueException($username);
                }
                $user->setUsername($username);
            }

            // check if password is valid
            if (!$patch || null !== $password) {
                if ($this->isValidPassword($password)) {
                    $user->setSalt($this->generateSalt());
                    $user->setPassword(
                        $this->encodePassword($user, $password, $user->getSalt())
                    );
                }
            }

            if (!$patch || null !== $this->getProperty($data, 'userRoles')) {
                if (!$this->processUserRoles($user, $this->getProperty($data, 'userRoles', []))) {
                    throw new \Exception('Could not update dependencies!');
                }
            }

            if (!$patch || null !== $this->getProperty($data, 'userGroups')) {
                if (!$this->processUserGroups($user, $this->getProperty($data, 'userGroups', []))) {
                    throw new \Exception('Could not update dependencies!');
                }
            }

            if (!$patch || (null !== $contact || null !== $contactId)) {
                if ($contact && !$contactId) {
                    @trigger_error(
                        'Usage of the contact object to define the contact corresponding to the user is deprecated'
                        . ' since version 1.4 and will be removed in 2.0. Use the contactId query parameter instead.',
                        E_USER_DEPRECATED
                    );
                }
                $user->setContact($this->getContact($contactId ? $contactId : $contact['id']));
            }

            if (!$patch || null !== $locale) {
                $user->setLocale($locale);
            }

            if (null !== $enabled) {
                $user->setEnabled($enabled);
            }

            if (null !== $locked) {
                $user->setLocked($locked);
            }
        } catch (\Exception $re) {
            if (isset($user)) {
                $this->em->remove($user);
            }

            throw $re;
        }

        $this->em->persist($user);
        if ($flush) {
            $this->em->flush();
        }

        return $user;
    }
812462
@Override
  public void logException(LogLevel logLevel, Throwable throwable, Class clazz, String methodName) {
  }
434157
public function initSdk() {
    $class_name = '\Google_Client';

    if (!class_exists($class_name)) {
      throw new SocialApiException(sprintf('The PHP SDK for Google Services could not be found. Class: %s.', $class_name));
    }

    if (!$this->validateConfig($this->settings)) {
      return FALSE;
    }

    $client = new $class_name();
    $client->setClientId($this->settings->getClientId());
    $client->setClientSecret($this->settings->getClientSecret());

    return $client;
  }
134641
@Override
  public void logException(LogLevel logLevel, Throwable throwable, Class clazz, String methodName) {
    Logger logger = Logger.getLogger(clazz.getName());
    logger.logp(convertToJDK14Level(logLevel), clazz.getName(), "-", throwable.getMessage(), throwable);
  }