All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dnastack.oauth.client.OAuthClientConfiguration Maven / Gradle / Ivy

package com.dnastack.oauth.client;

import lombok.*;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
@ToString
public class OAuthClientConfiguration {
    ///// Miscellaneous Configuration /////
    /* nullable */ private String name;
    /* nullable */ private String feignLoggerLevel;

    ///// Authentication Configuration /////
    private String tokenUri;
    private String clientId;
    private String clientSecret;

    /**
     * The audience to request
     */
    @Deprecated(forRemoval = false, since = "2021-11-16 - Use 'resource' instead. This stays for backward compatibility.")
    private String audience;

    /**
     * Space delimited scopes to request
     */
    private String scope;

    /**
     * Requested resource
     */
    private String resource;

    /**
     * Regex that must match the fully-qualified request URL for the access token to be included with the request.
     * Solves potential security issues where requests are made to a client-supplied URL, such as the source property
     * in some PubSub messages.
     */
    private String allowAuthenticationForUrl = null;

    public OAuthClientConfiguration update(OAuthClientConfiguration other) {
        OAuthClientConfiguration updated = this.toBuilder().build();

        if (other.getAllowAuthenticationForUrl() != null) {
            updated.setAllowAuthenticationForUrl(other.getAllowAuthenticationForUrl());
        }

        if (other.getClientId() != null) {
            updated.setClientId(other.getClientId());
        }

        if (other.getClientSecret() != null) {
            updated.setClientSecret(other.getClientSecret());
        }

        if (other.getAudience() != null) {
            updated.setAudience(other.getAudience());
        }

        if (other.getResource() != null) {
            updated.setResource(other.getResource());
        }

        if (other.getScope() != null) {
            updated.setScope(other.getScope());
        }

        if (other.getTokenUri() != null) {
            updated.setTokenUri(other.getTokenUri());
        }

        return updated;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy