Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.nio.charset.Charset;
- import org.apache.commons.codec.binary.Base64;
- public class AuthorizationHeaderBuilder {
- public static void main(String[] args) {
- System.out.println(build("admin", "admin1"));
- }
- public static String build(String username, String password) {
- String auth = username + ":" + password;
- byte[] encodedAuth = Base64.encodeBase64(
- auth.getBytes(Charset.forName("US-ASCII")) );
- String authHeader = "Basic " + new String( encodedAuth );
- return authHeader;
- }
- }
Add Comment
Please, Sign In to add comment