@JsonIgnore
    default String getShortenedId() throws Exception {
        val urlBuilder = new URIBuilder(getId());

        var serviceId = StringUtils.EMPTY;
        if (StringUtils.isNotBlank(urlBuilder.getScheme())) {
            serviceId += urlBuilder.getScheme().concat("://");
        }
        if (StringUtils.isNotBlank(urlBuilder.getHost())) {
            serviceId += urlBuilder.getHost();
        }
        if (urlBuilder.getPort() > 0) {
            serviceId += ":" + urlBuilder.getPort();
        }
        if (!urlBuilder.getPathSegments().isEmpty()) {
            serviceId += (StringUtils.isBlank(serviceId) ? StringUtils.EMPTY : '/') + urlBuilder.getPathSegments().getFirst();
        }
        if (urlBuilder.getPathSegments().size() >= 2) {
            serviceId += '/' + urlBuilder.getPathSegments().get(1);
        }
        if (!urlBuilder.getPathSegments().isEmpty()) {
            val lastSegment = urlBuilder.getPathSegments().getLast();
            if (!serviceId.contains(lastSegment)) {
                serviceId += '/' + lastSegment;
            }
        }
        return serviceId;
    }
Gets shortened id.

@return the shortened id
@throws Exception the exception
api/cas-server-core-api-authentication/src/main/java/org/apereo/cas/authentication/principal/Service.java