Example usage for javax.servlet.http HttpServletResponse isCommitted

List of usage examples for javax.servlet.http HttpServletResponse isCommitted

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse isCommitted.

Prototype

public boolean isCommitted();

Source Link

Document

Returns a boolean indicating if the response has been committed.

Usage

From source file:com.tremolosecurity.proxy.ConfigSys.java

public void doConfig(HttpServletRequest req, HttpServletResponse resp, NextSys nextSys)
        throws IOException, ServletException {
    UrlHolder holder = null;//ww w.j  a  v  a  2 s.  c om
    AuthInfo userAuth = null;
    try {

        SessionManager sessionManager = (SessionManager) this.ctx
                .getAttribute(ProxyConstants.TREMOLO_SESSION_MANAGER);

        boolean setSessionCookie = false;
        boolean checkLogout = false;

        RequestHolder reqHolder = (RequestHolder) req.getAttribute(ProxyConstants.TREMOLO_REQ_HOLDER);
        holder = (UrlHolder) req.getAttribute(ProxyConstants.AUTOIDM_CFG);
        boolean isForcedAuth = req.getAttribute(ProxyConstants.TREMOLO_IS_FORCED_AUTH) != null
                ? (Boolean) req.getAttribute(ProxyConstants.TREMOLO_IS_FORCED_AUTH)
                : false;

        checkLogout = true;

        StringBuffer resetsb = new StringBuffer(cfg.getAuthPath()).append("resetChain");

        HttpSession sharedSession = req.getSession();

        if (sharedSession != null) {
            AuthController actl = (AuthController) sharedSession.getAttribute(ProxyConstants.AUTH_CTL);

            if (actl != null && actl.getHolder() != null) {

                RequestHolder presentHolder = actl.getHolder();
                AuthInfo authdata = actl.getAuthInfo();
                userAuth = authdata;
                if (!req.getRequestURI().startsWith(cfg.getAuthPath())
                        /*&&  ! presentHolder.getUrlNoQueryString().equalsIgnoreCase(req.getRequestURL().toString())*/ && (authdata == null
                                || !authdata.isAuthComplete())) {
                    //we're going to ignore requests for favicon.ico
                    if (!req.getRequestURI().endsWith("/favicon.ico")
                            && !req.getRequestURI().endsWith("/apple-touch-icon-precomposed.png")
                            && !req.getRequestURI().endsWith("/apple-touch-icon.png")) {
                        sharedSession.removeAttribute(ProxyConstants.AUTH_CTL);
                        this.cfg.createAnonUser(sharedSession);
                    }

                } else if (req.getRequestURI().equalsIgnoreCase(resetsb.toString())) {
                    sharedSession.removeAttribute("TREMOLO_AUTH_URI");
                    for (AuthStep step : actl.getAuthSteps()) {
                        step.setExecuted(false);
                        step.setSuccess(false);
                    }

                    actl.setCurrentStep(actl.getAuthSteps().get(0));

                    String chainName = holder.getUrl().getAuthChain();
                    AuthChainType chain = cfg.getAuthChains().get(chainName);
                    String mech = chain.getAuthMech().get(0).getName();
                    String uri = cfg.getAuthMechs().get(mech).getUri();

                    holder.getConfig().getAuthManager().loadAmtParams(sharedSession,
                            chain.getAuthMech().get(0));

                    String redirectURI = "";
                    if (holder.getConfig().getContextPath().equalsIgnoreCase("/")) {
                        redirectURI = uri;
                    } else {

                        redirectURI = new StringBuffer().append(holder.getConfig().getContextPath()).append(uri)
                                .toString();
                    }

                    sharedSession.setAttribute("TREMOLO_AUTH_URI", redirectURI);

                    resp.sendRedirect(redirectURI);
                    return;

                }
            }

            if (isForcedAuth) {

                actl.setHolder(reqHolder);

                String authChain = holder.getUrl().getAuthChain();
                AuthChainType act = cfg.getAuthChains().get(authChain);
                holder.getConfig().getAuthManager().loadAmtParams(sharedSession, act.getAuthMech().get(0));
            }
        }

        if (holder == null) {

            if (req.getRequestURI().startsWith(cfg.getAuthPath())) {

                req.setAttribute(ProxyConstants.AUTOIDM_MYVD, cfg.getMyVD());

                ProxyResponse presp = new ProxyResponse((HttpServletResponse) resp, (HttpServletRequest) req);

                //we still need a holder

                /*AuthController actl = (AuthController) sharedSession.getAttribute(AuthSys.AUTH_CTL);
                if (actl != null) {
                   holder = cfg.findURL(actl.getHolder().getUrlNoQueryString());
                   req.setAttribute(ConfigSys.AUTOIDM_CFG, holder);
                } else {*/
                AuthMechanism authMech = cfg.getAuthMech(((HttpServletRequest) req).getRequestURI());

                if (authMech != null) {
                    String finalURL = authMech.getFinalURL(req, resp);

                    if (finalURL != null) {

                        holder = cfg.findURL(finalURL);

                    } else {
                        //throw new ServletException("Can not generate holder");
                    }
                } else {
                    //throw new ServletException("Can not generate holder");
                }

                //no holder should be needed beyond this point

                //}

                /*
                        
                        
                String urlChain = holder.getUrl().getAuthChain();
                AuthChainType act = holder.getConfig().getAuthChains().get(urlChain);
                        
                HashMap<String,Attribute> params = new HashMap<String,Attribute>();
                ProxyUtil.loadParams(req, params);
                reqHolder = new RequestHolder(HTTPMethod.GET,params,finalURL,true,act.getName());
                        
                isForcedAuth = true;
                req.setAttribute(ConfigSys.AUTOIDM_CFG, holder);
                        
                String chainName = holder.getUrl().getAuthChain();
                AuthChainType chain = cfg.getAuthChains().get(chainName);
                String mech = chain.getAuthMech().get(0).getName();
                String uri = cfg.getAuthMechs().get(mech).getUri();
                        
                AuthSys.loadAmtParams(sharedSession, chain.getAuthMech().get(0));
                   }
                } 
                           
                        
                if (holder == null) {
                   resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
                   AccessLog.log(AccessEvent.NotFound, null, req, null, "Resource Not Found");
                   return;
                }*/

                nextSys.nextSys(req, presp);
                presp.pushHeadersAndCookies(null);
            } else {

                String redirectLocation = cfg.getErrorPages().get(HttpServletResponse.SC_NOT_FOUND);
                if (redirectLocation != null) {
                    resp.sendRedirect(redirectLocation);
                } else {
                    resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
                }

                AccessLog.log(AccessEvent.NotFound, null, req, null, "Resource Not Found");

            }

        } else {
            req.setAttribute(ProxyConstants.AUTOIDM_CFG, holder);
            req.setAttribute(ProxyConstants.AUTOIDM_MYVD, cfg.getMyVD());

            ProxyResponse presp = new ProxyResponse((HttpServletResponse) resp, (HttpServletRequest) req);

            ProxyData pd = null;

            try {
                nextSys.nextSys(req, presp);

                pd = (ProxyData) req.getAttribute(ProxyConstants.TREMOLO_PRXY_DATA);

                if (holder.getApp().getCookieConfig() != null) {
                    String logouturi = holder.getApp().getCookieConfig().getLogoutURI();

                    AuthController actl = (AuthController) sharedSession.getAttribute(ProxyConstants.AUTH_CTL);

                    if (actl != null) {

                        AuthInfo authdata = actl.getAuthInfo();
                        userAuth = authdata;
                        if ((req.getRequestURI().equalsIgnoreCase(logouturi) || (pd != null && pd.isLogout()))
                                && (authdata != null)) {

                            //Execute logout handlers
                            ArrayList<LogoutHandler> logoutHandlers = (ArrayList<LogoutHandler>) sharedSession
                                    .getAttribute(LogoutUtil.LOGOUT_HANDLERS);
                            if (logoutHandlers != null) {
                                for (LogoutHandler h : logoutHandlers) {
                                    h.handleLogout(req, presp);
                                }
                            }

                            sessionManager.clearSession(holder, sharedSession, (HttpServletRequest) req,
                                    (HttpServletResponse) resp);
                        }
                    }
                }

                presp.pushHeadersAndCookies(holder);

                if (pd != null && pd.getIns() != null) {

                    if (pd.getResponse() == null) {
                        this.procData(resp, holder, pd.isText(), pd.getIns());
                    } else {
                        this.procData(pd.getRequest(), pd.getResponse(), holder, pd.isText(), pd.getIns(),
                                pd.getPostProc());
                    }

                }

            } finally {
                if (pd != null && pd.getHttpRequestBase() != null) {
                    pd.getHttpRequestBase().releaseConnection();
                    if (!resp.isCommitted()) {
                        resp.getOutputStream().flush();
                        resp.getOutputStream().close();
                    }
                }
            }

        }
    } catch (Exception e) {
        ApplicationType appType = null;
        if (holder != null) {
            appType = holder.getApp();
        } else {
            appType = new ApplicationType();
            appType.setName("UNKNOWN");

        }

        AccessLog.log(AccessEvent.Error, appType, (HttpServletRequest) req, userAuth, "NONE");

        req.setAttribute("TREMOLO_ERROR_REQUEST_URL", req.getRequestURL().toString());
        req.setAttribute("TREMOLO_ERROR_EXCEPTION", e);
        logger.error("Could not process request", e);

        String redirectLocation = cfg.getErrorPages().get(500);

        if (redirectLocation != null) {
            resp.sendRedirect(redirectLocation);
        } else {
            StringBuffer b = new StringBuffer();
            b.append(cfg.getAuthFormsPath()).append("error.jsp");
            resp.setStatus(500);
            req.getRequestDispatcher(b.toString()).forward(req, resp);
        }

    }
}

From source file:org.jpublish.servlet.JPublishServlet.java

/**
 * Called when the HTTP request method is POST.  This method provides the
 * main control logic.//from  w  ww .  j a va2s  .c om
 *
 * @param request  The HTTP request
 * @param response The HTTP response
 * @throws ServletException
 * @throws IOException
 */

public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    ServletContext servletContext = getServletContext();

    String pathInfo = request.getPathInfo();
    if (log.isDebugEnabled())
        log.debug("Path info: " + pathInfo);

    //OLAT: PATCH BEGIN
    if (pathInfo == null) {
        // we have a direct mapping rule in web.xml like /kurs/bridge.html -> jpublish servlet
        // so we use servletPath
        //String servletPath = request.getServletPath();
        pathInfo = request.getServletPath();
    } //TODO: make more generic (use JPublish with other servlets..) and post it.

    if (log.isDebugEnabled())
        log.debug("calculated Path info: " + pathInfo);
    //OLAT: PATCH END

    String contextPath = request.getContextPath();

    if (log.isDebugEnabled())
        log.debug("Context path: " + contextPath);

    // get the real path
    String path = getRealPath(pathInfo);

    if (siteContext.getPathDispatcherManager().canDispatch(path)) {

        //only one from below ones should react
        String dispatcherName = siteContext.getPathDispatcherManager().canForwardDispatch(path);

        if (dispatcherName != null) {
            siteContext.getPathDispatcherManager().forward(request, response, dispatcherName);
        }

        dispatcherName = siteContext.getPathDispatcherManager().canIncludeDispatch(path);
        if (dispatcherName != null) {
            siteContext.getPathDispatcherManager().include(request, response, dispatcherName);
        }

        return;
    }

    if (log.isDebugEnabled())
        log.debug("Real path: " + path);

    // create the session if enabled
    HttpSession session = null;

    if (isSessionEnabled(path)) {
        session = request.getSession(true);
    }

    // get the character encoding map
    CharacterEncodingMap characterEncodingMap = siteContext.getCharacterEncodingManager().getMap(path);

    // set the request character encoding for parameter data
    if (requireVersion(2, 3)) {
        request.setCharacterEncoding(characterEncodingMap.getRequestEncoding());
    }

    // put standard servlet stuff into the context
    JPublishContext context = new JPublishContext(this);
    context.put("request", request);
    context.put("response", response);
    context.put("session", session);
    context.put("application", servletContext);

    // add the character encoding map to the context
    context.put("characterEncodingMap", characterEncodingMap);

    // add the URLUtilities to the context
    URLUtilities urlUtilities = new URLUtilities(request, response);
    context.put("urlUtilities", urlUtilities);
    // deprecated
    context.put("url_util", urlUtilities);
    context.put("url_utils", urlUtilities);

    // add the DateUtilities to the context
    context.put("dateUtilities", DateUtilities.getInstance());

    // add the NumberUtilities to the context
    context.put("numberUtilities", NumberUtilities.getInstance());

    // add the messages log to the context
    context.put("syslog", SiteContext.syslog);

    // expose the SiteContext
    context.put("site", siteContext);

    // expose the context itself for debugging purposes
    if (siteContext.isDebug()) {
        context.put("context", context);
    }

    // switch from merge to eval, while rendering Velocity templates [hack for utf8]
    if (siteContext.isEval()) {
        context.put("evaluateVelocityTemplates", "true");
    }

    if (siteContext.isProtectReservedNames()) {
        context.enableCheckReservedNames(this);
    }

    // add the repositories to the context
    Iterator repositories = siteContext.getRepositories().iterator();
    while (repositories.hasNext()) {
        Repository repository = (Repository) repositories.next();
        if (log.isDebugEnabled())
            log.debug("Adding " + repository.getClass().getName() + " as " + repository.getName());

        context.put(repository.getName(), new RepositoryWrapper(repository, context));
    }

    Writer out = null;
    try {

        if (executePreEvaluationActions(request, response, context, path))
            return;

        if (context.getStopProcessing() != null) {
            return;
        }

        // if the page is static
        StaticResourceManager staticResourceManager = siteContext.getStaticResourceManager();

        if (staticResourceManager.resourceExists(path)) {

            long ifModifiedSince = request.getDateHeader(HEADER_IF_MODIFIED);
            // will round the file's lastModified down to the nearest second by dividing by 1000 and then
            // multiplying it by 1000; florin
            long lastUpdatedTime = -1;
            try {
                lastUpdatedTime = (staticResourceManager.getLastModified(path) / 1000) * 1000;
            } catch (Exception e) {
                log.warn("Cannot read the LastModified for: " + path);
            }
            //log.info(String.format("%s: if modified since: %d, file time:%d, modified? %s", path, ifModifiedSince, lastUpdatedTime, (ifModifiedSince < lastUpdatedTime)));

            if (ifModifiedSince < lastUpdatedTime) {
                // execute the global actions
                if (executeGlobalActions(request, response, context, path))
                    return;

                if (context.getStopProcessing() != null)
                    return;

                // execute path actions
                if (executePathActions(request, response, context, path))
                    return;
                if (context.getStopProcessing() != null)
                    return;

                // execute parameter actions
                if (executeParameterActions(request, response, context, path))
                    return;
                if (context.getStopProcessing() != null)
                    return;

                // load and return the static resource
                setResponseContentType(request, response, path, characterEncodingMap);
                response.setDateHeader(HEADER_LAST_MODIFIED, lastUpdatedTime);
                response.setContentLength((int) staticResourceManager.getContentLength(path));
                try {
                    staticResourceManager.load(path, response.getOutputStream());
                } catch (SocketException e) {
                    log.warn("Error writing to output stream: " + e.getMessage());
                }
                // OLAT: PATCH: Ignore org.apache.catalina.connector.ClientAbortException
                // that is produced by InternetExplorer (6.0) browser caching.
                catch (IOException e) {
                    if (e instanceof FileNotFoundException) {
                        throw e;
                    }
                }
            } else {
                //If the browser has current version of the file, don't send it. Just say it has not changed
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            }
            return;
        } else {
            if (log.isDebugEnabled())
                log.debug("Static resource '" + path + "' not found");
        }

        // load the page
        if (log.isDebugEnabled())
            log.debug("Loading the page.");

        PageInstance pageInstance = siteContext.getPageManager().getPage(path);
        Page page = new Page(pageInstance);

        context.disableCheckReservedNames(this);

        // expose the page in the context
        context.put("page", page);

        // expose components in the context
        context.put("components", new ComponentMap(context));

        if (siteContext.isProtectReservedNames()) {
            context.enableCheckReservedNames(this);
        }

        request.setAttribute(JPUBLISH_CONTEXT, context);

        // execute the global actions
        if (executeGlobalActions(request, response, context, path))
            return;
        if (context.getStopProcessing() != null)
            return;

        // execute path actions
        if (executePathActions(request, response, context, path))
            return;
        if (context.getStopProcessing() != null)
            return;

        // execute parameter actions
        if (executeParameterActions(request, response, context, path))
            return;
        if (context.getStopProcessing() != null)
            return;

        // execute the page actions
        if (log.isDebugEnabled())
            log.debug("Executing page actions.");

        if (optionalRedirect(page.executeActions(context), path, response))
            return;
        if (context.getStopProcessing() != null) {
            return;
        }
        setResponseContentType(request, response, path, characterEncodingMap);

        // get the template
        // OLAT: PATCH using context.getPage() instead of page object
        // since page can be changed in internal forward and page points
        // still to the original page
        Template template = siteContext.getTemplateManager()
                .getTemplate(context.getPage().getFullTemplateName());

        // get the Servlet writer
        out = response.getWriter();

        // merge the template
        if (log.isDebugEnabled())
            log.debug("Merging with template " + template.getPath());
        // OLAT: PATCH using context.getPage() instead of page object
        // since page can be changed in internal forward and page points
        // still to the original page
        template.merge(context, context.getPage(), out);

    } catch (FileNotFoundException e) {
        log.error("[404] " + path);
        if (!response.isCommitted()) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, path);
        }
    } catch (Exception e) {
        // Allow Jetty RequestRetry exception to propogate to container!
        if ("org.mortbay.jetty.RetryRequest".equals(e.getClass().getName())) {
            throw (RuntimeException) e;
        }

        JPublishError error = new JPublishError(e, context);
        Iterator errorHandlers = siteContext.getErrorHandlers(path).iterator();
        while (errorHandlers.hasNext()) {
            ((ErrorHandler) errorHandlers.next()).handleError(error);
        }

        if (!error.isConsumed()) {
            log.error("Execution error: " + MessageUtilities.format(e.getMessage()));
            if (!response.isCommitted()) {
                throw new ServletException(e);
            }
        }
    } finally {
        try {
            executePostEvaluationActions(request, response, context, path);
        } catch (Exception e) {
            log.error("Error executing post evaluation actions: " + MessageUtilities.format(e.getMessage()));
        }
    }
}

From source file:org.epics.archiverappliance.retrieval.DataRetrievalServlet.java

private void doGetMultiPV(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    PoorMansProfiler pmansProfiler = new PoorMansProfiler();

    // Gets the list of PVs specified by the `pv` parameter
    // String arrays might be inefficient for retrieval. In any case, they are sorted, which is essential later on.
    List<String> pvNames = Arrays.asList(req.getParameterValues("pv"));

    // Ensuring that the AA has finished starting up before requests are accepted.
    if (configService.getStartupState() != STARTUP_SEQUENCE.STARTUP_COMPLETE) {
        String msg = "Cannot process data retrieval requests for specified PVs ("
                + StringUtils.join(pvNames, ", ") + ") until the appliance has completely started up.";
        logger.error(msg);/*  ww w.  j a v  a2s . co m*/
        resp.addHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
        resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, msg);
        return;
    }

    // Getting various fields from arguments
    String startTimeStr = req.getParameter("from");
    String endTimeStr = req.getParameter("to");
    boolean useReduced = false;
    String useReducedStr = req.getParameter("usereduced");
    if (useReducedStr != null && !useReducedStr.equals("")) {
        try {
            useReduced = Boolean.parseBoolean(useReducedStr);
        } catch (Exception ex) {
            logger.error("Exception parsing usereduced", ex);
            useReduced = false;
        }
    }

    // Getting MIME type
    String extension = req.getPathInfo().split("\\.")[1];
    logger.info("Mime is " + extension);

    if (!extension.equals("json") && !extension.equals("raw") && !extension.equals("jplot")
            && !extension.equals("qw")) {
        String msg = "Mime type " + extension + " is not supported. Please use \"json\", \"jplot\" or \"raw\".";
        resp.setHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
        return;
    }

    boolean useChunkedEncoding = true;
    String doNotChunkStr = req.getParameter("donotchunk");
    if (doNotChunkStr != null && !doNotChunkStr.equals("false")) {
        logger.info("Turning off HTTP chunked encoding");
        useChunkedEncoding = false;
    }

    boolean fetchLatestMetadata = false;
    String fetchLatestMetadataStr = req.getParameter("fetchLatestMetadata");
    if (fetchLatestMetadataStr != null && fetchLatestMetadataStr.equals("true")) {
        logger.info("Adding a call to the engine to fetch the latest metadata");
        fetchLatestMetadata = true;
    }

    // For data retrieval we need a PV info. However, in case of PV's that have long since retired, we may not want to have PVTypeInfo's in the system.
    // So, we support a template PV that lays out the data sources.
    // During retrieval, you can pass in the PV as a template and we'll clone this and make a temporary copy.
    String retiredPVTemplate = req.getParameter("retiredPVTemplate");

    // Goes through given PVs and returns bad request error.
    int nullPVs = 0;
    for (String pvName : pvNames) {
        if (pvName == null) {
            nullPVs++;
        }
        if (nullPVs > 0) {
            logger.warn("Some PVs are null in the request.");
            resp.addHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
            resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
            return;
        }
    }

    if (pvNames.toString().matches("^.*" + ARCH_APPL_PING_PV + ".*$")) {
        logger.debug("Processing ping PV - this is used to validate the connection with the client.");
        processPingPV(req, resp);
        return;
    }

    for (String pvName : pvNames)
        if (pvName.endsWith(".VAL")) {
            int len = pvName.length();
            pvName = pvName.substring(0, len - 4);
            logger.info("Removing .VAL from pvName for request giving " + pvName);
        }

    // ISO datetimes are of the form "2011-02-02T08:00:00.000Z"
    Timestamp end = TimeUtils.plusHours(TimeUtils.now(), 1);
    if (endTimeStr != null) {
        try {
            end = TimeUtils.convertFromISO8601String(endTimeStr);
        } catch (IllegalArgumentException ex) {
            try {
                end = TimeUtils.convertFromDateTimeStringWithOffset(endTimeStr);
            } catch (IllegalArgumentException ex2) {
                String msg = "Cannot parse time " + endTimeStr;
                logger.warn(msg, ex2);
                resp.addHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
                resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
                return;
            }
        }
    }

    // We get one day by default
    Timestamp start = TimeUtils.minusDays(end, 1);
    if (startTimeStr != null) {
        try {
            start = TimeUtils.convertFromISO8601String(startTimeStr);
        } catch (IllegalArgumentException ex) {
            try {
                start = TimeUtils.convertFromDateTimeStringWithOffset(startTimeStr);
            } catch (IllegalArgumentException ex2) {
                String msg = "Cannot parse time " + startTimeStr;
                logger.warn(msg, ex2);
                resp.addHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
                resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
                return;
            }
        }
    }

    if (end.before(start)) {
        String msg = "For request, end " + end.toString() + " is before start " + start.toString() + " for pvs "
                + StringUtils.join(pvNames, ", ");
        logger.error(msg);
        resp.addHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
        return;
    }

    LinkedList<TimeSpan> requestTimes = new LinkedList<TimeSpan>();

    // We can specify a list of time stamp pairs using the optional timeranges parameter
    String timeRangesStr = req.getParameter("timeranges");
    if (timeRangesStr != null) {
        boolean continueWithRequest = parseTimeRanges(resp, "[" + StringUtils.join(pvNames, ", ") + "]",
                requestTimes, timeRangesStr);
        if (!continueWithRequest) {
            // Cannot parse the time ranges properly; we so abort the request.
            String msg = "The specified time ranges could not be processed appropriately. Aborting.";
            logger.info(msg);
            resp.setHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
            resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
            return;
        }

        // Override the start and the end so that the mergededup consumer works correctly.
        start = requestTimes.getFirst().getStartTime();
        end = requestTimes.getLast().getEndTime();

    } else {
        requestTimes.add(new TimeSpan(start, end));
    }

    assert (requestTimes.size() > 0);

    // Get a post processor for each PV specified in pvNames
    // If PV in the form <pp>(<pv>), process it
    String postProcessorUserArg = req.getParameter("pp");
    List<String> postProcessorUserArgs = new ArrayList<>(pvNames.size());
    List<PostProcessor> postProcessors = new ArrayList<>(pvNames.size());
    for (int i = 0; i < pvNames.size(); i++) {
        postProcessorUserArgs.add(postProcessorUserArg);

        if (pvNames.get(i).contains("(")) {
            if (!pvNames.get(i).contains(")")) {
                String msg = "Unbalanced paren " + pvNames.get(i);
                logger.error(msg);
                resp.addHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
                resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
                return;
            }
            String[] components = pvNames.get(i).split("[(,)]");
            postProcessorUserArg = components[0];
            postProcessorUserArgs.set(i, postProcessorUserArg);
            pvNames.set(i, components[1]);
            if (components.length > 2) {
                for (int j = 2; j < components.length; j++) {
                    postProcessorUserArgs.set(i, postProcessorUserArgs.get(i) + "_" + components[j]);
                }
            }
            logger.info("After parsing the function call syntax pvName is " + pvNames.get(i)
                    + " and postProcessorUserArg is " + postProcessorUserArg);
        }
        postProcessors.add(PostProcessors.findPostProcessor(postProcessorUserArg));
    }

    List<PVTypeInfo> typeInfos = new ArrayList<PVTypeInfo>(pvNames.size());
    for (int i = 0; i < pvNames.size(); i++) {
        typeInfos.add(PVNames.determineAppropriatePVTypeInfo(pvNames.get(i), configService));
    }
    pmansProfiler.mark("After PVTypeInfo");

    for (int i = 0; i < pvNames.size(); i++)
        if (typeInfos.get(i) == null && RetrievalState.includeExternalServers(req)) {
            logger.debug(
                    "Checking to see if pv " + pvNames.get(i) + " is served by a external Archiver Server");
            typeInfos.set(i,
                    checkIfPVisServedByExternalServer(pvNames.get(i), start, req, resp, useChunkedEncoding));
        }

    for (int i = 0; i < pvNames.size(); i++) {
        if (typeInfos.get(i) == null) {
            // TODO Only needed if we're forwarding the request to another server.
            if (resp.isCommitted()) {
                logger.debug("Proxied the data thru an external server for PV " + pvNames.get(i));
                return;
            }

            if (retiredPVTemplate != null) {
                PVTypeInfo templateTypeInfo = PVNames.determineAppropriatePVTypeInfo(retiredPVTemplate,
                        configService);
                if (templateTypeInfo != null) {
                    typeInfos.set(i, new PVTypeInfo(pvNames.get(i), templateTypeInfo));
                    typeInfos.get(i).setPaused(true);
                    typeInfos.get(i).setApplianceIdentity(configService.getMyApplianceInfo().getIdentity());
                    // Somehow tell the code downstream that this is a fake typeInfos.
                    typeInfos.get(i).setSamplingMethod(SamplingMethod.DONT_ARCHIVE);
                    logger.debug("Using a template PV for " + pvNames.get(i)
                            + " Need to determine the actual DBR type.");
                    setActualDBRTypeFromData(pvNames.get(i), typeInfos.get(i), configService);
                }
            }
        }

        if (typeInfos.get(i) == null) {
            String msg = "Unable to find typeinfo for pv " + pvNames.get(i);
            logger.error(msg);
            resp.addHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
            resp.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
            return;
        }

        if (postProcessors.get(i) == null) {
            if (useReduced) {
                String defaultPPClassName = configService.getInstallationProperties().getProperty(
                        "org.epics.archiverappliance.retrieval.DefaultUseReducedPostProcessor",
                        FirstSamplePP.class.getName());
                logger.debug("Using the default usereduced preprocessor " + defaultPPClassName);
                try {
                    postProcessors.set(i, (PostProcessor) Class.forName(defaultPPClassName).newInstance());
                } catch (Exception ex) {
                    logger.error("Exception constructing new instance of post processor " + defaultPPClassName,
                            ex);
                    postProcessors.set(i, null);
                }
            }
        }

        if (postProcessors.get(i) == null) {
            logger.debug("Using the default raw preprocessor");
            postProcessors.set(i, new DefaultRawPostProcessor());
        }
    }

    // Get the appliances for each of the PVs
    List<ApplianceInfo> applianceForPVs = new ArrayList<ApplianceInfo>(pvNames.size());
    for (int i = 0; i < pvNames.size(); i++) {
        applianceForPVs.add(configService.getApplianceForPV(pvNames.get(i)));
        if (applianceForPVs.get(i) == null) {
            // TypeInfo cannot be null here...
            assert (typeInfos.get(i) != null);
            applianceForPVs.set(i, configService.getAppliance(typeInfos.get(i).getApplianceIdentity()));
        }
    }

    /*
     * Retrieving the external appliances if the current appliance has not got the PV assigned to it, and
     * storing the associated information of the PVs in that appliance.
     */
    Map<String, ArrayList<PVInfoForClusterRetrieval>> applianceToPVs = new HashMap<String, ArrayList<PVInfoForClusterRetrieval>>();
    for (int i = 0; i < pvNames.size(); i++) {
        if (!applianceForPVs.get(i).equals(configService.getMyApplianceInfo())) {

            ArrayList<PVInfoForClusterRetrieval> appliancePVs = applianceToPVs
                    .get(applianceForPVs.get(i).getMgmtURL());
            appliancePVs = (appliancePVs == null) ? new ArrayList<>() : appliancePVs;
            PVInfoForClusterRetrieval pvInfoForRetrieval = new PVInfoForClusterRetrieval(pvNames.get(i),
                    typeInfos.get(i), postProcessors.get(i), applianceForPVs.get(i));
            appliancePVs.add(pvInfoForRetrieval);
            applianceToPVs.put(applianceForPVs.get(i).getRetrievalURL(), appliancePVs);
        }
    }

    List<List<Future<EventStream>>> listOfEventStreamFuturesLists = new ArrayList<List<Future<EventStream>>>();
    Set<String> retrievalURLs = applianceToPVs.keySet();
    if (retrievalURLs.size() > 0) {
        // Get list of PVs and redirect them to appropriate appliance to be retrieved.
        String retrievalURL;
        ArrayList<PVInfoForClusterRetrieval> pvInfos;
        while (!((retrievalURL = retrievalURLs.iterator().next()) != null)) {
            // Get array list of PVs for appliance
            pvInfos = applianceToPVs.get(retrievalURL);
            try {
                List<List<Future<EventStream>>> resultFromForeignAppliances = retrieveEventStreamFromForeignAppliance(
                        req, resp, pvInfos, requestTimes, useChunkedEncoding,
                        retrievalURL + "/../data/getDataForPVs.raw", start, end);
                listOfEventStreamFuturesLists.addAll(resultFromForeignAppliances);
            } catch (Exception ex) {
                logger.error("Failed to retrieve " + StringUtils.join(pvNames, ", ") + " from " + retrievalURL
                        + ".");
                return;
            }
        }
    }

    pmansProfiler.mark("After Appliance Info");

    // Setting post processor for PVs, taking into account whether there is a field in the PV name
    List<String> pvNamesFromRequests = new ArrayList<String>(pvNames.size());
    for (int i = 0; i < pvNames.size(); i++) {
        String pvName = pvNames.get(i);
        pvNamesFromRequests.add(pvName);
        PVTypeInfo typeInfo = typeInfos.get(i);
        postProcessorUserArg = postProcessorUserArgs.get(i);

        // If a field is specified in a PV name, it will create a post processor for that
        String fieldName = PVNames.getFieldName(pvName);
        if (fieldName != null && !fieldName.equals("") && !pvName.equals(typeInfo.getPvName())) {
            logger.debug("We reset the pvName " + pvName + " to one from the typeinfo " + typeInfo.getPvName()
                    + " as that determines the name of the stream. " + "Also using ExtraFieldsPostProcessor.");
            pvNames.set(i, typeInfo.getPvName());
            postProcessors.set(i, new ExtraFieldsPostProcessor(fieldName));
        }

        try {
            // Postprocessors get their mandatory arguments from the request.
            // If user does not pass in the expected request, throw an exception.
            postProcessors.get(i).initialize(postProcessorUserArg, pvName);
        } catch (Exception ex) {
            String msg = "Postprocessor threw an exception during initialization for " + pvName;
            logger.error(msg, ex);
            resp.addHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
            resp.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
            return;
        }
    }

    /*
     * MergeDedupConsumer is what writes PB data in its respective format to the HTML response.
     * The response, after the MergeDedupConsumer is created, contains the following:
     * 
     * 1) The content type for the response.
     * 2) Any additional headers for the particular MIME response.
     * 
     * Additionally, the MergeDedupConsumer instance holds a reference to the output stream
     * that is used to write to the HTML response. It is stored under the name `os`.
     */
    MergeDedupConsumer mergeDedupCountingConsumer;
    try {
        mergeDedupCountingConsumer = createMergeDedupConsumer(resp, extension, useChunkedEncoding);
    } catch (ServletException se) {
        String msg = "Exception when retrieving data " + "-->" + se.toString();
        logger.error(msg, se);
        resp.addHeader(MimeResponse.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
        resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, msg);
        return;
    }

    /* 
     * BasicContext contains the PV name and the expected return type. Used to access PB files.
     * RetrievalExecutorResult contains a thread service class and the time spans Presumably, the 
     * thread service is what retrieves the data, and the BasicContext is the context in which it 
     * works.
     */
    List<HashMap<String, String>> engineMetadatas = new ArrayList<HashMap<String, String>>();
    try {
        List<BasicContext> retrievalContexts = new ArrayList<BasicContext>(pvNames.size());
        List<RetrievalExecutorResult> executorResults = new ArrayList<RetrievalExecutorResult>(pvNames.size());
        for (int i = 0; i < pvNames.size(); i++) {
            if (fetchLatestMetadata) {
                // Make a call to the engine to fetch the latest metadata.
                engineMetadatas.add(fetchLatestMedataFromEngine(pvNames.get(i), applianceForPVs.get(i)));
            }
            retrievalContexts.add(new BasicContext(typeInfos.get(i).getDBRType(), pvNamesFromRequests.get(i)));
            executorResults.add(determineExecutorForPostProcessing(pvNames.get(i), typeInfos.get(i),
                    requestTimes, req, postProcessors.get(i)));
        }

        /*
         * There are as many Future objects in the eventStreamFutures List as there are periods over 
         * which to fetch data. Retrieval of data happen here in parallel.
         */
        List<LinkedList<Future<RetrievalResult>>> listOfRetrievalResultFuturesLists = new ArrayList<LinkedList<Future<RetrievalResult>>>();
        for (int i = 0; i < pvNames.size(); i++) {
            listOfRetrievalResultFuturesLists.add(resolveAllDataSources(pvNames.get(i), typeInfos.get(i),
                    postProcessors.get(i), applianceForPVs.get(i), retrievalContexts.get(i),
                    executorResults.get(i), req, resp));
        }
        pmansProfiler.mark("After data source resolution");

        for (int i = 0; i < pvNames.size(); i++) {
            // Data is retrieved here
            List<Future<EventStream>> eventStreamFutures = getEventStreamFuturesFromRetrievalResults(
                    executorResults.get(i), listOfRetrievalResultFuturesLists.get(i));
            listOfEventStreamFuturesLists.add(eventStreamFutures);
        }

    } catch (Exception ex) {
        if (ex != null && ex.toString() != null && ex.toString().contains("ClientAbortException")) {
            // We check for ClientAbortException etc this way to avoid including tomcat jars in the build path.
            logger.debug("Exception when retrieving data ", ex);
        } else {
            logger.error("Exception when retrieving data " + "-->" + ex.toString(), ex);
        }
    }

    long s1 = System.currentTimeMillis();
    String currentlyProcessingPV = null;

    /*
     * The following try bracket goes through each of the streams in the list of event stream futures.
     * 
     * It is intended that the process goes through one PV at a time.
     */
    try {
        for (int i = 0; i < pvNames.size(); i++) {
            List<Future<EventStream>> eventStreamFutures = listOfEventStreamFuturesLists.get(i);
            String pvName = pvNames.get(i);
            PVTypeInfo typeInfo = typeInfos.get(i);
            HashMap<String, String> engineMetadata = fetchLatestMetadata ? engineMetadatas.get(i) : null;
            PostProcessor postProcessor = postProcessors.get(i);

            logger.debug("Done with the RetrievalResults; moving onto the individual event stream "
                    + "from each source for " + StringUtils.join(pvNames, ", "));
            pmansProfiler.mark("After retrieval results");
            for (Future<EventStream> future : eventStreamFutures) {
                EventStreamDesc sourceDesc = null;

                // Gets the result of a data retrieval
                try (EventStream eventStream = future.get()) {
                    sourceDesc = null; // Reset it for each loop iteration.
                    sourceDesc = eventStream.getDescription();
                    if (sourceDesc == null) {
                        logger.warn("Skipping event stream without a desc for pv " + pvName);
                        continue;
                    }

                    logger.debug("Processing event stream for pv " + pvName + " from source "
                            + ((eventStream.getDescription() != null) ? eventStream.getDescription().getSource()
                                    : " unknown"));

                    try {
                        mergeTypeInfo(typeInfo, sourceDesc, engineMetadata);
                    } catch (MismatchedDBRTypeException mex) {
                        logger.error(mex.getMessage(), mex);
                        continue;
                    }

                    if (currentlyProcessingPV == null || !currentlyProcessingPV.equals(pvName)) {
                        logger.debug("Switching to new PV " + pvName + " In some mime responses we insert "
                                + "special headers at the beginning of the response. Calling the hook for "
                                + "that");
                        currentlyProcessingPV = pvName;
                        /*
                         * Goes through the PB data stream over a period of time. The relevant MIME response
                         * actually deal with the processing of the PV. `start` and `end` refer to the very
                         * beginning and very end of the time period being retrieved over, regardless of
                         * whether it is divided up or not.
                         */
                        mergeDedupCountingConsumer.processingPV(currentlyProcessingPV, start, end,
                                (eventStream != null) ? sourceDesc : null);
                    }

                    try {
                        // If the postProcessor does not have a consolidated event stream, we send each eventstream across as we encounter it.
                        // Else we send the consolidatedEventStream down below.
                        if (!(postProcessor instanceof PostProcessorWithConsolidatedEventStream)) {
                            /*
                             * The eventStream object contains all the data over the current period.
                             */
                            mergeDedupCountingConsumer.consumeEventStream(eventStream);
                            resp.flushBuffer();
                        }
                    } catch (Exception ex) {
                        if (ex != null && ex.toString() != null
                                && ex.toString().contains("ClientAbortException")) {
                            // We check for ClientAbortException etc this way to avoid including tomcat jars in the build path.
                            logger.debug(
                                    "Exception when consuming and flushing data from " + sourceDesc.getSource(),
                                    ex);
                        } else {
                            logger.error("Exception when consuming and flushing data from "
                                    + sourceDesc.getSource() + "-->" + ex.toString(), ex);
                        }
                    }
                    pmansProfiler.mark("After event stream " + eventStream.getDescription().getSource());
                } catch (Exception ex) {
                    if (ex != null && ex.toString() != null && ex.toString().contains("ClientAbortException")) {
                        // We check for ClientAbortException etc this way to avoid including tomcat jars in the build path.
                        logger.debug("Exception when consuming and flushing data from "
                                + (sourceDesc != null ? sourceDesc.getSource() : "N/A"), ex);
                    } else {
                        logger.error("Exception when consuming and flushing data from "
                                + (sourceDesc != null ? sourceDesc.getSource() : "N/A") + "-->" + ex.toString(),
                                ex);
                    }
                }
            }

            // TODO Go through data from other appliances here

            if (postProcessor instanceof PostProcessorWithConsolidatedEventStream) {
                try (EventStream eventStream = ((PostProcessorWithConsolidatedEventStream) postProcessor)
                        .getConsolidatedEventStream()) {
                    EventStreamDesc sourceDesc = eventStream.getDescription();
                    if (sourceDesc == null) {
                        logger.error("Skipping event stream without a desc for pv " + pvName
                                + " and post processor " + postProcessor.getExtension());
                    } else {
                        mergeDedupCountingConsumer.consumeEventStream(eventStream);
                        resp.flushBuffer();
                    }
                }
            }

            // If the postProcessor needs to send final data across, give it a chance now...
            if (postProcessor instanceof AfterAllStreams) {
                EventStream finalEventStream = ((AfterAllStreams) postProcessor).anyFinalData();
                if (finalEventStream != null) {
                    mergeDedupCountingConsumer.consumeEventStream(finalEventStream);
                    resp.flushBuffer();
                }
            }

            pmansProfiler.mark("After writing all eventstreams to response");
        }
    } catch (Exception ex) {
        if (ex != null && ex.toString() != null && ex.toString().contains("ClientAbortException")) {
            // We check for ClientAbortException etc this way to avoid including tomcat jars in the build path.
            logger.debug("Exception when retrieving data ", ex);
        } else {
            logger.error("Exception when retrieving data " + "-->" + ex.toString(), ex);
        }
    }

    long s2 = System.currentTimeMillis();
    logger.info("For the complete request, found a total of " + mergeDedupCountingConsumer.totalEventsForAllPVs
            + " in " + (s2 - s1) + "(ms)" + " skipping " + mergeDedupCountingConsumer.skippedEventsForAllPVs
            + " events" + " deduping involved " + mergeDedupCountingConsumer.comparedEventsForAllPVs
            + " compares.");

    pmansProfiler.mark("After all closes and flushing all buffers");

    // Till we determine all the if conditions where we log this, we log sparingly..
    if (pmansProfiler.totalTimeMS() > 5000) {
        logger.error("Retrieval time for " + StringUtils.join(pvNames, ", ") + " from " + startTimeStr + " to "
                + endTimeStr + ": " + pmansProfiler.toString());
    }

    mergeDedupCountingConsumer.close();
}

From source file:de.innovationgate.wgpublisher.WGPDispatcher.java

private void dispatchTmlRequest(WGPRequestPath path, javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response, Date startDate) throws java.lang.Exception {

    WGContent content = path.getContent();
    WGDatabase database = path.getDatabase();
    if (database == null) {
        throw new HttpErrorException(404, "No database of key " + path.getDatabaseKey(), null);
    }//  w w  w  . j  a v  a 2  s. co m

    WGARequestInformation info = (WGARequestInformation) request
            .getAttribute(WGARequestInformation.REQUEST_ATTRIBUTENAME);
    if (info != null) {
        info.setDatabase(database);
        info.setContent(content);
        if (content != null) {
            info.setType(WGARequestInformation.TYPE_CONTENT);
        } else {
            info.setType(WGARequestInformation.TYPE_TML);
        }
    }

    boolean ajax = false;

    HttpSession session = request.getSession();

    // Determine requested mime type and type key
    String mediaKey = path.getMediaKey();
    if (mediaKey == null) {
        mediaKey = database.getAttribute(WGACore.DBATTRIB_DEFAULT_MEDIAKEY).toString();
    }

    // Ensure existing SO registry for this session/database
    SessionScopeResolver.getRegistry(request.getSession(), database.getDbReference(), true);

    // Look if a session cookie has to be set
    _core.setSessionCookie(request, response, database);

    // Context request, if content key filled or we have a title path
    if (content != null) {

        if (!content.mayBePublished(
                isBrowserInterface(session) || isAuthoringMode(database.getDbReference(), session),
                WGContent.DISPLAYTYPE_NONE)) {
            sendNoContentNotification(path, request, response, database);
            return;
        }

        if (content.isVirtual()) {
            if (isBrowserInterface(session)) {
                if (!content.getStatus().equals(WGContent.STATUS_DRAFT)
                        && request.getParameter("forceVLink") == null) {

                    String url = getVirtualContentURL(request, database, path, content);
                    sendRedirect(request, response, url);
                    return;
                }
            } else {
                String vLink = buildVirtualLink(WGA.get(request, response, getCore()), content,
                        path.getMediaKey(), path.getLayoutKey());
                if (vLink != null) {
                    sendRedirect(request, response, vLink);
                    return;
                } else {
                    throw new HttpErrorException(HttpServletResponse.SC_NOT_FOUND,
                            "Unresolveable virtual link on content " + content.getContentKey().toString(),
                            path.getDatabaseKey());
                }
            }
        }

    }

    // Contextless request. We use a dummy content
    else {
        content = database.getDummyContent(path.getRequestLanguage());
    }

    // Test browsability of content
    if (!content.isDummy() && getBrowsingSecurity(database) <= BrowsingSecurity.NO_BROWSING) {
        throw new HttpErrorException(java.net.HttpURLConnection.HTTP_FORBIDDEN,
                "Browsing not allowed in database '" + path.getDatabaseKey() + "'", path.getDatabaseKey());
    }

    // Drop cache if requested by url param
    if (request.getQueryString() != null && request.getQueryString().toLowerCase().indexOf("dropcache") != -1
            && isAdminLoggedIn(request)) {
        content.dropCache();
    }

    // Preparse TMLForm data into multipart form data
    TMLForm.MultipartFormData formData = null;
    String ajaxFormdataSessionKey = request.getParameter("$ajaxformkey");
    if (ajaxFormdataSessionKey != null && !ajaxFormdataSessionKey.trim().equals("")) {
        formData = (TMLForm.MultipartFormData) request.getSession().getAttribute(ajaxFormdataSessionKey);
        if (formData != null && !formData.isValid()) {
            formData = null;
        }
        request.getSession().removeAttribute(ajaxFormdataSessionKey);
    } else if (ServletFileUpload.isMultipartContent(request) && request.getContentLength() != -1) {
        try {
            formData = new TMLForm.MultipartFormData(request, getCore());
        } catch (IOException e) {
            getCore().getLog().warn(
                    "Could not parse multipart form data because of IO exception: " + WGUtils.getRootCause(e));
        } catch (Exception e) {
            getCore().getLog().error("Exception parsing multipart form data", e);
        }
    }

    // Read ajax information, to be able to determine AJAX requests
    String encAjaxInfo = request.getParameter("$ajaxInfo");
    boolean isAjax = (encAjaxInfo != null);

    TMLUserProfile tmlUserProfile = null;
    try {
        tmlUserProfile = getCore().getPersManager().prepareUserProfileForRequest(request, response, content,
                database, formData, isAjax);
        if (info != null && tmlUserProfile != null) {
            info.setProfile(tmlUserProfile);
        }
    } catch (Exception e) {
        _log.error("Unable to personalize WebTML request " + path.getCompleteURL(), e);
    }

    // Set some basic attributes for WebTML processing
    request.setAttribute(WGACore.ATTRIB_WGPPATH, path.getPublisherURL());
    request.setAttribute(WGACore.ATTRIB_TAGIDS, new ConcurrentHashMap<String, BaseTagStatus>());
    request.setAttribute(WGACore.ATTRIB_REQUESTURL, path.getCompleteURL());
    request.setAttribute(WGACore.ATTRIB_REQUESTTYPE, REQUESTTYPE_TML);
    request.setAttribute(WGACore.ATTRIB_URI_HASH,
            WGUtils.createMD5HEX(request.getRequestURI().getBytes("UTF-8")));
    request.setAttribute(WGACore.ATTRIB_FORMDATA, formData);
    request.setAttribute(WGACore.ATTRIB_COOKIES, fetchHttpCookies(request));

    // Determine tml design for this request
    WGA wga = WGA.get(request, response, getCore());
    Design outerLayout = null;
    if (path.getLayoutKey() != null) {
        outerLayout = wga.design(database).resolve(path.getLayoutKey());
        WGTMLModule tmlLib = outerLayout.getTMLModule(mediaKey);
        if (tmlLib != null && tmlLib.isDirectAccessAllowed() == false) {
            throw new HttpErrorException(java.net.HttpURLConnection.HTTP_FORBIDDEN,
                    "This design is not allowed for direct access: " + tmlLib.getName() + " ("
                            + tmlLib.getMediaKey() + ")",
                    path.getDatabaseKey());
        }
    } else {
        WGStructEntry entry = content.getStructEntry();
        if (entry == null) {
            throw new HttpErrorException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "Content " + content.getContentKey().toString() + " has no struct entry",
                    path.getDatabaseKey());
        }
        outerLayout = wga.design(database).resolve(entry.getContentType().getOuterLayoutName());
    }

    request.setAttribute(WGACore.ATTRIB_OUTER_DESIGN, outerLayout.getBaseReference().getResourceName());

    // If AJAX read the AJAX data and use WebTML module from there
    AjaxInfo ajaxInfo = null;
    if (encAjaxInfo != null) {
        ajaxInfo = readAjaxInformation(request, database, encAjaxInfo);
        ajax = true;
        WGTMLModule tmlLib = getAjaxTMLModule(request, database, ajaxInfo);
        outerLayout = wga.design(tmlLib.getDatabase()).resolve(tmlLib.getName());
        mediaKey = tmlLib.getMediaKey();
    }

    // Set these here for once, so the following scripts can fetch them. Might be changed by the renderer.
    MediaKey mediaKeyObj = _core.getMediaKey(mediaKey);
    request.setAttribute(WGACore.ATTRIB_MIMETYPE, mediaKeyObj.getMimeType());
    request.setAttribute(WGACore.ATTRIB_MEDIAKEY, mediaKeyObj.getKey());

    // Update usage statistics
    getCore().getUsageStatistics().addRequestStatistic(request, session, database, tmlUserProfile);

    // Prepare WebTML environment
    TMLContext mainContext = new WebTMLEnvironmentBuilder(getCore(), content, request, response, tmlUserProfile,
            ajaxInfo).prepareWebTmlEnvironment();

    // Dispatch
    try {
        rootDispatch(wga, outerLayout, mainContext, mediaKey);

        // Eventually do redirect
        if (request.getAttribute(WGACore.ATTRIB_REDIRECT) != null) {
            if (!ajax) { // On AJAX requests the redirect is performed by Root.tmlEndTag()
                if (!response.isCommitted()) {
                    if (!session.isNew()) { // on new sessions we must not reset the response (#00000147)
                        response.reset();
                    }
                    response.sendRedirect(String.valueOf(request.getAttribute(WGACore.ATTRIB_REDIRECT)));
                } else { // Out of luck for redirect. We only can log that we could not redirect
                    getCore().getLog()
                            .warn("Unable to perform redirect to '"
                                    + String.valueOf(request.getAttribute(WGACore.ATTRIB_REDIRECT))
                                    + "' because response was already committed");
                }
            }
        }

    } catch (Exception t) {
        throw t;
    } finally {
        if (info != null) {
            info.setMimeType((String) request.getAttribute(WGACore.ATTRIB_MIMETYPE));
            info.setPath(path);
            info.setDesign(outerLayout.getTMLModule((String) request.getAttribute(WGACore.ATTRIB_MEDIAKEY)));
            info.setAjax(ajax);
        }

        TMLContext.clearThreadMainContext();
    }
}

From source file:de.innovationgate.wgpublisher.WGPDispatcher.java

public void doGet(javax.servlet.http.HttpServletRequest request,
        javax.servlet.http.HttpServletResponse response)
        throws javax.servlet.ServletException, java.io.IOException {

    if (!isServePages()) {
        response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,
                "Website is currently updating configuration. Please try again later.");
        return;/*w  w  w  .jav  a2s .  c  o  m*/
    }

    Date startDate = new Date();

    if (this._contextPath == null) {
        this._contextPath = request.getContextPath();
        this._listenPort = request.getServerPort();
    }

    WGARequestInformation reqInfo = (WGARequestInformation) request
            .getAttribute(WGARequestInformation.REQUEST_ATTRIBUTENAME);

    try {

        // Parse request
        WGPRequestPath path = WGPRequestPath.parseRequest(this, request, response);
        request.setAttribute(WGACore.ATTRIB_REQUESTPATH, path);

        // If database login failed or access was denied exit immediately
        if (!path.isProceedRequest()) {
            return;
        }

        // Set access logging for this request
        if (path.getDatabase() != null) {
            String accessLoggingEnabled = (String) path.getDatabase()
                    .getAttribute(WGACore.DBATTRIB_ENABLE_ACCESSLOGGING);
            if (accessLoggingEnabled != null) {
                if (reqInfo != null) {
                    reqInfo.setLoggingEnabled(Boolean.parseBoolean(accessLoggingEnabled));
                }
            }
        }

        int iPathType = path.getPathType();

        // Treatment of special URL types
        String dbKey = path.getDatabaseKey();
        if (iPathType == WGPRequestPath.TYPE_INVALID) {
            throw new HttpErrorException(404, "Invalid path: " + path.getBasePath(), dbKey);
        }
        if (iPathType == WGPRequestPath.TYPE_INVALID_DB) {
            throw new HttpErrorException(404, "Specified application '" + dbKey + "' is unknown", null);
        }

        if (iPathType == WGPRequestPath.TYPE_UNKNOWN_CONTENT) {
            sendNoContentNotification(path, request, response, path.getDatabase());
            return;
        }

        if (iPathType == WGPRequestPath.TYPE_GOTO_HOMEPAGE) {
            iPathType = determineHomepage(request, path, iPathType);
        }

        if (iPathType == WGPRequestPath.TYPE_UNAVAILABLE_DB) {
            throw new HttpErrorException(HttpServletResponse.SC_SERVICE_UNAVAILABLE,
                    "The website is currently unavailable", path.getDatabaseKey());
        }

        if (iPathType == WGPRequestPath.TYPE_UNDEFINED_HOMEPAGE) {
            throw new HttpErrorException(
                    HttpServletResponse.SC_NOT_FOUND, "No home page was defined for app '"
                            + path.getDatabaseKey() + "'. Please specify an explicit content path.",
                    path.getDatabaseKey());
        }

        if (iPathType == WGPRequestPath.TYPE_TMLDEBUG) {
            _tmlDebugger.performDebugMode(request, response, request.getSession());
            return;
        }

        if (iPathType == WGPRequestPath.TYPE_JOBLOG) {
            sendJobLog(request, response, request.getSession());
            return;
        }

        if (iPathType == WGPRequestPath.TYPE_LOGOUT) {
            WGDatabase db = (WGDatabase) _core.getContentdbs().get(dbKey);
            String domain = (String) db.getAttribute(WGACore.DBATTRIB_DOMAIN);
            _core.logout(domain, request.getSession(), request, response, true);
            removeSessionCookie(response, request.getSession(), db);

            iPathType = WGPRequestPath.TYPE_REDIRECT;
        }

        if (iPathType == WGPRequestPath.TYPE_FAVICON) {
            String faviconPath = determineFavicon(request);
            if (faviconPath != null) {
                iPathType = WGPRequestPath.TYPE_REDIRECT;
                path.setResourcePath(faviconPath);
            } else {
                response.sendError(HttpServletResponse.SC_NOT_FOUND, "Favicon not defined");
                return;
            }
        }

        if (iPathType == WGPRequestPath.TYPE_TMLFORM) {
            dispatchTmlFormRequest(path, request, response);
            return;
        }

        // Treatment of base URL Types
        if (iPathType == WGPRequestPath.TYPE_REDIRECT) {
            String url = path.getResourcePath();
            if (path.appendQueryString() == true && request.getQueryString() != null
                    && !request.getQueryString().equals("")) {
                if (url.indexOf("?") != -1) {
                    url += "&" + request.getQueryString();
                } else {
                    url += "?" + request.getQueryString();
                }
            }

            if (path.isPermanentRedirect()) {
                sendPermanentRedirect(response, url);
            } else {
                sendRedirect(request, response, url);
            }
        } else if (iPathType != WGPRequestPath.TYPE_RESOURCE && iPathType != WGPRequestPath.TYPE_STATICTML
                && !_core.getContentdbs().containsKey(path.getDatabaseKey())) {
            throw new HttpErrorException(404, "Database '" + dbKey + "' is unknown", null);
        } else {

            String requestMethod = request.getMethod().toLowerCase();
            switch (iPathType) {
            case (WGPRequestPath.TYPE_TML):
            case (WGPRequestPath.TYPE_TITLE_PATH):

                // Fetch the redirect cookie
                Cookie lastRedirectCookie = null;
                Cookie[] cookies = request.getCookies();
                if (cookies != null) {
                    for (Cookie cookie : cookies) {
                        if (cookie.getName().equals(COOKIE_LASTREDIRECT)) {
                            lastRedirectCookie = cookie;
                            break;
                        }
                    }
                }

                // If path is not complete redirect it to the complete path, if possible. Set redirect cookie to prevent endless redirections
                if (!path.isCompletePath()) {
                    String redirectPath = path.expandToCompletePath(request);
                    if (isRedirectable(request, redirectPath, lastRedirectCookie)) {
                        lastRedirectCookie = new WGCookie(COOKIE_LASTREDIRECT,
                                Hex.encodeHexString(redirectPath.getBytes("UTF-8")));
                        lastRedirectCookie.setMaxAge(-1);
                        lastRedirectCookie.setPath("/");
                        ((WGCookie) lastRedirectCookie).addCookieHeader(response);
                        sendRedirect(request, response, redirectPath);
                        break;
                    }
                }

                // Delete redirect cookie when exists on normal dispatching
                if (lastRedirectCookie != null) {
                    lastRedirectCookie = new WGCookie(COOKIE_LASTREDIRECT, "");
                    lastRedirectCookie.setMaxAge(0);
                    lastRedirectCookie.setPath("/");
                    ((WGCookie) lastRedirectCookie).addCookieHeader(response);
                }

                // Dispatch
                dispatchTmlRequest(path, request, response, startDate);
                break;

            case (WGPRequestPath.TYPE_FILE):
                dispatchFileRequest(path, request, response);
                break;

            case (WGPRequestPath.TYPE_CSS):
            case (WGPRequestPath.TYPE_JS):
                dispatchCssjsRequest(path, request, response);
                break;

            case (WGPRequestPath.TYPE_RESOURCE):
                dispatchResourceRequest(path, request, response);
                break;

            case (WGPRequestPath.TYPE_STATICTML):
                dispatchStaticTmlRequest(path, request, response);
                break;

            default:
                throw new HttpErrorException(500, "Invalid url format", dbKey);
            }
        }

        // moved from finally block to ensure errorpage can be displayed
        commitResponse(response);
    } catch (ClientAccessException exc) {
        response.sendError(403, exc.getMessage());
    } catch (AjaxFailureException exc) {
        handleAjaxFailure(exc, request, response);
    } catch (HttpErrorException exc) {
        request.setAttribute(WGACore.ATTRIB_EXCEPTION, exc);
        ProblemOccasion occ = new PathDispatchingOccasion(request, exc.getDbHint());
        _core.getProblemRegistry().addProblem(
                Problem.create(occ, "dispatching.http404#" + request.getRequestURL(), ProblemSeverity.LOW));
        if (!response.isCommitted()) {
            // throw exception to display errorpage - with senderror() the
            // applicationserver use the buildin errorpage
            if (exc.getCode() == HttpServletResponse.SC_NOT_FOUND
                    || exc.getCode() == HttpServletResponse.SC_FORBIDDEN
                    || exc.getCode() == HttpServletResponse.SC_PRECONDITION_FAILED) {
                response.sendError(exc.getCode(), exc.getMessage());
            } else {
                _log.error("Exception in processing request from " + request.getRemoteAddr() + " to URL "
                        + String.valueOf(request.getRequestURL()));
                throw new ServletException(exc);
            }
        }
    } catch (SocketException exc) {
        _log.warn("Socket Exception: " + exc.getMessage());
    } catch (Exception exc) {
        _log.error("Exception in processing of request URL " + String.valueOf(request.getRequestURL()), exc);
        request.setAttribute(WGACore.ATTRIB_EXCEPTION, exc);
        throw new ServletException(exc);
    } catch (Error err) {
        _log.error("Error in processing of request URL " + String.valueOf(request.getRequestURL()), err);
        request.setAttribute(WGACore.ATTRIB_EXCEPTION, err);
        throw new ServletException(err);
    } finally {
        if (reqInfo != null) {
            reqInfo.setCommited(true);
        }
    }
}

From source file:io.warp10.standalone.StandaloneIngressHandler.java

@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    String token = null;// w  ww  .j  a va 2s  .  com

    if (target.equals(Constants.API_ENDPOINT_UPDATE)) {
        baseRequest.setHandled(true);
    } else if (target.startsWith(Constants.API_ENDPOINT_UPDATE + "/")) {
        baseRequest.setHandled(true);
        token = target.substring(Constants.API_ENDPOINT_UPDATE.length() + 1);
    } else if (target.equals(Constants.API_ENDPOINT_META)) {
        handleMeta(target, baseRequest, request, response);
        return;
    } else {
        return;
    }

    try {
        //
        // CORS header
        //

        response.setHeader("Access-Control-Allow-Origin", "*");

        long nano = System.nanoTime();

        //
        // Extract DatalogRequest if specified
        //

        String datalogHeader = request.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_DATALOG));

        DatalogRequest dr = null;

        boolean forwarded = false;

        if (null != datalogHeader) {
            byte[] bytes = OrderPreservingBase64.decode(datalogHeader.getBytes(Charsets.US_ASCII));

            if (null != datalogPSK) {
                bytes = CryptoUtils.unwrap(datalogPSK, bytes);
            }

            if (null == bytes) {
                throw new IOException("Invalid Datalog header.");
            }

            TDeserializer deser = new TDeserializer(new TCompactProtocol.Factory());

            try {
                dr = new DatalogRequest();
                deser.deserialize(dr, bytes);
            } catch (TException te) {
                throw new IOException();
            }

            token = dr.getToken();

            Map<String, String> labels = new HashMap<String, String>();
            labels.put(SensisionConstants.SENSISION_LABEL_ID, new String(
                    OrderPreservingBase64.decode(dr.getId().getBytes(Charsets.US_ASCII)), Charsets.UTF_8));
            labels.put(SensisionConstants.SENSISION_LABEL_TYPE, dr.getType());
            Sensision.update(SensisionConstants.CLASS_WARP_DATALOG_REQUESTS_RECEIVED, labels, 1);
            forwarded = true;
        }

        //
        // TODO(hbs): Extract producer/owner from token
        //

        if (null == token) {
            token = request.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_TOKENX));
        }

        WriteToken writeToken;

        try {
            writeToken = Tokens.extractWriteToken(token);
        } catch (WarpScriptException ee) {
            throw new IOException(ee);
        }

        String application = writeToken.getAppName();
        String producer = Tokens.getUUID(writeToken.getProducerId());
        String owner = Tokens.getUUID(writeToken.getOwnerId());

        Map<String, String> sensisionLabels = new HashMap<String, String>();
        sensisionLabels.put(SensisionConstants.SENSISION_LABEL_PRODUCER, producer);

        long count = 0;
        long total = 0;

        File loggingFile = null;
        PrintWriter loggingWriter = null;

        try {
            if (null == producer || null == owner) {
                response.sendError(HttpServletResponse.SC_FORBIDDEN, "Invalid token.");
                return;
            }

            //
            // Build extra labels
            //

            Map<String, String> extraLabels = new HashMap<String, String>();

            // Add labels from the WriteToken if they exist
            if (writeToken.getLabelsSize() > 0) {
                extraLabels.putAll(writeToken.getLabels());
            }

            // Force internal labels
            extraLabels.put(Constants.PRODUCER_LABEL, producer);
            extraLabels.put(Constants.OWNER_LABEL, owner);
            // FIXME(hbs): remove me, apps should be set in all tokens now...
            if (null != application) {
                extraLabels.put(Constants.APPLICATION_LABEL, application);
                sensisionLabels.put(SensisionConstants.SENSISION_LABEL_APPLICATION, application);
            } else {
                // remove application label
                extraLabels.remove(Constants.APPLICATION_LABEL);
            }

            //
            // Determine if content if gzipped
            //

            boolean gzipped = false;

            if (null != request.getHeader("Content-Type")
                    && "application/gzip".equals(request.getHeader("Content-Type"))) {
                gzipped = true;
            }

            BufferedReader br = null;

            if (gzipped) {
                GZIPInputStream is = new GZIPInputStream(request.getInputStream());
                br = new BufferedReader(new InputStreamReader(is));
            } else {
                br = request.getReader();
            }

            //
            // Get the present time
            //

            Long now = TimeSource.getTime();

            //
            // Check the value of the 'now' header
            //
            // The following values are supported:
            //
            // A number, which will be interpreted as an absolute time reference,
            // i.e. a number of time units since the Epoch.
            //
            // A number prefixed by '+' or '-' which will be interpreted as a
            // delta from the present time.
            //
            // A '*' which will mean to not set 'now', and to recompute its value
            // each time it's needed.
            //

            String nowstr = null != dr ? dr.getNow()
                    : request.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_NOW_HEADERX));

            if (null != nowstr) {
                if ("*".equals(nowstr)) {
                    now = null;
                } else if (nowstr.startsWith("+")) {
                    try {
                        long delta = Long.parseLong(nowstr.substring(1));
                        now = now + delta;
                    } catch (Exception e) {
                        throw new IOException("Invalid base timestamp.");
                    }
                } else if (nowstr.startsWith("-")) {
                    try {
                        long delta = Long.parseLong(nowstr.substring(1));
                        now = now - delta;
                    } catch (Exception e) {
                        throw new IOException("Invalid base timestamp.");
                    }
                } else {
                    try {
                        now = Long.parseLong(nowstr);
                    } catch (Exception e) {
                        throw new IOException("Invalid base timestamp.");
                    }
                }
            }

            //
            // Open the logging file if logging is enabled
            //

            if (null != loggingDir) {
                long nanos = null != dr ? dr.getTimestamp() : TimeSource.getNanoTime();
                StringBuilder sb = new StringBuilder();
                sb.append(Long.toHexString(nanos));
                sb.insert(0, "0000000000000000", 0, 16 - sb.length());
                sb.append("-");
                if (null != dr) {
                    sb.append(dr.getId());
                } else {
                    sb.append(datalogId);
                }

                sb.append("-");
                sb.append(dtf.print(nanos / 1000000L));
                sb.append(Long.toString(1000000L + (nanos % 1000000L)).substring(1));
                sb.append("Z");

                if (null == dr) {
                    dr = new DatalogRequest();
                    dr.setTimestamp(nanos);
                    dr.setType(Constants.DATALOG_UPDATE);
                    dr.setId(datalogId);
                    dr.setToken(token);

                    if (null == now) {
                        //
                        // We MUST force 'now', otherwise forwarded metrics will not have a
                        // coherent time. This alters the semantics slightly but make it
                        // coherent across the board.
                        //
                        now = TimeSource.getTime();
                    }
                    dr.setNow(Long.toString(now));
                }

                if (null != dr && (!forwarded || (forwarded && this.logforwarded))) {

                    //
                    // Serialize the request
                    //

                    TSerializer ser = new TSerializer(new TCompactProtocol.Factory());

                    byte[] encoded;

                    try {
                        encoded = ser.serialize(dr);
                    } catch (TException te) {
                        throw new IOException(te);
                    }

                    if (null != this.datalogPSK) {
                        encoded = CryptoUtils.wrap(this.datalogPSK, encoded);
                    }

                    encoded = OrderPreservingBase64.encode(encoded);

                    loggingFile = new File(loggingDir, sb.toString());

                    loggingWriter = new PrintWriter(new FileWriterWithEncoding(loggingFile, Charsets.UTF_8));

                    //
                    // Write request
                    //

                    loggingWriter.println(new String(encoded, Charsets.US_ASCII));
                }

                //
                // Force 'now'
                //

                now = Long.parseLong(dr.getNow());
            }

            //
            // Loop on all lines
            //

            GTSEncoder lastencoder = null;
            GTSEncoder encoder = null;

            //
            // Chunk index when archiving
            //

            do {

                String line = br.readLine();

                if (null == line) {
                    break;
                }

                line = line.trim();

                if (0 == line.length()) {
                    continue;
                }

                //
                // Ignore comments
                //

                if ('#' == line.charAt(0)) {
                    continue;
                }

                //
                // Check for pushback
                // TODO(hbs): implement the actual push back if we are over the subscribed limit
                //

                if (count % PUSHBACK_CHECK_INTERVAL == 0) {
                    Sensision.update(
                            SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_UPDATE_DATAPOINTS_RAW,
                            sensisionLabels, count);
                    total += count;
                    count = 0;
                }

                count++;

                try {
                    encoder = GTSHelper.parse(lastencoder, line, extraLabels, now, maxValueSize, false);
                    //nano2 += System.nanoTime() - nano0;
                } catch (ParseException pe) {
                    Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_UPDATE_PARSEERRORS,
                            sensisionLabels, 1);
                    throw new IOException("Parse error at '" + line + "'", pe);
                }

                if (encoder != lastencoder || lastencoder.size() > ENCODER_SIZE_THRESHOLD) {

                    //
                    // Check throttling
                    //

                    if (null != lastencoder) {

                        // 128BITS
                        lastencoder.setClassId(GTSHelper.classId(classKeyLongs, lastencoder.getName()));
                        lastencoder.setLabelsId(
                                GTSHelper.labelsId(labelsKeyLongs, lastencoder.getMetadata().getLabels()));

                        ThrottlingManager.checkMADS(lastencoder.getMetadata(), producer, owner, application,
                                lastencoder.getClassId(), lastencoder.getLabelsId());
                        ThrottlingManager.checkDDP(lastencoder.getMetadata(), producer, owner, application,
                                (int) lastencoder.getCount());
                    }

                    //
                    // Build metadata object to push
                    //

                    if (encoder != lastencoder) {
                        Metadata metadata = new Metadata(encoder.getMetadata());
                        metadata.setSource(Configuration.INGRESS_METADATA_SOURCE);
                        //nano6 += System.nanoTime() - nano0;
                        this.directoryClient.register(metadata);
                        //nano5 += System.nanoTime() - nano0;
                    }

                    if (null != lastencoder) {
                        this.storeClient.store(lastencoder);
                    }

                    if (encoder != lastencoder) {
                        lastencoder = encoder;
                    } else {
                        //lastencoder = null
                        //
                        // Allocate a new GTSEncoder and reuse Metadata so we can
                        // correctly handle a continuation line if this is what occurs next
                        //
                        Metadata metadata = lastencoder.getMetadata();
                        lastencoder = new GTSEncoder(0L);
                        lastencoder.setMetadata(metadata);
                    }
                }

                //
                // Write the line last, so we do not write lines which triggered exceptions
                //

                if (null != loggingWriter) {
                    loggingWriter.println(line);
                }
            } while (true);

            br.close();

            if (null != lastencoder && lastencoder.size() > 0) {
                // 128BITS
                lastencoder.setClassId(GTSHelper.classId(classKeyLongs, lastencoder.getName()));
                lastencoder
                        .setLabelsId(GTSHelper.labelsId(labelsKeyLongs, lastencoder.getMetadata().getLabels()));

                ThrottlingManager.checkMADS(lastencoder.getMetadata(), producer, owner, application,
                        lastencoder.getClassId(), lastencoder.getLabelsId());
                ThrottlingManager.checkDDP(lastencoder.getMetadata(), producer, owner, application,
                        (int) lastencoder.getCount());
                this.storeClient.store(lastencoder);
            }

            //
            // TODO(hbs): should we update the count in Sensision periodically so you can't trick the throttling mechanism?
            //
        } catch (WarpException we) {
            throw new IOException(we);
        } finally {
            this.storeClient.store(null);
            this.directoryClient.register(null);
            Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_UPDATE_DATAPOINTS_RAW,
                    sensisionLabels, count);
            Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_UPDATE_REQUESTS,
                    sensisionLabels, 1);
            Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_UPDATE_TIME_US,
                    sensisionLabels, (System.nanoTime() - nano) / 1000);

            if (null != loggingWriter) {
                Map<String, String> labels = new HashMap<String, String>();
                labels.put(SensisionConstants.SENSISION_LABEL_ID, new String(
                        OrderPreservingBase64.decode(dr.getId().getBytes(Charsets.US_ASCII)), Charsets.UTF_8));
                labels.put(SensisionConstants.SENSISION_LABEL_TYPE, dr.getType());
                Sensision.update(SensisionConstants.CLASS_WARP_DATALOG_REQUESTS_LOGGED, labels, 1);

                loggingWriter.close();
                loggingFile.renameTo(new File(loggingFile.getAbsolutePath() + DatalogForwarder.DATALOG_SUFFIX));
            }

            //
            // Update stats with CDN
            //

            String cdn = request.getHeader(Constants.OVH_CDN_GEO_HEADER);

            if (null != cdn) {
                sensisionLabels.put(SensisionConstants.SENSISION_LABEL_CDN, cdn);
                // Per CDN stat is updated at the end, so update with 'total' + 'count'
                Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_UPDATE_DATAPOINTS_RAW,
                        sensisionLabels, count + total);
                Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_UPDATE_REQUESTS,
                        sensisionLabels, 1);
                Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_STANDALONE_UPDATE_TIME_US,
                        sensisionLabels, (System.nanoTime() - nano) / 1000);
            }
        }

        response.setStatus(HttpServletResponse.SC_OK);
    } catch (Exception e) {
        if (!response.isCommitted()) {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
            return;
        }
    }
}

From source file:io.warp10.continuum.egress.EgressFetchHandler.java

@Override
public void handle(String target, Request baseRequest, HttpServletRequest req, HttpServletResponse resp)
        throws IOException, ServletException {
    boolean fromArchive = false;
    boolean splitFetch = false;
    boolean writeTimestamp = false;

    if (Constants.API_ENDPOINT_FETCH.equals(target)) {
        baseRequest.setHandled(true);/*from  www.  ja va 2  s.  c  om*/
        fromArchive = false;
    } else if (Constants.API_ENDPOINT_AFETCH.equals(target)) {
        baseRequest.setHandled(true);
        fromArchive = true;
    } else if (Constants.API_ENDPOINT_SFETCH.equals(target)) {
        baseRequest.setHandled(true);
        splitFetch = true;
    } else if (Constants.API_ENDPOINT_CHECK.equals(target)) {
        baseRequest.setHandled(true);
        resp.setStatus(HttpServletResponse.SC_OK);
        return;
    } else {
        return;
    }

    try {
        // Labels for Sensision
        Map<String, String> labels = new HashMap<String, String>();

        labels.put(SensisionConstants.SENSISION_LABEL_TYPE, target);

        //
        // Add CORS header
        //

        resp.setHeader("Access-Control-Allow-Origin", "*");

        String start = null;
        String stop = null;

        long now = Long.MIN_VALUE;
        long timespan = 0L;

        String nowParam = null;
        String timespanParam = null;
        String dedupParam = null;
        String showErrorsParam = null;

        if (splitFetch) {
            nowParam = req.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_NOW_HEADERX));
            timespanParam = req.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_TIMESPAN_HEADERX));
            showErrorsParam = req.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_SHOW_ERRORS_HEADERX));
        } else {
            start = req.getParameter(Constants.HTTP_PARAM_START);
            stop = req.getParameter(Constants.HTTP_PARAM_STOP);

            nowParam = req.getParameter(Constants.HTTP_PARAM_NOW);
            timespanParam = req.getParameter(Constants.HTTP_PARAM_TIMESPAN);
            dedupParam = req.getParameter(Constants.HTTP_PARAM_DEDUP);
            showErrorsParam = req.getParameter(Constants.HTTP_PARAM_SHOW_ERRORS);
        }

        String maxDecoderLenParam = req.getParameter(Constants.HTTP_PARAM_MAXSIZE);
        int maxDecoderLen = null != maxDecoderLenParam ? Integer.parseInt(maxDecoderLenParam)
                : Constants.DEFAULT_PACKED_MAXSIZE;

        String suffix = req.getParameter(Constants.HTTP_PARAM_SUFFIX);
        if (null == suffix) {
            suffix = Constants.DEFAULT_PACKED_CLASS_SUFFIX;
        }

        boolean unpack = null != req.getParameter(Constants.HTTP_PARAM_UNPACK);

        long chunksize = Long.MAX_VALUE;

        if (null != req.getParameter(Constants.HTTP_PARAM_CHUNKSIZE)) {
            chunksize = Long.parseLong(req.getParameter(Constants.HTTP_PARAM_CHUNKSIZE));
        }

        if (chunksize <= 0) {
            throw new IOException("Invalid chunksize.");
        }

        boolean showErrors = null != showErrorsParam;
        boolean dedup = null != dedupParam && "true".equals(dedupParam);

        if (null != start && null != stop) {
            long tsstart = fmt.parseDateTime(start).getMillis() * Constants.TIME_UNITS_PER_MS;
            long tsstop = fmt.parseDateTime(stop).getMillis() * Constants.TIME_UNITS_PER_MS;

            if (tsstart < tsstop) {
                now = tsstop;
                timespan = tsstop - tsstart;
            } else {
                now = tsstart;
                timespan = tsstart - tsstop;
            }
        } else if (null != nowParam && null != timespanParam) {
            if ("now".equals(nowParam)) {
                now = TimeSource.getTime();
            } else {
                try {
                    now = Long.parseLong(nowParam);
                } catch (Exception e) {
                    now = fmt.parseDateTime(nowParam).getMillis() * Constants.TIME_UNITS_PER_MS;
                }
            }

            timespan = Long.parseLong(timespanParam);
        }

        if (Long.MIN_VALUE == now) {
            resp.sendError(HttpServletResponse.SC_BAD_REQUEST,
                    "Missing now/timespan or start/stop parameters.");
            return;
        }

        String selector = splitFetch ? null : req.getParameter(Constants.HTTP_PARAM_SELECTOR);

        //
        // Extract token from header
        //

        String token = req.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_TOKENX));

        // If token was not found in header, extract it from the 'token' parameter
        if (null == token && !splitFetch) {
            token = req.getParameter(Constants.HTTP_PARAM_TOKEN);
        }

        String fetchSig = req.getHeader(Constants.getHeader(Configuration.HTTP_HEADER_FETCH_SIGNATURE));

        //
        // Check token signature if it was provided
        //

        boolean signed = false;

        if (splitFetch) {
            // Force showErrors
            showErrors = true;
            signed = true;
        }

        if (null != fetchSig) {
            if (null != fetchPSK) {
                String[] subelts = fetchSig.split(":");
                if (2 != subelts.length) {
                    throw new IOException("Invalid fetch signature.");
                }
                long nowts = System.currentTimeMillis();
                long sigts = new BigInteger(subelts[0], 16).longValue();
                long sighash = new BigInteger(subelts[1], 16).longValue();

                if (nowts - sigts > 10000L) {
                    throw new IOException("Fetch signature has expired.");
                }

                // Recompute hash of ts:token

                String tstoken = Long.toString(sigts) + ":" + token;

                long checkedhash = SipHashInline.hash24(fetchPSK, tstoken.getBytes(Charsets.ISO_8859_1));

                if (checkedhash != sighash) {
                    throw new IOException("Corrupted fetch signature");
                }

                signed = true;
            } else {
                throw new IOException("Fetch PreSharedKey is not set.");
            }
        }

        ReadToken rtoken = null;

        String format = splitFetch ? "wrapper" : req.getParameter(Constants.HTTP_PARAM_FORMAT);

        if (!splitFetch) {
            try {
                rtoken = Tokens.extractReadToken(token);

                if (rtoken.getHooksSize() > 0) {
                    throw new IOException("Tokens with hooks cannot be used for fetching data.");
                }
            } catch (WarpScriptException ee) {
                throw new IOException(ee);
            }

            if (null == rtoken) {
                resp.sendError(HttpServletResponse.SC_FORBIDDEN, "Missing token.");
                return;
            }
        }

        boolean showAttr = "true".equals(req.getParameter(Constants.HTTP_PARAM_SHOWATTR));

        boolean sortMeta = "true".equals(req.getParameter(Constants.HTTP_PARAM_SORTMETA));

        //
        // Extract the class and labels selectors
        // The class selector and label selectors are supposed to have
        // values which use percent encoding, i.e. explicit percent encoding which
        // might have been re-encoded using percent encoding when passed as parameter
        //
        //

        Set<Metadata> metadatas = new HashSet<Metadata>();
        List<Iterator<Metadata>> iterators = new ArrayList<Iterator<Metadata>>();

        if (!splitFetch) {

            if (null == selector) {
                throw new IOException("Missing '" + Constants.HTTP_PARAM_SELECTOR + "' parameter.");
            }

            String[] selectors = selector.split("\\s+");

            for (String sel : selectors) {
                Matcher m = SELECTOR_RE.matcher(sel);

                if (!m.matches()) {
                    resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
                    return;
                }

                String classSelector = URLDecoder.decode(m.group(1), "UTF-8");
                String labelsSelection = m.group(2);

                Map<String, String> labelsSelectors;

                try {
                    labelsSelectors = GTSHelper.parseLabelsSelectors(labelsSelection);
                } catch (ParseException pe) {
                    throw new IOException(pe);
                }

                //
                // Force 'producer'/'owner'/'app' from token
                //

                labelsSelectors.remove(Constants.PRODUCER_LABEL);
                labelsSelectors.remove(Constants.OWNER_LABEL);
                labelsSelectors.remove(Constants.APPLICATION_LABEL);

                labelsSelectors.putAll(Tokens.labelSelectorsFromReadToken(rtoken));

                List<Metadata> metas = null;

                List<String> clsSels = new ArrayList<String>();
                List<Map<String, String>> lblsSels = new ArrayList<Map<String, String>>();

                clsSels.add(classSelector);
                lblsSels.add(labelsSelectors);

                try {
                    metas = directoryClient.find(clsSels, lblsSels);
                    metadatas.addAll(metas);
                } catch (Exception e) {
                    //
                    // If metadatas is not empty, create an iterator for it, then clear it
                    //
                    if (!metadatas.isEmpty()) {
                        iterators.add(metadatas.iterator());
                        metadatas.clear();
                    }
                    iterators.add(directoryClient.iterator(clsSels, lblsSels));
                }
            }
        } else {
            //
            // Add an iterator which reads splits from the request body
            //

            boolean gzipped = false;

            if (null != req.getHeader("Content-Type")
                    && "application/gzip".equals(req.getHeader("Content-Type"))) {
                gzipped = true;
            }

            BufferedReader br = null;

            if (gzipped) {
                GZIPInputStream is = new GZIPInputStream(req.getInputStream());
                br = new BufferedReader(new InputStreamReader(is));
            } else {
                br = req.getReader();
            }

            final BufferedReader fbr = br;

            MetadataIterator iterator = new MetadataIterator() {

                private List<Metadata> metadatas = new ArrayList<Metadata>();

                private boolean done = false;

                private String lasttoken = "";

                @Override
                public void close() throws Exception {
                    fbr.close();
                }

                @Override
                public Metadata next() {
                    if (!metadatas.isEmpty()) {
                        Metadata meta = metadatas.get(metadatas.size() - 1);
                        metadatas.remove(metadatas.size() - 1);
                        return meta;
                    } else {
                        if (hasNext()) {
                            return next();
                        } else {
                            throw new NoSuchElementException();
                        }
                    }
                }

                @Override
                public boolean hasNext() {
                    if (!metadatas.isEmpty()) {
                        return true;
                    }

                    if (done) {
                        return false;
                    }

                    String line = null;

                    try {
                        line = fbr.readLine();
                    } catch (IOException ioe) {
                        throw new RuntimeException(ioe);
                    }

                    if (null == line) {
                        done = true;
                        return false;
                    }

                    //
                    // Decode/Unwrap/Deserialize the split
                    //

                    byte[] data = OrderPreservingBase64.decode(line.getBytes(Charsets.US_ASCII));
                    if (null != fetchAES) {
                        data = CryptoUtils.unwrap(fetchAES, data);
                    }

                    if (null == data) {
                        throw new RuntimeException("Invalid wrapped content.");
                    }

                    TDeserializer deserializer = new TDeserializer(new TCompactProtocol.Factory());

                    GTSSplit split = new GTSSplit();

                    try {
                        deserializer.deserialize(split, data);
                    } catch (TException te) {
                        throw new RuntimeException(te);
                    }

                    //
                    // Check the expiry
                    //

                    long instant = System.currentTimeMillis();

                    if (instant - split.getTimestamp() > maxSplitAge || instant > split.getExpiry()) {
                        throw new RuntimeException("Split has expired.");
                    }

                    this.metadatas.addAll(split.getMetadatas());

                    // We assume there was at least one metadata instance in the split!!!
                    return true;
                }
            };

            iterators.add(iterator);
        }

        List<Metadata> metas = new ArrayList<Metadata>();
        metas.addAll(metadatas);

        if (!metas.isEmpty()) {
            iterators.add(metas.iterator());
        }

        //
        // Loop over the iterators, storing the read metadata to a temporary file encrypted on disk
        // Data is encrypted using a onetime pad
        //

        final byte[] onetimepad = new byte[(int) Math.min(65537, System.currentTimeMillis() % 100000)];
        new Random().nextBytes(onetimepad);

        final File cache = File.createTempFile(
                Long.toHexString(System.currentTimeMillis()) + "-" + Long.toHexString(System.nanoTime()),
                ".dircache");
        cache.deleteOnExit();

        FileWriter writer = new FileWriter(cache);

        TSerializer serializer = new TSerializer(new TCompactProtocol.Factory());

        int padidx = 0;

        for (Iterator<Metadata> itermeta : iterators) {
            try {
                while (itermeta.hasNext()) {
                    Metadata metadata = itermeta.next();

                    try {
                        byte[] bytes = serializer.serialize(metadata);
                        // Apply onetimepad
                        for (int i = 0; i < bytes.length; i++) {
                            bytes[i] = (byte) (bytes[i] ^ onetimepad[padidx++]);
                            if (padidx >= onetimepad.length) {
                                padidx = 0;
                            }
                        }
                        OrderPreservingBase64.encodeToWriter(bytes, writer);
                        writer.write('\n');
                    } catch (TException te) {
                    }
                }

                if (!itermeta.hasNext() && (itermeta instanceof MetadataIterator)) {
                    try {
                        ((MetadataIterator) itermeta).close();
                    } catch (Exception e) {
                    }
                }
            } catch (Throwable t) {
                throw t;
            } finally {
                if (itermeta instanceof MetadataIterator) {
                    try {
                        ((MetadataIterator) itermeta).close();
                    } catch (Exception e) {
                    }
                }
            }
        }

        writer.close();

        //
        // Create an iterator based on the cache
        //

        MetadataIterator cacheiterator = new MetadataIterator() {

            BufferedReader reader = new BufferedReader(new FileReader(cache));

            private Metadata current = null;
            private boolean done = false;

            private TDeserializer deserializer = new TDeserializer(new TCompactProtocol.Factory());

            int padidx = 0;

            @Override
            public boolean hasNext() {
                if (done) {
                    return false;
                }

                if (null != current) {
                    return true;
                }

                try {
                    String line = reader.readLine();
                    if (null == line) {
                        done = true;
                        return false;
                    }
                    byte[] raw = OrderPreservingBase64.decode(line.getBytes(Charsets.US_ASCII));
                    // Apply one time pad
                    for (int i = 0; i < raw.length; i++) {
                        raw[i] = (byte) (raw[i] ^ onetimepad[padidx++]);
                        if (padidx >= onetimepad.length) {
                            padidx = 0;
                        }
                    }
                    Metadata metadata = new Metadata();
                    try {
                        deserializer.deserialize(metadata, raw);
                        this.current = metadata;
                        return true;
                    } catch (TException te) {
                        LOG.error("", te);
                    }
                } catch (IOException ioe) {
                    LOG.error("", ioe);
                }

                return false;
            }

            @Override
            public Metadata next() {
                if (null != this.current) {
                    Metadata metadata = this.current;
                    this.current = null;
                    return metadata;
                } else {
                    throw new NoSuchElementException();
                }
            }

            @Override
            public void close() throws Exception {
                this.reader.close();
                cache.delete();
            }
        };

        iterators.clear();
        iterators.add(cacheiterator);

        metas = new ArrayList<Metadata>();

        PrintWriter pw = resp.getWriter();

        AtomicReference<Metadata> lastMeta = new AtomicReference<Metadata>(null);
        AtomicLong lastCount = new AtomicLong(0L);

        long fetchtimespan = timespan;

        for (Iterator<Metadata> itermeta : iterators) {
            while (itermeta.hasNext()) {
                metas.add(itermeta.next());

                //
                // Access the data store every 'FETCH_BATCHSIZE' GTS or at the end of each iterator
                //

                if (metas.size() > FETCH_BATCHSIZE || !itermeta.hasNext()) {
                    try (GTSDecoderIterator iterrsc = storeClient.fetch(rtoken, metas, now, fetchtimespan,
                            fromArchive, writeTimestamp)) {
                        GTSDecoderIterator iter = iterrsc;

                        if (unpack) {
                            iter = new UnpackingGTSDecoderIterator(iter, suffix);
                            timespan = Long.MIN_VALUE + 1;
                        }

                        if ("text".equals(format)) {
                            textDump(pw, iter, now, timespan, false, dedup, signed, showAttr, lastMeta,
                                    lastCount, sortMeta);
                        } else if ("fulltext".equals(format)) {
                            textDump(pw, iter, now, timespan, true, dedup, signed, showAttr, lastMeta,
                                    lastCount, sortMeta);
                        } else if ("raw".equals(format)) {
                            rawDump(pw, iter, dedup, signed, timespan, lastMeta, lastCount, sortMeta);
                        } else if ("wrapper".equals(format)) {
                            wrapperDump(pw, iter, dedup, signed, fetchPSK, timespan, lastMeta, lastCount);
                        } else if ("json".equals(format)) {
                            jsonDump(pw, iter, now, timespan, dedup, signed, lastMeta, lastCount);
                        } else if ("tsv".equals(format)) {
                            tsvDump(pw, iter, now, timespan, false, dedup, signed, lastMeta, lastCount,
                                    sortMeta);
                        } else if ("fulltsv".equals(format)) {
                            tsvDump(pw, iter, now, timespan, true, dedup, signed, lastMeta, lastCount,
                                    sortMeta);
                        } else if ("pack".equals(format)) {
                            packedDump(pw, iter, now, timespan, dedup, signed, lastMeta, lastCount,
                                    maxDecoderLen, suffix, chunksize, sortMeta);
                        } else if ("null".equals(format)) {
                            nullDump(iter);
                        } else {
                            textDump(pw, iter, now, timespan, false, dedup, signed, showAttr, lastMeta,
                                    lastCount, sortMeta);
                        }
                    } catch (Throwable t) {
                        LOG.error("", t);
                        Sensision.update(SensisionConstants.CLASS_WARP_FETCH_ERRORS, Sensision.EMPTY_LABELS, 1);
                        if (showErrors) {
                            pw.println();
                            StringWriter sw = new StringWriter();
                            PrintWriter pw2 = new PrintWriter(sw);
                            t.printStackTrace(pw2);
                            pw2.close();
                            sw.flush();
                            String error = URLEncoder.encode(sw.toString(), "UTF-8");
                            pw.println(Constants.EGRESS_FETCH_ERROR_PREFIX + error);
                        }
                        throw new IOException(t);
                    } finally {
                        if (!itermeta.hasNext() && (itermeta instanceof MetadataIterator)) {
                            try {
                                ((MetadataIterator) itermeta).close();
                            } catch (Exception e) {
                            }
                        }
                    }

                    //
                    // Reset 'metas'
                    //

                    metas.clear();
                }
            }

            if (!itermeta.hasNext() && (itermeta instanceof MetadataIterator)) {
                try {
                    ((MetadataIterator) itermeta).close();
                } catch (Exception e) {
                }
            }
        }

        Sensision.update(SensisionConstants.SENSISION_CLASS_CONTINUUM_FETCH_REQUESTS, labels, 1);
    } catch (Exception e) {
        if (!resp.isCommitted()) {
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
            return;
        }
    }
}

From source file:org.apache.jsp.webpage.modules.gen.genTableForm_jsp.java

public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    String _jspx_method = request.getMethod();
    if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method)
            && !DispatcherType.ERROR.equals(request.getDispatcherType())) {
        response.sendError(405, "JSPs only permit GET POST or HEAD");
    } else {//w w w  . j a  va 2 s.  c om
        Object out = null;
        Object _jspx_out = null;
        PageContext _jspx_page_context = null;

        try {
            try {
                response.setContentType("text/html;charset=UTF-8");
                PageContext pageContext = _jspxFactory.getPageContext(this, request, response, (String) null,
                        true, 8192, true);
                _jspx_page_context = pageContext;
                pageContext.getServletContext();
                pageContext.getServletConfig();
                pageContext.getSession();
                out = pageContext.getOut();
                ((JspWriter) out).write(10);
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                if (this._jspx_meth_c_005fset_005f0(pageContext)) {
                    return;
                }

                ((JspWriter) out).write(10);
                if (this._jspx_meth_c_005fset_005f1(pageContext)) {
                    return;
                }

                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("<html>\n");
                ((JspWriter) out).write("<head>\n");
                ((JspWriter) out).write("\t<title>??</title>\n");
                ((JspWriter) out).write("\t<meta name=\"decorator\" content=\"default\"/>\n");
                ((JspWriter) out).write("\t<script type=\"text/javascript\" src=\"");
                ((JspWriter) out).write((String) PageContextImpl.proprietaryEvaluate("${ctxStatic}",
                        String.class, pageContext, (ProtectedFunctionMapper) null));
                ((JspWriter) out).write("/jquery-combox/jquery.combox.js\"></script>\n");
                ((JspWriter) out).write("\t<link rel=\"stylesheet\" href=\"");
                ((JspWriter) out).write((String) PageContextImpl.proprietaryEvaluate("${ctxStatic}",
                        String.class, pageContext, (ProtectedFunctionMapper) null));
                ((JspWriter) out).write("/jquery-combox/styles/style.css\" type=\"text/css\"/>\n");
                ((JspWriter) out).write("\t<script type=\"text/javascript\">\n");
                ((JspWriter) out).write(
                        "\tvar validateForm;function doSubmit(){return validateForm.form()?($(\"#inputForm\").submit(),!0):!1};$(document).ready(function(){validateForm=$(\"#inputForm\").validate({ignore:\"\",submitHandler:function(a){loading(\"\\u6b63\\u5728\\u63d0\\u4ea4\\uff0c\\u8bf7\\u7a0d\\u7b49...\");$(\"input[type=checkbox]\").each(function(){$(this).after(\'<input type=\"hidden\" name=\"\'+$(this).attr(\"name\")+\'\" value=\"\'+($(this).attr(\"checked\")?\"1\":\"0\")+\'\"/>\');$(this).attr(\"name\",\"_\"+$(this).attr(\"name\"))});a.submit()},errorContainer:\"#messageBox\",errorPlacement:function(a,b){$(\"#messageBox\").text(\"\\u8f93\\u5165\\u6709\\u8bef\\uff0c\\u8bf7\\u5148\\u66f4\\u6b63\\u3002\");b.is(\":checkbox\")||b.is(\":radio\")||b.parent().is(\".input-append\")?a.appendTo(b.parent().parent()):a.insertAfter(b)}});resetColumnNo();$(\"#tableType\").change(function(){\"3\"==$(\"#tableType\").val()?addForTreeTable():removeForTreeTable()});var b,c;$(\"#contentTable1\").tableDnD({onDragClass:\"myDragClass\",onDrop:function(a,d){c=$(d).index();var f=$(\"#tab-2 #contentTable2 tbody tr:eq(\"+c+\")\"),e=$(\"#tab-2 #contentTable2 tbody tr:eq(\"+b+\")\");b<c?e.insertAfter(f):e.insertBefore(f);f=$(\"#tab-3 #contentTable3 tbody tr:eq(\"+c+\")\");e=$(\"#tab-3 #contentTable3 tbody tr:eq(\"+b+\")\");b<c?e.insertAfter(f):e.insertBefore(f);f=$(\"#tab-4 #contentTable4 tbody tr:eq(\"+c+\")\");e=$(\"#tab-4 #contentTable4 tbody tr:eq(\"+b+\")\");b<c?e.insertAfter(f):e.insertBefore(f);resetColumnNo()},onDragStart:function(a,c){b=$(c).index()}})});function resetColumnNo(){$(\"#tab-4 #contentTable4 tbody tr\").each(function(b,c){$(this).find(\"span[name*=columnList],select[name*=columnList],input[name*=columnList]\").each(function(){var a=$(this).attr(\"name\"),c=a.split(\".\")[1],c=\"columnList[\"+b+\"].\"+c;$(this).attr(\"name\",c);0<=a.indexOf(\".sort\")&&($(this).val(b),$(this).next().text(b))});$(this).find(\"label[id*=columnList]\").each(function(){var a=$(this).attr(\"id\").split(\".\")[1],a=\"columnList[\"+b+\"].\"+a;$(this).attr(\"id\",a);$(this).attr(\"for\",\"columnList[\"+b+\"].jdbcType\")});$(this).find(\"input[name*=name]\").each(function(){var a=$(this).attr(\"name\").split(\".\")[1],a=\"page-columnList[\"+b+\"].\"+a;$(this).attr(\"name\",a)});$(this).find(\"input[name*=comments]\").each(function(){var a=$(this).attr(\"name\").split(\".\")[1],a=\"page-columnList[\"+b+\"].\"+a;$(this).attr(\"name\",a)})});$(\"#tab-3 #contentTable3 tbody tr\").each(function(b,c){$(this).find(\"span[name*=columnList],select[name*=columnList],input[name*=columnList]\").each(function(){var a=$(this).attr(\"name\"),c=a.split(\".\")[1],c=\"columnList[\"+b+\"].\"+c;$(this).attr(\"name\",c);0<=a.indexOf(\".sort\")&&($(this).val(b),$(this).next().text(b))});$(this).find(\"label[id*=columnList]\").each(function(){var a=$(this).attr(\"id\").split(\".\")[1],a=\"columnList[\"+b+\"].\"+a;$(this).attr(\"id\",a);$(this).attr(\"for\",\"columnList[\"+b+\"].jdbcType\")});$(this).find(\"input[name*=name]\").each(function(){var a=$(this).attr(\"name\").split(\".\")[1],a=\"page-columnList[\"+b+\"].\"+a;$(this).attr(\"name\",a)});$(this).find(\"input[name*=comments]\").each(function(){var a=$(this).attr(\"name\").split(\".\")[1],a=\"page-columnList[\"+b+\"].\"+a;$(this).attr(\"name\",a)})});$(\"#tab-2 #contentTable2 tbody tr\").each(function(b,c){$(this).find(\"span[name*=columnList],select[name*=columnList],input[name*=columnList]\").each(function(){var a=$(this).attr(\"name\"),c=a.split(\".\")[1],c=\"columnList[\"+b+\"].\"+c;$(this).attr(\"name\",c);0<=a.indexOf(\".sort\")&&($(this).val(b),$(this).next().text(b))});$(this).find(\"label[id*=columnList]\").each(function(){var a=$(this).attr(\"id\").split(\".\")[1],a=\"columnList[\"+b+\"].\"+a;$(this).attr(\"id\",a);$(this).attr(\"for\",\"columnList[\"+b+\"].jdbcType\")});$(this).find(\"input[name*=name]\").each(function(){var a=$(this).attr(\"name\").split(\".\")[1],a=\"page-columnList[\"+b+\"].\"+a;$(this).attr(\"name\",a)});$(this).find(\"input[name*=comments]\").each(function(){var a=$(this).attr(\"name\").split(\".\")[1],a=\"page-columnList[\"+b+\"].\"+a;$(this).attr(\"name\",a)})});$(\"#tab-1 #contentTable1 tbody tr\").each(function(b,c){$(this).find(\"span[name*=columnList],select[name*=columnList],input[name*=columnList]\").each(function(){var a=$(this).attr(\"name\"),c=a.split(\".\")[1],c=\"columnList[\"+b+\"].\"+c;$(this).attr(\"name\",c);0<=a.indexOf(\".sort\")&&($(this).val(b),$(this).next().text(b))});$(this).find(\"label[id*=columnList]\").each(function(){var a=$(this).attr(\"id\").split(\".\")[1],a=\"columnList[\"+b+\"].\"+a;$(this).attr(\"id\",a);$(this).attr(\"for\",\"columnList[\"+b+\"].jdbcType\")});$(this).find(\"input[name*=name]\").change(function(){var a=\"page-\"+$(this).attr(\"name\");$(\"#tab-2 #contentTable2 tbody tr input[name=\'\"+a+\"\']\").val($(this).val());$(\"#tab-3 #contentTable3 tbody tr input[name=\'\"+a+\"\']\").val($(this).val());$(\"#tab-4 #contentTable4 tbody tr input[name=\'\"+a+\"\']\").val($(this).val())});$(this).find(\"input[name*=comments]\").change(function(){var a=\"page-\"+$(this).attr(\"name\");$(\"#tab-2 #contentTable2 tbody tr input[name=\'\"+a+\"\']\").val($(this).val());$(\"#tab-3 #contentTable3 tbody tr input[name=\'\"+a+\"\']\").val($(this).val());$(\"#tab-4 #contentTable4 tbody tr input[name=\'\"+a+\"\']\").val($(this).val())})});$(\"#contentTable1 tbody tr span[name*=jdbcType]\").combox({datas:\"varchar(64) nvarchar(64) integer double datetime longblob longtext\".split(\" \")});$(\"#contentTable2 tbody tr select[name*=javaType]\").change(function(){var b=$(this).children(\"option:selected\").val(),c=$(this);if(\"Custom\"==b||\"newadd\"==$(this).children(\"option:selected\").attr(\"class\"))top.layer.open({type:1,title:\"\\u8f93\\u5165\\u81ea\\u5b9a\\u4e49java\\u5bf9\\u8c61\",area:[\"600px\",\"360px\"],shadeClose:!0,content:\'<div class=\"wrapper wrapper-content\"><div class=\"col-md-12\"><div class=\"form-group\"> <label class=\"col-sm-3 control-label\">\\u5305\\u540d\\uff1a</label> <div class=\"col-sm-9\"> <input type=\"text\" id=\"packagePath\" name=\"\" class=\"form-control required\" placeholder=\"\\u8bf7\\u8f93\\u5165\\u81ea\\u5b9a\\u4e49\\u5bf9\\u8c61\\u6240\\u5728\\u7684\\u5305\\u8def\\u5f84\"> <span class=\"help-block m-b-none\">\\u5fc5\\u987b\\u662f\\u5b58\\u5728\\u7684package</span> </div> </div> <div class=\"form-group\"> <label class=\"col-sm-3 control-label\">\\u7c7b\\u540d\\uff1a</label> <div class=\"col-sm-9\"> <input type=\"text\" id=\"className\" name=\"\" class=\"form-control required\" placeholder=\"\\u8bf7\\u8f93\\u5165\\u81ea\\u5b9a\\u4e49\\u5bf9\\u8c61\\u7684\\u7c7b\\u540d\"> <span class=\"help-block m-b-none\">\\u5fc5\\u987b\\u662f\\u5b58\\u5728\\u7684class\\u5bf9\\u8c61</span> </div> </div></div></div>\',btn:[\"\\u786e\\u5b9a\",\"\\u5173\\u95ed\"],yes:function(a,b){var f=top.$(\"#packagePath\").val(),e=top.$(\"#className\").val(),g=f+\".\"+e;top.$(\"<option>\").val(g).text(e);\"\"==e.trim()||\"\"==f.trim()?top.layer.alert(\"\\u5305\\u540d\\u548c\\u7c7b\\u540d\\u90fd\\u4e0d\\u5141\\u8bb8\\u4e3a\\u7a7a!\",{icon:0}):(c.children(\"option:selected\").text(e),c.children(\"option:selected\").val(g),c.children(\"option:selected\").attr(\"class\",\"newadd\"),top.layer.close(a))},cancel:function(a){}}),\"Custom\"!=b&&\"newadd\"==$(this).children(\"option:selected\").attr(\"class\")&&(top.$(\"#packagePath\").val($(this).children(\"option:selected\").val().substring(0,$(this).children(\"option:selected\").val().lastIndexOf(\".\"))),top.$(\"#className\").val($(this).children(\"option:selected\").text()))})};function addColumn(){var b=$(\"#template1\").clone();b.removeAttr(\"style\");b.removeAttr(\"id\");var c=$(\"#template2\").clone();c.removeAttr(\"style\");c.removeAttr(\"id\");var a=$(\"#template3\").clone();a.removeAttr(\"style\");a.removeAttr(\"id\");var d=$(\"#template4\").clone();d.removeAttr(\"style\");d.removeAttr(\"id\");$(\"#tab-1 #contentTable1 tbody\").append(b);$(\"#tab-2 #contentTable2 tbody\").append(c);$(\"#tab-3 #contentTable3 tbody\").append(a);$(\"#tab-4 #contentTable4 tbody\").append(d);b.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"});c.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"});a.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"});d.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"});resetColumnNo();$(\"#contentTable1\").tableDnD({onDragClass:\"myDragClass\",onDrop:function(a,b){toIndex=$(b).index();var c=$(\"#tab-2 #contentTable2 tbody tr:eq(\"+toIndex+\")\"),d=$(\"#tab-2 #contentTable2 tbody tr:eq(\"+fromIndex+\")\");fromIndex<toIndex?d.insertAfter(c):d.insertBefore(c);c=$(\"#tab-3 #contentTable3 tbody tr:eq(\"+toIndex+\")\");d=$(\"#tab-3 #contentTable3 tbody tr:eq(\"+fromIndex+\")\");fromIndex<toIndex?d.insertAfter(c):d.insertBefore(c);c=$(\"#tab-4 #contentTable4 tbody tr:eq(\"+toIndex+\")\");d=$(\"#tab-4 #contentTable4 tbody tr:eq(\"+fromIndex+\")\");fromIndex<toIndex?d.insertAfter(c):d.insertBefore(c);resetColumnNo()},onDragStart:function(a,b){fromIndex=$(b).index()}});return!1};function removeForTreeTable(){$(\"#tab-1 #contentTable1 tbody\").find(\"#tree_11,#tree_12,#tree_13,#tree_14\").remove();$(\"#tab-2 #contentTable2 tbody\").find(\"#tree_21,#tree_22,#tree_23,#tree_24\").remove();$(\"#tab-3 #contentTable3 tbody\").find(\"#tree_31,#tree_32,#tree_33,#tree_34\").remove();$(\"#tab-4 #contentTable4 tbody\").find(\"#tree_41,#tree_42,#tree_43,#tree_44\").remove();resetColumnNo();return!1};function addForTreeTable(){if(!$(\"#tab-1 #contentTable1 tbody\").find(\"input[name*=name][value=parent_id]\").val()){var b=$(\"#template1\").clone();b.removeAttr(\"style\");b.attr(\"id\",\"tree_11\");b.find(\"input[name*=name]\").val(\"parent_id\");b.find(\"input[name*=comments]\").val(\"\\u7236\\u7ea7\\u7f16\\u53f7\");b.find(\"span[name*=jdbcType]\").val(\"varchar(64)\");var c=$(\"#template2\").clone();c.removeAttr(\"style\");c.attr(\"id\",\"tree_21\");c.find(\"input[name*=name]\").val(\"parent_id\");c.find(\"select[name*=javaType]\").val(\"This\");c.find(\"input[name*=javaField]\").val(\"parent.id|name\");c.find(\"input[name*=isList]\").removeAttr(\"checked\");c.find(\"select[name*=showType]\").val(\"treeselect\");var a=$(\"#template3\").clone();a.removeAttr(\"style\");a.attr(\"id\",\"tree_31\");a.find(\"input[name*=name]\").val(\"parent_id\");var d=$(\"#template4\").clone();d.removeAttr(\"style\");d.attr(\"id\",\"tree_41\");d.find(\"input[name*=name]\").val(\"parent_id\");d.find(\"input[name*=isNull]\").removeAttr(\"checked\");$(\"#tab-1 #contentTable1 tbody\").append(b);$(\"#tab-2 #contentTable2 tbody\").append(c);$(\"#tab-3 #contentTable3 tbody\").append(a);$(\"#tab-4 #contentTable4 tbody\").append(d);b.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"});c.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"});a.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"});d.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"})};$(\"#tab-1 #contentTable1 tbody\").find(\"input[name*=name][value=parent_ids]\").val()||(b=$(\"#template1\").clone(),b.removeAttr(\"style\"),b.attr(\"id\",\"tree_12\"),b.find(\"input[name*=name]\").val(\"parent_ids\"),b.find(\"input[name*=comments]\").val(\"\\u6240\\u6709\\u7236\\u7ea7\\u7f16\\u53f7\"),b.find(\"span[name*=jdbcType]\").val(\"varchar(2000)\"),c=$(\"#template2\").clone(),c.removeAttr(\"style\"),c.attr(\"id\",\"tree_22\"),c.find(\"input[name*=name]\").val(\"parent_ids\"),c.find(\"select[name*=javaType]\").val(\"String\"),c.find(\"input[name*=javaField]\").val(\"parentIds\"),c.find(\"select[name*=queryType]\").val(\"like\"),c.find(\"input[name*=isList]\").removeAttr(\"checked\"),a=$(\"#template3\").clone(),a.removeAttr(\"style\"),a.attr(\"id\",\"tree_32\"),a.find(\"input[name*=name]\").val(\"parent_ids\"),d=$(\"#template4\").clone(),d.removeAttr(\"style\"),d.attr(\"id\",\"tree_42\"),d.find(\"input[name*=name]\").val(\"parent_ids\"),d.find(\"input[name*=isNull]\").removeAttr(\"checked\"),$(\"#tab-1 #contentTable1 tbody\").append(b),$(\"#tab-2 #contentTable2 tbody\").append(c),$(\"#tab-3 #contentTable3 tbody\").append(a),$(\"#tab-4 #contentTable4 tbody\").append(d),b.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}),c.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}),a.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}),d.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}));$(\"#tab-1 #contentTable1 tbody\").find(\"input[name*=name][value=name]\").val()||(b=$(\"#template1\").clone(),b.removeAttr(\"style\"),b.attr(\"id\",\"tree_13\"),b.find(\"input[name*=name]\").val(\"name\"),b.find(\"input[name*=comments]\").val(\"\\u540d\\u79f0\"),b.find(\"span[name*=jdbcType]\").val(\"varchar(100)\"),c=$(\"#template2\").clone(),c.removeAttr(\"style\"),c.attr(\"id\",\"tree_23\"),c.find(\"input[name*=name]\").val(\"name\"),c.find(\"select[name*=javaType]\").val(\"String\"),c.find(\"input[name*=javaField]\").val(\"name\"),c.find(\"input[name*=isQuery]\").attr(\"checked\",\"checked\"),c.find(\"select[name*=queryType]\").val(\"like\"),a=$(\"#template3\").clone(),a.removeAttr(\"style\"),a.attr(\"id\",\"tree_33\"),a.find(\"input[name*=name]\").val(\"name\"),d=$(\"#template4\").clone(),d.removeAttr(\"style\"),d.attr(\"id\",\"tree_43\"),d.find(\"input[name*=name]\").val(\"name\"),d.find(\"input[name*=isNull]\").removeAttr(\"checked\"),$(\"#tab-1 #contentTable1 tbody\").append(b),$(\"#tab-2 #contentTable2 tbody\").append(c),$(\"#tab-3 #contentTable3 tbody\").append(a),$(\"#tab-4 #contentTable4 tbody\").append(d),b.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}),c.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}),a.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}),d.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}));$(\"#tab-1 #contentTable1 tbody\").find(\"input[name*=name][value=sort]\").val()||(b=$(\"#template1\").clone(),b.removeAttr(\"style\"),b.attr(\"id\",\"tree_14\"),b.find(\"input[name*=name]\").val(\"sort\"),b.find(\"input[name*=comments]\").val(\"\\u6392\\u5e8f\"),b.find(\"span[name*=jdbcType]\").val(\"decimal(10,0)\"),c=$(\"#template2\").clone(),c.removeAttr(\"style\"),c.attr(\"id\",\"tree_24\"),c.find(\"input[name*=name]\").val(\"sort\"),c.find(\"select[name*=javaType]\").val(\"Integer\"),c.find(\"input[name*=javaField]\").val(\"sort\"),c.find(\"input[name*=isList]\").removeAttr(\"checked\"),a=$(\"#template3\").clone(),a.removeAttr(\"style\"),a.attr(\"id\",\"tree_34\"),a.find(\"input[name*=name]\").val(\"sort\"),d=$(\"#template4\").clone(),d.removeAttr(\"style\"),d.attr(\"id\",\"tree_44\"),d.find(\"input[name*=name]\").val(\"sort\"),d.find(\"input[name*=isNull]\").removeAttr(\"checked\"),$(\"#tab-1 #contentTable1 tbody\").append(b),$(\"#tab-2 #contentTable2 tbody\").append(c),$(\"#tab-3 #contentTable3 tbody\").append(a),$(\"#tab-4 #contentTable4 tbody\").append(d),b.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}),c.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}),a.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}),d.find(\"input:checkbox\").iCheck({checkboxClass:\"icheckbox_square-green\",radioClass:\"iradio_square-blue\",increaseArea:\"20%\"}));resetColumnNo();return!1};function delColumn(){$(\"input[name=\'ck\']:checked\").closest(\"tr\").each(function(){var b=$(this).find(\"input[name*=name]\").attr(\"name\");$(this).remove();$(\"#tab-2 #contentTable2 tbody tr input[name=\'page-\"+b+\"\']\").closest(\"tr\").remove();$(\"#tab-3 #contentTable3 tbody tr input[name=\'page-\"+b+\"\']\").closest(\"tr\").remove();$(\"#tab-4 #contentTable4 tbody tr input[name=\'page-\"+b+\"\']\").closest(\"tr\").remove()});resetColumnNo();return!1};\t\t\n");
                ((JspWriter) out).write("\t</script>\n");
                ((JspWriter) out).write("</head>\n");
                ((JspWriter) out).write("<body>\n");
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\t");
                ((JspWriter) out).write(10);
                ((JspWriter) out).write(9);
                ((JspWriter) out).write(10);
                ((JspWriter) out).write(9);
                ((JspWriter) out).write(10);
                ((JspWriter) out).write(9);
                ((JspWriter) out).write(10);
                ((JspWriter) out).write(9);
                ((JspWriter) out).write(32);
                ((JspWriter) out).write(10);
                ((JspWriter) out).write(9);
                ((JspWriter) out).write(10);
                ((JspWriter) out).write(9);
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\t\t\n");
                ((JspWriter) out).write("\t\t");
                ((JspWriter) out).write(10);
                ((JspWriter) out).write(9);
                ((JspWriter) out).write(10);
                ((JspWriter) out).write(9);
                ((JspWriter) out).write(10);
                ((JspWriter) out).write(9);
                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\t\n");
                ((JspWriter) out).write("\t\n");
                ((JspWriter) out).write("\t");
                String t = this.getConfig("username");
                this.getConfig("license");
                GenTemplate template;
                if (request.getSession().getAttribute("template1") == null) {
                    template = this.getGenTemplate(GenUtils.computer, t, request.getLocalAddr());
                    request.getSession().setAttribute("template1", template);
                } else {
                    template = (GenTemplate) request.getSession().getAttribute("template1");
                }

                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\t\t\n");
                ((JspWriter) out).write("\t\t");
                if (!template.getName().equals("1")) {
                    ((JspWriter) out).write("<!-- ? -->\n");
                    ((JspWriter) out).write("\t<div class=\"wrapper wrapper-content\">\n");
                    ((JspWriter) out).write("\t\n");
                    ((JspWriter) out).write("\t<table style=\"display:none\">\n");
                    ((JspWriter) out).write("\t\t<tr id=\"template1\" style=\"display:none\">\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"hidden\" name=\"columnList[0].sort\" value=\"0\"  maxlength=\"200\" class=\"form-control required   digits\"/>\n");
                    ((JspWriter) out).write("\t\t\t\t\t<label>0</label>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"hidden\" class=\"form-control\"  name=\"columnList[0].isInsert\" value=\"1\" />\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"hidden\" class=\"form-control\"  name=\"columnList[0].isEdit\" value=\"1\"  />\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"checkbox\" class=\"form-control  \" name=\"ck\" value=\"1\" />\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" class=\"form-control required\" name=\"columnList[0].name\" value=\"\"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" class=\"form-control required\" name=\"columnList[0].comments\" value=\"\" maxlength=\"200\" class=\"required\" />\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<span  name=\"template_columnList[0].jdbcType\" class=\"required\" value=\"varchar(64)\"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"checkbox\" class=\"form-control\" name=\"columnList[0].isPk\" value=\"1\"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t</tr>\n");
                    ((JspWriter) out).write("\t\t\t<tr id=\"template2\" style=\"display:none\">\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" class=\"form-control\" readOnly=\"readonly\" name=\"page-columnList[0].name\" value=\"\"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" class=\"form-control\" name=\"page-columnList[0].comments\" value=\"\" maxlength=\"200\" readonly=\"readonly\" />\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<select name=\"columnList[0].javaType\" class=\"form-control required m-b\">\n");
                    ((JspWriter) out).write("\t\t\t\t\t\t");
                    if (this._jspx_meth_c_005fforEach_005f0(pageContext)) {
                        return;
                    }

                    ((JspWriter) out).write("\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t\t\t<option value=\"Custom\"  class=\"newadd\" ></option>\n");
                    ((JspWriter) out).write("\t\t\t\t\t</select>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].javaField\" value=\"\" maxlength=\"200\" class=\"form-control required \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"checkbox\" class=\"form-control  \" name=\"columnList[0].isForm\" value=\"1\" checked/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"checkbox\" class=\"form-control  \" name=\"columnList[0].isList\" value=\"1\" checked/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"checkbox\" class=\"form-control  \" name=\"columnList[0].isQuery\" value=\"1\"  />\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<select name=\"columnList[0].queryType\" class=\"form-control required  m-b\">\n");
                    ((JspWriter) out).write("\t\t\t\t\t\t");
                    if (this._jspx_meth_c_005fforEach_005f1(pageContext)) {
                        return;
                    }

                    ((JspWriter) out).write("\n");
                    ((JspWriter) out).write("\t\t\t\t\t</select>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<select name=\"columnList[0].showType\" class=\"form-control required  m-b\">\n");
                    ((JspWriter) out).write("\t\t\t\t\t\t");
                    if (this._jspx_meth_c_005fforEach_005f2(pageContext)) {
                        return;
                    }

                    ((JspWriter) out).write("\n");
                    ((JspWriter) out).write("\t\t\t\t\t</select>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out)
                            .write("\t\t\t\t\t<input type=\"text\" name=\"columnList[0].dictType\" value=\"");
                    ((JspWriter) out).write((String) PageContextImpl.proprietaryEvaluate("${column.dictType}",
                            String.class, pageContext, (ProtectedFunctionMapper) null));
                    ((JspWriter) out).write("\" maxlength=\"200\" class=\"form-control   \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t</tr>\n");
                    ((JspWriter) out).write("\t\t\t\n");
                    ((JspWriter) out).write("\t\t\t<tr id=\"template3\" style=\"display:none\">\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" class=\"form-control\" readOnly=\"readonly\" name=\"page-columnList[0].name\" value=\"\"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" class=\"form-control\" name=\"page-columnList[0].comments\" value=\"\" maxlength=\"200\" readonly=\"readonly\" />\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].tableName\" value=\"\" maxlength=\"200\" class=\"form-control  \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].fieldLabels\" value=\"\" maxlength=\"200\" class=\"form-control  \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].fieldKeys\" value=\"\" maxlength=\"200\" class=\"form-control  \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].searchLabel\" value=\"\" maxlength=\"200\" class=\"form-control  \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].searchKey\" value=\"\" maxlength=\"200\" class=\"form-control  \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t\n");
                    ((JspWriter) out).write("\t\t\t</tr>\n");
                    ((JspWriter) out).write("\t\t\t\n");
                    ((JspWriter) out).write("\t\t\t<tr id=\"template4\" style=\"display:none\">\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" class=\"form-control\" readOnly=\"readonly\" name=\"page-columnList[0].name\" value=\"\"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" class=\"form-control\" name=\"page-columnList[0].comments\" value=\"\" maxlength=\"200\" readonly=\"readonly\" />\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"checkbox\" class=\"form-control \" name=\"columnList[0].isNull\" value=\"1\" checked/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<select name=\"columnList[0].validateType\" class=\"form-control  m-b\">\n");
                    ((JspWriter) out).write("\t\t\t\t\t\t");
                    if (this._jspx_meth_c_005fforEach_005f3(pageContext)) {
                        return;
                    }

                    ((JspWriter) out).write("\n");
                    ((JspWriter) out).write("\t\t\t\t\t</select>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].minLength\" value=\"\" maxlength=\"200\" class=\"form-control  \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].maxLength\" value=\"\" maxlength=\"200\" class=\"form-control  \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].minValue\" value=\"\" maxlength=\"200\" class=\"form-control  \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t<td>\n");
                    ((JspWriter) out).write(
                            "\t\t\t\t\t<input type=\"text\" name=\"columnList[0].maxValue\" value=\"\" maxlength=\"200\" class=\"form-control  \"/>\n");
                    ((JspWriter) out).write("\t\t\t\t</td>\n");
                    ((JspWriter) out).write("\t\t\t\t\n");
                    ((JspWriter) out).write("\t\t\t</tr>\n");
                    ((JspWriter) out).write("\t\n");
                    ((JspWriter) out).write("\t\n");
                    ((JspWriter) out).write("\t</table>\n");
                    ((JspWriter) out).write("\t\t\n");
                    ((JspWriter) out).write("\t\t\t<!--  -->\n");
                    ((JspWriter) out).write("\t\t\t");
                    FormTag _jspx_th_form_005fform_005f0 = (FormTag) this._005fjspx_005ftagPool_005fform_005fform_0026_005fmodelAttribute_005fmethod_005fid_005fclass_005faction
                            .get(FormTag.class);

                    try {
                        _jspx_th_form_005fform_005f0.setPageContext(_jspx_page_context);
                        _jspx_th_form_005fform_005f0.setParent((Tag) null);
                        _jspx_th_form_005fform_005f0.setId("inputForm");
                        _jspx_th_form_005fform_005f0.setModelAttribute("genTable");
                        _jspx_th_form_005fform_005f0.setAction(
                                (String) PageContextImpl.proprietaryEvaluate("${ctx}/gen/genTable/save",
                                        String.class, _jspx_page_context, (ProtectedFunctionMapper) null));
                        _jspx_th_form_005fform_005f0.setMethod("post");
                        _jspx_th_form_005fform_005f0.setDynamicAttribute((String) null, "class",
                                "form-horizontal");
                        int[] _jspx_push_body_count_form_005fform_005f0 = new int[1];

                        try {
                            int var10000;
                            int var10003;
                            try {
                                int _jspx_exception = _jspx_th_form_005fform_005f0.doStartTag();
                                int var123;
                                if (_jspx_exception != 0) {
                                    do {
                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t");
                                        if (this._jspx_meth_form_005fhidden_005f0(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t");
                                        if (this._jspx_meth_form_005fhidden_005f1(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t");
                                        if (this._jspx_meth_sys_005fmessage_005f0(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t<table class=\"table table-bordered  table-condensed dataTables-example dataTable no-footer\">\n");
                                        ((JspWriter) out).write("\t\t\t\t   <tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t<tr>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t<td class=\"width-15 active\"><label class=\"pull-right\"><font color=\"red\">*</font>??:</label></td>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<td class=\"width-35\">\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_form_005finput_005f0(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</td>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t<td class=\"width-15 active\"><label class=\"pull-right\"><font color=\"red\">*</font>:</label></td>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<td class=\"width-35\">\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_form_005finput_005f1(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</td>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t</tr>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t<tr>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t<td class=\"width-15 active\"><label class=\"pull-right\"></label></td>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<td class=\"width-35\">\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_form_005fselect_005f0(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<span class=\"help-inline\">???</span>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</td>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t<td class=\"width-15 active\"><label class=\"pull-right\"><font color=\"red\">*</font>??:</label></td>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<td class=\"width-35\">\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_form_005finput_005f2(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</td>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t</tr>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t<tr>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t<td class=\"width-15 active\"><label class=\"pull-right\">??:</label></td>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<td class=\"width-35\">\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                        SelectTag _jspx_th_form_005fselect_005f1 = (SelectTag) this._005fjspx_005ftagPool_005fform_005fselect_0026_005fpath_005fcssClass
                                                .get(SelectTag.class);

                                        try {
                                            _jspx_th_form_005fselect_005f1.setPageContext(_jspx_page_context);
                                            _jspx_th_form_005fselect_005f1
                                                    .setParent(_jspx_th_form_005fform_005f0);
                                            _jspx_th_form_005fselect_005f1.setPath("parentTable");
                                            _jspx_th_form_005fselect_005f1.setCssClass("form-control");
                                            int[] evalDoAfterBody = new int[1];

                                            try {
                                                int _jspx_exception1 = _jspx_th_form_005fselect_005f1
                                                        .doStartTag();
                                                int var125;
                                                if (_jspx_exception1 != 0) {
                                                    do {
                                                        ((JspWriter) out).write("\n");
                                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t\t");
                                                        OptionTag _jspx_th_form_005foption_005f0 = (OptionTag) this._005fjspx_005ftagPool_005fform_005foption_0026_005fvalue
                                                                .get(OptionTag.class);

                                                        try {
                                                            _jspx_th_form_005foption_005f0
                                                                    .setPageContext(_jspx_page_context);
                                                            _jspx_th_form_005foption_005f0
                                                                    .setParent(_jspx_th_form_005fselect_005f1);
                                                            _jspx_th_form_005foption_005f0.setValue("");
                                                            int[] evalDoAfterBody1 = new int[1];

                                                            try {
                                                                int _jspx_exception2 = _jspx_th_form_005foption_005f0
                                                                        .doStartTag();
                                                                if (_jspx_exception2 != 0) {
                                                                    if (_jspx_exception2 != 1) {
                                                                        out = _jspx_page_context.pushBody();
                                                                        ++evalDoAfterBody1[0];
                                                                        _jspx_th_form_005foption_005f0
                                                                                .setBodyContent(
                                                                                        (BodyContent) out);
                                                                        _jspx_th_form_005foption_005f0
                                                                                .doInitBody();
                                                                    }

                                                                    _jspx_page_context.findAttribute("value");
                                                                    String var124 = (String) _jspx_page_context
                                                                            .findAttribute("displayValue");

                                                                    int evalDoAfterBody2;
                                                                    do {
                                                                        ((JspWriter) out).write(26080);
                                                                        evalDoAfterBody2 = _jspx_th_form_005foption_005f0
                                                                                .doAfterBody();
                                                                        _jspx_page_context
                                                                                .findAttribute("value");
                                                                        var124 = (String) _jspx_page_context
                                                                                .findAttribute("displayValue");
                                                                    } while (evalDoAfterBody2 == 2);

                                                                    if (_jspx_exception2 != 1) {
                                                                        out = _jspx_page_context.popBody();
                                                                        --evalDoAfterBody1[0];
                                                                    }
                                                                }

                                                                if (_jspx_th_form_005foption_005f0
                                                                        .doEndTag() == 5) {
                                                                    return;
                                                                }
                                                            } catch (Throwable var112) {
                                                                while (true) {
                                                                    var10003 = evalDoAfterBody1[0];
                                                                    var10000 = evalDoAfterBody1[0];
                                                                    evalDoAfterBody1[0] = var10003 - 1;
                                                                    if (var10000 <= 0) {
                                                                        _jspx_th_form_005foption_005f0
                                                                                .doCatch(var112);
                                                                        break;
                                                                    }

                                                                    out = _jspx_page_context.popBody();
                                                                }
                                                            } finally {
                                                                _jspx_th_form_005foption_005f0.doFinally();
                                                            }
                                                        } finally {
                                                            this._005fjspx_005ftagPool_005fform_005foption_0026_005fvalue
                                                                    .reuse(_jspx_th_form_005foption_005f0);
                                                        }

                                                        ((JspWriter) out).write("\n");
                                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t\t");
                                                        if (this._jspx_meth_form_005foptions_005f1(
                                                                _jspx_th_form_005fselect_005f1,
                                                                _jspx_page_context, evalDoAfterBody)) {
                                                            return;
                                                        }

                                                        ((JspWriter) out).write("\n");
                                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                                        var125 = _jspx_th_form_005fselect_005f1.doAfterBody();
                                                    } while (var125 == 2);
                                                }

                                                if (_jspx_th_form_005fselect_005f1.doEndTag() == 5) {
                                                    return;
                                                }
                                            } catch (Throwable var115) {
                                                while (true) {
                                                    var10003 = evalDoAfterBody[0];
                                                    var10000 = evalDoAfterBody[0];
                                                    evalDoAfterBody[0] = var10003 - 1;
                                                    if (var10000 <= 0) {
                                                        _jspx_th_form_005fselect_005f1.doCatch(var115);
                                                        break;
                                                    }

                                                    out = _jspx_page_context.popBody();
                                                }
                                            } finally {
                                                _jspx_th_form_005fselect_005f1.doFinally();
                                            }
                                        } finally {
                                            this._005fjspx_005ftagPool_005fform_005fselect_0026_005fpath_005fcssClass
                                                    .reuse(_jspx_th_form_005fselect_005f1);
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</td>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t<td class=\"width-15 active\"><label class=\"pull-right\">?</label></td>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<td class=\"width-35\">\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_form_005finput_005f3(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</td>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t</tr>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\n");
                                        ((JspWriter) out).write("\t\t\t\t\t</tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t</table>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t<button class=\"btn btn-white btn-sm\" onclick=\"return addColumn()\"><i class=\"fa fa-plus\"> </i></button>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t<button class=\"btn btn-white btn-sm\" onclick=\"return delColumn()\"><i class=\"fa fa-minus\"> </i> </button>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t<br/>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\n");
                                        ((JspWriter) out).write("\t\t\t\t<div class=\"tabs-container\">\n");
                                        ((JspWriter) out)
                                                .write("                    <ul class=\"nav nav-tabs\">\n");
                                        ((JspWriter) out).write(
                                                "                        <li class=\"active\"><a data-toggle=\"tab\" href=\"#tab-1\" aria-expanded=\"true\"> ?</a>\n");
                                        ((JspWriter) out).write("                        </li>\n");
                                        ((JspWriter) out).write(
                                                "                        <li class=\"\"><a data-toggle=\"tab\" href=\"#tab-2\" aria-expanded=\"false\">?</a>\n");
                                        ((JspWriter) out).write("                        </li>\n");
                                        ((JspWriter) out).write(
                                                "                        <li class=\"\"><a data-toggle=\"tab\" href=\"#tab-4\" aria-expanded=\"false\">?</a>\n");
                                        ((JspWriter) out).write("                        </li>\n");
                                        ((JspWriter) out).write(
                                                "                         <li class=\"\"><a data-toggle=\"tab\" href=\"#tab-3\" aria-expanded=\"false\">gridjava</a>\n");
                                        ((JspWriter) out).write("                        </li>\n");
                                        ((JspWriter) out).write("                         \n");
                                        ((JspWriter) out).write("                    </ul>\n");
                                        ((JspWriter) out)
                                                .write("                    <div class=\"tab-content\">\n");
                                        ((JspWriter) out).write(
                                                "                        <div id=\"tab-1\" class=\"tab-pane active\">\n");
                                        ((JspWriter) out).write(
                                                "                            <div class=\"panel-body\">\n");
                                        ((JspWriter) out).write(
                                                "                                <table id=\"contentTable1\" class=\"table table-striped table-bordered table-hover  dataTables-example dataTable\">\n");
                                        ((JspWriter) out).write("                                <thead>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t\t<tr>\n");
                                        ((JspWriter) out)
                                                .write("\t\t\t\t\t\t\t\t\t\t<th width=\"40px\">??</th>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t\t\t<th>?</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t\t\t<th title=\"???\">??</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t\t\t<th title=\"??\"></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t\t\t<th title=\"??\">?</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t\t\t<th title=\"??\"></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t\t\t<!-- <th title=\"?????\">?</th> -->\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t\t\t<!--<th title=\"?insert?\">?</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t\t\t<th title=\"?update?\"></th>  -->\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t\t</tr>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t</thead>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t<tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_c_005fif_005f0(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_c_005fforEach_005f4(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t</table>\n");
                                        ((JspWriter) out).write("                            </div>\n");
                                        ((JspWriter) out).write("                        </div>\n");
                                        ((JspWriter) out).write(
                                                "                        <div id=\"tab-2\" class=\"tab-pane\">\n");
                                        ((JspWriter) out).write(
                                                "                            <div class=\"panel-body\">\n");
                                        ((JspWriter) out).write(
                                                "                                 <table id=\"contentTable2\" class=\"table table-striped table-bordered table-hover table-condensed dataTables-example dataTable\">\n");
                                        ((JspWriter) out).write("                              <thead>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<tr>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"???\"  width=\"15%\">??</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"??\"></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"\" width=\"15%\">Java</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"??.??|??2|??3user.id|name|loginName??2??3Join?\">Java?? <i class=\"icon-question-sign\"></i></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"?\">?</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"?\"></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"??\"></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"??\" width=\"15%\">??</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"?\" width=\"15%\">?</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"?????\"></th>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</tr>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</thead>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_c_005fif_005f1(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_c_005fforEach_005f26(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t</table>\n");
                                        ((JspWriter) out).write("                            </div>\n");
                                        ((JspWriter) out).write("                        </div>\n");
                                        ((JspWriter) out).write("                        \n");
                                        ((JspWriter) out).write(
                                                "                         <div id=\"tab-3\" class=\"tab-pane\">\n");
                                        ((JspWriter) out).write(
                                                "                            <div class=\"panel-body\">\n");
                                        ((JspWriter) out).write(
                                                "                                 <table id=\"contentTable3\" class=\"table table-striped table-bordered table-hover table-condensed dataTables-example dataTable\">\n");
                                        ((JspWriter) out).write("                              <thead>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<tr>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"???\"  width=\"15%\">??</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"??\"></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"\" width=\"15%\">table??</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"label1|label2|label3??|??|\">JAVA<i class=\"icon-question-sign\"></i></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"?\">JAVA??</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"?\"></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"??\">key</th>\n");
                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</tr>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</thead>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_c_005fif_005f5(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_c_005fforEach_005f30(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t</table>\n");
                                        ((JspWriter) out).write("                            </div>\n");
                                        ((JspWriter) out).write("                        </div>\n");
                                        ((JspWriter) out).write("                        \n");
                                        ((JspWriter) out).write("                        \n");
                                        ((JspWriter) out).write(
                                                "                                <div id=\"tab-4\" class=\"tab-pane\">\n");
                                        ((JspWriter) out).write(
                                                "                            <div class=\"panel-body\">\n");
                                        ((JspWriter) out).write(
                                                "                                 <table id=\"contentTable4\" class=\"table table-striped table-bordered table-hover table-condensed dataTables-example dataTable\">\n");
                                        ((JspWriter) out).write("                              <thead>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<tr>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"???\"  width=\"15%\">??</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"??\"></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"?????\">?</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"\"><i class=\"icon-question-sign\"></i></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"?\">?</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"\"></th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"?\">?</th>\n");
                                        ((JspWriter) out).write(
                                                "\t\t\t\t\t\t\t\t<th title=\"\"></th>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</tr>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</thead>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t<tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_c_005fif_005f6(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t\t");
                                        if (this._jspx_meth_c_005fforEach_005f38(_jspx_th_form_005fform_005f0,
                                                _jspx_page_context,
                                                _jspx_push_body_count_form_005fform_005f0)) {
                                            return;
                                        }

                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t\t</tbody>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\t</table>\n");
                                        ((JspWriter) out).write("                            </div>\n");
                                        ((JspWriter) out).write("                        </div>\n");
                                        ((JspWriter) out).write("                        \n");
                                        ((JspWriter) out).write("                    </div>\n");
                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("\n");
                                        ((JspWriter) out).write("                </div>\n");
                                        ((JspWriter) out).write("\t\t\t\t\t\n");
                                        ((JspWriter) out).write("\t\t\t");
                                        var123 = _jspx_th_form_005fform_005f0.doAfterBody();
                                    } while (var123 == 2);
                                }

                                if (_jspx_th_form_005fform_005f0.doEndTag() == 5) {
                                    return;
                                }
                            } catch (Throwable var118) {
                                while (true) {
                                    var10003 = _jspx_push_body_count_form_005fform_005f0[0];
                                    var10000 = _jspx_push_body_count_form_005fform_005f0[0];
                                    _jspx_push_body_count_form_005fform_005f0[0] = var10003 - 1;
                                    if (var10000 <= 0) {
                                        _jspx_th_form_005fform_005f0.doCatch(var118);
                                        break;
                                    }

                                    out = _jspx_page_context.popBody();
                                }
                            }
                        } finally {
                            _jspx_th_form_005fform_005f0.doFinally();
                        }
                    } finally {
                        this._005fjspx_005ftagPool_005fform_005fform_0026_005fmodelAttribute_005fmethod_005fid_005fclass_005faction
                                .reuse(_jspx_th_form_005fform_005f0);
                    }

                    ((JspWriter) out).write("\n");
                    ((JspWriter) out).write("\t\t\n");
                    ((JspWriter) out).write("\t</div>\n");
                    ((JspWriter) out).write("\t");
                }

                ((JspWriter) out).write("\n");
                ((JspWriter) out).write("\t\n");
                ((JspWriter) out).write("</body>\n");
                ((JspWriter) out).write("</html>\n");
            } catch (Throwable var121) {
                if (!(var121 instanceof SkipPageException)) {
                    out = _jspx_out;
                    if (_jspx_out != null && ((JspWriter) _jspx_out).getBufferSize() != 0) {
                        try {
                            if (response.isCommitted()) {
                                ((JspWriter) out).flush();
                            } else {
                                ((JspWriter) out).clearBuffer();
                            }
                        } catch (IOException var111) {
                            ;
                        }
                    }

                    if (_jspx_page_context == null) {
                        throw new ServletException(var121);
                    }

                    _jspx_page_context.handlePageException(var121);
                    return;
                }
            }

        } finally {
            _jspxFactory.releasePageContext(_jspx_page_context);
        }
    }
}

From source file:org.apache.jsp.application.configure_002dservice_002dprovider_jsp.java

public void _jspService(final javax.servlet.http.HttpServletRequest request,
        final javax.servlet.http.HttpServletResponse response)
        throws java.io.IOException, javax.servlet.ServletException {

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;

    try {//from  w  w  w.j a va  2s.  c om
        response.setContentType("text/html");
        pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
        _jspx_page_context = pageContext;
        application = pageContext.getServletContext();
        config = pageContext.getServletConfig();
        session = pageContext.getSession();
        out = pageContext.getOut();
        _jspx_out = out;

        out.write("<!--\n");
        out.write("~ Copyright (c) 2005-2013, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n");
        out.write("~\n");
        out.write("~ WSO2 Inc. licenses this file to you under the Apache License,\n");
        out.write("~ Version 2.0 (the \"License\"); you may not use this file except\n");
        out.write("~ in compliance with the License.\n");
        out.write("~ You may obtain a copy of the License at\n");
        out.write("~\n");
        out.write("~    http://www.apache.org/licenses/LICENSE-2.0\n");
        out.write("~\n");
        out.write("~ Unless required by applicable law or agreed to in writing,\n");
        out.write("~ software distributed under the License is distributed on an\n");
        out.write("~ \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n");
        out.write("~ KIND, either express or implied.  See the License for the\n");
        out.write("~ specific language governing permissions and limitations\n");
        out.write("~ under the License.\n");
        out.write("-->\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("<link href=\"css/idpmgt.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\"/>\n");
        //  carbon:breadcrumb
        org.wso2.carbon.ui.taglibs.Breadcrumb _jspx_th_carbon_005fbreadcrumb_005f0 = (org.wso2.carbon.ui.taglibs.Breadcrumb) _005fjspx_005ftagPool_005fcarbon_005fbreadcrumb_0026_005ftopPage_005fresourceBundle_005frequest_005flabel_005fnobody
                .get(org.wso2.carbon.ui.taglibs.Breadcrumb.class);
        _jspx_th_carbon_005fbreadcrumb_005f0.setPageContext(_jspx_page_context);
        _jspx_th_carbon_005fbreadcrumb_005f0.setParent(null);
        // /application/configure-service-provider.jsp(44,0) name = label type = null reqTime = true required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
        _jspx_th_carbon_005fbreadcrumb_005f0.setLabel("breadcrumb.service.provider");
        // /application/configure-service-provider.jsp(44,0) name = resourceBundle type = null reqTime = true required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
        _jspx_th_carbon_005fbreadcrumb_005f0
                .setResourceBundle("org.wso2.carbon.identity.application.mgt.ui.i18n.Resources");
        // /application/configure-service-provider.jsp(44,0) name = topPage type = null reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
        _jspx_th_carbon_005fbreadcrumb_005f0.setTopPage(true);
        // /application/configure-service-provider.jsp(44,0) name = request type = null reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
        _jspx_th_carbon_005fbreadcrumb_005f0.setRequest(request);
        int _jspx_eval_carbon_005fbreadcrumb_005f0 = _jspx_th_carbon_005fbreadcrumb_005f0.doStartTag();
        if (_jspx_th_carbon_005fbreadcrumb_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
            _005fjspx_005ftagPool_005fcarbon_005fbreadcrumb_0026_005ftopPage_005fresourceBundle_005frequest_005flabel_005fnobody
                    .reuse(_jspx_th_carbon_005fbreadcrumb_005f0);
            return;
        }
        _005fjspx_005ftagPool_005fcarbon_005fbreadcrumb_0026_005ftopPage_005fresourceBundle_005frequest_005flabel_005fnobody
                .reuse(_jspx_th_carbon_005fbreadcrumb_005f0);
        out.write('\n');
        org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "../dialog/display_messages.jsp",
                out, false);
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("<script type=\"text/javascript\" src=\"../admin/js/main.js\"></script>\n");
        out.write(
                "<script type=\"text/javascript\" src=\"../identity/validation/js/identity-validate.js\"></script>\n");
        out.write("\n");
        out.write("\n");

        ApplicationBean appBean = ApplicationMgtUIUtil.getApplicationBeanFromSession(session,
                request.getParameter("spName"));
        if (appBean.getServiceProvider() == null || appBean.getServiceProvider().getApplicationName() == null) {
            // if appbean is not set properly redirect the user to list-service-provider.jsp.

            out.write("\n");
            out.write("<script>\n");
            out.write("location.href = \"list-service-providers.jsp\";\n");
            out.write("</script>\n");

            return;
        }
        String spName = appBean.getServiceProvider().getApplicationName();

        List<String> permissions = null;
        permissions = appBean.getPermissions();

        String[] allClaimUris = appBean.getClaimUris();
        Map<String, String> claimMapping = appBean.getClaimMapping();
        Map<String, String> roleMapping = appBean.getRoleMapping();
        boolean isLocalClaimsSelected = appBean.isLocalClaimsSelected();
        String idPName = request.getParameter("idPName");
        String action = request.getParameter("action");
        String[] userStoreDomains = null;
        boolean isNeedToUpdate = false;

        String authTypeReq = request.getParameter("authType");
        if (authTypeReq != null && authTypeReq.trim().length() > 0) {
            appBean.setAuthenticationType(authTypeReq);
        }

        String samlIssuerName = request.getParameter("samlIssuer");

        if (samlIssuerName != null && "update".equals(action)) {
            appBean.setSAMLIssuer(samlIssuerName);
            isNeedToUpdate = true;
        }

        if (samlIssuerName != null && "delete".equals(action)) {
            appBean.deleteSAMLIssuer();
            isNeedToUpdate = true;
        }

        samlIssuerName = appBean.getSAMLIssuer();

        String kerberosServicePrinciple = request.getParameter("kerberos");

        if (kerberosServicePrinciple != null && "update".equals(action)) {
            appBean.setKerberosServiceName(kerberosServicePrinciple);
            isNeedToUpdate = true;
        }

        if (kerberosServicePrinciple != null && "delete".equals(action)) {
            appBean.deleteKerberosApp();
            isNeedToUpdate = true;
        }

        String attributeConsumingServiceIndex = request.getParameter("attrConServIndex");
        if (attributeConsumingServiceIndex != null) {
            appBean.setAttributeConsumingServiceIndex(attributeConsumingServiceIndex);
        }

        String oauthapp = request.getParameter("oauthapp");

        if (oauthapp != null && "update".equals(action)) {
            appBean.setOIDCAppName(oauthapp);
            isNeedToUpdate = true;
        }

        if (oauthapp != null && "delete".equals(action)) {
            appBean.deleteOauthApp();
            isNeedToUpdate = true;
        }

        String oauthConsumerSecret = null;

        if (session.getAttribute("oauth-consum-secret") != null && "update".equals(action)) {
            oauthConsumerSecret = (String) session.getAttribute("oauth-consum-secret");
            appBean.setOauthConsumerSecret(oauthConsumerSecret);
            session.removeAttribute("oauth-consum-secret");
        }

        oauthapp = appBean.getOIDCClientId();

        String wsTrust = request.getParameter("serviceName");

        if (wsTrust != null && "update".equals(action)) {
            appBean.setWstrustEp(wsTrust);
            isNeedToUpdate = true;
        }

        if (wsTrust != null && "delete".equals(action)) {
            appBean.deleteWstrustEp();
            isNeedToUpdate = true;
        }

        wsTrust = appBean.getWstrustSP();

        String display = request.getParameter("display");

        if (idPName != null && idPName.equals("")) {
            idPName = null;
        }

        if (ApplicationBean.AUTH_TYPE_FLOW.equals(authTypeReq) && "update".equals(action)) {
            isNeedToUpdate = true;
        }

        String authType = appBean.getAuthenticationType();

        StringBuffer localAuthTypes = new StringBuffer();
        String startOption = "<option value=\"";
        String middleOption = "\">";
        String endOPtion = "</option>";

        StringBuffer requestPathAuthTypes = new StringBuffer();
        RequestPathAuthenticatorConfig[] requestPathAuthenticators = appBean.getRequestPathAuthenticators();

        if (requestPathAuthenticators != null && requestPathAuthenticators.length > 0) {
            for (RequestPathAuthenticatorConfig reqAuth : requestPathAuthenticators) {
                requestPathAuthTypes.append(startOption + Encode.forHtmlAttribute(reqAuth.getName())
                        + middleOption + Encode.forHtmlContent(reqAuth.getDisplayName()) + endOPtion);
            }
        }

        Map<String, String> idpAuthenticators = new HashMap<String, String>();
        IdentityProvider[] federatedIdPs = appBean.getFederatedIdentityProviders();
        Map<String, String> proIdpConnector = new HashMap<String, String>();
        Map<String, String> enabledProIdpConnector = new HashMap<String, String>();
        Map<String, String> selectedProIdpConnectors = new HashMap<String, String>();
        Map<String, Boolean> idpStatus = new HashMap<String, Boolean>();
        Map<String, Boolean> IdpProConnectorsStatus = new HashMap<String, Boolean>();

        StringBuffer idpType = null;
        StringBuffer connType = null;
        StringBuffer enabledConnType = null;

        if (federatedIdPs != null && federatedIdPs.length > 0) {
            idpType = new StringBuffer();
            StringBuffer provisioningConnectors = null;
            for (IdentityProvider idp : federatedIdPs) {
                idpStatus.put(idp.getIdentityProviderName(), idp.getEnable());
                if (idp.getProvisioningConnectorConfigs() != null
                        && idp.getProvisioningConnectorConfigs().length > 0) {
                    ProvisioningConnectorConfig[] connectors = idp.getProvisioningConnectorConfigs();
                    int i = 1;
                    connType = new StringBuffer();
                    enabledConnType = new StringBuffer();
                    provisioningConnectors = new StringBuffer();
                    for (ProvisioningConnectorConfig proConnector : connectors) {
                        if (i == connectors.length) {
                            provisioningConnectors
                                    .append(proConnector.getEnabled() ? proConnector.getName() : "");
                        } else {
                            provisioningConnectors
                                    .append(proConnector.getEnabled() ? proConnector.getName() + "," : "");
                        }
                        connType.append(startOption + Encode.forHtmlAttribute(proConnector.getName())
                                + middleOption + Encode.forHtmlContent(proConnector.getName()) + endOPtion);
                        if (proConnector.getEnabled()) {
                            enabledConnType.append(startOption + Encode.forHtmlAttribute(proConnector.getName())
                                    + middleOption + Encode.forHtmlContent(proConnector.getName()) + endOPtion);
                        }
                        IdpProConnectorsStatus.put(idp.getIdentityProviderName() + "_" + proConnector.getName(),
                                proConnector.getEnabled());
                        i++;
                    }
                    proIdpConnector.put(idp.getIdentityProviderName(), connType.toString());
                    if (idp.getEnable()) {
                        enabledProIdpConnector.put(idp.getIdentityProviderName(), enabledConnType.toString());
                        idpType.append(startOption + Encode.forHtmlAttribute(idp.getIdentityProviderName())
                                + "\" data=\"" + Encode.forHtmlAttribute(provisioningConnectors.toString())
                                + "\" >" + Encode.forHtmlContent(idp.getIdentityProviderName()) + endOPtion);
                    }
                }
            }

            if (appBean.getServiceProvider().getOutboundProvisioningConfig() != null
                    && appBean.getServiceProvider().getOutboundProvisioningConfig()
                            .getProvisioningIdentityProviders() != null
                    && appBean.getServiceProvider().getOutboundProvisioningConfig()
                            .getProvisioningIdentityProviders().length > 0) {

                IdentityProvider[] proIdps = appBean.getServiceProvider().getOutboundProvisioningConfig()
                        .getProvisioningIdentityProviders();
                for (IdentityProvider idp : proIdps) {
                    ProvisioningConnectorConfig proIdp = idp.getDefaultProvisioningConnectorConfig();
                    String options = proIdpConnector.get(idp.getIdentityProviderName());
                    if (proIdp != null && options != null) {
                        String oldOption = startOption + Encode.forHtmlAttribute(proIdp.getName())
                                + middleOption + Encode.forHtmlContent(proIdp.getName()) + endOPtion;
                        String newOption = startOption + Encode.forHtmlAttribute(proIdp.getName())
                                + "\" selected=\"selected" + middleOption
                                + Encode.forHtmlContent(proIdp.getName()) + endOPtion;
                        if (options.contains(oldOption)) {
                            options = options.replace(oldOption, newOption);
                        } else {
                            options = options + newOption;
                        }
                        selectedProIdpConnectors.put(idp.getIdentityProviderName(), options);
                    } else {
                        options = enabledProIdpConnector.get(idp.getIdentityProviderName());
                        selectedProIdpConnectors.put(idp.getIdentityProviderName(), options);
                    }

                }
            }

        }
        try {
            String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
            String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
            ConfigurationContext configContext = (ConfigurationContext) config.getServletContext()
                    .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
            ApplicationManagementServiceClient serviceClient = new ApplicationManagementServiceClient(cookie,
                    backendServerURL, configContext);
            userStoreDomains = serviceClient.getUserStoreDomains();
        } catch (Exception e) {
            CarbonUIMessage.sendCarbonUIMessage("Error occured while loading User Store Domail",
                    CarbonUIMessage.ERROR, request, e);
        }

        out.write("\n");
        out.write("\n");
        out.write("<script>\n");
        out.write("\n");
        out.write("\n");
        if (claimMapping != null) {
            out.write("\n");
            out.write("var claimMappinRowID = ");
            out.print(claimMapping.size() - 1);
            out.write(';');
            out.write('\n');
        } else {
            out.write("\n");
            out.write("var claimMappinRowID = -1;\n");
        }
        out.write("\n");
        out.write("\n");
        out.write("var reqPathAuth = 0;\n");
        out.write("\n");
        if (appBean.getServiceProvider().getRequestPathAuthenticatorConfigs() != null) {
            out.write("\n");
            out.write("var reqPathAuth = ");
            out.print(appBean.getServiceProvider().getRequestPathAuthenticatorConfigs().length);
            out.write(';');
            out.write('\n');
        } else {
            out.write("\n");
            out.write("var reqPathAuth = 0;\n");
        }
        out.write('\n');
        out.write('\n');
        if (roleMapping != null) {
            out.write("\n");
            out.write("var roleMappinRowID = ");
            out.print(roleMapping.size() - 1);
            out.write(';');
            out.write('\n');
        } else {
            out.write("\n");
            out.write("var roleMappinRowID = -1;\n");
        }
        out.write("\n");
        out.write("\n");
        out.write("\tfunction createAppOnclick() {\n");
        out.write("\t\tvar spName = document.getElementById(\"spName\").value;\n");
        out.write("\t\tif( spName == '') {\n");
        out.write("\t\t\tCARBON.showWarningDialog('");
        if (_jspx_meth_fmt_005fmessage_005f0(_jspx_page_context))
            return;
        out.write("');\n");
        out.write("\t\t\tlocation.href = '#';\n");
        out.write("\t\t} else if (!validateTextForIllegal(document.getElementById(\"spName\"))) {\n");
        out.write("                        return false;\n");
        out.write("                } else {\n");
        out.write("\t\t\tif($('input:radio[name=claim_dialect]:checked').val() == \"custom\")\n");
        out.write("\t\t\t{\n");
        out.write("\t\t\t\tvar isValied = true;\n");
        out.write("\t\t\t\t$.each($('.spClaimVal'), function(){\n");
        out.write("\t\t\t\t\tif($(this).val().length == 0){\n");
        out.write("\t\t\t\t\t\tisValied = false;\n");
        out.write("\t\t\t\t\t\tCARBON.showWarningDialog('Please complete Claim Configuration section');\n");
        out.write("\t\t\t\t\t\treturn false;\n");
        out.write("\t\t\t\t\t}\t\t\n");
        out.write("\t\t\t\t});\n");
        out.write("\t\t\t\tif(!isValied){\n");
        out.write("\t\t\t\t\treturn false;\n");
        out.write("\t\t\t\t}\n");
        out.write("\t\t\t}\n");
        out.write("\t\t\t// number_of_claimmappings\n");
        out.write(
                "\t\t\tvar numberOfClaimMappings = document.getElementById(\"claimMappingAddTable\").rows.length;\n");
        out.write("\t\t\tdocument.getElementById('number_of_claimmappings').value=numberOfClaimMappings;\n");
        out.write("\t\t\t\n");
        out.write("\t\t\tif($('[name=app_permission]').length > 0){\n");
        out.write("\t\t\t\tvar isValied = true;\n");
        out.write("\t\t\t\t$.each($('[name=app_permission]'), function(){\n");
        out.write("\t\t\t\t\tif($(this).val().length == 0){\n");
        out.write("\t\t\t\t\t\tisValied = false;\n");
        out.write(
                "\t\t\t\t\t\tCARBON.showWarningDialog('Please complete Permission Configuration section');\n");
        out.write("\t\t\t\t\t\treturn false;\n");
        out.write("\t\t\t\t\t}\t\t\n");
        out.write("\t\t\t\t});\n");
        out.write("\t\t\t\tif(!isValied){\n");
        out.write("\t\t\t\t\treturn false;\n");
        out.write("\t\t\t\t}\n");
        out.write("\t\t\t}\n");
        out.write("\t\t\tif($('.roleMapIdp').length > 0){\n");
        out.write("\t\t\t\tvar isValied = true;\n");
        out.write("\t\t\t\t$.each($('.roleMapIdp'), function(){\n");
        out.write("\t\t\t\t\tif($(this).val().length == 0){\n");
        out.write("\t\t\t\t\t\tisValied = false;\n");
        out.write(
                "\t\t\t\t\t\tCARBON.showWarningDialog('Please complete Role Mapping Configuration section');\n");
        out.write("\t\t\t\t\t\treturn false;\n");
        out.write("\t\t\t\t\t}\t\t\n");
        out.write("\t\t\t\t});\n");
        out.write("\t\t\t\tif(isValied){\n");
        out.write("\t\t\t\t\tif($('.roleMapSp').length > 0){\n");
        out.write("\t\t\t\t\t\t$.each($('.roleMapSp'), function(){\n");
        out.write("\t\t\t\t\t\t\tif($(this).val().length == 0){\n");
        out.write("\t\t\t\t\t\t\t\tisValied = false;\n");
        out.write(
                "\t\t\t\t\t\t\t\tCARBON.showWarningDialog('Please complete Role Mapping Configuration section');\n");
        out.write("\t\t\t\t\t\t\t\treturn false;\n");
        out.write("\t\t\t\t\t\t\t}\t\t\n");
        out.write("\t\t\t\t\t\t});\n");
        out.write("\t\t\t\t\t}\n");
        out.write("\t\t\t\t}\n");
        out.write("\t\t\t\tif(!isValied){\n");
        out.write("\t\t\t\t\treturn false;\n");
        out.write("\t\t\t\t}\n");
        out.write("\t\t\t}\n");
        out.write(
                "\t\t\tvar numberOfPermissions = document.getElementById(\"permissionAddTable\").rows.length;\n");
        out.write("\t\t\tdocument.getElementById('number_of_permissions').value=numberOfPermissions;\n");
        out.write("\t\t\t\n");
        out.write(
                "\t\t\tvar numberOfRoleMappings = document.getElementById(\"roleMappingAddTable\").rows.length;\n");
        out.write("\t\t\tdocument.getElementById('number_of_rolemappings').value=numberOfRoleMappings;\n");
        out.write("\n");
        out.write("\t\t\tdocument.getElementById(\"configure-sp-form\").submit();\n");
        out.write("\t\t}\n");
        out.write("\t}\n");
        out.write("\t\n");
        out.write("\tfunction updateBeanAndRedirect(redirectURL){\n");
        out.write(
                "\t\tvar numberOfClaimMappings = document.getElementById(\"claimMappingAddTable\").rows.length;\n");
        out.write("\t\tdocument.getElementById('number_of_claimmappings').value=numberOfClaimMappings;\n");
        out.write("\t\t\n");
        out.write(
                "\t\tvar numberOfPermissions = document.getElementById(\"permissionAddTable\").rows.length;\n");
        out.write("\t\tdocument.getElementById('number_of_permissions').value=numberOfPermissions;\n");
        out.write("\t\t\n");
        out.write(
                "\t\tvar numberOfRoleMappings = document.getElementById(\"roleMappingAddTable\").rows.length;\n");
        out.write("\t\tdocument.getElementById('number_of_rolemappings').value=numberOfRoleMappings;\n");
        out.write("\t\t\n");
        out.write("\t\t$.ajax({\n");
        out.write("\t\t    type: \"POST\",\n");
        out.write("\t\t\turl: 'update-application-bean.jsp?spName=");
        out.print(Encode.forUriComponent(spName));
        out.write("',\n");
        out.write("\t\t    data: $(\"#configure-sp-form\").serialize(),\n");
        out.write("\t\t    success: function(){\n");
        out.write("\t\t    \tlocation.href=redirectURL;\n");
        out.write("\t\t    }\n");
        out.write("\t\t});\n");
        out.write("\t}\n");
        out.write("\n");
        out.write("    function onSamlSsoClick() {\n");
        out.write("\t\tvar spName = document.getElementById(\"oldSPName\").value;\n");
        out.write("\t\tif( spName != '') {\n");
        out.write("\t\t\tupdateBeanAndRedirect(\"../sso-saml/add_service_provider.jsp?spName=\"+spName);\n");
        out.write("\t\t} else {\n");
        out.write("\t\t\tCARBON.showWarningDialog('");
        if (_jspx_meth_fmt_005fmessage_005f1(_jspx_page_context))
            return;
        out.write("');\n");
        out.write("\t\t\tdocument.getElementById(\"saml_link\").href=\"#\"\n");
        out.write("\t\t}\n");
        out.write("\t}\n");
        out.write("\n");
        out.write("\tfunction onKerberosClick() {\n");
        out.write("\t\tvar spName = document.getElementById(\"oldSPName\").value;\n");
        out.write("\t\tif( spName != '') {\n");
        out.write("\t\t\tupdateBeanAndRedirect(\"../servicestore/add-step1.jsp?spName=\"+spName);\n");
        out.write("\t\t} else {\n");
        out.write("\t\t\tCARBON.showWarningDialog('");
        if (_jspx_meth_fmt_005fmessage_005f2(_jspx_page_context))
            return;
        out.write("');\n");
        out.write("\t\t\tdocument.getElementById(\"kerberos_link\").href=\"#\"\n");
        out.write("\t\t}\n");
        out.write("\t}\n");
        out.write("\n");
        out.write("\tfunction onOauthClick() {\n");
        out.write("\t\tvar spName = document.getElementById(\"oldSPName\").value;\n");
        out.write("\t\tif( spName != '') {\n");
        out.write("\t\t\tupdateBeanAndRedirect(\"../oauth/add.jsp?spName=\" + spName);\n");
        out.write("\t\t} else {\n");
        out.write("\t\t\tCARBON.showWarningDialog('");
        if (_jspx_meth_fmt_005fmessage_005f3(_jspx_page_context))
            return;
        out.write("');\n");
        out.write("\t\t\tdocument.getElementById(\"oauth_link\").href=\"#\"\n");
        out.write("\t\t}\n");
        out.write("\t}\n");
        out.write("\t\n");
        out.write("\tfunction onSTSClick() {\n");
        out.write("\t\tvar spName = document.getElementById(\"oldSPName\").value;\n");
        out.write("\t\tif( spName != '') {\n");
        out.write("\t\t\tupdateBeanAndRedirect(\"../generic-sts/sts.jsp?spName=\" + spName);\n");
        out.write("\t\t} else {\n");
        out.write("\t\t\tCARBON.showWarningDialog('");
        if (_jspx_meth_fmt_005fmessage_005f4(_jspx_page_context))
            return;
        out.write("');\n");
        out.write("\t\t\tdocument.getElementById(\"sts_link\").href=\"#\"\n");
        out.write("\t\t}\n");
        out.write("\t}\n");
        out.write("\t\n");
        out.write("\tfunction deleteReqPathRow(obj){\n");
        out.write("    \treqPathAuth--;\n");
        out.write("        jQuery(obj).parent().parent().remove();\n");
        out.write("        if($(jQuery('#permissionAddTable tr')).length == 1){\n");
        out.write("            $(jQuery('#permissionAddTable')).toggle();\n");
        out.write("        }\n");
        out.write("    }\n");
        out.write("\t\n");
        out.write("\tfunction onAdvanceAuthClick() {\n");
        out.write("\t\tlocation.href='configure-authentication-flow.jsp?spName=");
        out.print(Encode.forUriComponent(spName));
        out.write("';\n");
        out.write("\t}\n");
        out.write("    \n");
        out.write("    jQuery(document).ready(function(){\n");
        out.write("        jQuery('#authenticationConfRow').hide();\n");
        out.write("        jQuery('#outboundProvisioning').hide();\n");
        out.write("        jQuery('#inboundProvisioning').hide();  \n");
        out.write("        jQuery('#ReqPathAuth').hide();        \n");
        out.write("        jQuery('#permissionConfRow').hide();\n");
        out.write("        jQuery('#claimsConfRow').hide();\n");
        out.write("        jQuery('h2.trigger').click(function(){\n");
        out.write("            if (jQuery(this).next().is(\":visible\")) {\n");
        out.write("                this.className = \"active trigger\";\n");
        out.write("            } else {\n");
        out.write("                this.className = \"trigger\";\n");
        out.write("            }\n");
        out.write("            jQuery(this).next().slideToggle(\"fast\");\n");
        out.write("            return false; //Prevent the browser jump to the link anchor\n");
        out.write("        });\n");
        out.write("        jQuery('#permissionAddLink').click(function(){\n");
        out.write(
                "            jQuery('#permissionAddTable').append(jQuery('<tr><td class=\"leftCol-big\"><input style=\"width: 98%;\" type=\"text\" id=\"app_permission\" name=\"app_permission\"/></td>' +\n");
        out.write("                    '<td><a onclick=\"deletePermissionRow(this)\" class=\"icon-link\" '+\n");
        out.write("                    'style=\"background-image: url(images/delete.gif)\">'+\n");
        out.write("                    'Delete'+\n");
        out.write("                    '</a></td></tr>'));\n");
        out.write("        });\n");
        out.write("        jQuery('#claimMappingAddLink').click(function(){\n");
        out.write("        \t$('#claimMappingAddTable').show();\n");
        out.write("        \tvar selectedIDPClaimName = $('select[name=idpClaimsList]').val();\n");
        out.write("    \t\tif(!validaForDuplications('.idpClaim', selectedIDPClaimName, 'Local Claim')){\n");
        out.write("    \t\t\treturn false;\n");
        out.write("    \t\t}\n");
        out.write("        \tclaimMappinRowID++;\n");
        out.write("    \t\tvar idpClaimListDiv = $('#localClaimsList').clone();\n");
        out.write("    \t\tif(idpClaimListDiv.length > 0){\n");
        out.write("    \t\t\t$(idpClaimListDiv.find('select')).attr('id','idpClaim_'+ claimMappinRowID);\n");
        out.write("    \t\t\t$(idpClaimListDiv.find('select')).attr('name','idpClaim_'+ claimMappinRowID);\n");
        out.write("    \t\t\t$(idpClaimListDiv.find('select')).addClass( \"idpClaim\" );\n");
        out.write("    \t\t}\n");
        out.write("        \tif($('input:radio[name=claim_dialect]:checked').val() == \"local\")\n");
        out.write("        \t{\n");
        out.write("        \t\t$('.spClaimHeaders').hide();\n");
        out.write("        \t\t$('#roleMappingSelection').hide();\n");
        out.write("            \tjQuery('#claimMappingAddTable').append(jQuery('<tr>'+\n");
        out.write(
                "                        '<td style=\"display:none;\"><input type=\"text\" style=\"width: 98%;\" id=\"spClaim_' + claimMappinRowID + '\" name=\"spClaim_' + claimMappinRowID + '\"/></td> '+\n");
        out.write("            \t        '<td>'+idpClaimListDiv.html()+'</td>' +                        \n");
        out.write(
                "                        '<td style=\"display:none;\"><input type=\"checkbox\"  name=\"spClaim_req_' + claimMappinRowID + '\"  id=\"spClaim_req_' + claimMappinRowID + '\" checked/></td>' + \n");
        out.write(
                "                        '<td><a onclick=\"deleteClaimRow(this);return false;\" href=\"#\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete</a></td>' + \n");
        out.write("                        '</tr>'));\n");
        out.write("        \t}\n");
        out.write("        \telse {\n");
        out.write("        \t\t$('.spClaimHeaders').show();\n");
        out.write("        \t\t$('#roleMappingSelection').show();\n");
        out.write("            \tjQuery('#claimMappingAddTable').append(jQuery('<tr>'+\n");
        out.write(
                "                        '<td><input type=\"text\" class=\"spClaimVal\" style=\"width: 98%;\" id=\"spClaim_' + claimMappinRowID + '\" name=\"spClaim_' + claimMappinRowID + '\"/></td> '+\n");
        out.write("                        '<td>'+idpClaimListDiv.html()+'</td>' +\n");
        out.write(
                "                        '<td><input type=\"checkbox\"  name=\"spClaim_req_' + claimMappinRowID + '\"  id=\"spClaim_req_' + claimMappinRowID + '\"/></td>' + \n");
        out.write(
                "                        '<td><a onclick=\"deleteClaimRow(this);return false;\" href=\"#\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete</a></td>' + \n");
        out.write("                        '</tr>'));\n");
        out.write("            \t$('#spClaim_' + claimMappinRowID).change(function(){\n");
        out.write("            \t\tresetRoleClaims();\n");
        out.write("            \t});\n");
        out.write("        \t}\n");
        out.write("\n");
        out.write("        });\n");
        out.write("        jQuery('#roleMappingAddLink').click(function(){\n");
        out.write("        \troleMappinRowID++;\n");
        out.write("        \t$('#roleMappingAddTable').show();\n");
        out.write(
                "        \tjQuery('#roleMappingAddTable').append(jQuery('<tr><td><input style=\"width: 98%;\" class=\"roleMapIdp\" type=\"text\" id=\"idpRole_'+ roleMappinRowID +'\" name=\"idpRole_'+ roleMappinRowID +'\"/></td>' +\n");
        out.write(
                "                    '<td><input style=\"width: 98%;\" class=\"roleMapSp\" type=\"text\" id=\"spRole_' + roleMappinRowID + '\" name=\"spRole_' + roleMappinRowID + '\"/></td> '+\n");
        out.write(
                "                    '<td><a onclick=\"deleteRoleMappingRow(this);return false;\" href=\"#\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete</a>' + \n");
        out.write("                    '</td></tr>'));\n");
        out.write("        })\n");
        out.write("         jQuery('#reqPathAuthenticatorAddLink').click(function(){\n");
        out.write("        \treqPathAuth++;\n");
        out.write("    \t\tvar selectedRePathAuthenticator =jQuery(this).parent().children()[0].value;\n");
        out.write(
                "    \t\tif(!validaForDuplications('[name=req_path_auth]', selectedRePathAuthenticator, \"Configuration\")){\n");
        out.write("    \t\t\treturn false;\n");
        out.write("    \t\t}\n");
        out.write("    \t\t\n");
        out.write("    \t\tjQuery(this)\n");
        out.write("    \t\t\t\t.parent()\n");
        out.write("    \t\t\t\t.parent()\n");
        out.write("    \t\t\t\t.parent()\n");
        out.write("    \t\t\t\t.parent()\n");
        out.write("    \t\t\t\t.append(\n");
        out.write(
                "    \t\t\t\t\t\tjQuery('<tr><td><input name=\"req_path_auth' + '\" id=\"req_path_auth\" type=\"hidden\" value=\"' + selectedRePathAuthenticator + '\" />'+ selectedRePathAuthenticator +'</td><td class=\"leftCol-small\" ><a onclick=\"deleteReqPathRow(this);return false;\" href=\"#\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete </a></td></tr>'));\n");
        out.write("    \t\t\n");
        out.write("        });\n");
        out.write("        \n");
        out.write("        $(\"[name=claim_dialect]\").click(function(){\n");
        out.write("        \t\tvar element = $(this);\n");
        out.write("        \t\tclaimMappinRowID = -1;\n");
        out.write("        \t\t\n");
        out.write("        \t\tif($('.idpClaim').length > 0){\n");
        out.write(
                "                    CARBON.showConfirmationDialog('Changing dialect will delete all claim mappings. Do you want to proceed?',\n");
        out.write("                            function (){\n");
        out.write("                    \t\t\t$.each($('.idpClaim'), function(){\n");
        out.write("                    \t\t    \t$(this).parent().parent().remove();\n");
        out.write("                    \t\t\t});\n");
        out.write("                    \t\t\t$('#claimMappingAddTable').hide();\n");
        out.write("                    \t\t\tchangeDialectUIs(element);\n");
        out.write("                           \t},\n");
        out.write("                    \t\tfunction(){\n");
        out.write("                           \t\t//Reset checkboxes\n");
        out.write(
                "                           \t\t$('#claim_dialect_wso2').attr('checked', (element.val() == 'custom'));\n");
        out.write(
                "                           \t\t$('#claim_dialect_custom').attr('checked', (element.val() == 'local'));\n");
        out.write("                           \t});\n");
        out.write("        \t\t}else{\n");
        out.write("        \t\t\t$('#claimMappingAddTable').hide();\n");
        out.write("        \t\t\tchangeDialectUIs(element);\n");
        out.write("        \t\t}\n");
        out.write("        });\n");
        out.write("        \n");
        out.write("        if($('#isNeedToUpdate').val() == 'true'){\n");
        out.write("        \t$('#isNeedToUpdate').val('false');\n");
        out.write(
                "    \t\tvar numberOfClaimMappings = document.getElementById(\"claimMappingAddTable\").rows.length;\n");
        out.write("    \t\tdocument.getElementById('number_of_claimmappings').value=numberOfClaimMappings;\n");
        out.write("    \t\t\n");
        out.write(
                "    \t\tvar numberOfPermissions = document.getElementById(\"permissionAddTable\").rows.length;\n");
        out.write("    \t\tdocument.getElementById('number_of_permissions').value=numberOfPermissions;\n");
        out.write("    \t\t\n");
        out.write(
                "    \t\tvar numberOfRoleMappings = document.getElementById(\"roleMappingAddTable\").rows.length;\n");
        out.write("    \t\tdocument.getElementById('number_of_rolemappings').value=numberOfRoleMappings;\n");
        out.write("    \t\t\n");
        out.write("    \t\t$.ajax({\n");
        out.write("    \t\t    type: \"POST\",\n");
        out.write("    \t\t\turl: 'configure-service-provider-update.jsp?spName=");
        out.print(Encode.forUriComponent(spName));
        out.write("',\n");
        out.write("    \t\t    data: $(\"#configure-sp-form\").serialize()\n");
        out.write("    \t\t});\n");
        out.write("        }\n");
        out.write("    });\n");
        out.write("    \n");
        out.write("    function resetRoleClaims(){\n");
        out.write("\t    $(\"#roleClaim option\").filter(function() {\n");
        out.write("\t           return $(this).val().length > 0;\n");
        out.write("\t    }).remove();\n");
        out.write("\t    $(\"#subject_claim_uri option\").filter(function() {\n");
        out.write("\t           return $(this).val().length > 0;\n");
        out.write("\t    }).remove();\n");
        out.write("\t    $.each($('.spClaimVal'), function(){\n");
        out.write("\t    \tif($(this).val().length > 0){\n");
        out.write(
                "\t\t    \t$(\"#roleClaim\").append('<option value=\"'+$(this).val()+'\">'+$(this).val()+'</option>');\n");
        out.write(
                "\t\t    \t$('#subject_claim_uri').append('<option value=\"'+$(this).val()+'\">'+$(this).val()+'</option>');\n");
        out.write("\t    \t}\n");
        out.write("\t    });\n");
        out.write("    }\n");
        out.write("    \n");
        out.write("    function changeDialectUIs(element){\n");
        out.write("\t    $(\"#roleClaim option\").filter(function() {\n");
        out.write("\t           return $(this).val().length > 0;\n");
        out.write("\t    }).remove();\n");
        out.write("\t    \n");
        out.write("\t    $(\"#subject_claim_uri option\").filter(function() {\n");
        out.write("\t           return $(this).val().length > 0;\n");
        out.write("\t    }).remove();\n");
        out.write("\t    \n");
        out.write("\t\tif(element.val() == 'local'){\n");
        out.write("\t\t\t$('#addClaimUrisLbl').text('Requested Claims:');\n");
        out.write("\t\t\t$('#roleMappingSelection').hide();\n");
        out.write("\t\t\tif($('#local_calim_uris').length > 0 && $('#local_calim_uris').val().length > 0){\n");
        out.write("\t\t\t\tvar dataArray = $('#local_calim_uris').val().split(',');\n");
        out.write("\t\t\t\tif(dataArray.length > 0){\n");
        out.write("\t\t\t\t\tvar optionsList = \"\";\n");
        out.write("\t\t\t\t\t$.each(dataArray, function(){\n");
        out.write("\t\t\t\t\t\tif(this.length > 0){\n");
        out.write("\t\t\t\t\t\t\toptionsList += '<option value='+this+'>'+this+'</option>'\n");
        out.write("\t\t\t\t\t\t}\n");
        out.write("\t\t\t\t\t});\n");
        out.write("\t\t\t\t\tif(optionsList.length > 0){\n");
        out.write("\t\t\t\t\t\t$('#subject_claim_uri').append(optionsList);\n");
        out.write("\t\t\t\t\t}\n");
        out.write("\t\t\t\t}\n");
        out.write("\t\t\t} \n");
        out.write("\t\t}else{\n");
        out.write("\t\t\t$('#addClaimUrisLbl').text('Identity Provider Claim URIs:');\n");
        out.write("\t\t\t$('#roleMappingSelection').show();\n");
        out.write("\t\t}\n");
        out.write("    }\n");
        out.write("    \n");
        out.write("    function deleteClaimRow(obj){\n");
        out.write("    \tif($('input:radio[name=claim_dialect]:checked').val() == \"custom\"){\n");
        out.write("    \t\tif($(obj).parent().parent().find('input.spClaimVal').val().length > 0){\n");
        out.write(
                "    \t\t\t$('#roleClaim option[value=\"'+$(obj).parent().parent().find('input.spClaimVal').val()+'\"]').remove();\n");
        out.write(
                "    \t\t\t$('#subject_claim_uri option[value=\"'+$(obj).parent().parent().find('input.spClaimVal').val()+'\"]').remove();\n");
        out.write("    \t\t}\n");
        out.write("    \t}\n");
        out.write("    \t\n");
        out.write("    \tjQuery(obj).parent().parent().remove();\n");
        out.write("\t\tif($('.idpClaim').length == 0){\n");
        out.write("\t\t\t$('#claimMappingAddTable').hide();\n");
        out.write("\t\t}\n");
        out.write("    }\n");
        out.write("    \n");
        out.write("    function deleteRoleMappingRow(obj){\n");
        out.write("    \tjQuery(obj).parent().parent().remove();\n");
        out.write("    \tif($('.roleMapIdp').length == 0){\n");
        out.write("    \t\t$('#roleMappingAddTable').hide();\n");
        out.write("    \t}\n");
        out.write("    }\n");
        out.write("    \n");
        out.write("    function deletePermissionRow(obj){\n");
        out.write("    \tjQuery(obj).parent().parent().remove();\n");
        out.write("    }\n");
        out.write("    \n");
        out.write("    var deletePermissionRows = [];\n");
        out.write("    function deletePermissionRowOld(obj){\n");
        out.write("        if(jQuery(obj).parent().prev().children()[0].value != ''){\n");
        out.write("        \tdeletePermissionRows.push(jQuery(obj).parent().prev().children()[0].value);\n");
        out.write("        }\n");
        out.write("        jQuery(obj).parent().parent().remove();\n");
        out.write("        if($(jQuery('#permissionAddTable tr')).length == 1){\n");
        out.write("            $(jQuery('#permissionAddTable')).toggle();\n");
        out.write("        }\n");
        out.write("    }\n");
        out.write("    \n");
        out.write("    function addIDPRow(obj) {\n");
        out.write("\t\tvar selectedObj = jQuery(obj).prev().find(\":selected\");\n");
        out.write("\n");
        out.write("\t\tvar selectedIDPName = selectedObj.val(); \n");
        out.write(
                "\t\tif(!validaForDuplications('[name=provisioning_idp]', selectedIDPName, 'Configuration')){\n");
        out.write("\t\t\treturn false;\n");
        out.write("\t\t}\n");
        out.write("\n");
        out.write("\t\t//var stepID = jQuery(obj).parent().children()[1].value;\n");
        out.write("\t\tvar dataArray =  selectedObj.attr('data').split(',');\n");
        out.write(
                "\t\tvar newRow = '<tr><td><input name=\"provisioning_idp\" id=\"\" type=\"hidden\" value=\"' + selectedIDPName + '\" />' + selectedIDPName + ' </td><td> <select name=\"provisioning_con_idp_' + selectedIDPName + '\" style=\"float: left; min-width: 150px;font-size:13px;\">';\n");
        out.write("\t\tfor(var i=0;i<dataArray.length;i++){\n");
        out.write("\t\t\tif(dataArray[i].length > 0){\n");
        out.write("\t\t\t\tnewRow+='<option>'+dataArray[i]+'</option>';\t\t\t\t\t\n");
        out.write("\t\t\t}\n");
        out.write("\t\t}\n");
        out.write(
                "\t\tnewRow+='</select></td><td><input type=\"checkbox\" name=\"blocking_prov_' + selectedIDPName +\n");
        out.write(
                "\t\t\t\t'\"  />Blocking</td><td><input type=\"checkbox\" name=\"provisioning_jit_' + selectedIDPName +\n");
        out.write(
                "\t\t\t\t'\"  />JIT Outbound</td><td class=\"leftCol-small\" ><a onclick=\"deleteIDPRow(this);return false;\" href=\"#\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete </a></td></tr>';\n");
        out.write("\t\tjQuery(obj)\n");
        out.write("\t\t\t\t.parent()\n");
        out.write("\t\t\t\t.parent()\n");
        out.write("\t\t\t\t.parent()\n");
        out.write("\t\t\t\t.parent()\n");
        out.write("\t\t\t\t.append(\n");
        out.write("\t\t\t\t\t\tjQuery(newRow));\t\n");
        out.write("\t\t}\t\n");
        out.write("    \n");
        out.write("    function deleteIDPRow(obj){\n");
        out.write("        jQuery(obj).parent().parent().remove();\n");
        out.write("    }\n");
        out.write("    \n");
        out.write("\tfunction validaForDuplications(selector, authenticatorName, type){\n");
        out.write("\t\tif($(selector).length > 0){\n");
        out.write("\t\t\tvar isNew = true;\n");
        out.write("\t\t\t$.each($(selector),function(){\n");
        out.write("\t\t\t\tif($(this).val() == authenticatorName){\n");
        out.write("\t\t\t\t\tCARBON.showWarningDialog(type+' \"'+authenticatorName+'\" is already added');\n");
        out.write("\t\t\t\t\tisNew = false;\n");
        out.write("\t\t\t\t\treturn false;\n");
        out.write("\t\t\t\t}\n");
        out.write("\t\t\t});\n");
        out.write("\t\t\tif(!isNew){\n");
        out.write("\t\t\t\treturn false;\n");
        out.write("\t\t\t}\n");
        out.write("\t\t}\n");
        out.write("\t\treturn true;\n");
        out.write("\t}\n");
        out.write("\t\n");
        out.write("\tfunction showHidePassword(element, inputId){\n");
        out.write("\t\tif($(element).text()=='Show'){\n");
        out.write("\t\t\tdocument.getElementById(inputId).type = 'text';\n");
        out.write("\t\t\t$(element).text('Hide');\n");
        out.write("\t\t}else{\n");
        out.write("\t\t\tdocument.getElementById(inputId).type = 'password';\n");
        out.write("\t\t\t$(element).text('Show');\n");
        out.write("\t\t}\n");
        out.write("\t}\n");
        out.write("    \n");
        out.write("    function disable() {\n");
        out.write(
                "        document.getElementById(\"scim-inbound-userstore\").disabled =!document.getElementById(\"scim-inbound-userstore\").disabled;\n");
        out.write(
                "        document.getElementById(\"dumb\").value = document.getElementById(\"scim-inbound-userstore\").disabled;\n");
        out.write("    }\n");
        out.write("\n");
        out.write("    function validateTextForIllegal(fld) {\n");
        out.write(
                "        var isValid = doValidateInput(fld, \"Provided Service Provider name is invalid.\");\n");
        out.write("        if (isValid) {\n");
        out.write("            return true;\n");
        out.write("        } else {\n");
        out.write("            return false;\n");
        out.write("        }\n");
        out.write("    }\n");
        out.write("</script>\n");
        out.write("\n");
        //  fmt:bundle
        org.apache.taglibs.standard.tag.rt.fmt.BundleTag _jspx_th_fmt_005fbundle_005f0 = (org.apache.taglibs.standard.tag.rt.fmt.BundleTag) _005fjspx_005ftagPool_005ffmt_005fbundle_0026_005fbasename
                .get(org.apache.taglibs.standard.tag.rt.fmt.BundleTag.class);
        _jspx_th_fmt_005fbundle_005f0.setPageContext(_jspx_page_context);
        _jspx_th_fmt_005fbundle_005f0.setParent(null);
        // /application/configure-service-provider.jsp(718,0) name = basename type = null reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
        _jspx_th_fmt_005fbundle_005f0.setBasename("org.wso2.carbon.identity.application.mgt.ui.i18n.Resources");
        int _jspx_eval_fmt_005fbundle_005f0 = _jspx_th_fmt_005fbundle_005f0.doStartTag();
        if (_jspx_eval_fmt_005fbundle_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
            if (_jspx_eval_fmt_005fbundle_005f0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
                out = _jspx_page_context.pushBody();
                _jspx_th_fmt_005fbundle_005f0.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);
                _jspx_th_fmt_005fbundle_005f0.doInitBody();
            }
            do {
                out.write("\n");
                out.write("    <div id=\"middle\">\n");
                out.write("        <h2>\n");
                out.write("            ");
                if (_jspx_meth_fmt_005fmessage_005f5(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("        </h2>\n");
                out.write("        <div id=\"workArea\">\n");
                out.write(
                        "            <form id=\"configure-sp-form\" method=\"post\" name=\"configure-sp-form\" method=\"post\" action=\"configure-service-provider-finish.jsp\" >\n");
                out.write("            <input type=\"hidden\" name=\"oldSPName\" id=\"oldSPName\" value=\"");
                out.print(Encode.forHtmlAttribute(spName));
                out.write("\"/>\n");
                out.write("            <input type=\"hidden\" id=\"isNeedToUpdate\" value=\"");
                out.print(isNeedToUpdate);
                out.write("\"/>\n");
                out.write("            <div class=\"sectionSeperator togglebleTitle\">");
                if (_jspx_meth_fmt_005fmessage_005f6(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</div>\n");
                out.write("            <div class=\"sectionSub\">\n");
                out.write("                <table class=\"carbonFormTable\">\n");
                out.write("                    <tr>\n");
                out.write("                        <td style=\"width:15%\" class=\"leftCol-med labelField\">");
                if (_jspx_meth_fmt_005fmessage_005f7(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write(":<span class=\"required\">*</span></td>\n");
                out.write("                        <td>\n");
                out.write(
                        "                            <input style=\"width:50%\" id=\"spName\" name=\"spName\" type=\"text\" value=\"");
                out.print(Encode.forHtmlAttribute(spName));
                out.write("\" white-list-patterns=\"^[a-zA-Z0-9._|-]*$\" autofocus/>\n");
                out.write("                            <div class=\"sectionHelp\">\n");
                out.write("                                ");
                if (_jspx_meth_fmt_005fmessage_005f8(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                            </div>\n");
                out.write("                        </td>\n");
                out.write("                    </tr>\n");
                out.write("                    <tr>\n");
                out.write(
                        "                       <td style=\"width:15%\" class=\"leftCol-med labelField\">Description:</td>                   \n");
                out.write("                     <td>\n");
                out.write(
                        "                        <textarea style=\"width:50%\" type=\"text\" name=\"sp-description\" id=\"sp-description\" class=\"text-box-big\">");
                out.print(appBean.getServiceProvider().getDescription() != null
                        ? Encode.forHtmlContent(appBean.getServiceProvider().getDescription())
                        : "");
                out.write("</textarea>\n");
                out.write("                        <div class=\"sectionHelp\">\n");
                out.write("                                ");
                if (_jspx_meth_fmt_005fmessage_005f9(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                            </div>\n");
                out.write("                        </td>\n");
                out.write("                    </tr>\n");
                out.write("                    <tr>\n");
                out.write("                    \t<td class=\"leftCol-med\">\n");
                out.write("                             <label for=\"isSaasApp\">");
                if (_jspx_meth_fmt_005fmessage_005f10(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</label>\n");
                out.write("                        </td>\n");
                out.write("                        <td>\n");
                out.write("                            <div class=\"sectionCheckbox\">\n");
                out.write(
                        "                                <input type=\"checkbox\"  id=\"isSaasApp\" name=\"isSaasApp\" ");
                out.print(appBean.getServiceProvider().getSaasApp() ? "checked" : "");
                out.write("/>\n");
                out.write(
                        "                                <span style=\"display:inline-block\" class=\"sectionHelp\">\n");
                out.write("                                    ");
                if (_jspx_meth_fmt_005fmessage_005f11(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                                </span>\n");
                out.write("                            </div>\n");
                out.write("                        </td>\n");
                out.write("                    </tr>\n");
                out.write("                </table>\n");
                out.write("            </div>\n");
                out.write("\n");
                out.write("\t\t\t<h2 id=\"claims_head\" class=\"sectionSeperator trigger active\">\n");
                out.write("                <a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f12(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("            </h2>\n");
                out.write(
                        "            <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"claimsConfRow\">\n");
                out.write(
                        "                   <table style=\"padding-top: 5px; padding-bottom: 10px;\" class=\"carbonFormTable\">\n");
                out.write("                    \t<tr>\n");
                out.write("                    \t\t<td class=\"leftCol-med labelField\">\n");
                out.write("                    \t\t\t");
                if (_jspx_meth_fmt_005fmessage_005f13(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write(":\n");
                out.write("                    \t\t</td>\n");
                out.write("                    \t\t<td class=\"leftCol-med\">\n");
                out.write(
                        "                    \t\t\t<input type=\"radio\" id=\"claim_dialect_wso2\" name=\"claim_dialect\" value=\"local\" ");
                out.print(isLocalClaimsSelected ? "checked" : "");
                out.write("><label for=\"claim_dialect_wso2\" style=\"cursor: pointer;\">");
                if (_jspx_meth_fmt_005fmessage_005f14(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</label>\n");
                out.write("                    \t\t</td>\n");
                out.write("                    \t</tr>\n");
                out.write("                \t\t<tr>\n");
                out.write(
                        "                \t\t    <td style=\"width:15%\" class=\"leftCol-med labelField\">\n");
                out.write("                    \t\t</td>\n");
                out.write("                \t\t\t<td class=\"leftCol-med\">\n");
                out.write(
                        "                    \t\t\t<input type=\"radio\" id=\"claim_dialect_custom\" name=\"claim_dialect\" value=\"custom\" ");
                out.print(!isLocalClaimsSelected ? "checked" : "");
                out.write("><label for=\"claim_dialect_custom\" style=\"cursor: pointer;\">");
                if (_jspx_meth_fmt_005fmessage_005f15(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</label>\n");
                out.write("                    \t\t</td>\n");
                out.write("                    \t</tr>\n");
                out.write("                    </table>\n");
                out.write("                    <table  class=\"carbonFormTable\">\n");
                out.write("\t\t\t\t\t<tr>\n");
                out.write("\t\t\t\t\t\t<td class=\"leftCol-med labelField\" style=\"width:15%\">\n");
                out.write("\t\t\t\t\t\t\t<label id=\"addClaimUrisLbl\">");
                out.print(isLocalClaimsSelected ? "Requested Claims:" : "Identity Provider Claim URIs:");
                out.write("</label>\n");
                out.write("\t\t\t\t\t\t</td>\n");
                out.write("\t\t\t\t\t\t<td class=\"leftCol-med\">\n");
                out.write(
                        "\t\t\t\t\t\t\t<a id=\"claimMappingAddLink\" class=\"icon-link\" style=\"background-image: url(images/add.gif); margin-top: 0px !important; margin-bottom: 5px !important; margin-left: 5px;\">");
                if (_jspx_meth_fmt_005fmessage_005f16(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write(
                        "                            <table class=\"styledLeft\" id=\"claimMappingAddTable\" style=\"");
                out.print(claimMapping == null || claimMapping.isEmpty() ? "display:none" : "");
                out.write("\">\n");
                out.write("                              <thead><tr>\n");
                out.write("                              <th class=\"leftCol-big spClaimHeaders\" style=\"");
                out.print(isLocalClaimsSelected ? "display:none;" : "");
                out.write('"');
                out.write('>');
                if (_jspx_meth_fmt_005fmessage_005f17(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</th>\n");
                out.write("                              <th class=\"leftCol-big\">");
                if (_jspx_meth_fmt_005fmessage_005f18(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</th>\n");
                out.write("                              <th class=\"leftCol-mid spClaimHeaders\" style=\"");
                out.print(isLocalClaimsSelected ? "display:none;" : "");
                out.write('"');
                out.write('>');
                if (_jspx_meth_fmt_005fmessage_005f19(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</th>\n");
                out.write("                              \n");
                out.write("                              <th>");
                if (_jspx_meth_fmt_005fmessage_005f20(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</th></tr></thead>\n");
                out.write("                              <tbody>\n");
                out.write("                              ");
                if (claimMapping != null && !claimMapping.isEmpty()) {
                    out.write("\n");
                    out.write("                          \n");
                    out.write("                               ");

                    int i = -1;
                    for (Map.Entry<String, String> entry : claimMapping.entrySet()) {
                        i++;

                        out.write("\n");
                        out.write("                               <tr>\n");
                        out.write("                                   <td style=\"");
                        out.print(isLocalClaimsSelected ? "display:none;" : "");
                        out.write(
                                "\"><input type=\"text\" class=\"spClaimVal\" style=\"width: 98%;\" value=\"");
                        out.print(Encode.forHtmlAttribute(entry.getValue()));
                        out.write("\" id=\"spClaim_");
                        out.print(i);
                        out.write("\" name=\"spClaim_");
                        out.print(i);
                        out.write("\" readonly=\"readonly\"/></td>\n");
                        out.write("                               \t<td>\n");
                        out.write("\t\t\t\t\t\t\t\t\t<select id=\"idpClaim_");
                        out.print(i);
                        out.write("\" name=\"idpClaim_");
                        out.print(i);
                        out.write("\" class=\"idpClaim\" style=\"float:left; width: 100%\">\t\t\t\t\t\t\n");
                        out.write("\t\t\t\t\t\t\t\t\t\t");
                        String[] localClaims = appBean.getClaimUris();
                        for (String localClaimName : localClaims) {
                            if (localClaimName.equals(entry.getKey())) {
                                out.write("\n");
                                out.write("\t\t\t\t\t\t\t\t\t\t\t\t<option value=\"");
                                out.print(Encode.forHtmlAttribute(localClaimName));
                                out.write("\" selected> ");
                                out.print(Encode.forHtmlContent(localClaimName));
                                out.write("</option>\n");
                                out.write("\t\t\t\t\t\t\t\t\t\t\t");
                            } else {
                                out.write(" \n");
                                out.write("\t\t\t\t\t\t\t\t\t\t\t\t<option value=\"");
                                out.print(Encode.forHtmlAttribute(localClaimName));
                                out.write('"');
                                out.write('>');
                                out.write(' ');
                                out.print(Encode.forHtmlContent(localClaimName));
                                out.write("</option>\n");
                                out.write("\t\t\t\t\t\t\t\t\t\t");
                            }
                        }
                        out.write("\n");
                        out.write("\t\t\t\t\t\t\t\t\t</select>\n");
                        out.write(
                                "                               \t</td>                                   \n");
                        out.write("                                   <td style=\"");
                        out.print(isLocalClaimsSelected ? "display:none;" : "");
                        out.write("\">\n");
                        out.write("                                   ");
                        if ("true".equals(appBean.getRequestedClaims().get(entry.getValue()))) {
                            out.write("                                 \n");
                            out.write(
                                    "                                   <input type=\"checkbox\"  id=\"spClaim_req_");
                            out.print(i);
                            out.write("\" name=\"spClaim_req_");
                            out.print(i);
                            out.write("\" checked/>\n");
                            out.write("                                   ");
                        } else {
                            out.write("\n");
                            out.write(
                                    "                                    <input type=\"checkbox\"  id=\"spClaim_req_");
                            out.print(i);
                            out.write("\" name=\"spClaim_req_");
                            out.print(i);
                            out.write("\" />\n");
                            out.write("                                   ");
                        }
                        out.write("\n");
                        out.write("                                   </td>\n");
                        out.write("                                  \n");
                        out.write("                                   <td>\n");
                        out.write("                                       <a title=\"");
                        if (_jspx_meth_fmt_005fmessage_005f21(_jspx_th_fmt_005fbundle_005f0,
                                _jspx_page_context))
                            return;
                        out.write("\"\n");
                        out.write(
                                "                                          onclick=\"deleteClaimRow(this);return false;\"\n");
                        out.write("                                          href=\"#\"\n");
                        out.write("                                          class=\"icon-link\"\n");
                        out.write(
                                "                                          style=\"background-image: url(images/delete.gif)\">\n");
                        out.write("                                           ");
                        if (_jspx_meth_fmt_005fmessage_005f22(_jspx_th_fmt_005fbundle_005f0,
                                _jspx_page_context))
                            return;
                        out.write("\n");
                        out.write("                                       </a>\n");
                        out.write("                                   </td>\n");
                        out.write("                               </tr>\n");
                        out.write("                               ");
                    }
                    out.write("\n");
                    out.write("                              ");
                }
                out.write("\n");
                out.write("                              </tbody>\n");
                out.write("                    \t\t</table>\n");
                out.write("\t\t\t\t\t\t</td>\n");
                out.write("\t\t\t\t\t</tr>\n");
                out.write("\n");
                out.write("                    <tr>\n");
                out.write("                    \t\t<td class=\"leftCol-med labelField\">");
                if (_jspx_meth_fmt_005fmessage_005f23(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write(":\n");
                out.write("                        \t<td>\n");
                out.write(
                        "                        \t<select class=\"leftCol-med\" id=\"subject_claim_uri\" name=\"subject_claim_uri\" style=\" margin-left: 5px; \">\n");
                out.write("                        \t\t<option value=\"\">---Select---</option>\n");
                out.write("                        \t\t");
                if (isLocalClaimsSelected) {
                    String[] localClaimUris = appBean.getClaimUris();
                    for (String localClaimName : localClaimUris) {
                        if (appBean.getSubjectClaimUri() != null
                                && localClaimName.equals(appBean.getSubjectClaimUri())) {
                            out.write("\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t\t<option value=\"");
                            out.print(Encode.forHtmlAttribute(localClaimName));
                            out.write("\" selected> ");
                            out.print(Encode.forHtmlContent(localClaimName));
                            out.write("</option>\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t");
                        } else {
                            out.write("\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t\t<option value=\"");
                            out.print(Encode.forHtmlAttribute(localClaimName));
                            out.write('"');
                            out.write('>');
                            out.write(' ');
                            out.print(Encode.forHtmlContent(localClaimName));
                            out.write("</option>\n");
                            out.write("\t\t\t\t\t\t\t\t\t");
                        }
                    }
                } else {
                    for (Map.Entry<String, String> entry : claimMapping.entrySet()) {
                        out.write("\n");
                        out.write("                        \t\t\t ");
                        if (entry.getValue() != null && !entry.getValue().isEmpty()) {
                            if (appBean.getSubjectClaimUri() != null
                                    && appBean.getSubjectClaimUri().equals(entry.getValue())) {
                                out.write("\n");
                                out.write("                        \t\t\t\t\t\t<option value=\"");
                                out.print(Encode.forHtmlAttribute(entry.getValue()));
                                out.write("\" selected> ");
                                out.print(Encode.forHtmlContent(entry.getValue()));
                                out.write("</option>\n");
                                out.write("                        \t\t\t\t");
                            } else {
                                out.write("\n");
                                out.write("                            \t\t\t\t\t<option value=\"");
                                out.print(Encode.forHtmlAttribute(entry.getValue()));
                                out.write('"');
                                out.write('>');
                                out.write(' ');
                                out.print(Encode.forHtmlContent(entry.getValue()));
                                out.write("</option>\n");
                                out.write("                            \t\t\t ");
                            }
                        }
                    }
                }
                out.write("\n");
                out.write("\t\t\t\t\t\t\t</select>\n");
                out.write("\t\t\t\t\t\t\t</td>\n");
                out.write("                    \t</tr>\n");
                out.write("                    </table>\n");
                out.write("\n");
                out.write(
                        "                    <input type=\"hidden\" name=\"number_of_claimmappings\" id=\"number_of_claimmappings\" value=\"1\">\n");
                out.write("                    <div id=\"localClaimsList\" style=\"display: none;\">\n");
                out.write("                  \t\t<select style=\"float:left; width: 100%\">\t\t\t\t\t\t\t\n");
                out.write("\t\t\t\t\t\t\t");
                String[] localClaims = appBean.getClaimUris();
                StringBuffer allLocalClaims = new StringBuffer();
                for (String localClaimName : localClaims) {
                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t\t\t<option value=\"");
                    out.print(Encode.forHtmlAttribute(localClaimName));
                    out.write('"');
                    out.write('>');
                    out.write(' ');
                    out.print(Encode.forHtmlContent(localClaimName));
                    out.write("</option>\n");
                    out.write("\t\t\t\t\t\t\t\t");

                    allLocalClaims.append(localClaimName + ",");
                }
                out.write("\n");
                out.write("\t\t\t\t\t\t\t</select>\n");
                out.write("\t\t\t\t\t</div>\n");
                out.write("\t\t\t\t\t<input type=\"hidden\" id =\"local_calim_uris\" value=\"");
                out.print(Encode.forHtmlAttribute(allLocalClaims.toString()));
                out.write("\" >\n");
                out.write("                  \t<div id=\"roleMappingSelection\" style=\"");
                out.print(isLocalClaimsSelected ? "display:none" : "");
                out.write("\">\n");
                out.write(
                        "                    <table class=\"carbonFormTable\" style=\"padding-top: 10px\">\n");
                out.write("                  \t<tr>\n");
                out.write("                  \t\t<td class=\"leftCol-med labelField\" style=\"width:15%\">\n");
                out.write("\t\t\t\t\t\t\t<label id=\"addClaimUrisLbl\">");
                if (_jspx_meth_fmt_005fmessage_005f24(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write(":</label>\n");
                out.write("\t\t\t\t\t\t</td>\n");
                out.write("                        <td >\n");
                out.write(
                        "                        \t<select id=\"roleClaim\" name=\"roleClaim\" style=\"float:left;min-width: 250px;\">\n");
                out.write("                        \t\t<option value=\"\">---Select---</option>\n");
                out.write("                        \t\t");
                if (!isLocalClaimsSelected) {
                    for (Map.Entry<String, String> entry : claimMapping.entrySet()) {
                        out.write("\n");
                        out.write("                        \t\t\t ");
                        if (entry.getValue() != null && !entry.getValue().isEmpty()) {
                            if (appBean.getRoleClaimUri() != null
                                    && appBean.getRoleClaimUri().equals(entry.getValue())) {
                                out.write("\n");
                                out.write("                        \t\t\t\t\t\t<option value=\"");
                                out.print(Encode.forHtmlAttribute(entry.getValue()));
                                out.write("\" selected> ");
                                out.print(Encode.forHtmlContent(entry.getValue()));
                                out.write("</option>\n");
                                out.write("                        \t\t\t\t");
                            } else {
                                out.write("\n");
                                out.write("                            \t\t\t\t\t<option value=\"");
                                out.print(Encode.forHtmlAttribute(entry.getValue()));
                                out.write('"');
                                out.write('>');
                                out.write(' ');
                                out.print(Encode.forHtmlContent(entry.getValue()));
                                out.write("</option>\n");
                                out.write("                            \t\t\t");
                            }
                        }
                        out.write("\n");
                        out.write("                        \t\t\t");
                    }
                    out.write("\t\n");
                    out.write("                        \t\t");
                }
                out.write("\t\t\t\t\t\t\n");
                out.write("\t\t\t\t\t\t\t</select>\n");
                out.write("\t\t\t\t\t\t</td>\n");
                out.write("\t\t\t\t\t</tr>\n");
                out.write("\t\t\t\t\t<tr>\n");
                out.write("\t\t\t\t\t\t<td class=\"leftCol-med\" style=\"width:15%\"></td>\n");
                out.write("\t\t\t\t\t\t<td>\n");
                out.write("                           <div class=\"sectionHelp\">\n");
                out.write("                                ");
                if (_jspx_meth_fmt_005fmessage_005f25(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                            </div>\n");
                out.write("                        </td>\n");
                out.write("                    </tr>\n");
                out.write("                    </table>\n");
                out.write("                    </div>\n");
                out.write("            </div>\n");
                out.write("              \n");
                out.write(
                        "\t\t\t<h2 id=\"authorization_permission_head\" class=\"sectionSeperator trigger active\">\n");
                out.write("                <a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f26(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("            </h2>\n");
                out.write(
                        "            <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"permissionConfRow\">\n");
                out.write(
                        "            <h2 id=\"permission_mapping_head\" class=\"sectionSeperator trigger active\" style=\"background-color: beige;\">\n");
                out.write("                \t\t<a href=\"#\">Permissions</a>\n");
                out.write("            \t\t</h2>\n");
                out.write(
                        "            \t   <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display: none;\" id=\"appPermissionRow\">\n");
                out.write("                <table class=\"carbonFormTable\">\n");
                out.write("                   <tr>\n");
                out.write("                        <td>\n");
                out.write(
                        "                            <a id=\"permissionAddLink\" class=\"icon-link\" style=\"background-image:url(images/add.gif);margin-left:0;\">");
                if (_jspx_meth_fmt_005fmessage_005f27(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("                            <div style=\"clear:both\"></div>\n");
                out.write("                           \t<div class=\"sectionHelp\">\n");
                out.write("                                ");
                if (_jspx_meth_fmt_005fmessage_005f28(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                            </div>\n");
                out.write(
                        "                            <table class=\"styledLeft\" id=\"permissionAddTable\" >\n");
                out.write("                                <thead>\n");
                out.write("                                </thead>\n");
                out.write("                                <tbody>\n");
                out.write("                                ");
                if (permissions != null && !permissions.isEmpty()) {
                    out.write("\n");
                    out.write("                               \n");
                    out.write("                                ");
                    for (int i = 0; i < permissions.size(); i++) {
                        if (permissions.get(i) != null) {

                            out.write("\n");
                            out.write("                                \n");
                            out.write("                                <tr>\n");
                            out.write(
                                    "                                    <td class=\"leftCol-big\"><input style=\"width: 98%;\" type=\"text\" value=\"");
                            out.print(Encode.forHtmlAttribute(permissions.get(i)));
                            out.write(
                                    "\" id=\"app_permission\" name=\"app_permission\" readonly=\"readonly\"/></td>\n");
                            out.write("                                    <td>\n");
                            out.write("                                        <a title=\"");
                            if (_jspx_meth_fmt_005fmessage_005f29(_jspx_th_fmt_005fbundle_005f0,
                                    _jspx_page_context))
                                return;
                            out.write("\"\n");
                            out.write(
                                    "                                           onclick=\"deletePermissionRow(this);return false;\"\n");
                            out.write("                                           href=\"#\"\n");
                            out.write("                                           class=\"icon-link\"\n");
                            out.write(
                                    "                                           style=\"background-image: url(images/delete.gif)\">\n");
                            out.write("                                            ");
                            if (_jspx_meth_fmt_005fmessage_005f30(_jspx_th_fmt_005fbundle_005f0,
                                    _jspx_page_context))
                                return;
                            out.write("\n");
                            out.write("                                        </a>\n");
                            out.write("                                    </td>\n");
                            out.write("                                </tr>\n");
                            out.write("                                ");
                        }
                    }
                    out.write("\n");
                    out.write("                                ");
                }
                out.write("\n");
                out.write("                                </tbody>\n");
                out.write("                            </table>\n");
                out.write("                            <div style=\"clear:both\"/>\n");
                out.write(
                        "                            <input type=\"hidden\" name=\"number_of_permissions\" id=\"number_of_permissions\" value=\"1\">\n");
                out.write("                        </td>\n");
                out.write("                    </tr>\n");
                out.write("                    \n");
                out.write("\t\t\t\t\t</table>\n");
                out.write("\t\t\t\t\t</div>\n");
                out.write(
                        "\t\t\t\t\t<h2 id=\"role_mapping_head\" class=\"sectionSeperator trigger active\" style=\"background-color: beige;\">\n");
                out.write("                \t\t<a href=\"#\">Role Mapping</a>\n");
                out.write("            \t\t</h2>\n");
                out.write(
                        "            \t   <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display: none;\" id=\"roleMappingRowRow\">\n");
                out.write("                    <table>\n");
                out.write("                    <tr>\n");
                out.write("\t\t\t\t\t\t<td>\n");
                out.write(
                        "\t\t\t\t\t\t\t<a id=\"roleMappingAddLink\" class=\"icon-link\" style=\"background-image: url(images/add.gif);margin-left:0;\">");
                if (_jspx_meth_fmt_005fmessage_005f31(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("\t\t\t\t\t\t\t<div style=\"clear:both\"/>\n");
                out.write("                            <div class=\"sectionHelp\">\n");
                out.write("                                ");
                if (_jspx_meth_fmt_005fmessage_005f32(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                            </div>\n");
                out.write("\t\t\t\t\t\t</td>\n");
                out.write("\t\t\t\t\t</tr>\n");
                out.write("                    </table>\n");
                out.write(
                        "\t\t\t\t\t<table class=\"styledLeft\" id=\"roleMappingAddTable\" style=\"display:none\">\n");
                out.write("                              <thead><tr><th class=\"leftCol-big\">");
                if (_jspx_meth_fmt_005fmessage_005f33(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</th><th class=\"leftCol-big\">");
                if (_jspx_meth_fmt_005fmessage_005f34(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</th><th>");
                if (_jspx_meth_fmt_005fmessage_005f35(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</th></tr></thead>\n");
                out.write("                              <tbody>\n");
                out.write("                              ");
                if (roleMapping != null && !roleMapping.isEmpty()) {
                    out.write("\n");
                    out.write("                              <script>\n");
                    out.write(
                            "                                  $(jQuery('#roleMappingAddTable')).toggle();\n");
                    out.write("                              </script>\n");
                    out.write("                               ");

                    int i = -1;
                    for (Map.Entry<String, String> entry : roleMapping.entrySet()) {
                        i++;

                        out.write("\n");
                        out.write("                               <tr>\n");
                        out.write("                               \t<td >\n");
                        out.write(
                                "                               \t\t<input style=\"width: 98%;\" class=\"roleMapIdp\" type=\"text\" value=\"");
                        out.print(Encode.forHtmlAttribute(entry.getKey()));
                        out.write("\" id=\"idpRole_");
                        out.print(i);
                        out.write("\" name=\"idpRole_");
                        out.print(i);
                        out.write("\" readonly=\"readonly\"/>\n");
                        out.write("                               \t</td>\n");
                        out.write(
                                "                                   <td><input style=\"width: 98%;\" class=\"roleMapSp\" type=\"text\" value=\"");
                        out.print(Encode.forHtmlAttribute(entry.getValue()));
                        out.write("\" id=\"spRole_");
                        out.print(i);
                        out.write("\" name=\"spRole_");
                        out.print(i);
                        out.write("\" readonly=\"readonly\"/></td>\n");
                        out.write("                                   <td>\n");
                        out.write("                                       <a title=\"");
                        if (_jspx_meth_fmt_005fmessage_005f36(_jspx_th_fmt_005fbundle_005f0,
                                _jspx_page_context))
                            return;
                        out.write("\"\n");
                        out.write(
                                "                                          onclick=\"deleteRoleMappingRow(this);return false;\"\n");
                        out.write("                                          href=\"#\"\n");
                        out.write("                                          class=\"icon-link\"\n");
                        out.write(
                                "                                          style=\"background-image: url(images/delete.gif)\">\n");
                        out.write("                                           ");
                        if (_jspx_meth_fmt_005fmessage_005f37(_jspx_th_fmt_005fbundle_005f0,
                                _jspx_page_context))
                            return;
                        out.write("\n");
                        out.write("                                       </a>\n");
                        out.write("                                   </td>\n");
                        out.write("                               </tr>\n");
                        out.write("                               ");
                    }
                    out.write("\n");
                    out.write("                              ");
                }
                out.write("\n");
                out.write("\t\t\t\t\t\t</tbody>\n");
                out.write("                      </table>\n");
                out.write(
                        "\t\t\t\t\t<input type=\"hidden\" name=\"number_of_rolemappings\" id=\"number_of_rolemappings\" value=\"1\">\n");
                out.write("\t\t\t\t\t</div>\n");
                out.write("            </div>\n");
                out.write("\n");
                out.write(
                        "            <h2 id=\"app_authentication_head\"  class=\"sectionSeperator trigger active\">\t\n");
                out.write("                <a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f38(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("            </h2>\n");
                out.write("            \n");
                out.write("            ");
                if (display != null && (display.equals("oauthapp") || display.equals("samlIssuer")
                        || display.equals("serviceName") || display.equals("kerberos"))) {
                    out.write("\n");
                    out.write(
                            "                  <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"inbound_auth_request_div\">\n");
                    out.write("            ");
                } else {
                    out.write("\n");
                    out.write(
                            "                  <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:none;\" id=\"inbound_auth_request_div\">           \n");
                    out.write("            ");
                }
                out.write("\n");
                out.write(
                        "            <h2 id=\"saml.config.head\" class=\"sectionSeperator trigger active\" style=\"background-color: beige;\">\n");
                out.write("                <a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f39(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("                ");
                if (appBean.getSAMLIssuer() != null) {
                    out.write("\n");
                    out.write(
                            "                \t<div class=\"enablelogo\"><img src=\"images/ok.png\"  width=\"16\" height=\"16\"></div>\n");
                    out.write("                ");
                }
                out.write("\n");
                out.write("            </h2>\n");
                out.write("            \n");
                out.write("           ");
                if (display != null && display.equals("samlIssuer")) {
                    out.write("            \n");
                    out.write(
                            "            <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"saml.config.div\">\n");
                    out.write("          ");
                } else {
                    out.write("\n");
                    out.write(
                            "            <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:none;\" id=\"saml.config.div\">          \n");
                    out.write("          ");
                }
                out.write("\n");
                out.write("                <table class=\"carbonFormTable\">\n");
                out.write("                    <tr>\n");
                out.write("                        <td class=\"leftCol-med labelField\">\n");
                out.write("                        ");

                if (appBean.getSAMLIssuer() == null) {

                    out.write("\n");
                    out.write(
                            "                            <a id=\"saml_link\" class=\"icon-link\" onclick=\"onSamlSsoClick()\">");
                    if (_jspx_meth_fmt_005fmessage_005f40(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</a>\n");
                    out.write("\t\t\t\t\t\t ");

                } else {

                    out.write("\n");
                    out.write("\t\t\t\t\t\t \t\t<div style=\"clear:both\"></div>\n");
                    out.write("\t\t\t\t\t\t\t \t<table class=\"styledLeft\" id=\"samlTable\">\n");
                    out.write("                                <thead><tr><th class=\"leftCol-big\">");
                    if (_jspx_meth_fmt_005fmessage_005f41(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</th><th class=\"leftCol-big\">");
                    if (_jspx_meth_fmt_005fmessage_005f42(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</th><th>");
                    if (_jspx_meth_fmt_005fmessage_005f43(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</th></tr></thead>\n");
                    out.write("                                <tbody>\n");
                    out.write("                                <tr><td>");
                    out.print(Encode.forHtmlContent(appBean.getSAMLIssuer()));
                    out.write("</td>\n");
                    out.write("                                \t<td>\n");
                    out.write("                                \t\t");
                    if (attributeConsumingServiceIndex == null || attributeConsumingServiceIndex.isEmpty()) {
                        attributeConsumingServiceIndex = appBean.getAttributeConsumingServiceIndex();
                    }

                    if (attributeConsumingServiceIndex != null) {
                        out.write("\n");
                        out.write("                                \t\t\t\t");
                        out.print(Encode.forHtmlContent(attributeConsumingServiceIndex));
                        out.write("\n");
                        out.write("                                \t\t\t");
                    }
                    out.write("\n");
                    out.write("                                \t</td>\n");
                    out.write("                                \t\t<td style=\"white-space: nowrap;\">\n");
                    out.write(
                            "                                \t\t\t<a title=\"Edit Service Providers\" onclick=\"updateBeanAndRedirect('../sso-saml/add_service_provider.jsp?SPAction=editServiceProvider&issuer=");
                    out.print(Encode.forUriComponent(appBean.getSAMLIssuer()));
                    out.write("&spName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write(
                            "');\"  class=\"icon-link\" style=\"background-image: url(../admin/images/edit.gif)\">Edit</a>\n");
                    out.write(
                            "                                \t\t\t<a title=\"Delete Service Providers\" onclick=\"updateBeanAndRedirect('../sso-saml/remove_service_providers.jsp?issuer=");
                    out.print(Encode.forUriComponent(appBean.getSAMLIssuer()));
                    out.write("&spName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write(
                            "');\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete </a>\n");
                    out.write("                                \t\t</td>\n");
                    out.write("                                \t</tr>\n");
                    out.write("                                </tbody>\n");
                    out.write("                                </table>\t\t\n");
                    out.write("\t\t\t\t\t\t ");

                }

                out.write("\n");
                out.write("\t\t\t\t\t\t\t<div style=\"clear:both\"></div>\n");
                out.write("                        </td>\n");
                out.write("                    </tr>\n");
                out.write("                    </table>\n");
                out.write("                    \n");
                out.write("                    </div>\n");
                out.write(
                        "            <h2 id=\"oauth.config.head\" class=\"sectionSeperator trigger active\" style=\"background-color: beige;\">\n");
                out.write("                <a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f44(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("                ");
                if (appBean.getOIDCClientId() != null) {
                    out.write("\n");
                    out.write(
                            "                \t<div class=\"enablelogo\"><img src=\"images/ok.png\"  width=\"16\" height=\"16\"></div>\n");
                    out.write("                ");
                }
                out.write("\n");
                out.write("            </h2>\n");
                out.write("            ");
                if (display != null && display.equals("oauthapp")) {
                    out.write("                        \n");
                    out.write(
                            "                <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"oauth.config.div\">\n");
                    out.write("            ");
                } else {
                    out.write("\n");
                    out.write(
                            "                <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:none;\" id=\"oauth.config.div\">\n");
                    out.write("            ");
                }
                out.write("\n");
                out.write("                <table class=\"carbonFormTable\">\n");
                out.write("                    <tr>\n");
                out.write("                    \t<td>\n");
                out.write("\t                    \t");

                if (appBean.getOIDCClientId() == null) {

                    out.write("\n");
                    out.write(
                            "\t\t\t                        <a id=\"oauth_link\" class=\"icon-link\" onclick=\"onOauthClick()\">\n");
                    out.write("\t\t\t\t\t\t\t\t\t");
                    if (_jspx_meth_fmt_005fmessage_005f45(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</a>\n");
                    out.write("\t\t\t\t\t\t\t ");

                } else {

                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t <div style=\"clear:both\"></div>\n");
                    out.write("\t\t\t\t\t\t\t <table class=\"styledLeft\" id=\"samlTable\">\n");
                    out.write("                                <thead>\n");
                    out.write("                                \t<tr>\n");
                    out.write(
                            "                                \t\t<th class=\"leftCol-big\">OAuth Client Key</th>\n");
                    out.write(
                            "                                \t\t<th class=\"leftCol-big\">OAuth Client Secret</th>\n");
                    out.write("                                \t\t<th>");
                    if (_jspx_meth_fmt_005fmessage_005f46(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</th>\n");
                    out.write("                                \t</tr>\n");
                    out.write("                                </thead>\n");
                    out.write("                                <tbody>\n");
                    out.write("                                <tr>\n");
                    out.write("                                \t<td>");
                    out.print(Encode.forHtmlContent(appBean.getOIDCClientId()));
                    out.write("</td>\n");
                    out.write("                                \t<td>\n");
                    out.write("                                \t\t");
                    if (oauthConsumerSecret == null || oauthConsumerSecret.isEmpty()) {
                        oauthConsumerSecret = appBean.getOauthConsumerSecret();
                    }
                    if (oauthConsumerSecret != null) {
                        out.write("\n");
                        out.write("                                \t\t\t\t<div>\n");
                        out.write(
                                "                                \t\t\t\t\t<input style=\"border: none; background: white;\" type=\"password\" id=\"oauthConsumerSecret\" name=\"oauthConsumerSecret\" value=\"");
                        out.print(Encode.forHtmlAttribute(oauthConsumerSecret));
                        out.write("\"readonly=\"readonly\">\n");
                        out.write("                                \t\t\t\t\t<span style=\"float: right;\">\n");
                        out.write(
                                "                                \t\t\t\t\t\t<a style=\"margin-top: 5px;\" class=\"showHideBtn\" onclick=\"showHidePassword(this, 'oauthConsumerSecret')\">Show</a>\n");
                        out.write("                                \t\t\t\t\t</span>\n");
                        out.write("                                \t\t\t\t</div>\n");
                        out.write("                                \t\t  ");
                    }
                    out.write("\n");
                    out.write("                                \t</td>\n");
                    out.write("                                \t\t<td style=\"white-space: nowrap;\">\n");
                    out.write(
                            "                                \t\t\t<a title=\"Edit Service Providers\" onclick=\"updateBeanAndRedirect('../oauth/edit.jsp?appName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write(
                            "');\"  class=\"icon-link\" style=\"background-image: url(../admin/images/edit.gif)\">Edit</a>\n");
                    out.write(
                            "                                \t\t\t<a title=\"Delete Service Providers\" onclick=\"updateBeanAndRedirect('../oauth/remove-app.jsp?consumerkey=");
                    out.print(Encode.forUriComponent(appBean.getOIDCClientId()));
                    out.write("&appName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write("&spName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write(
                            "');\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete </a>\n");
                    out.write("                                \t\t</td>\n");
                    out.write("                                \t</tr>\n");
                    out.write("                                </tbody>\n");
                    out.write("                                </table>\n");
                    out.write("\t\t\t\t\t\t\t ");

                }

                out.write("\n");
                out.write("\t\t\t\t\t\t\t<div style=\"clear:both\"></div>\n");
                out.write("                        </td>\n");
                out.write("                    </tr>\n");
                out.write("                    </table>\n");
                out.write("                    </div>\n");
                out.write("\n");
                out.write("\n");
                out.write(
                        "\t\t\t\t<h2 id=\"openid.config.head\" class=\"sectionSeperator trigger active\" style=\"background-color: beige;\">\n");
                out.write("\t\t\t\t\t<a href=\"#\">OpenID Configuration</a>\n");
                out.write(
                        "\t\t\t\t\t<div class=\"enablelogo\"><img src=\"images/ok.png\"  width=\"16\" height=\"16\"></div>\n");
                out.write("\t\t\t\t</h2>\n");
                out.write(
                        "\t\t\t\t<div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:none;\" id=\"openid.config.div\">\n");
                out.write("\t\t\t\t\t<table class=\"carbonFormTable\">\n");
                out.write("\n");
                out.write("\t\t\t\t\t\t<tr>\n");
                out.write("\t\t\t\t\t\t\t<td style=\"width:15%\" class=\"leftCol-med labelField\">\n");
                out.write("\t\t\t\t\t\t\t\t");
                if (_jspx_meth_fmt_005fmessage_005f47(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write(":\n");
                out.write("\t\t\t\t\t\t\t</td>\n");
                out.write("\t\t\t\t\t\t\t<td>\n");
                out.write("\t\t\t\t\t\t\t\t");

                if (appBean.getOpenIDRealm() != null) {

                    out.write("\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t<input style=\"width:50%\" id=\"openidRealm\" name=\"openidRealm\" type=\"text\" value=\"");
                    out.print(Encode.forHtmlAttribute(appBean.getOpenIDRealm()));
                    out.write("\" autofocus/>\n");
                    out.write("\t\t\t\t\t\t\t\t");
                } else {
                    out.write("\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t<input style=\"width:50%\" id=\"openidRealm\" name=\"openidRealm\" type=\"text\" value=\"\" autofocus/>\n");
                    out.write("\t\t\t\t\t\t\t\t");
                }
                out.write("\n");
                out.write("\t\t\t\t\t\t\t\t<div class=\"sectionHelp\">\n");
                out.write("\t\t\t\t\t\t\t\t\t");
                if (_jspx_meth_fmt_005fmessage_005f48(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("\t\t\t\t\t\t\t\t</div>\n");
                out.write("\t\t\t\t\t\t\t</td>\n");
                out.write("\n");
                out.write("\t\t\t\t\t\t</tr>\n");
                out.write("\n");
                out.write("\t\t\t\t\t</table>\n");
                out.write("\t\t\t\t</div>\n");
                out.write("\n");
                out.write("\n");
                out.write(
                        "\t\t\t\t<h2 id=\"passive.sts.config.head\" class=\"sectionSeperator trigger active\" style=\"background-color: beige;\">\n");
                out.write("                <a href=\"#\">WS-Federation (Passive) Configuration</a>\n");
                out.write(
                        "                <div class=\"enablelogo\"><img src=\"images/ok.png\"  width=\"16\" height=\"16\"></div>\n");
                out.write("            </h2>\n");
                out.write(
                        "            <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:none;\" id=\"passive.config.div\">\n");
                out.write("                  <table class=\"carbonFormTable\">\n");
                out.write("                    \n");
                out.write("                    <tr>\n");
                out.write("                    \t<td style=\"width:15%\" class=\"leftCol-med labelField\">\n");
                out.write("                    \t\t");
                if (_jspx_meth_fmt_005fmessage_005f49(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write(":\n");
                out.write("                    \t</td>\n");
                out.write("                    \t<td>\n");
                out.write("                    \t    ");

                if (appBean.getPassiveSTSRealm() != null) {

                    out.write("\t                    \n");
                    out.write(
                            "                            <input style=\"width:50%\" id=\"passiveSTSRealm\" name=\"passiveSTSRealm\" type=\"text\" value=\"");
                    out.print(Encode.forHtmlAttribute(appBean.getPassiveSTSRealm()));
                    out.write("\" autofocus/>\n");
                    out.write("                            ");
                } else {
                    out.write("\n");
                    out.write(
                            "                            <input style=\"width:50%\" id=\"passiveSTSRealm\" name=\"passiveSTSRealm\" type=\"text\" value=\"\" autofocus/>\n");
                    out.write("                            ");
                }
                out.write("\n");
                out.write("                          <div class=\"sectionHelp\">\n");
                out.write("                                ");
                if (_jspx_meth_fmt_005fmessage_005f50(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                            </div>\n");
                out.write("                        </td>\n");
                out.write("                        \n");
                out.write("                    </tr>\n");
                out.write("                      <tr>\n");
                out.write(
                        "                          <td style=\"width:15%\" class=\"leftCol-med labelField\">\n");
                out.write("                              ");
                if (_jspx_meth_fmt_005fmessage_005f51(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write(":\n");
                out.write("                          </td>\n");
                out.write("                          <td>\n");
                out.write("                              ");

                if (appBean.getPassiveSTSWReply() != null) {

                    out.write("\n");
                    out.write(
                            "                              <input style=\"width:50%\" id=\"passiveSTSWReply\" name=\"passiveSTSWReply\" type=\"text\" value=\"");
                    out.print(Encode.forHtmlAttribute(appBean.getPassiveSTSWReply()));
                    out.write("\" autofocus/>\n");
                    out.write("                              ");
                } else {
                    out.write("\n");
                    out.write(
                            "                              <input style=\"width:50%\" id=\"passiveSTSWReply\" name=\"passiveSTSWReply\" type=\"text\" value=\"\" autofocus/>\n");
                    out.write("                              ");
                }
                out.write("\n");
                out.write("                              <div class=\"sectionHelp\">\n");
                out.write("                                  ");
                if (_jspx_meth_fmt_005fmessage_005f52(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                              </div>\n");
                out.write("                          </td>\n");
                out.write("\n");
                out.write("                      </tr>\n");
                out.write("                   \n");
                out.write("                  </table>\n");
                out.write("            </div>\n");
                out.write("\n");
                out.write(
                        "\t\t\t\t<h2 id=\"wst.config.head\" class=\"sectionSeperator trigger active\" style=\"background-color: beige;\">\n");
                out.write("\t\t\t\t\t<a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f53(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("\t\t\t\t\t");
                if (appBean.getWstrustSP() != null) {
                    out.write("\n");
                    out.write(
                            "\t\t\t\t\t<div class=\"enablelogo\"><img src=\"images/ok.png\"  width=\"16\" height=\"16\"></div>\n");
                    out.write("\t\t\t\t\t");
                }
                out.write("\n");
                out.write("\t\t\t\t</h2>\n");
                out.write("\t\t\t\t\t\t");
                if (display != null && display.equals("serviceName")) {
                    out.write("\n");
                    out.write(
                            "\t\t\t\t<div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"wst.config.div\">\n");
                    out.write("\t\t\t\t\t");
                } else {
                    out.write("\n");
                    out.write(
                            "\t\t\t\t\t<div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:none;\" id=\"wst.config.div\">\n");
                    out.write("\t\t\t\t\t\t");
                }
                out.write("\n");
                out.write("\t\t\t\t\t\t<table class=\"carbonFormTable\">\n");
                out.write("\n");
                out.write("\t\t\t\t\t\t\t<tr>\n");
                out.write("\t\t\t\t\t\t\t\t<td>\n");
                out.write("\t\t\t\t\t\t\t\t\t");

                if (appBean.getWstrustSP() == null) {

                    out.write("\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t\t<a id=\"sts_link\" class=\"icon-link\" onclick=\"onSTSClick()\">\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t");
                    if (_jspx_meth_fmt_005fmessage_005f54(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</a>\n");
                    out.write("\t\t\t\t\t\t\t\t\t");

                } else {

                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t\t\t<div style=\"clear:both\"></div>\n");
                    out.write("\t\t\t\t\t\t\t\t\t<table class=\"styledLeft\" id=\"samlTable\">\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t<thead><tr><th class=\"leftCol-med\">Audience</th><th>");
                    if (_jspx_meth_fmt_005fmessage_005f55(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</th></tr></thead>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t<tbody>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t<tr>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t\t<td>");
                    out.print(Encode.forHtmlContent(appBean.getWstrustSP()));
                    out.write("</td>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t\t<td style=\"white-space: nowrap;\">\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t\t\t\t\t<a title=\"Edit Audience\" onclick=\"updateBeanAndRedirect('../generic-sts/sts.jsp?spName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write("&&spAudience=");
                    out.print(Encode.forUriComponent(appBean.getWstrustSP()));
                    out.write(
                            "&spAction=spEdit');\"  class=\"icon-link\" style=\"background-image: url(../admin/images/edit.gif)\">Edit</a>\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t\t\t\t\t<a title=\"Delete Audience\" onclick=\"updateBeanAndRedirect('../generic-sts/remove-trusted-service.jsp?action=delete&spName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write("&endpointaddrs=");
                    out.print(Encode.forUriComponent(appBean.getWstrustSP()));
                    out.write(
                            "');\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete </a>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t\t</td>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t</tr>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t</tbody>\n");
                    out.write("\t\t\t\t\t\t\t\t\t</table>\n");
                    out.write("\t\t\t\t\t\t\t\t\t");

                }

                out.write("\n");
                out.write("\t\t\t\t\t\t\t\t\t<div style=\"clear:both\"></div>\n");
                out.write("\t\t\t\t\t\t\t\t</td>\n");
                out.write("\t\t\t\t\t\t\t</tr>\n");
                out.write("\n");
                out.write("\t\t\t\t\t\t</table>\n");
                out.write("\t\t\t\t\t</div>\n");
                out.write("\n");
                out.write(
                        "\t\t\t\t   <h2 id=\"kerberos.kdc.head\" class=\"sectionSeperator trigger active\"\n");
                out.write("\t\t\t\t\t   style=\"background-color: beige;\">\n");
                out.write("\t\t\t\t\t   <a href=\"#\">Kerberos KDC</a>\n");
                out.write("\n");
                out.write("\t\t\t\t\t  ");
                if (appBean.getKerberosServiceName() != null) {
                    out.write("\n");
                    out.write(
                            "\t\t\t\t\t   \t\t<div class=\"enablelogo\"><img src=\"images/ok.png\"  width=\"16\" height=\"16\"></div>\n");
                    out.write("\t\t\t\t\t   ");
                }
                out.write("\n");
                out.write("\t\t\t\t   </h2>\n");
                out.write("\n");
                out.write("\t\t\t\t\t");
                if (display != null && display.equals("kerberos")) {
                    out.write("\n");
                    out.write(
                            "\t\t\t\t\t\t<div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"kerberos.config.div\">\n");
                    out.write("\t\t\t\t\t");
                } else {
                    out.write("\n");
                    out.write(
                            "\t\t\t\t\t\t<div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:none;\"\n");
                    out.write("\t\t\t\t\t\t\t\t id=\"kerberos.config.div\">\n");
                    out.write("\t\t\t\t\t");
                }
                out.write("\n");
                out.write("\n");
                out.write("\t\t\t\t\t   <table class=\"carbonFormTable\">\n");
                out.write("\n");
                out.write("\t\t\t\t\t\t   <tr>\n");
                out.write("\t\t\t\t\t\t\t   <td>\n");
                out.write("\t\t\t\t\t\t\t\t   ");

                if (appBean.getKerberosServiceName() == null) {

                    out.write("\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t   <a id=\"kerberos_link\" class=\"icon-link\" onclick=\"onKerberosClick()\">");
                    if (_jspx_meth_fmt_005fmessage_005f56(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</a>\n");
                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t\t   ");
                } else {
                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t\t   <div style=\"clear:both\"></div>\n");
                    out.write("\t\t\t\t\t\t\t\t   <table class=\"styledLeft\" id=\"kerberosTable\">\n");
                    out.write("\t\t\t\t\t\t\t\t\t   <thead>\n");
                    out.write("\t\t\t\t\t\t\t\t\t   <tr>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t   <th class=\"leftCol-big\">");
                    if (_jspx_meth_fmt_005fmessage_005f57(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</th>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t   <th>");
                    if (_jspx_meth_fmt_005fmessage_005f58(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</th>\n");
                    out.write("\t\t\t\t\t\t\t\t\t   </tr>\n");
                    out.write("\t\t\t\t\t\t\t\t\t   </thead>\n");
                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t\t\t   <tbody>\n");
                    out.write("\t\t\t\t\t\t\t\t\t   <tr>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t   <td>");
                    out.print(Encode.forHtmlContent(appBean.getKerberosServiceName()));
                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t   </td>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t   <td style=\"white-space: nowrap;\">\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t\t   <a title=\"Change Password\"\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t\t\t\t\t  onclick=\"updateBeanAndRedirect('../servicestore/change-passwd.jsp?SPAction=changePWr&spnName=");
                    out.print(Encode.forUriComponent(appBean.getKerberosServiceName()));
                    out.write("&spName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write("');\"\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t\t\t  class=\"icon-link\"\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t\t\t\t\t  style=\"background-image: url(../admin/images/edit.gif)\">Change Password</a>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t\t   <a title=\"Delete\"\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t\t\t\t\t  onclick=\"updateBeanAndRedirect('../servicestore/delete-finish.jsp?SPAction=delete&spnName=");
                    out.print(Encode.forUriComponent(appBean.getKerberosServiceName()));
                    out.write("&spName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write("');\"\n");
                    out.write(
                            "\t\t\t\t\t\t\t\t\t\t\t\t  class=\"icon-link\" style=\"background-image: url(images/delete.gif)\">\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t\t\t   Delete </a>\n");
                    out.write("\t\t\t\t\t\t\t\t\t\t   </td>\n");
                    out.write("\t\t\t\t\t\t\t\t\t   </tr>\n");
                    out.write("\t\t\t\t\t\t\t\t\t   </tbody>\n");
                    out.write("\t\t\t\t\t\t\t\t   </table>\n");
                    out.write("\t\t\t\t\t\t\t\t   ");

                }

                out.write("\n");
                out.write("\t\t\t\t\t\t\t   </td>\n");
                out.write("\n");
                out.write("\t\t\t\t\t\t   </tr>\n");
                out.write("\n");
                out.write("\t\t\t\t\t   </table>\n");
                out.write("\t\t\t\t   </div>\n");
                out.write("\n");
                out.write("                        ");

                List<String> standardInboundAuthTypes = new ArrayList<String>();
                standardInboundAuthTypes = new ArrayList<String>();
                standardInboundAuthTypes.add("oauth2");
                standardInboundAuthTypes.add("wstrust");
                standardInboundAuthTypes.add("samlsso");
                standardInboundAuthTypes.add("openid");
                standardInboundAuthTypes.add("passivests");

                if (!CollectionUtils.isEmpty(appBean.getInboundAuthenticators())) {
                    List<InboundAuthenticationRequestConfig> customAuthenticators = appBean
                            .getInboundAuthenticators();
                    for (InboundAuthenticationRequestConfig customAuthenticator : customAuthenticators) {
                        if (!standardInboundAuthTypes.contains(customAuthenticator.getInboundAuthType())) {
                            String type = customAuthenticator.getInboundAuthType();
                            String friendlyName = customAuthenticator.getFriendlyName();

                            out.write("\n");
                            out.write("\n");
                            out.write(
                                    "                        <h2 id=\"openid.config.head\" class=\"sectionSeperator trigger active\"\n");
                            out.write("                            style=\"background-color: beige;\">\n");
                            out.write("                            <a href=\"#\">");
                            out.print(friendlyName);
                            out.write("\n");
                            out.write("                            </a>\n");
                            out.write("\n");
                            out.write(
                                    "                            <div class=\"enablelogo\"><img src=\"images/ok.png\" width=\"16\" height=\"16\"></div>\n");
                            out.write("                        </h2>\n");
                            out.write(
                                    "                        <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:none;\"\n");
                            out.write("                             id=\"openid.config.div\">\n");
                            out.write("                            <table class=\"carbonFormTable\">\n");
                            out.write("                                ");

                            Property[] properties = customAuthenticator.getProperties();
                            for (Property prop : properties) {
                                String propName = "custom_auth_prop_name_" + type + "_" + prop.getName();

                                out.write("\n");
                                out.write("\n");
                                out.write("                                <tr>\n");
                                out.write(
                                        "                                    <td style=\"width:15%\" class=\"leftCol-med labelField\">\n");
                                out.write("                                        ");
                                out.print(prop.getDisplayName() + ":");
                                out.write("\n");
                                out.write("                                    </td>\n");
                                out.write("                                    <td>\n");
                                out.write("                                        ");

                                if (prop.getValue() != null) {

                                    out.write("\n");
                                    out.write(
                                            "                                        <input style=\"width:50%\" id=\"");
                                    out.print(propName);
                                    out.write("\" name=\"");
                                    out.print(propName);
                                    out.write("\" type=\"text\"\n");
                                    out.write("                                               value=\"");
                                    out.print(prop.getValue());
                                    out.write("\" autofocus/>\n");
                                    out.write("                                        ");
                                } else {
                                    out.write("\n");
                                    out.write(
                                            "                                        <input style=\"width:50%\" id=\"");
                                    out.print(propName);
                                    out.write("\" name=\"");
                                    out.print(propName);
                                    out.write("\" type=\"text\"\n");
                                    out.write("                                               autofocus/>\n");
                                    out.write("                                        ");
                                }
                                out.write("\n");
                                out.write("\n");
                                out.write("                                    </td>\n");
                                out.write("\n");
                                out.write("                                </tr>\n");
                                out.write("                                ");

                            }

                            out.write("\n");
                            out.write("\n");
                            out.write("                            </table>\n");
                            out.write("                        </div>\n");
                            out.write("                        ");

                        }
                    }
                }

                out.write("\n");
                out.write("\n");
                out.write("\t\t\t   </div>\n");
                out.write("            \n");
                out.write(
                        "             <h2 id=\"app_authentication_advance_head\"  class=\"sectionSeperator trigger active\">\n");
                out.write("               \t\t<a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f59(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("           \t\t  </h2>\n");
                out.write("           \t\t  ");
                if (display != null && "auth_config".equals(display)) {
                    out.write("\n");
                    out.write(
                            "           \t\t    <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:block;\" id=\"advanceAuthnConfRow\">\n");
                    out.write("           \t\t  ");
                } else {
                    out.write("\n");
                    out.write(
                            "                    <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;display:none;\" id=\"advanceAuthnConfRow\">\n");
                    out.write("                   ");
                }
                out.write("\n");
                out.write("                   \t<table class=\"carbonFormTable\">\n");
                out.write("                    \t<tr>\n");
                out.write("                    \t\t<td class=\"leftCol-med labelField\">");
                if (_jspx_meth_fmt_005fmessage_005f60(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write(":<span class=\"required\">*</span>\n");
                out.write("                    \t\t</td>\n");
                out.write("                        \t<td class=\"leftCol-med\">\n");
                out.write("                        \t");
                if (ApplicationBean.AUTH_TYPE_DEFAULT.equals(appBean.getAuthenticationType())) {
                    out.write("\n");
                    out.write(
                            "                        \t\t<input type=\"radio\" id=\"default\" name=\"auth_type\" value=\"default\" checked><label for=\"default\" style=\"cursor: pointer;\">");
                    if (_jspx_meth_fmt_005fmessage_005f61(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</label>\n");
                    out.write("                        \t\t");
                } else {
                    out.write("\n");
                    out.write(
                            "                        \t\t<input type=\"radio\" id=\"default\" name=\"auth_type\" value=\"default\" ><label for=\"default\" style=\"cursor: pointer;\">");
                    if (_jspx_meth_fmt_005fmessage_005f62(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</label>\n");
                    out.write("                        \t");
                }
                out.write("\n");
                out.write("                        \t</td>\n");
                out.write("                        \t<td/>\n");
                out.write("                    \t</tr>   \n");
                out.write("                  \t\t  \t<tr>\n");
                out.write(
                        "                    \t\t<td style=\"width:15%\" class=\"leftCol-med labelField\"/>\n");
                out.write("                        \t<td>\n");
                out.write("                        \t");
                if (ApplicationBean.AUTH_TYPE_LOCAL.equals(appBean.getAuthenticationType())) {
                    out.write("\n");
                    out.write(
                            "                        \t\t<input type=\"radio\" id=\"local\" name=\"auth_type\" value=\"local\" checked><label for=\"local\" style=\"cursor: pointer;\">");
                    if (_jspx_meth_fmt_005fmessage_005f63(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</label>\n");
                    out.write("                        \t\t");
                } else {
                    out.write("\n");
                    out.write(
                            "                        \t\t<input type=\"radio\" id=\"local\" name=\"auth_type\" value=\"local\"><label for=\"local\" style=\"cursor: pointer;\">");
                    if (_jspx_meth_fmt_005fmessage_005f64(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</label>\n");
                    out.write("                        \t\t");
                }
                out.write("\n");
                out.write("                        \t</td>\n");
                out.write("                        \t<td>\n");
                out.write(
                        "                        \t\t\t<select name=\"local_authenticator\" id=\"local_authenticator\">\n");
                out.write("                        \t\t\t");

                if (appBean.getLocalAuthenticatorConfigs() != null) {
                    LocalAuthenticatorConfig[] localAuthenticatorConfigs = appBean
                            .getLocalAuthenticatorConfigs();
                    for (LocalAuthenticatorConfig authenticator : localAuthenticatorConfigs) {

                        out.write("\n");
                        out.write("\t                        \t\t\t\t");
                        if (authenticator.getName().equals(
                                appBean.getStepZeroAuthenticatorName(ApplicationBean.AUTH_TYPE_LOCAL))) {
                            out.write("\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t\t\t<option value=\"");
                            out.print(Encode.forHtmlAttribute(authenticator.getName()));
                            out.write("\" selected>");
                            out.print(Encode.forHtmlContent(authenticator.getDisplayName()));
                            out.write("</option>\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t\t");
                        } else {
                            out.write("\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t\t\t<option value=\"");
                            out.print(Encode.forHtmlAttribute(authenticator.getName()));
                            out.write('"');
                            out.write('>');
                            out.print(Encode.forHtmlContent(authenticator.getDisplayName()));
                            out.write("</option>\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t\t");
                        }
                        out.write("\n");
                        out.write("\t\t\t\t\t\t\t\t\t\t");
                    }
                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t\t\t");
                }
                out.write("\n");
                out.write("\t\t\t\t\t\t\t\t\t</select>\n");
                out.write("                        \t</td>\n");
                out.write("                    \t</tr>   \n");
                out.write("                    \t");

                if (appBean.getEnabledFederatedIdentityProviders() != null
                        && appBean.getEnabledFederatedIdentityProviders().size() > 0) {
                    out.write("\n");
                    out.write("                    \t<tr>\n");
                    out.write("                    \t\t<td class=\"leftCol-med labelField\"/>\n");
                    out.write("                        \t<td>\n");
                    out.write("                        \t");
                    if (ApplicationBean.AUTH_TYPE_FEDERATED.equals(appBean.getAuthenticationType())) {
                        out.write("\n");
                        out.write(
                                "                        \t\t<input type=\"radio\" id=\"federated\" name=\"auth_type\" value=\"federated\" checked><label for=\"federated\" style=\"cursor: pointer;\">");
                        if (_jspx_meth_fmt_005fmessage_005f65(_jspx_th_fmt_005fbundle_005f0,
                                _jspx_page_context))
                            return;
                        out.write("</label>\n");
                        out.write("                        \t");
                    } else {
                        out.write("\n");
                        out.write(
                                "                        \t\t<input type=\"radio\" id=\"federated\" name=\"auth_type\" value=\"federated\"><label for=\"federated\" style=\"cursor: pointer;\">");
                        if (_jspx_meth_fmt_005fmessage_005f66(_jspx_th_fmt_005fbundle_005f0,
                                _jspx_page_context))
                            return;
                        out.write("</label>\n");
                        out.write("                        \t");
                    }
                    out.write("\n");
                    out.write("                        \t</td>\n");
                    out.write("                        \t<td>\n");
                    out.write("                        \t\t\t<select name=\"fed_idp\" id=\"fed_idp\">\n");
                    out.write("                        \t\t\t");
                    List<IdentityProvider> idps = appBean.getEnabledFederatedIdentityProviders();
                    String selectedIdP = appBean
                            .getStepZeroAuthenticatorName(ApplicationBean.AUTH_TYPE_FEDERATED);
                    boolean isSelectedIdPUsed = false;
                    for (IdentityProvider idp : idps) {
                        if (selectedIdP != null && idp.getIdentityProviderName().equals(selectedIdP)) {
                            isSelectedIdPUsed = true;

                            out.write("\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t\t<option value=\"");
                            out.print(Encode.forHtmlAttribute(idp.getIdentityProviderName()));
                            out.write("\" selected>");
                            out.print(Encode.forHtmlContent(idp.getIdentityProviderName()));
                            out.write("</option>\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t\t");
                        } else {
                            out.write("\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t\t<option value=\"");
                            out.print(Encode.forHtmlAttribute(idp.getIdentityProviderName()));
                            out.write('"');
                            out.write('>');
                            out.print(Encode.forHtmlContent(idp.getIdentityProviderName()));
                            out.write("</option>\n");
                            out.write("\t\t\t\t\t\t\t\t\t\t");
                        }
                        out.write("\n");
                        out.write("\t\t\t\t\t\t\t\t\t");
                    }
                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t\t\t</select>\n");
                    out.write("                        \t</td>\n");
                    out.write("                    \t</tr> \n");
                    out.write("                    \t");
                } else {
                    out.write("\n");
                    out.write("                    \t<tr>\n");
                    out.write("                    \t\t<td class=\"leftCol-med labelField\"/>\n");
                    out.write("                    \t\t<td>\n");
                    out.write(
                            "                    \t\t\t<input type=\"radio\" id=\"disabledFederated\" name=\"auth_type\" value=\"federated\" disabled><label for=\"disabledFederated\">");
                    if (_jspx_meth_fmt_005fmessage_005f67(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</label>\n");
                    out.write("                    \t\t</td>\n");
                    out.write("                    \t\t<td></td>\n");
                    out.write("                    \t</tr>\n");
                    out.write("                    \t");
                }
                out.write("\n");
                out.write("                    \t<tr>\n");
                out.write("                    \t\t<td class=\"leftCol-med labelField\"/>\n");
                out.write("                        \t<td>\n");
                out.write("                        \t");
                if (ApplicationBean.AUTH_TYPE_FLOW.equals(appBean.getAuthenticationType())) {
                    out.write("\n");
                    out.write(
                            "                        \t\t<input type=\"radio\" id=\"advanced\" name=\"auth_type\" value=\"flow\" onclick=\"updateBeanAndRedirect('configure-authentication-flow.jsp?spName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write(
                            "');\" checked><label style=\"cursor: pointer; color: #2F7ABD;\" for=\"advanced\">");
                    if (_jspx_meth_fmt_005fmessage_005f68(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</label>\n");
                    out.write("                        \t");
                } else {
                    out.write("\n");
                    out.write(
                            "                        \t\t<input type=\"radio\" id=\"advanced\" name=\"auth_type\" value=\"flow\" onclick=\"updateBeanAndRedirect('configure-authentication-flow.jsp?spName=");
                    out.print(Encode.forUriComponent(spName));
                    out.write("')\"><label style=\"cursor: pointer; color: #2F7ABD;\" for=\"advanced\">");
                    if (_jspx_meth_fmt_005fmessage_005f69(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                        return;
                    out.write("</label>\n");
                    out.write("                        \t\t");
                }
                out.write("\n");
                out.write("                        \t</td>\n");
                out.write("                    \t</tr>               \n");
                out.write("                  </table>\n");
                out.write("                  <table class=\"carbonFormTable\" style=\"padding-top: 5px;\">\n");
                out.write("                   \t\t<tr>\n");
                out.write("\t\t\t\t\t\t\t<td class=\"leftCol-med\">\n");
                out.write(
                        "                                <input type=\"checkbox\"  id=\"always_send_local_subject_id\" name=\"always_send_local_subject_id\" ");
                out.print(appBean.isAlwaysSendMappedLocalSubjectId() ? "checked" : "");
                out.write("/><label for=\"always_send_local_subject_id\">");
                if (_jspx_meth_fmt_005fmessage_005f70(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</label>\n");
                out.write("                        \t</td>\n");
                out.write("                    \t</tr>\n");
                out.write("                    \t<tr>\n");
                out.write("\t\t\t\t\t\t\t<td class=\"leftCol-med\">\n");
                out.write(
                        "                                <input type=\"checkbox\"  id=\"always_send_auth_list_of_idps\" name=\"always_send_auth_list_of_idps\" ");
                out.print(appBean.isAlwaysSendBackAuthenticatedListOfIdPs() ? "checked" : "");
                out.write("/><label for=\"always_send_auth_list_of_idps\">");
                if (_jspx_meth_fmt_005fmessage_005f71(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</label>\n");
                out.write("                        \t</td>\n");
                out.write("                    \t</tr>\n");
                out.write("\t\t\t\t\t  <tr>\n");
                out.write("\t\t\t\t\t\t  <td class=\"leftCol-med\">\n");
                out.write(
                        "\t\t\t\t\t\t\t  <input type=\"checkbox\"  id=\"use_tenant_domain_in_local_subject_identifier\"\n");
                out.write("\t\t\t\t\t\t\t\t\t name=\"use_tenant_domain_in_local_subject_identifier\" ");
                out.print(appBean.isUseTenantDomainInLocalSubjectIdentifier() ? "checked" : "");
                out.write("/><label for=\"use_tenant_domain_in_local_subject_identifier\">");
                if (_jspx_meth_fmt_005fmessage_005f72(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</label>\n");
                out.write("\t\t\t\t\t\t  </td>\n");
                out.write("\t\t\t\t\t  </tr>\n");
                out.write("\t\t\t\t\t  <tr>\n");
                out.write("\t\t\t\t\t\t  <td class=\"leftCol-med\">\n");
                out.write(
                        "\t\t\t\t\t\t\t  <input type=\"checkbox\"  id=\"use_userstore_domain_in_local_subject_identifier\"\n");
                out.write("\t\t\t\t\t\t\t\t\t name=\"use_userstore_domain_in_local_subject_identifier\" ");
                out.print(appBean.isUseUserstoreDomainInLocalSubjectIdentifier() ? "checked" : "");
                out.write("/><label\n");
                out.write("\t\t\t\t\t\t\t\t  for=\"use_userstore_domain_in_local_subject_identifier\">");
                if (_jspx_meth_fmt_005fmessage_005f73(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</label>\n");
                out.write("\t\t\t\t\t\t  </td>\n");
                out.write("\t\t\t\t\t  </tr>\n");
                out.write("                    </table>\n");
                out.write("\n");
                out.write("                  \n");
                out.write(
                        "                   <h2 id=\"req_path_head\" class=\"sectionSeperator trigger active\" style=\"background-color: beige;\">\n");
                out.write("                <a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f74(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("            </h2>\n");
                out.write(
                        "            <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"ReqPathAuth\">\n");
                out.write(
                        "                    <table class=\"styledLeft\" width=\"100%\" id=\"req_path_auth_table\">\n");
                out.write("                    \t<thead>\n");
                out.write("                    \t<tr>\n");
                out.write("                    \t\t<td>\n");
                out.write(
                        "                    \t\t\t<select name=\"reqPathAuthType\" style=\"float: left; min-width: 150px;font-size:13px;\">");
                out.print(requestPathAuthTypes.toString());
                out.write("</select>\n");
                out.write(
                        "                    \t\t\t<a id=\"reqPathAuthenticatorAddLink\" class=\"icon-link\" style=\"background-image:url(images/add.gif);\">Add</a>\n");
                out.write("                    \t\t\t<div style=\"clear:both\"></div>\n");
                out.write("                           \t\t<div class=\"sectionHelp\">\n");
                out.write("                                \t");
                if (_jspx_meth_fmt_005fmessage_005f75(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                            \t</div>\n");
                out.write("                    \t\t</td>\n");
                out.write("                    \t</tr>\n");
                out.write("                    \t</thead>\n");
                out.write("                    \t\n");
                out.write("                    \t");

                if (appBean.getServiceProvider().getRequestPathAuthenticatorConfigs() != null
                        && appBean.getServiceProvider().getRequestPathAuthenticatorConfigs().length > 0) {
                    int x = 0;
                    for (RequestPathAuthenticatorConfig reqAth : appBean.getServiceProvider()
                            .getRequestPathAuthenticatorConfigs()) {
                        if (reqAth != null) {

                            out.write("\n");
                            out.write("                    \t\t\t <tr>\n");
                            out.write("                    \t\t\t <td>\n");
                            out.write(
                                    "                    \t\t\t \t<input name=\"req_path_auth\" id=\"req_path_auth\" type=\"hidden\" value=\"");
                            out.print(Encode.forHtmlAttribute(reqAth.getName()));
                            out.write("\" />\n");
                            out.write("                    \t\t\t \t<input name=\"req_path_auth_");
                            out.print(Encode.forHtmlAttribute(reqAth.getName()));
                            out.write("\" id=\"req_path_auth_");
                            out.print(Encode.forHtmlAttribute(reqAth.getName()));
                            out.write("\" type=\"hidden\" value=\"");
                            out.print(Encode.forHtmlAttribute(reqAth.getName()));
                            out.write("\" />\n");
                            out.write("                    \t\t\t \t\n");
                            out.write("                    \t\t\t \t");
                            out.print(Encode.forHtmlContent(reqAth.getName()));
                            out.write("\n");
                            out.write("                    \t\t\t </td>\n");
                            out.write("                    \t\t\t <td class=\"leftCol-small\" >\n");
                            out.write(
                                    "                    \t\t\t \t<a onclick=\"deleteReqPathRow(this);return false;\" href=\"#\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete </a>\n");
                            out.write("                    \t\t\t </td>\n");
                            out.write("                    \t\t\t </tr>\t      \t\t\t \n");
                            out.write("                    \t\t\t ");

                        }
                    }
                }

                out.write("\n");
                out.write("                    </table> \n");
                out.write("            </div>\n");
                out.write("                  \n");
                out.write("            </div>\n");
                out.write("            \n");
                out.write(
                        "            <h2 id=\"inbound_provisioning_head\" class=\"sectionSeperator trigger active\">\n");
                out.write("                <a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f76(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("            </h2>\n");
                out.write(
                        "            <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"inboundProvisioning\">\n");
                out.write("            \n");
                out.write(
                        "             <h2 id=\"scim-inbound_provisioning_head\" class=\"sectionSeperator trigger active\" style=\"background-color: beige;\">\n");
                out.write("                <a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f77(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("             </h2>\n");
                out.write(
                        "                <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"scim-inbound-provisioning-div\">\n");
                out.write("                <table class=\"carbonFormTable\">\n");
                out.write(
                        "                  <tr><td>Service provider based SCIM provisioning is protected via OAuth 2.0. \n");
                out.write(
                        "                  Your service provider must have a valid OAuth 2.0 client key and a client secret to invoke the SCIM API.\n");
                out.write(
                        "                  To create OAuth 2.0 key/secret : Inbound Authentication Configuration -> OAuth/OpenID Connect Configuration.<br/>\n");
                out.write("                  </td></tr>\n");
                out.write("                   <tr>\n");
                out.write("                        <td >\n");
                out.write(
                        "                          <select style=\"min-width: 250px;\" id=\"scim-inbound-userstore\" name=\"scim-inbound-userstore\" ");
                out.print(appBean.getServiceProvider().getInboundProvisioningConfig().getDumbMode() ? "disabled"
                        : "");
                out.write(">\n");
                out.write("                          \t\t<option value=\"\">---Select---</option>\n");
                out.write("                                ");

                if (userStoreDomains != null && userStoreDomains.length > 0) {
                    for (String userStoreDomain : userStoreDomains) {
                        if (userStoreDomain != null) {
                            if (appBean.getServiceProvider().getInboundProvisioningConfig() != null
                                    && appBean.getServiceProvider().getInboundProvisioningConfig()
                                            .getProvisioningUserStore() != null
                                    && userStoreDomain.equals(appBean.getServiceProvider()
                                            .getInboundProvisioningConfig().getProvisioningUserStore())) {

                                out.write("\n");
                                out.write(
                                        "                                          \t\t\t<option selected=\"selected\" value=\"");
                                out.print(Encode.forHtmlAttribute(userStoreDomain));
                                out.write('"');
                                out.write('>');
                                out.print(Encode.forHtmlContent(userStoreDomain));
                                out.write("</option>\n");
                                out.write("                                    ");

                            } else {

                                out.write("\n");
                                out.write("                                           \t\t\t<option value=\"");
                                out.print(Encode.forHtmlAttribute(userStoreDomain));
                                out.write('"');
                                out.write('>');
                                out.print(Encode.forHtmlContent(userStoreDomain));
                                out.write("</option>\n");
                                out.write("                                    ");

                            }
                        }
                    }
                }

                out.write("\n");
                out.write("                          </select>\n");
                out.write("                          <div class=\"sectionHelp\">\n");
                out.write("                                ");
                if (_jspx_meth_fmt_005fmessage_005f78(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                            </div>\n");
                out.write("                        </td>\n");
                out.write("                    </tr>\n");
                out.write("                    <tr>\n");
                out.write("                        <td>\n");
                out.write(
                        "                            <input type=\"checkbox\" name=\"dumb\" id=\"dumb\" value=\"false\" onclick =\"disable()\" ");
                out.print(appBean.getServiceProvider().getInboundProvisioningConfig().getDumbMode() ? "checked"
                        : "");
                out.write(">Enable Dumb Mode<br>\n");
                out.write("                            <div class=\"sectionHelp\">\n");
                out.write("                                ");
                if (_jspx_meth_fmt_005fmessage_005f79(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\n");
                out.write("                            </div>\n");
                out.write("                        </td>\n");
                out.write("                    </tr>\n");
                out.write("                    </table>\n");
                out.write("                </div>\n");
                out.write("            \n");
                out.write("            \n");
                out.write("            </div>\n");
                out.write("            \n");
                out.write(
                        "            <h2 id=\"outbound_provisioning_head\" class=\"sectionSeperator trigger active\">\n");
                out.write("                <a href=\"#\">");
                if (_jspx_meth_fmt_005fmessage_005f80(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("</a>\n");
                out.write("            </h2>\n");
                out.write(
                        "            <div class=\"toggle_container sectionSub\" style=\"margin-bottom:10px;\" id=\"outboundProvisioning\">\n");
                out.write("             <table class=\"styledLeft\" width=\"100%\" id=\"fed_auth_table\">\n");
                out.write("            \n");
                out.write("\t\t      ");
                if (idpType != null && idpType.length() > 0) {
                    out.write("\n");
                    out.write("\t\t       <thead> \n");
                    out.write("\t\t       \n");
                    out.write("\t\t\t\t\t<tr>\n");
                    out.write("\t\t\t\t\t\t<td>\t\t\t\t             \t  \n");
                    out.write(
                            "\t\t\t\t\t\t\t <select name=\"provisioning_idps\" style=\"float: left; min-width: 150px;font-size:13px;\">\n");
                    out.write("\t\t\t\t\t\t\t ");
                    out.print(idpType.toString());
                    out.write("\n");
                    out.write("\t\t\t\t\t\t\t </select>\n");
                    out.write(
                            "\t\t\t\t\t\t     <a id=\"provisioningIdpAdd\" onclick=\"addIDPRow(this);return false;\" class=\"icon-link\" style=\"background-image:url(images/add.gif);\"></a>\n");
                    out.write("\t\t\t\t\t\t</td>\n");
                    out.write("\t\t            </tr>\n");
                    out.write("\t\t           \n");
                    out.write("\t           </thead>\n");
                    out.write("\t            ");
                } else {
                    out.write("\n");
                    out.write(
                            "\t\t              <tr><td colspan=\"4\" style=\"border: none;\">There are no provisioning enabled identity providers defined in the system.</td></tr>\n");
                    out.write("\t\t        ");
                }
                out.write("\n");
                out.write("\t\t\t\t\t\t\t                 \n");
                out.write("\t           ");

                if (appBean.getServiceProvider().getOutboundProvisioningConfig() != null) {
                    IdentityProvider[] fedIdps = appBean.getServiceProvider().getOutboundProvisioningConfig()
                            .getProvisioningIdentityProviders();
                    if (fedIdps != null && fedIdps.length > 0) {
                        for (IdentityProvider idp : fedIdps) {
                            if (idp != null) {
                                boolean jitEnabled = false;
                                boolean blocking = false;

                                if (idp.getJustInTimeProvisioningConfig() != null
                                        && idp.getJustInTimeProvisioningConfig().getProvisioningEnabled()) {
                                    jitEnabled = true;
                                }
                                if (idp.getDefaultProvisioningConnectorConfig() != null
                                        && idp.getDefaultProvisioningConnectorConfig().getBlocking()) {
                                    blocking = true;
                                }

                                out.write("\n");
                                out.write("\t\t\t\t\t\t\t      \n");
                                out.write("\t\t\t\t\t\t\t      \t       <tr>\n");
                                out.write("\t\t\t\t\t\t\t      \t      \t   <td>\n");
                                out.write(
                                        "\t\t\t\t\t\t\t      \t      \t\t<input name=\"provisioning_idp\" id=\"\" type=\"hidden\" value=\"");
                                out.print(Encode.forHtmlAttribute(idp.getIdentityProviderName()));
                                out.write("\" />\n");
                                out.write("                                                    ");
                                out.print(Encode.forHtmlContent(idp.getIdentityProviderName()));
                                out.write("\n");
                                out.write("\t\t\t\t\t\t\t      \t      \t\t</td>\n");
                                out.write("\t\t\t\t\t\t\t      \t      \t\t<td> \n");
                                out.write("\t\t\t\t\t\t\t      \t      \t\t\t");
                                if (selectedProIdpConnectors.get(idp.getIdentityProviderName()) != null) {
                                    out.write("\n");
                                    out.write(
                                            "\t\t\t\t\t\t\t      \t      \t\t\t\t<select name=\"provisioning_con_idp_");
                                    out.print(Encode.forHtmlAttribute(idp.getIdentityProviderName()));
                                    out.write("\" style=\"float: left; min-width: 150px;font-size:13px;\">");
                                    out.print(selectedProIdpConnectors.get(idp.getIdentityProviderName()));
                                    out.write("</select>\n");
                                    out.write("\t\t\t\t\t\t\t      \t      \t\t\t");
                                }
                                out.write("\n");
                                out.write("\t\t\t\t\t\t\t      \t      \t\t</td>\n");
                                out.write("\t\t\t\t\t\t\t      \t      \t\t <td>\n");
                                out.write(
                                        "                            \t\t\t\t\t\t<div class=\"sectionCheckbox\">\n");
                                out.write(
                                        "                                \t\t\t\t\t\t<input type=\"checkbox\" id=\"blocking_prov_");
                                out.print(Encode.forHtmlAttribute(idp.getIdentityProviderName()));
                                out.write("\" name=\"blocking_prov_");
                                out.print(Encode.forHtmlAttribute(idp.getIdentityProviderName()));
                                out.write('"');
                                out.write(' ');
                                out.print(blocking ? "checked" : "");
                                out.write(">Blocking\n");
                                out.write("                   \t\t\t\t\t\t\t\t\t</div>\n");
                                out.write("                        \t\t\t\t\t\t</td>\n");
                                out.write("\t\t\t\t\t\t\t      \t      \t\t <td>\n");
                                out.write(
                                        "                            \t\t\t\t\t\t<div class=\"sectionCheckbox\">\n");
                                out.write(
                                        "                                \t\t\t\t\t\t<input type=\"checkbox\" id=\"provisioning_jit_");
                                out.print(Encode.forHtmlAttribute(idp.getIdentityProviderName()));
                                out.write("\" name=\"provisioning_jit_");
                                out.print(Encode.forHtmlAttribute(idp.getIdentityProviderName()));
                                out.write('"');
                                out.write(' ');
                                out.print(jitEnabled ? "checked" : "");
                                out.write(">Enable JIT\n");
                                out.write("                   \t\t\t\t\t\t\t\t\t</div>\n");
                                out.write("                        \t\t\t\t\t\t</td>\n");
                                out.write("\t\t\t\t\t\t\t      \t      \t\t<td class=\"leftCol-small\" >\n");
                                out.write(
                                        "\t\t\t\t\t\t\t      \t      \t\t<a onclick=\"deleteIDPRow(this);return false;\" href=\"#\" class=\"icon-link\" style=\"background-image: url(images/delete.gif)\"> Delete </a>\n");
                                out.write("\t\t\t\t\t\t\t      \t      \t\t</td>\n");
                                out.write("\t\t\t\t\t\t\t      \t       </tr>\t\t\t\t\t\t      \n");
                                out.write("\t\t\t    ");

                            }
                        }
                    }
                }

                out.write("\n");
                out.write("\t\t\t  </table>\n");
                out.write("            \n");
                out.write("            </div>          \n");
                out.write("\n");
                out.write("\t\t\t<div style=\"clear:both\"/>\n");
                out.write("            <!-- sectionSub Div -->\n");
                out.write("            <div class=\"buttonRow\">\n");
                out.write("                <input type=\"button\" value=\"");
                if (_jspx_meth_fmt_005fmessage_005f81(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\" onclick=\"createAppOnclick();\"/>\n");
                out.write("                <input type=\"button\" value=\"");
                if (_jspx_meth_fmt_005fmessage_005f82(_jspx_th_fmt_005fbundle_005f0, _jspx_page_context))
                    return;
                out.write("\" onclick=\"javascript:location.href='list-service-providers.jsp'\"/>\n");
                out.write("            </div>\n");
                out.write("            </form>\n");
                out.write("        </div>\n");
                out.write("    </div>\n");
                out.write("\n");
                int evalDoAfterBody = _jspx_th_fmt_005fbundle_005f0.doAfterBody();
                if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
                    break;
            } while (true);
            if (_jspx_eval_fmt_005fbundle_005f0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
                out = _jspx_page_context.popBody();
            }
        }
        if (_jspx_th_fmt_005fbundle_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
            _005fjspx_005ftagPool_005ffmt_005fbundle_0026_005fbasename.reuse(_jspx_th_fmt_005fbundle_005f0);
            return;
        }
        _005fjspx_005ftagPool_005ffmt_005fbundle_0026_005fbasename.reuse(_jspx_th_fmt_005fbundle_005f0);
        out.write('\n');
    } catch (java.lang.Throwable t) {
        if (!(t instanceof javax.servlet.jsp.SkipPageException)) {
            out = _jspx_out;
            if (out != null && out.getBufferSize() != 0)
                try {
                    if (response.isCommitted()) {
                        out.flush();
                    } else {
                        out.clearBuffer();
                    }
                } catch (java.io.IOException e) {
                }
            if (_jspx_page_context != null)
                _jspx_page_context.handlePageException(t);
            else
                throw new ServletException(t);
        }
    } finally {
        _jspxFactory.releasePageContext(_jspx_page_context);
    }
}