Returns the first surrogate which supports the requested capability.

@param surrogateCapabilitiesHeader
@param capability
@return a Surrogate or null if the capability is not found.
501354
private String getFirstSurrogateFor(SurrogateCapabilitiesHeader surrogateCapabilitiesHeader, String capability) {
        for (SurrogateCapabilities surrogate : surrogateCapabilitiesHeader.getSurrogates()) {

            for (Capability sc : surrogate.getCapabilities()) {
                if (capability.equals(sc.toString())) {
                    return surrogate.getDeviceToken();
                }
            }
        }
        return null;
    }
352044
@Override
    public Capabilities getResponse(final byte[] content, final String mimeType)
            throws ContentException {
        if (mimeType == null || !mimeType.startsWith(TEXT_PLAIN)) {
            LOGGER.warn(
                    "Content-Type mismatch: was '{}', expected 'text/plain'",
                    mimeType);
        }

        final EnumSet<Capability> caps = EnumSet.noneOf(Capability.class);

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("CA capabilities:");
        }
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                new ByteArrayInputStream(content),
                Charset.forName(Charsets.US_ASCII.name())));
        Set<String> caCaps = new HashSet<String>();
        String capability;
        try {
            while ((capability = reader.readLine()) != null) {
                caCaps.add(capability);
            }
        } catch (IOException e) {
            throw new InvalidContentTypeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                LOGGER.error("Error closing reader", e);
            }
        }

        for (Capability enumValue : Capability.values()) {
            if (caCaps.contains(enumValue.toString())) {
                LOGGER.debug("[\u2713] {}", enumValue.getDescription());
                caps.add(enumValue);
            } else {
                LOGGER.debug("[\u2717] {}", enumValue.getDescription());
            }
        }

        return new Capabilities(caps.toArray(new Capability[caps.size()]));
    }
821290
public OkRequest<T> header(final Map.Entry<String, String> header) {
        return header(header.getKey(), header.getValue());
    }
35931
@View(name = "by_surrogate", map = "function(doc) { if(doc.surrogate && doc.principal) { emit(doc.principal, doc.surrogate) } }")
    public List<String> findByPrincipal(final String surrogate) {
        val view = createQuery("by_surrogate").key(surrogate);
        return db.queryView(view, String.class);
    }
1239259
@GetMapping("/sp/metadata")
    public ResponseEntity<String> getFirstServiceProviderMetadata() {
        val saml2Client = builtClients.findClient(SAML2Client.class);
        if (saml2Client != null) {
            return getSaml2ClientServiceProviderMetadataResponseEntity(saml2Client);
        }
        return getNotAcceptableResponseEntity();
    }
1353588
protected static Set<StreamCapability> addCapabilities(@Nullable StreamSupplier<?> supplier,
			StreamCapability capability, StreamCapability... capabilities) {
		EnumSet<StreamCapability> result = EnumSet.of(capability, capabilities);
		if (supplier != null) {
			result.addAll(supplier.getCapabilities());
		}
		return result;
	}
1228162
def capability(self, cap_name):
		
		if isinstance(cap_name, WNetworkClientCapabilities) is True:
			cap_name = cap_name.value
		return WCapabilitiesHolder.capability(self, cap_name)
916747
public String getHeaderValue(final String headerName) {
     if (headerName == null) { return null; }
     return request.headers().get(headerName);
   }
1374231
@Nullable
  public String getHeader (@Nullable final String sName)
  {
    final ICommonsOrderedSet <String> aSet = m_aHeaders.get (_unifyHeaderName (sName));
    return aSet == null ? null : aSet.getFirst ();
  }
816014
public void setCapabilities(java.util.Collection<String> capabilities) {
        if (capabilities == null) {
            this.capabilities = null;
            return;
        }

        this.capabilities = new com.amazonaws.internal.SdkInternalList<String>(capabilities);
    }
1370062
public void retrieveEngine() throws GeneralSecurityException, IOException {
        if (serverEngineFactory == null) {
            return;
        }
        engine = serverEngineFactory.retrieveHTTPServerEngine(nurl.getPort());
        if (engine == null) {
            engine = serverEngineFactory.getHTTPServerEngine(nurl.getHost(), nurl.getPort(), nurl.getProtocol());
        }

        assert engine != null;
        TLSServerParameters serverParameters = engine.getTlsServerParameters();
        if (serverParameters != null && serverParameters.getCertConstraints() != null) {
            CertificateConstraintsType constraints = serverParameters.getCertConstraints();
            if (constraints != null) {
                certConstraints = CertConstraintsJaxBUtils.createCertConstraints(constraints);
            }
        }

        // When configuring for "http", however, it is still possible that
        // Spring configuration has configured the port for https.
        if (!nurl.getProtocol().equals(engine.getProtocol())) {
            throw new IllegalStateException("Port " + engine.getPort() + " is configured with wrong protocol \"" + engine.getProtocol() + "\" for \"" + nurl + "\"");
        }
    }
775733
public String getHeader(@NotNull final String name, String defaultValue) {
        if (headers().contains(name)) {
            return getHeader(name);
        } else {
            return defaultValue;
        }
    }
569412
@Override
    public boolean isCapabilitySatisfied(Collection<ProvisioningFeatureDefinition> featureDefinitionsToCheck) {
        // If it isn't an autofeature, it's satisfied.
        if (!iAttr.isAutoFeature)
            return true;

        if (mfDetails == null)
            throw new IllegalStateException("Method called outside of provisioining operation or without a registered service");

        boolean isCapabilitySatisfied = true;

        Iterator<Filter> iter = mfDetails.getCapabilityFilters().iterator();
        Set<ProvisioningFeatureDefinition> satisfiedFeatureDefs = new HashSet<ProvisioningFeatureDefinition>();

        // Now we need to iterate over each of the filters, until we find we don't have a match.
        while (iter.hasNext() && isCapabilitySatisfied) {
            Filter checkFilter = iter.next();
            Iterator<ProvisioningFeatureDefinition> featureDefIter = featureDefinitionsToCheck.iterator();

            // Now for each filter, iterate over each of the FeatureDefinition headers, checking to see if we have a match.
            boolean featureMatch = false;
            while (featureDefIter.hasNext() && !featureMatch) {
                ProvisioningFeatureDefinition featureDef = featureDefIter.next();

                // If we've already satisfied a capability with this FeatureDefinition, we don't need to use it again
                if (!satisfiedFeatureDefs.contains(featureDef)) {

                    // We have a mismatch between the key the filter is using to look up the feature name and the property containing the name in the
                    // headers. So we need to add a new property for osgi.identity (filter key) that contains the value of the 
                    // Subsystem-SymbolicName (manifest header).
                    // We also have to do this for the Subsystem-Type(manifest header) and the type (filter key).
                    Map<String, String> filterProps = new HashMap<String, String>();

                    filterProps.put(FeatureDefinitionUtils.FILTER_FEATURE_KEY, featureDef.getSymbolicName());
                    try {
                        filterProps.put(FeatureDefinitionUtils.FILTER_TYPE_KEY,
                                        mfDetails.getMainAttributeValue(FeatureDefinitionUtils.TYPE));
                    } catch (IOException e) {
                        // We should be well beyond any IOException issues.. 
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "IOException reading manifest attribute from {0}: {1}", iAttr.featureFile, e);
                        }
                        continue;
                    }

                    if (checkFilter.matches(filterProps)) {
                        satisfiedFeatureDefs.add(featureDef);
                        featureMatch = true;
                    }
                }
            }
            // Once we've checked all the FeatureDefinitions, apply the result to the isCapabilitySatisfied boolean, 
            // so we stop processing as soon as we know we don't have a match.
            isCapabilitySatisfied = featureMatch;
        }

        return isCapabilitySatisfied;
    }
60857
@Override
    public ProtocolDef getProtocolConfiguration(ProtocolDescription description) {
        for (ProtocolDef protocol : containerConfiguration.getProtocols()) {
            if (description.getName().equals(protocol.getType())) {
                return protocol;
            }
        }
        return null;
    }
599570
private Capability[] getCapabilities(String addDrop, TestContext context) {
        String[] capabilities = StringUtils.commaDelimitedListToStringArray(getParameter(addDrop, context));
        Capability[] capAdd = new Capability[capabilities.length];

        for (int i = 0; i < capabilities.length; i++) {
            capAdd[i] = Capability.valueOf(capabilities[i]);
        }

        return capAdd;
    }
414517
public String getResponseHeaderValue(String name, String defaultVal) {
        if (m_response.containsHeader(name)) {
            return m_response.getFirstHeader(name).getValue();
        } else {
            return defaultVal;
        }
    }
814296
public PactDslRequestWithPath headers(String firstHeaderName, String firstHeaderValue, String... headerNameValuePairs) {
        if (headerNameValuePairs.length % 2 != 0) {
            throw new IllegalArgumentException("Pair key value should be provided, but there is one key without value.");
        }
        requestHeaders.put(firstHeaderName, Collections.singletonList(firstHeaderValue));

        for (int i = 0; i < headerNameValuePairs.length; i+=2) {
          requestHeaders.put(headerNameValuePairs[i], Collections.singletonList(headerNameValuePairs[i+1]));
        }

        return this;
    }