AgpConnection connection = new AgpConnection();
AgpDestination destination = new AgpDestination();
destination.setConnection(connection);
HostContextPair hcp = HostContextPair.makeHostContextPair(parameters.getValue("agp.host"));
connection.setHost(hcp.getHost());
connection.setWebContext(hcp.getContext());
AgpTokenCriteria agpTokenCriteria = new AgpTokenCriteria();
agpTokenCriteria.setCredentials(new AgpCredentials(parameters.getValue("agp.userName"), parameters.getValue("agp.userPassword")));
agpTokenCriteria.setReferer(getReferrer());
connection.setTokenCriteria(agpTokenCriteria);