Adapt saml metadata and parse. Acts as a facade.

@param resolver          the resolver
@param registeredService the service
@param entityID          the entity id
@return the saml metadata adaptor
327000
public static Optional<SamlRegisteredServiceServiceProviderMetadataFacade> get(final SamlRegisteredServiceCachingMetadataResolver resolver,
                                                                                   final SamlRegisteredService registeredService,
                                                                                   final String entityID) {
        return get(resolver, registeredService, entityID, new CriteriaSet());
    }
1140989
@SneakyThrows
    protected Encrypter buildEncrypterForSamlObject(final Object samlObject,
                                                    final SamlRegisteredService service,
                                                    final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) {
        val className = samlObject.getClass().getName();
        val entityId = adaptor.getEntityId();
        LOGGER.debug("Attempting to encrypt [{}] for [{}]", className, entityId);
        val credential = getKeyEncryptionCredential(entityId, adaptor, service);
        LOGGER.info("Found encryption public key: [{}]", EncodingUtils.encodeBase64(credential.getPublicKey().getEncoded()));

        val keyEncParams = getKeyEncryptionParameters(samlObject, service, adaptor, credential);
        LOGGER.debug("Key encryption algorithm for [{}] is [{}]", keyEncParams.getRecipient(), keyEncParams.getAlgorithm());

        val dataEncParams = getDataEncryptionParameters(samlObject, service, adaptor);
        LOGGER.debug("Data encryption algorithm for [{}] is [{}]", entityId, dataEncParams.getAlgorithm());

        val encrypter = getEncrypter(samlObject, service, adaptor, keyEncParams, dataEncParams);
        LOGGER.debug("Attempting to encrypt [{}] for [{}] with key placement of [{}]",
            className, entityId, encrypter.getKeyPlacement());
        return encrypter;
    }
333547
public function addCustomResolver($id, $resolver)
    {
        if (!$resolver instanceof EventResolverInterface) {
            $this->handleException(new InvalidServiceException(
                'Resolver Service must implement'.EventResolverInterface::class
            ));

            return;
        }

        $this->customResolvers[$id] = $resolver;
    }
983300
protected Map<String, List<Object>> resolveAttributesFromPrincipalAttributeRepository(final Principal principal, final RegisteredService registeredService) {
        val repository = ObjectUtils.defaultIfNull(this.principalAttributesRepository,
            getPrincipalAttributesRepositoryFromApplicationContext());
        if (repository != null) {
            LOGGER.debug("Using principal attribute repository [{}] to retrieve attributes", repository);
            return repository.getAttributes(principal, registeredService);
        }
        return principal.getAttributes();
    }
1045568
public function configureOptions(OptionsResolver $resolver)
    {
        $registry = $this->registry;

        $entityManagerNormalizer = function (Options $options, $entityManager) use ($registry) {
            if (null !== $entityManager) {
                if ($entityManager instanceof ObjectManager) {
                    return $entityManager;
                }

                return $registry->getManager($entityManager);
            }

            $entityManager = $registry->getManagerForClass($options['class']);

            if (null === $entityManager) {
                throw new RuntimeException(sprintf(
                    'Class "%s" seems not to be a managed Doctrine entity. Did you forget to map it?',
                    $options['class']
                ));
            }

            return $entityManager;
        };

        $compoundNormalizer = function () {
            return false;
        };

        $resolver->setDefaults([
            'entity_manager' => null,
        ]);

        $resolver->setRequired([
            'class',
        ]);

        $resolver->setNormalizer('entity_manager', $entityManagerNormalizer);
        $resolver->setNormalizer('compound', $compoundNormalizer);

        $resolver->setAllowedTypes('entity_manager', [
            'null',
            'string',
            ObjectManager::class,
        ]);
    }
1124747
@Override
    public InputSource resolveEntity(String publicId, String systemId) {

	for (int i = 0; i < Constants.DTDS_TLD.length; i++) {
	    if (publicId.equals(Constants.DTDS_TLD[i])) {
		return new InputSource(getClass().getResourceAsStream(LUCEE_DTD_1_0));
	    }
	}

	if (publicId.equals("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN")) {
	    return new InputSource(getClass().getResourceAsStream(SUN_DTD_1_1));
	}
	else if (publicId.equals("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN")) {
	    return new InputSource(getClass().getResourceAsStream(SUN_DTD_1_2));
	}
	return null;
    }
366803
public <T> String resolveApitraryEntityId(T entity) {
		if (entity == null) {
			throw new ApitraryOrmIdDefinitionsException("Apitrary entity has not to be null.");
		}
		List<java.lang.reflect.Field> fields = ClassUtil.getAnnotatedFields(entity.getClass(), Id.class);
		if (fields.isEmpty()) {
			throw new ApitraryOrmIdDefinitionsException("Apitrary entity must own an annotated ID field.");
		}
		if (fields.size() > 1) {
			throw new ApitraryOrmIdDefinitionsException("Apitrary entity can not have more than one ID field.");
		}

		java.lang.reflect.Field field = fields.get(0);
		String id = ClassUtil.getValueOf(field, entity, entity.getClass(), String.class);
		if (id == null || id.isEmpty()) {
			throw new ApitraryOrmIdException("Entity lacks ID and is probably not persisted.");
		}
		return id;
	}
87724
protected RegisteredService resolveRegisteredServiceInRequestContext(final RequestContext requestContext) {
        val resolvedService = resolveServiceFromAuthenticationRequest(requestContext);
        if (resolvedService != null) {
            val service = getWebflowEventResolutionConfigurationContext().getServicesManager().findServiceBy(resolvedService);
            RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(resolvedService, service);
            return service;
        }
        LOGGER.debug("Authentication request is not accompanied by a service given none is specified");
        return null;
    }
1153240
@Override
    public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
        if (validating) {
            try {
                InputSource source = null;
                if (publicId != null) {
                    String path = doctypeMap.get(publicId.toUpperCase());
                    source = getInputSource(path);
                }
                if (source == null && systemId != null) {
                    String path = doctypeMap.get(systemId.toUpperCase());
                    source = getInputSource(path);
                }
                return source;
            } catch (Exception e) {
                throw new SAXException(e.toString());
            }
        } else {
            return new InputSource(new StringReader(""));
        }
    }
130404
protected TransformerBuilder createTransformerBuilder(URIResolver resolver) {
		//return new CachingTransformerBuilder(new DefaultTransformerBuilder(resolver));
		URIResolver resolver1 = new GlossaryResolver(new DocBookResolver (resolver, getType()), getType());
		return new CachingTransformerBuilder(new DefaultTransformerBuilder(resolver1));
	}
869515
protected void configureAndInitializeSingleMetadataResolver(final AbstractMetadataResolver metadataProvider,
                                                                final SamlRegisteredService service) throws Exception {
        configureAndInitializeSingleMetadataResolver(metadataProvider, service, new ArrayList<>());
    }
221889
private EntityDecl expandUnresolvedEntity(String id)
        throws XMLStreamException
    {
        XMLResolver resolver = mConfig.getUndeclaredEntityResolver();
        if (resolver != null) {
            /* Ok, we can check for recursion here; but let's only do that
             * if there is any chance that it might get resolved by
             * the special resolver (it must have been resolved this way
             * earlier, too...)
             */
            if (mInput.isOrIsExpandedFrom(id)) {
                throwRecursionError(id);
            }

            WstxInputSource oldInput = mInput;
            oldInput.saveContext(this);
            // null, null -> no public or system ids
            int xmlVersion = mDocXmlVersion;
            // 05-Feb-2006, TSa: If xmlVersion not explicitly known, defaults to 1.0
            if (xmlVersion == XmlConsts.XML_V_UNKNOWN) {
                xmlVersion = XmlConsts.XML_V_10;
            }
            WstxInputSource newInput;
            try {
                newInput = DefaultInputResolver.resolveEntityUsing
                    (oldInput, id, null, null, resolver, mConfig, xmlVersion);
                if (mCfgTreatCharRefsAsEntities) {
                    return new IntEntity(WstxInputLocation.getEmptyLocation(), newInput.getEntityId(),
                            newInput.getSource(), new char[]{}, WstxInputLocation.getEmptyLocation());
                }
            } catch (IOException ioe) {
                throw constructFromIOE(ioe);
            }
            if (newInput != null) {
                // true -> is external
                initInputSource(newInput, true, id);
                return null;
            }
        }
        handleUndeclaredEntity(id);
        return null;
    }
789921
private Cache<String, Map<String, List<Object>>> getRegisteredServiceCacheInstance(final RegisteredService registeredService,
                                                                                       final CachingPrincipalAttributesRepository repository) {
        val key = buildRegisteredServiceCacheKey(registeredService);
        if (registeredServicesCache.containsKey(key)) {
            return registeredServicesCache.get(key);
        }
        val cache = initializeCache(repository);
        registeredServicesCache.put(key, cache);
        return cache;
    }
510257
public static ObjectModelResolver get(String resolverId) {
        List<ObjectModelResolver> resolvers = getResolvers();

        for (ObjectModelResolver resolver : resolvers) {
            if (resolver.accept(resolverId)) {
                return resolver;
            }
        }

        return null;
    }
593467
private function resolveEntityClassName(ContainerInterface $serviceLocator, $id, $default)
    {
        /** @var $sampleService \SynergyCommon\Service\BaseService */
        $reverseFilter   = new CamelCaseToDash();
        $entityId        = strtolower($reverseFilter->filter($id));
        $sampleService   = $serviceLocator->get('synergycommon\service\base');
        $entityClassName = $sampleService->getClassnameFromEntityKey($entityId);

        if ($entityClassName) {
            return new $entityClassName;
        }

        return $serviceLocator->get($default);
    }
1345462
public static Optional<SamlRegisteredServiceServiceProviderMetadataFacade> get(final SamlRegisteredServiceCachingMetadataResolver resolver,
                                                                                   final SamlRegisteredService registeredService,
                                                                                   final RequestAbstractType request) {
        return get(resolver, registeredService, SamlIdPUtils.getIssuerFromSamlObject(request));
    }
428419
@SneakyThrows
    protected SignatureSigningParameters buildSignatureSigningParameters(final RoleDescriptor descriptor,
                                                                         final SamlRegisteredService service) {
        val criteria = new CriteriaSet();
        val signatureSigningConfiguration = getSignatureSigningConfiguration(descriptor, service);
        criteria.add(new SignatureSigningConfigurationCriterion(signatureSigningConfiguration));
        criteria.add(new RoleDescriptorCriterion(descriptor));
        val resolver = new SAMLMetadataSignatureSigningParametersResolver();
        LOGGER.trace("Resolving signature signing parameters for [{}]", descriptor.getElementQName().getLocalPart());
        val params = resolver.resolveSingle(criteria);
        if (params != null) {
            LOGGER.trace("Created signature signing parameters."
                            + "\nSignature algorithm: [{}]"
                            + "\nSignature canonicalization algorithm: [{}]"
                            + "\nSignature reference digest methods: [{}]",
                    params.getSignatureAlgorithm(),
                    params.getSignatureCanonicalizationAlgorithm(),
                    params.getSignatureReferenceDigestMethod());
        } else {
            LOGGER.warn("Unable to resolve SignatureSigningParameters, response signing will fail."
                    + " Make sure domain names in IDP metadata URLs and certificates match CAS domain name");
        }
        return params;
    }