package com.xnarum.custom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class MyAuthenticator {
public List execute(HashMap map, String id, String password, String authUrl) throws Exception {
ArrayList rtn = new ArrayList();
rtn.add(new BasicNameValuePair("X-Auth-Token", getToken(id, password, authUrl)));
return rtn;
}
public String getToken(String id, String password, String url) throws Exception {
return new String(Base64.encodeBase64(String.format("%s.%s", id, password).getBytes()));
}
}