@Override
    public OidcRegisteredService translate(
        final OidcClientRegistrationRequest registrationRequest,
        final Optional<OidcRegisteredService> givenService) throws Exception {

        val context = configurationContext.getObject();

        val containsFragment = registrationRequest.getRedirectUris()
            .stream()
            .anyMatch(uri -> uri.contains("#"));
        if (containsFragment) {
            throw new IllegalArgumentException("Redirect URI cannot contain a fragment");
        }

        val servicesManager = context.getServicesManager();
        val registeredService = givenService.orElseGet(() -> registrationRequest.getRedirectUris()
            .stream()
            .map(uri -> (OidcRegisteredService) OAuth20Utils.getRegisteredOAuthServiceByRedirectUri(servicesManager, uri))
            .filter(Objects::nonNull)
            .findFirst()
            .orElseGet(OidcRegisteredService::new));

        if (StringUtils.isNotBlank(registrationRequest.getClientName())) {
            registeredService.setName(registrationRequest.getClientName());
        } else if (StringUtils.isBlank(registeredService.getName())) {
            registeredService.setName(RandomUtils.randomAlphabetic(GENERATED_CLIENT_NAME_LENGTH));
        }

        val serviceId = String.join("|", registrationRequest.getRedirectUris());
        registeredService.setServiceId(serviceId);

        registeredService.setSectorIdentifierUri(registrationRequest.getSectorIdentifierUri());
        registeredService.setSubjectType(registrationRequest.getSubjectType());
        if (StringUtils.equalsIgnoreCase(OidcSubjectTypes.PAIRWISE.getType(), registeredService.getSubjectType())) {
            registeredService.setUsernameAttributeProvider(new PairwiseOidcRegisteredServiceUsernameAttributeProvider());
        }

        if (StringUtils.isNotBlank(registrationRequest.getJwksUri())) {
            registeredService.setJwks(registrationRequest.getJwksUri());
        } else {
            val jwks = registrationRequest.getJwks();
            if (jwks != null && !jwks.getJsonWebKeys().isEmpty()) {
                jwks.getJsonWebKeys().stream()
                    .filter(key -> StringUtils.isBlank(key.getKeyId()))
                    .forEach(key -> key.setKeyId(RandomUtils.randomAlphabetic(6)));
                registeredService.setJwks(jwks.toJson());
            }
        }

        FunctionUtils.doIfNotBlank(registrationRequest.getTokenEndpointAuthMethod(),
            __ -> registeredService.setTokenEndpointAuthenticationMethod(registrationRequest.getTokenEndpointAuthMethod()));

        if (StringUtils.isBlank(registeredService.getClientId())) {
            registeredService.setClientId(context.getClientIdGenerator().getNewString());
        }
        if (StringUtils.isBlank(registeredService.getClientSecret())) {
            registeredService.setClientSecret(context.getClientSecretGenerator().getNewString());
        }
        registeredService.setEvaluationOrder(0);
        val urls = org.springframework.util.StringUtils.collectionToCommaDelimitedString(
            registrationRequest.getPostLogoutRedirectUris());
        registeredService.setLogoutUrl(urls);

        FunctionUtils.doIfNotBlank(registrationRequest.getLogo(), __ -> registeredService.setLogo(registrationRequest.getLogo()));
        FunctionUtils.doIfNotBlank(registrationRequest.getPolicyUri(), __ -> registeredService.setInformationUrl(registrationRequest.getPolicyUri()));
        FunctionUtils.doIfNotBlank(registrationRequest.getTermsOfUseUri(), __ -> registeredService.setPrivacyUrl(registrationRequest.getTermsOfUseUri()));

        processUserInfoSigningAndEncryption(registrationRequest, registeredService);
        processScopesAndResponsesAndGrants(registrationRequest, registeredService);

        if (!registrationRequest.getDefaultAcrValues().isEmpty()) {
            val multifactorPolicy = new DefaultRegisteredServiceMultifactorPolicy();
            multifactorPolicy.setMultifactorAuthenticationProviders(new HashSet<>(registrationRequest.getDefaultAcrValues()));
            registeredService.setMultifactorAuthenticationPolicy(multifactorPolicy);
        }

        processIdTokenSigningAndEncryption(registrationRequest, registeredService);
        processIntrospectionSigningAndEncryption(registrationRequest, registeredService);
        processContacts(registrationRequest, registeredService);
        processTlsClientAuthentication(registrationRequest, registeredService);
        processClientSecretExpiration(context, registeredService);
        processClientBackchannelAuthentication(registrationRequest, registeredService);

        registeredService.setDescription("Registered service ".concat(registeredService.getName()));
        validate(registrationRequest, registeredService);
        return registeredService;
    }
This is {@link OidcDefaultClientRegistrationRequestTranslator}.

@author Misagh Moayyed
@since 6.6.0
support/cas-server-support-oidc-core-api/src/main/java/org/apereo/cas/oidc/web/controllers/dynareg/OidcDefaultClientRegistrationRequestTranslator.java