@Override
    public URL build(final String username, final WebApplicationService service) throws Throwable {
        val query = PasswordManagementQuery.builder().username(username).build();
        LOGGER.debug("Creating password reset URL designed for [{}]", username);

        val token = passwordManagementService.createToken(query);
        if (StringUtils.isNotBlank(token)) {
            val transientFactory = (TransientSessionTicketFactory) ticketFactory.get(TransientSessionTicket.class);

            val properties = CollectionUtils.<String, Serializable>wrap(
                PasswordManagementService.PARAMETER_TOKEN, token,
                ExpirationPolicy.class.getName(), computeExpirationPolicy());
            val ticket = transientFactory.create(service, properties);
            ticketRegistry.addTicket(ticket);

            val resetUrl = new StringBuilder(casProperties.getServer().getPrefix())
                .append('/').append(CasWebflowConfigurer.FLOW_ID_LOGIN).append('?')
                .append(PasswordManagementService.PARAMETER_PASSWORD_RESET_TOKEN).append('=').append(ticket.getId());

            if (service != null) {
                val encodeServiceUrl = UriUtils.encode(service.getOriginalUrl(), StandardCharsets.UTF_8);
                resetUrl.append('&').append(CasProtocolConstants.PARAMETER_SERVICE).append('=').append(encodeServiceUrl);
            }

            val url = resetUrl.toString();
            LOGGER.debug("Final password reset URL designed for [{}] is [{}]", username, url);
            return new URI(url).toURL();
        }
        LOGGER.error("Could not create password reset url since no reset token could be generated");
        return null;
    }
This is {@link DefaultPasswordResetUrlBuilder}.

@author Misagh Moayyed
@since 6.6.0
support/cas-server-support-pm-core/src/main/java/org/apereo/cas/pm/impl/DefaultPasswordResetUrlBuilder.java