package com.dw.lib;

import java.util.Base64;

public class BasicAuthentication {
	
	

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		String name = "admin";
		String password = "admin";

		String authString = name + ":" + password;
		System.out.println("auth string: " + authString);
		byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
		String authStringEnc = new String(authEncBytes);
		System.out.println("Base64 encoded auth string: " + authStringEnc);
	}
	
	public static String GetBase64AuthCode(String username,String password)	{
		String authString = username + ":" + password;
		System.out.println("auth string: " + authString);
		byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
		String authStringEnc = new String(authEncBytes);
		//System.out.println("Base64 encoded auth string: " + authStringEnc);
		return authStringEnc;
	}

}

@@ -913,12 +913,339 @@
 gEnc;%0A%09%7D
+%0A%09%0A%09public boolean auth(String username,String password, String dbUsername, String dbPassword, String salt) throws Exception %7B%0A%09%09%0A%09%09MD5Generator generator = new MD5Generator();%0A%09%09if(username != dbUsername) return false;%0A%09%09%0A%09%09if(generator.generateValue(password + salt) != dbPassword) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%09%0A%09%09return true;%0A%09%7D
 %0A%0A%7D%0A

add basic auth process