Iterates a JSON object containing authorization challenges and builds a list of reals.

@param jsonChallenges Collection of challenges.
@return Array with realms.
553415
private ArrayList<String> getRealmsFromJson(JSONObject jsonChallenges) {
        Iterator<String> challengesIterator = jsonChallenges.keys();
        ArrayList<String> challenges = new ArrayList<>();

        while (challengesIterator.hasNext()) {
            challenges.add(challengesIterator.next());
        }

        return challenges;
    }
377140
public void sendChallenge(UserRealm realm,
                              HttpResponse response)
        throws IOException
    {
        response.setField(HttpFields.__WwwAuthenticate,
                          "basic realm=\""+realm.getName()+'"');
        response.sendError(HttpResponse.__401_Unauthorized);
    }
939878
public ImmutableList<RoleInfo> getRoles() {
        TypeReference<List<RoleInfo>> typeReference = new TypeReference<List<RoleInfo>>() { };
        
        String errorMessage = String.format("Failed to retrieve roles from Conqueso server: %s",
                conquesoUrl.toExternalForm());
        
        return ImmutableList.copyOf(readObjectFromJson(typeReference, "/api/roles", errorMessage));
    }
580193
public static List<ReqUrl> getUrlListFromValidationDatas(List<ValidationData> datas) {
        Map<String, ReqUrl> urlMap = new HashMap<>();
        datas.stream().forEach(data -> {
            ReqUrl url = new ReqUrl(data);
            urlMap.put(url.getUniqueKey(), url);
        });

        return urlMap.entrySet().stream().map(entry -> entry.getValue()).collect(Collectors.toList());
    }
1136288
private List<T> unmarshallResponseHeaderToList(
            JsonUnmarshallerContext context) throws Exception {

        String headerValue = context.readText();

        List<T> list = new ArrayList<T>();

        String[] headerValues = headerValue.split("[,]");

        for (final String headerVal : headerValues) {
            list.add(itemUnmarshaller.unmarshall(new JsonUnmarshallerContext() {
                @Override
                public String readText() {
                    return headerVal;
                }
            }));
        }
        return list;
    }
307855
public String toChallengeDisp() {
        final StringBuilder sb = new StringBuilder();
        sb.append("\n ").append(toTypeAssignableMark()).append(" ");
        sb.append(propertyType.getSimpleName()).append(" ").append(propertyName);
        if (mappedValue != null) {
            final Class<?> valueType = getValueType().get();
            if (isNestedProperty(valueType)) {
                sb.append(" = ... (unknown if assignable)"); // nested is unsupported about challenge for now (so difficult)
            } else {
                sb.append(" = (").append(valueType.getSimpleName()).append(") \"").append(mappedValue).append("\"");
            }
        } else {
            sb.append(" = null");
        }
        return sb.toString();
    }
1179898
public String[] getServerAliases(String keyType, Principal[] issuers) {
        return certMapping.values().toArray(new String[certMapping.size()]);
    }
362982
public JSONArray toJSON(Collection<SatConstraint> e) throws JSONConverterException {
        JSONArray arr = new JSONArray();
        for (SatConstraint cstr : e) {
            arr.add(toJSON(cstr));
        }
        return arr;
    }
172589
public static Optional<JsonWebKeySet> getJsonWebKeySet(final OidcRegisteredService service) {
        try {
            LOGGER.trace("Loading JSON web key from [{}]", service.getJwks());

            val resource = getJsonWebKeySetResource(service);
            val jsonWebKeySet = buildJsonWebKeySet(resource);

            if (jsonWebKeySet == null || jsonWebKeySet.getJsonWebKeys().isEmpty()) {
                LOGGER.warn("No JSON web keys could be found for [{}]", service);
                return Optional.empty();
            }

            val badKeysCount = jsonWebKeySet.getJsonWebKeys().stream().filter(k ->
                StringUtils.isBlank(k.getAlgorithm())
                    && StringUtils.isBlank(k.getKeyId())
                    && StringUtils.isBlank(k.getKeyType())).count();

            if (badKeysCount == jsonWebKeySet.getJsonWebKeys().size()) {
                LOGGER.warn("No valid JSON web keys could be found for [{}]", service);
                return Optional.empty();
            }

            val webKey = getJsonWebKeyFromJsonWebKeySet(jsonWebKeySet);
            if (Objects.requireNonNull(webKey).getPublicKey() == null) {
                LOGGER.warn("JSON web key retrieved [{}] has no associated public key", webKey.getKeyId());
                return Optional.empty();
            }
            return Optional.of(jsonWebKeySet);

        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }

        return Optional.empty();
    }
157909
def _get_auth_challenge(self, exc):
        
        response = HttpResponse(content=exc.content, status=exc.get_code_num())
        response['WWW-Authenticate'] = 'Basic realm="%s"' % REALM
        return response
593785
@Override
	public Collection<Object> getMeasureKeys() {
		HashSet<Object> keys = new HashSet<>();
		keys.addAll(pullers.keySet());
		keys.addAll(pushers.keySet());
		return keys;
	}
278989
public static Collection<X509CRL> getCRLs(X509CRLSelector selector,
                                              boolean signFlag,
                                              PublicKey prevKey,
                                              String provider,
                                              List<CertStore> certStores,
                                              boolean[] reasonsMask,
                                              Set<TrustAnchor> trustAnchors,
                                              Date validity)
        throws CertStoreException
    {
        return getCRLs(selector, signFlag, prevKey, null, provider, certStores,
                       reasonsMask, trustAnchors, validity);
    }
590876
public function jsonSerialize()
    {
        if (!$this->count()) {
            return [];
        }

        $records = [];

        foreach ($this as $record) {
            if ($record instanceof JsonSerializable) {
                $records[] = $record->jsonSerialize();
            } else {
                $records[] = $record;
            }
        }

        return $records;
    }
850692
public function jsonSerialize(): array
    {
        $data = ['required' => $this->requiresAuth()];
        if ($this->requiresAuth()) {
            $data['requiresLogin'] = $this->requiresLogin();
        }

        if ($this->requiresRoles()) {
            $data['requiresRoles'] = true;
            $data['requiredRole']  = $this->requiredRole();
        }

        return $data;
    }
288068
private static JsonArray toJsonArray(Collection<String> values) {
        JsonArray array = new JsonArray();
        for (String value : values) {
            array.add(value);
        }
        return array;

    }
207543
public function unauthorized(array $challenges): self
    {
        if (count($challenges) === 0) {
            throw new \InvalidArgumentException('Challenges must contain at least one entry');
        }

        $this->headers->add('WWW-Authenticate', join(', ', $challenges));
        return $this->fixateCode(401);
    }
740174
private function toJsonRequest($accounts) {
    $jsonUsers = array();
    foreach($accounts as $account) {
      $user = array(
        'email' => $account->getEmail(),
        'localId' => $account->getUserId(),
        'emailVerified' => $account->isEmailVerified(),
        'displayName' => $account->getDisplayName(),
        'passwordHash' => Google_Utils::urlSafeB64Encode(
            $account->getPasswordHash()),
        'salt' => Google_Utils::urlSafeB64Encode($account->getSalt())
      );
      array_push($jsonUsers, $user);
    }
    return $jsonUsers;
  }