class CustomRegisteredClientRepository implements RegisteredClientRepository {
    private final RegisteredClientService clientService;
    @Override
    public void save(RegisteredClient registeredClient) {

    }

    @Override
    public RegisteredClient findById(String id) {
        return this.findByClientId(id);
    }

    @Override
    public RegisteredClient findByClientId(String clientId) {<FILL_FUNCTION_BODY>}
}

        ClientDto clientObj = clientService.loadClientByClientId(clientId);
        if (clientObj == null) {
            return null;
        }
        RegisteredClient.Builder builder = RegisteredClient.withId(clientObj.getClientId())
                .clientId(clientObj.getClientId())
                .clientSecret(clientObj.getClientSecret())
                .clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC);

        if (StrUtil.isNotBlank(clientObj.getAuthorizedGrantTypes())) {
            for (String authorizedGrantType : clientObj.getAuthorizedGrantTypes().split(StrUtil.COMMA)) {
                builder.authorizationGrantType(new AuthorizationGrantType(authorizedGrantType));
            }
        }

        if (StrUtil.isNotBlank(clientObj.getWebServerRedirectUri())) {
            for (String redirectUri : clientObj.getWebServerRedirectUri().split(StrUtil.COMMA)) {
                builder.redirectUri(redirectUri);
            }
        }

        if (StrUtil.isNotBlank(clientObj.getScope())) {
            for (String scope : clientObj.getScope().split(StrUtil.COMMA)) {
                builder.scope(scope);
            }
        }

        OAuth2TokenFormat tokenFormat;
        if (OAuth2TokenFormat.SELF_CONTAINED.getValue().equals(clientObj.getTokenFormat())) {
            tokenFormat = OAuth2TokenFormat.SELF_CONTAINED;
        } else {
            tokenFormat = OAuth2TokenFormat.REFERENCE;
        }

        return builder
                .tokenSettings(
                        TokenSettings.builder()
                            .accessTokenFormat(tokenFormat)
                            .accessTokenTimeToLive(Duration.ofSeconds(clientObj.getAccessTokenValiditySeconds()))
                            .refreshTokenTimeToLive(Duration.ofSeconds(clientObj.getRefreshTokenValiditySeconds()))
                            .build()
                )
                .clientSettings(
                        ClientSettings.builder()
                            .requireAuthorizationConsent(!BooleanUtil.toBoolean(clientObj.getAutoapprove()))
                            .build()
                )
                .build();
    
<no_super_class>