Create endpoints for google issuers.
@param issuer $issuer issuer the endpoints should be created for.
@return mixed
@throws \coding_exception
@throws \core\invalid_persistent_exception
420202
private static function create_endpoints_for_google($issuer) {

        $record = (object) [
            'issuerid' => $issuer->get('id'),
            'name' => 'discovery_endpoint',
            'url' => 'https://accounts.google.com/.well-known/openid-configuration'
        ];
        $endpoint = new endpoint(0, $record);
        $endpoint->create();
        return $issuer;
    }
254884
public static function create_endpoints_for_standard_issuer($type, $issuer) {
        require_capability('moodle/site:config', context_system::instance());
        if ($type == 'google') {
            $issuer = self::create_endpoints_for_google($issuer);
            self::discover_endpoints($issuer);
            return $issuer;
        } else if ($type == 'microsoft') {
            return self::create_endpoints_for_microsoft($issuer);
        } else if ($type == 'facebook') {
            return self::create_endpoints_for_facebook($issuer);
        } else if ($type == 'nextcloud') {
            return self::create_endpoints_for_nextcloud($issuer);
        } else {
            throw new moodle_exception('OAuth 2 service type not recognised: ' . $type);
        }
    }
1272087
private static String constructOpenIdUrl(String issuer) {
    String url = issuer;
    if (!URI.create(issuer).isAbsolute()) {
      // Use HTTPS if the protocol scheme is not specified in the URL.
      url = HTTPS_PROTOCOL_PREFIX + issuer;
    }
    if (!url.endsWith("/")) {
      url += "/";
    }
    return url + OPEN_ID_CONFIG_PATH;
  }
160821
public function getCountries()
    {
        if (!isset($this->_issuerData))
            throw new Exception("Issuer must be selected first");
        $countries = array();
        foreach ($this->_issuerData["Countries"] as $country) {
            array_push($countries, $country["CountryCode"]);
        }
        return $countries;
    }
373839
protected function buildIssueAdapter($name)
    {
        $issueAdapter = $this
            ->getApplication()
            ->getAdapterFactory()
            ->createIssueTracker(
                $name,
                $this->getConfig()->get(
                    ['adapters', $name],
                    \Gush\Config::CONFIG_SYSTEM
                ),
                $this->getConfig()
            );
        $issueAdapter->authenticate();

        return $issueAdapter;
    }
1346046
public static function send_confirm_account_email($userinfo, $issuer) {
        global $CFG, $DB;
        require_once($CFG->dirroot.'/user/profile/lib.php');
        require_once($CFG->dirroot.'/user/lib.php');

        if (linked_login::has_existing_issuer_match($issuer, $userinfo['username'])) {
            throw new moodle_exception('alreadylinked', 'auth_oauth2');
        }

        $user = new stdClass();
        $user->username = $userinfo['username'];
        $user->email = $userinfo['email'];
        $user->auth = 'oauth2';
        $user->mnethostid = $CFG->mnet_localhost_id;
        $user->lastname = isset($userinfo['lastname']) ? $userinfo['lastname'] : '';
        $user->firstname = isset($userinfo['firstname']) ? $userinfo['firstname'] : '';
        $user->url = isset($userinfo['url']) ? $userinfo['url'] : '';
        $user->alternatename = isset($userinfo['alternatename']) ? $userinfo['alternatename'] : '';
        $user->secret = random_string(15);

        $user->password = '';
        // This user is not confirmed.
        $user->confirmed = 0;

        $user->id = user_create_user($user, false, true);

        // The linked account is pre-confirmed.
        $record = new stdClass();
        $record->issuerid = $issuer->get('id');
        $record->username = $userinfo['username'];
        $record->userid = $user->id;
        $record->email = $userinfo['email'];
        $record->confirmtoken = '';
        $record->confirmtokenexpires = 0;

        $linkedlogin = new linked_login(0, $record);
        $linkedlogin->create();

        // Construct the email.
        $site = get_site();
        $supportuser = \core_user::get_support_user();
        $user = get_complete_user_data('id', $user->id);

        $data = new stdClass();
        $data->fullname = fullname($user);
        $data->sitename  = format_string($site->fullname);
        $data->admin     = generate_email_signoff();

        $subject = get_string('confirmaccountemailsubject', 'auth_oauth2', format_string($site->fullname));

        $params = [
            'token' => $user->secret,
            'username' => $userinfo['username']
        ];
        $confirmationurl = new moodle_url('/auth/oauth2/confirm-account.php', $params);

        $data->link = $confirmationurl->out(false);
        $message = get_string('confirmaccountemail', 'auth_oauth2', $data);

        $data->link = $confirmationurl->out();
        $messagehtml = text_to_html(get_string('confirmaccountemail', 'auth_oauth2', $data), false, false, true);

        $user->mailformat = 1;  // Always send HTML version as well.

        // Directly email rather than using the messaging system to ensure its not routed to a popup or jabber.
        email_to_user($user, $supportuser, $subject, $message, $messagehtml);
        return $user;
    }
895838
def issuer(self):
        """"""
        return Subject([(s.oid, s.value) for s in self.x509.issuer])
1032408
public function createLogoutRequest()
    {
        return (new LogoutRequest())
            ->setID(Helper::generateID())
            ->setVersion(SamlConstants::VERSION_20)
            ->setIssueInstant(new \DateTime())
            ->setIssuer(new Issuer($this->getMetadata()->getServiceProvider()->getEntityID()));
    }
1056885
public function create(array $data, $debtor)
    {
        $debtors = new Debtor($this->client_raw);
        $debtorHandle = $debtors->getHandle($debtor);

        $id = $this->client
            ->DebtorContact_Create(array(
                'debtorHandle' => $debtorHandle,
                'name'         => $data['name']
            ))->DebtorContact_CreateResult;

        return $this->update($id->Id, $data);
    }
1163736
public function createTotp($identifier, $issuer = null)
    {
        $totp = $this->factory->createTotp($identifier, $issuer);

        return $totp;
    }
1323288
protected static function guess_image($issuer) {
        if (empty($issuer->get('image')) && !empty($issuer->get('baseurl'))) {
            $baseurl = parse_url($issuer->get('baseurl'));
            $imageurl = $baseurl['scheme'] . '://' . $baseurl['host'] . '/favicon.ico';
            $issuer->set('image', $imageurl);
            $issuer->update();
        }
    }
584972
private function is_ready_for_login_page(\core\oauth2\issuer $issuer) {
        return $issuer->get('enabled') &&
                $issuer->is_configured() &&
                !empty($issuer->get('showonloginpage'));
    }
1269638
@Override
    public Builder issuer(String issuerUrl) throws InvalidClaimException {
        if (issuerUrl != null && !issuerUrl.isEmpty()) {
            claims.put(Claims.ISSUER, issuerUrl);
        } else {
            String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_ERR", new Object[] { Claims.ISSUER, issuerUrl });
            throw new InvalidClaimException(err);
        }
        return this;
    }
1085665
def _possible_issuers(self, cert):
        

        issuer_hashable = cert.issuer.hashable
        if issuer_hashable not in self._subject_map:
            return

        for issuer in self._subject_map[issuer_hashable]:
            # Info from the authority key identifier extension can be used to
            # eliminate possible options when multiple keys with the same
            # subject exist, such as during a transition, or with cross-signing.
            if cert.authority_key_identifier and issuer.key_identifier:
                if cert.authority_key_identifier != issuer.key_identifier:
                    continue
            elif cert.authority_issuer_serial:
                if cert.authority_issuer_serial != issuer.issuer_serial:
                    continue

            yield issuer
1006490
function setIssuerException(/*callable*/ $callable)
    {
        if (!is_callable($callable))
            throw new \InvalidArgumentException(sprintf(
                'Issuer must be callable; given: (%s).'
                , \Poirot\Std\flatten($callable)
            ));
        
        $this->issuer_exception = $callable;
        return $this;
    }
1263310
public Assertion newAssertion(final AuthnStatement authnStatement, final String issuer,
                                  final ZonedDateTime issuedAt, final String id) {
        val list = new ArrayList<Statement>();
        list.add(authnStatement);
        return newAssertion(list, issuer, issuedAt, id);
    }
742841
public function setWatchers($issue_key, array $watchers)
	{
		$result = array();

		foreach ( $watchers as $watcher ) {
			$result[] = $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/watchers', $issue_key), $watcher);
		}

		return $result;
	}