public static <T extends BaseRegisteredService> T getRegisteredService(
        final String id, final Class<T> clazz,
        final boolean uniq, final Map requiredAttributes) throws Exception {
        val baseRegisteredService = (BaseRegisteredService) clazz.getDeclaredConstructor().newInstance();
        baseRegisteredService.setServiceId(id);
        baseRegisteredService.setEvaluationOrder(1);
        if (uniq) {
            val uuid = Iterables.get(Splitter.on('-').split(UUID.randomUUID().toString()), 0);
            baseRegisteredService.setName("TestService" + uuid);
        } else {
            baseRegisteredService.setName(id);
        }
        baseRegisteredService.setDescription("Registered service description");
        baseRegisteredService.setId(RandomUtils.nextInt());
        baseRegisteredService.setTheme("exampleTheme");
        baseRegisteredService.setUsernameAttributeProvider(new PrincipalAttributeRegisteredServiceUsernameProvider("uid"));
        val accessStrategy = new DefaultRegisteredServiceAccessStrategy(true, true);
        accessStrategy.setRequireAllAttributes(true);
        accessStrategy.setRequiredAttributes(requiredAttributes);
        accessStrategy.setUnauthorizedRedirectUrl(new URI("https://www.github.com"));
        baseRegisteredService.setAccessStrategy(accessStrategy);
        baseRegisteredService.setLogo("https://logo.example.org/logo.png");
        baseRegisteredService.setLogoutType(RegisteredServiceLogoutType.BACK_CHANNEL);
        baseRegisteredService.setLogoutUrl("https://sys.example.org/logout.png");

        if (baseRegisteredService instanceof final CasRegisteredService casRegisteredService) {
            val policy = new RegexMatchingRegisteredServiceProxyPolicy();
            policy.setPattern("^http.+");
            casRegisteredService.setProxyPolicy(policy);
        }
        baseRegisteredService.setPublicKey(new RegisteredServicePublicKeyImpl("classpath:RSA1024Public.key", "RSA"));

        val policy = new ReturnAllowedAttributeReleasePolicy();
        policy.setAuthorizedToReleaseCredentialPassword(true);
        policy.setAuthorizedToReleaseProxyGrantingTicket(true);

        val repo = new CachingPrincipalAttributesRepository(TimeUnit.SECONDS.name(), 10);
        repo.setMergingStrategy(PrincipalAttributesCoreProperties.MergingStrategyTypes.ADD);
        policy.setPrincipalAttributesRepository(repo);
        policy.setAttributeFilter(new RegisteredServiceRegexAttributeFilter("https://.+"));
        policy.setAllowedAttributes(new ArrayList<>(getTestAttributes().keySet()));
        baseRegisteredService.setAttributeReleasePolicy(policy);

        return (T) baseRegisteredService;
    }
Gets web application service factory.

@return the web application service factory
core/cas-server-core-services/src/test/java/org/apereo/cas/services/RegisteredServiceTestUtils.java