org.apache.jsp.registration_jsp.java Source code

Java tutorial

Introduction

Here is the source code for org.apache.jsp.registration_jsp.java

Source

/*
 * Generated by the Jasper component of Apache Tomcat
 * Version: Apache Tomcat/7.0.59
 * Generated at: 2016-06-23 15:50:08 UTC
 * Note: The last modified time of this file was set to
 *       the last modified time of the source file after
 *       generation to assist with modification tracking.
 */
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.wso2.carbon.identity.application.authentication.endpoint.util.UserRegistrationAdminServiceClient;
import org.owasp.encoder.Encode;
import org.wso2.carbon.identity.user.registration.stub.dto.UserFieldDTO;
import java.util.List;
import org.apache.commons.lang.StringUtils;

public final class registration_jsp extends org.apache.jasper.runtime.HttpJspBase
        implements org.apache.jasper.runtime.JspSourceDependent {

    private static final javax.servlet.jsp.JspFactory _jspxFactory = javax.servlet.jsp.JspFactory
            .getDefaultFactory();

    private static java.util.Map<java.lang.String, java.lang.Long> _jspx_dependants;

    private javax.el.ExpressionFactory _el_expressionfactory;
    private org.apache.tomcat.InstanceManager _jsp_instancemanager;

    public java.util.Map<java.lang.String, java.lang.Long> getDependants() {
        return _jspx_dependants;
    }

    public void _jspInit() {
        _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext())
                .getExpressionFactory();
        _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory
                .getInstanceManager(getServletConfig());
    }

    public void _jspDestroy() {
    }

    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 {
            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;

            /**
            * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
            *
            * WSO2 Inc. licenses this file to you under the Apache License,
            * Version 2.0 (the "License"); you may not use this file except
            * in compliance with the License.
            * You may obtain a copy of the License at
            *
            * http://www.apache.org/licenses/LICENSE-2.0
            *
            * Unless required by applicable law or agreed to in writing,
            * software distributed under the License is distributed on an
            * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
            * KIND, either express or implied. See the License for the
            * specific language governing permissions and limitations
            * under the License.
            */
            out.write("\n");
            out.write("\n");
            out.write("\n");
            out.write("\n");
            out.write("\n");
            out.write("\n");
            out.write("\n");

            String forwardTo;
            try {

                UserRegistrationAdminServiceClient registrationClient = new UserRegistrationAdminServiceClient();
                boolean isExistingUser = registrationClient.isUserExist(request.getParameter("reg_username"));

                if (StringUtils.equals(request.getParameter("is_validation"), "true")) {
                    if (isExistingUser) {
                        out.write("User Exist");
                    } else {
                        out.write("Ok");
                    }
                    return;
                }

                if (isExistingUser) {
                    throw new Exception("User exist");
                }

                List<UserFieldDTO> fields = (List<UserFieldDTO>) session.getAttribute("fields");

                for (UserFieldDTO userFieldDTO : fields) {
                    userFieldDTO.setFieldValue(request.getParameter(userFieldDTO.getFieldName()));
                }

                String username = request.getParameter("reg_username");
                char[] password = request.getParameter("reg_password").toCharArray();
                registrationClient.addUser(username, password, fields);

                forwardTo = "../dashboard/index.jag";

            } catch (Exception e) {
                String error = "An internal error occurred.";
                response.sendRedirect("create-account.jsp?sessionDataKey=" + request.getParameter("sessionDataKey")
                        + "&failedPrevious=true&errorCode=" + error);
                return;
            }

            out.write("\n");
            out.write("<html>\n");
            out.write("<head>\n");
            out.write("    <link href=\"libs/bootstrap_3.3.5/css/bootstrap.min.css\" rel=\"stylesheet\">\n");
            out.write("    <link href=\"css/Roboto.css\" rel=\"stylesheet\">\n");
            out.write("    <link href=\"css/custom-common.css\" rel=\"stylesheet\">\n");
            out.write("</head>\n");
            out.write("<body>\n");
            out.write("<div class=\"container\">\n");
            out.write("    <div id=\"infoModel\" class=\"modal fade\" role=\"dialog\">\n");
            out.write("        <div class=\"modal-dialog\">\n");
            out.write("            <div class=\"modal-content\">\n");
            out.write("                <div class=\"modal-header\">\n");
            out.write(
                    "                    <button type=\"button\" class=\"close\" data-dismiss=\"modal\">&times;</button>\n");
            out.write("                    <h4 class=\"modal-title\">Information</h4>\n");
            out.write("                </div>\n");
            out.write("                <div class=\"modal-body\">\n");
            out.write("                    <p>User details successfully submitted</p>\n");
            out.write("                </div>\n");
            out.write("                <div class=\"modal-footer\">\n");
            out.write(
                    "                    <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>\n");
            out.write("                </div>\n");
            out.write("            </div>\n");
            out.write("        </div>\n");
            out.write("    </div>\n");
            out.write("</div>\n");
            out.write("<script src=\"libs/jquery_1.11.3/jquery-1.11.3.js\"></script>\n");
            out.write("<script src=\"libs/bootstrap_3.3.5/js/bootstrap.min.js\"></script>\n");
            out.write("<script type=\"application/javascript\" >\n");
            out.write("    $(document).ready(function () {\n");
            out.write("        var infoModel = $(\"#infoModel\");\n");
            out.write("        infoModel.modal(\"show\");\n");
            out.write("        infoModel.on('hidden.bs.modal', function() {\n");
            out.write("            location.href = \"");
            out.print(Encode.forJavaScriptBlock(forwardTo));
            out.write("\";\n");
            out.write("        })\n");
            out.write("    });\n");
            out.write("</script>\n");
            out.write("</body>\n");
            out.write("</html>");
        } 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);
        }
    }
}