Guest User

Untitled

a guest
Feb 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import java.nio.charset.Charset;
  2.  
  3. import org.apache.commons.codec.binary.Base64;
  4.  
  5. public class AuthorizationHeaderBuilder {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. System.out.println(build("admin", "admin1"));
  10.  
  11. }
  12.  
  13. public static String build(String username, String password) {
  14. String auth = username + ":" + password;
  15. byte[] encodedAuth = Base64.encodeBase64(
  16. auth.getBytes(Charset.forName("US-ASCII")) );
  17. String authHeader = "Basic " + new String( encodedAuth );
  18. return authHeader;
  19. }
  20.  
  21. }
Add Comment
Please, Sign In to add comment