/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.common.security;

import java.util.Base64;

/**
 * @author 田平 create 2019年11月29日下午5:03:58
 *
 */
public class BasicAuth {

	private static final String USERNAME = "microBasic";
	private static final String PASSWORD = "microBasic,.123";

	public static boolean matchAuth(String basicString) {
		return matchAuth(USERNAME, PASSWORD, basicString);
	}

	public static boolean matchAuth(String username, String password, String basicString) {
		String auth = username + ":" + password;
		String authHeader = "Basic " + Base64.getEncoder().encodeToString(auth.getBytes());
		return authHeader.equals(basicString);
	}
}
