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

net.nemerosa.ontrack.model.support.UserPasswordConfiguration Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.model.support;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.StringUtils;

import javax.annotation.Nullable;
import java.util.Optional;
import java.util.function.Function;

public interface UserPasswordConfiguration> extends Configuration {

    /**
     * Name of the configuration
     */
    String getName();

    @Nullable
    String getUser();

    @Nullable
    String getPassword();

    T withPassword(@Nullable String password);

    T clone(String targetConfigurationName, Function replacementFunction);

    @JsonIgnore
    default Optional getCredentials() {
        String user = getUser();
        if (StringUtils.isNotBlank(user)) {
            return Optional.of(new UserPassword(user, getPassword()));
        } else {
            return Optional.empty();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy