package axiom.web;

import org.apache.log4j.Logger;

public class SelfAuthenticator extends AxiomSupport {
    private static Logger logger = Logger.getLogger(SelfAuthenticator.class);

    @Override
    public String execute() throws Exception {

        String auth = getServletRequest().getParameter("auth");

        if (auth == null) {
            logger.debug("Sending to input page.");
            return INPUT;
        } else {
            logger.debug("preparing response.");

            Long wait = 0L;

            try {
                wait = Long.valueOf(getServletRequest().getParameter("wait"));
            } catch (NumberFormatException nfe) {
                logger.warn("invalid number format" + nfe);
            }

            logger.debug("sleeping for " + wait + " ms");
            Thread.sleep(wait);

            logger.debug("retutning success for response to be delivered");
            return SUCCESS;
        }

    }

    public String getServiceEndpoint() {
        return getServletRequest().getRequestURL().toString();
    }

    @Override
    public Breadcrumbable getParentPage() {
        return new Home();
    }

}

@@ -46,16 +46,77 @@
 ogger;%0A%0A
+import java.net.MalformedURLException;%0Aimport java.net.URL;%0A%0A
 public c
@@ -1047,70 +1047,360 @@
 t() 
-%7B%0A        return getServletRequest().getRequestURL().toString(
+throws MalformedURLException %7B%0A        final URL self = new URL(getServletRequest().getRequestURL().toString());%0A        return self.getProtocol() + %22://%22 + self.getHost() +%0A                (self.getPort() != 80 %7C%7C self.getPort() != 443 ? %22:%22 + self.getPort() : %22%22) +%0A                getServletRequest().getAttribute(%22javax.servlet.forward.request_uri%22
 );%0A 

fix axiom.web.SelfAuthenticator#getServiceEndpoint for jetty