private XMLObject getSecurityTokenFromRequestedToken(final RequestedSecurityToken reqToken, final Collection<WsFederationConfiguration> config) {
        LOGGER.debug("Locating the first occurrence of a security token from the requested security token");
        val securityTokenFromAssertion = getAssertionFromSecurityToken(reqToken);

        val func = FunctionUtils.doIf(Predicates.instanceOf(EncryptedData.class),
            () -> {
                LOGGER.trace("Security token is encrypted. Attempting to decrypt to extract the assertion");
                val encryptedData = (EncryptedData) securityTokenFromAssertion;
                val it = config.iterator();
                while (it.hasNext()) {
                    try {
                        val data = it.next();
                        val decrypter = buildAssertionDecrypter(data);
                        LOGGER.trace("Built an instance of [{}]", decrypter.getClass().getName());
                        return decrypter.decryptData(encryptedData);
                    } catch (final Exception e) {
                        LOGGER.debug(e.getMessage(), e);
                    }
                }
                LOGGER.error("Could not extract or decrypt an assertion based on the security token provided");
                return null;
            },
            () -> securityTokenFromAssertion);

        return func.apply(securityTokenFromAssertion);
    }
Get the relying party id for a service.

@param service       the service to get an id for
@param configuration the configuration
@return relying party id
support/cas-server-support-wsfederation/src/main/java/org/apereo/cas/support/wsfederation/WsFederationHelper.java