public URI getKeyUri() throws GuacamoleException {

        // Do not generate a key URI if no key is being exposed
        if (key == null)
            return null;

        // Format "otpauth" URL (see https://github.com/google/google-authenticator/wiki/Key-Uri-Format)
        String issuer = confService.getIssuer();
        return UriBuilder.fromUri("otpauth://totp/")
                .path(issuer + ":" + key.getUsername())
                .queryParam("secret", BASE32.encode(key.getSecret()))
                .queryParam("issuer", issuer)
                .queryParam("algorithm", confService.getMode())
                .queryParam("digits", confService.getDigits())
                .queryParam("period", confService.getPeriod())
                .build();

    }
Returns the "otpauth" URI for the secret key used to generate TOTP codes
for the current user. If the secret key is not being exposed to
facilitate enrollment, null is returned.

@return
    The "otpauth" URI for the secret key used to generate TOTP codes
    for the current user, or null is the secret ket is not being exposed
    to facilitate enrollment.

@throws GuacamoleException
    If the configuration information required for generating the key URI
    cannot be read from guacamole.properties.
extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/form/AuthenticationCodeField.java