// Path: src/main/java/com/syndicapp/scraper/FSSUserAgent.java
// public class FSSUserAgent {
//     public static HttpClient httpclient = HttpClientBuilder.create().build();
//     public static Logger log = Logger.getLogger(FSSUserAgent.class);
//     public static BasicHttpContext context = new BasicHttpContext();
// 
//     public FSSUserAgent() {
//     }
// 
// 
// }
// 
// Path: src/main/java/com/syndicapp/scraper/aib/model/Account.java
// public class Account {
// 
// 	static Logger Log = Logger.getLogger(Account.class);
// 	private int id;
// 	private String name;
// 	private BigDecimal balance;
// 	private String drcr;
// 	private ArrayList<Transaction> transactions;
// 	private boolean pending;
// 
// 	public Account(int id, String name, String balance, String drcr, boolean pending) {
// 		Log.debug((new StringBuilder()).append("New Account - ").append(name).append(" - ")
// 				.append(balance).append(drcr).toString());
// 		this.id = id;
// 		this.name = name;
// 		this.balance = new BigDecimal(balance.replace(",", ""));
// 		this.drcr = (null == drcr ? "" : drcr);
// 		this.pending = pending;
// 	}
// 
// 	public String getDrcr() {
// 		return drcr;
// 	}
// 
// 	public void setDrcr(String drcr) {
// 		this.drcr = drcr;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public void setBalance(String balance) {
// 		this.balance = new BigDecimal(balance.replace(",", ""));
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public BigDecimal getBalance() {
// 		return balance;
// 	}
// 
// 	public boolean isDR() {
// 		return drcr.equalsIgnoreCase("DR");
// 	}
// 
// 
// 	public boolean isPending() {
// 		return pending;
// 	}
// 
// 	public void setTransactions(ArrayList<Transaction> t) {
// 		transactions = t;
// 	}
// 
// 	public ArrayList<Transaction> getTransactions() {
// 		return transactions;
// 	}
// 
// 	public int getId() {
// 		return id;
// 	}
// 
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 
// }
// 
// Path: src/main/java/com/syndicapp/scraper/exception/UnexpectedPageContentsException.java
// public class UnexpectedPageContentsException extends Exception
// {
// 
//     public UnexpectedPageContentsException(String s)
//     {
//         super(s);
//     }
// 
//     private static final long serialVersionUID = 0xf57ed4fa93f8378aL;
// }


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import com.syndicapp.scraper.FSSUserAgent;
import com.syndicapp.scraper.aib.model.Account;
import com.syndicapp.scraper.exception.UnexpectedPageContentsException;
        nvps.add(new BasicNameValuePair("jsEnabled", "TRUE"));
        nvps.add(new BasicNameValuePair("pacDetails.pacDigit1", (String)inputParams.get("pacDetails.pacDigit1")));
        nvps.add(new BasicNameValuePair("pacDetails.pacDigit2", (String)inputParams.get("pacDetails.pacDigit2")));
        nvps.add(new BasicNameValuePair("pacDetails.pacDigit3", (String)inputParams.get("pacDetails.pacDigit3")));
        
        httppost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));
        httppost.setHeader("Referer", PageUtils.getReferer(page));
        
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        page = EntityUtils.toString(entity);
        
        log.trace(page);
        
        if(!page.contains("QuickPay Start")) {
            // check for action="accountoverview.htm" - we are probably on an info page that AIB display now and again.
        	
        	p = Pattern.compile("action=\"accountoverview.htm\"");
            m = p.matcher(page);
            
            if (m.find()) {
            	// looks like we're on an info page 
            	
                outputParams.put("page", thisPage + "\n" + page);
                outputParams.put("infoPage", true);
                
                return outputParams;
            
            } else {
            	// dunno what happened.            	
// Path: src/main/java/com/syndicapp/scraper/FSSUserAgent.java
// public class FSSUserAgent {
//     public static HttpClient httpclient = HttpClientBuilder.create().build();
//     public static Logger log = Logger.getLogger(FSSUserAgent.class);
//     public static BasicHttpContext context = new BasicHttpContext();
// 
//     public FSSUserAgent() {
//     }
// 
// 
// }
// 
// Path: src/main/java/com/syndicapp/scraper/aib/model/Account.java
// public class Account {
// 
// 	static Logger Log = Logger.getLogger(Account.class);
// 	private int id;
// 	private String name;
// 	private BigDecimal balance;
// 	private String drcr;
// 	private ArrayList<Transaction> transactions;
// 	private boolean pending;
// 
// 	public Account(int id, String name, String balance, String drcr, boolean pending) {
// 		Log.debug((new StringBuilder()).append("New Account - ").append(name).append(" - ")
// 				.append(balance).append(drcr).toString());
// 		this.id = id;
// 		this.name = name;
// 		this.balance = new BigDecimal(balance.replace(",", ""));
// 		this.drcr = (null == drcr ? "" : drcr);
// 		this.pending = pending;
// 	}
// 
// 	public String getDrcr() {
// 		return drcr;
// 	}
// 
// 	public void setDrcr(String drcr) {
// 		this.drcr = drcr;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public void setBalance(String balance) {
// 		this.balance = new BigDecimal(balance.replace(",", ""));
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public BigDecimal getBalance() {
// 		return balance;
// 	}
// 
// 	public boolean isDR() {
// 		return drcr.equalsIgnoreCase("DR");
// 	}
// 
// 
// 	public boolean isPending() {
// 		return pending;
// 	}
// 
// 	public void setTransactions(ArrayList<Transaction> t) {
// 		transactions = t;
// 	}
// 
// 	public ArrayList<Transaction> getTransactions() {
// 		return transactions;
// 	}
// 
// 	public int getId() {
// 		return id;
// 	}
// 
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 
// }
// 
// Path: src/main/java/com/syndicapp/scraper/exception/UnexpectedPageContentsException.java
// public class UnexpectedPageContentsException extends Exception
// {
// 
//     public UnexpectedPageContentsException(String s)
//     {
//         super(s);
//     }
// 
//     private static final long serialVersionUID = 0xf57ed4fa93f8378aL;
// }


// Path: src/main/java/com/syndicapp/scraper/aib/PACAndChallengePage.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import com.syndicapp.scraper.FSSUserAgent;
import com.syndicapp.scraper.aib.model.Account;
import com.syndicapp.scraper.exception.UnexpectedPageContentsException;

        nvps.add(new BasicNameValuePair("jsEnabled", "TRUE"));
        nvps.add(new BasicNameValuePair("pacDetails.pacDigit1", (String)inputParams.get("pacDetails.pacDigit1")));
        nvps.add(new BasicNameValuePair("pacDetails.pacDigit2", (String)inputParams.get("pacDetails.pacDigit2")));
        nvps.add(new BasicNameValuePair("pacDetails.pacDigit3", (String)inputParams.get("pacDetails.pacDigit3")));
        
        httppost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));
        httppost.setHeader("Referer", PageUtils.getReferer(page));
        
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        page = EntityUtils.toString(entity);
        
        log.trace(page);
        
        if(!page.contains("QuickPay Start")) {
            // check for action="accountoverview.htm" - we are probably on an info page that AIB display now and again.
        	
        	p = Pattern.compile("action=\"accountoverview.htm\"");
            m = p.matcher(page);
            
            if (m.find()) {
            	// looks like we're on an info page 
            	
                outputParams.put("page", thisPage + "\n" + page);
                outputParams.put("infoPage", true);
                
                return outputParams;
            
            } else {
            	// dunno what happened.            	
            	throw new UnexpectedPageContentsException("Didn't get to the Account Overview Page!");