001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006 007package org.fcrepo.camel.common.helpers; 008 009import java.util.Base64; 010 011/** 012 * Helper class to generate a Basic Auth Header 013 * 014 * @author Thomas Bernhart 015 * @since 2021-10-11 016 */ 017public final class BasicAuth { 018 019 public static final String BASIC_AUTH_HEADER = "Authorization"; 020 021 private BasicAuth() { 022 //intentionally left blank 023 } 024 public static final String generateBasicAuthHeader(final String username, final String password) { 025 return "Basic " + Base64.getEncoder() 026 .encodeToString((username + ":" + password).getBytes()); 027 } 028}