public AwsIotMqttConnectionBuilder withCustomAuthorizer()

in sdk/src/main/java/software/amazon/awssdk/iot/AwsIotMqttConnectionBuilder.java [631:685]


    public AwsIotMqttConnectionBuilder withCustomAuthorizer(String username, String authorizerName, String authorizerSignature, String password, String tokenKeyName, String tokenValue) {
        if (authorizerSignature != null || tokenKeyName != null || tokenValue != null) {
            if (tokenKeyName == null || tokenValue == null || authorizerSignature == null) {
                throw new RuntimeException("Token-based custom authentication requires all token-related properties to be set");
            }
        }

        isUsingCustomAuthorizer = true;
        String usernameString = "";
        Boolean addedStringToUsername = false;

        if (username == null) {
            if (config.getUsername() != null) {
                usernameString += config.getUsername();
            }
        } else {
            usernameString += username;
        }

        if (authorizerName != null) {
            usernameString = addUsernameParameter(usernameString, authorizerName, "x-amz-customauthorizer-name=", addedStringToUsername);
            addedStringToUsername = true;
        }

        if (authorizerSignature != null)
        {
            if (!authorizerSignature.contains("%")) {
                try {
                    authorizerSignature = URLEncoder.encode(authorizerSignature, StandardCharsets.UTF_8.toString());
                } catch (UnsupportedEncodingException uee) {
                    throw new CrtRuntimeException(uee.toString());
                }
            }

            usernameString = addUsernameParameter(usernameString, authorizerSignature, "x-amz-customauthorizer-signature=", addedStringToUsername);
        }

        if (tokenKeyName != null && tokenValue != null) {
            usernameString = addUsernameParameter(usernameString, tokenValue, tokenKeyName + "=", addedStringToUsername);
        }

        config.setUsername(usernameString);

        if (password != null) {
            config.setPassword(password);
        }

        if (config.getUseWebsockets() == false) {
            tlsOptions.alpnList.clear();
            tlsOptions.alpnList.add("mqtt");
        }
        config.setPort(443);

        return this;
    }