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

de.captaingoldfish.scim.sdk.client.http.BasicAuth Maven / Gradle / Ivy

There is a newer version: 1.26.0
Show newest version
// Generated by delombok at Sat Oct 07 17:30:34 CEST 2023
package de.captaingoldfish.scim.sdk.client.http;

import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Optional;


/**
 * author Pascal Knueppel 
* created at: 11.12.2019 - 15:51
*
* wrapper class for basic auth details */ public class BasicAuth { /** * the username for basic authentication */ private String username; /** * the password for basic authentication */ private String password; /** * generates a basic authentication header value */ public String getAuthorizationHeaderValue() { byte[] encoded = (Optional.ofNullable(username).orElse("") + ":" + Optional.ofNullable(password).orElse("")).getBytes(StandardCharsets.UTF_8); return "Basic " + Base64.getEncoder().encodeToString(encoded); } @java.lang.SuppressWarnings("all") BasicAuth(final String username, final String password) { this.username = username; this.password = password; } @java.lang.SuppressWarnings("all") public static class BasicAuthBuilder { @java.lang.SuppressWarnings("all") private String username; @java.lang.SuppressWarnings("all") private String password; @java.lang.SuppressWarnings("all") BasicAuthBuilder() {} /** * the username for basic authentication * * @return {@code this}. */ @java.lang.SuppressWarnings("all") public BasicAuth.BasicAuthBuilder username(final String username) { this.username = username; return this; } /** * the password for basic authentication * * @return {@code this}. */ @java.lang.SuppressWarnings("all") public BasicAuth.BasicAuthBuilder password(final String password) { this.password = password; return this; } @java.lang.SuppressWarnings("all") public BasicAuth build() { return new BasicAuth(this.username, this.password); } @java.lang.Override @java.lang.SuppressWarnings("all") public java.lang.String toString() { return "BasicAuth.BasicAuthBuilder(username=" + this.username + ", password=" + this.password + ")"; } } @java.lang.SuppressWarnings("all") public static BasicAuth.BasicAuthBuilder builder() { return new BasicAuth.BasicAuthBuilder(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy