package jeus_jspwork._moniter._environment;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.kldp.ebmsh.moniter.persistant.EbmsMoniterManager;
import org.kldp.ebmsh.moniter.permission.PermissionManager;
import org.kldp.ebmsh.moniter.permission.PermissionManager;
import org.kldp.ebmsh.config.EbmsConstants;
import org.kldp.ebmsh.moniter.permission.PermissionManager;
import org.kldp.ebmsh.config.EbmsConstants;

public final class _500_adminModifyProcess_5fjsp extends jeus.servlet.jsp2.runtime.HttpJspBase
    implements jeus.servlet.jsp2.runtime.JspSourceDependent {

  private static java.util.Vector _jspx_dependants;

  static {
    _jspx_dependants = new java.util.Vector(2);
    _jspx_dependants.add("/authorize/loginCheck.jsp");
    _jspx_dependants.add("/setup/setupCheck.jsp");
  }

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

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

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html; charset=euc-kr");
      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("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");

	if( !PermissionManager.isAdminLogin(session) ) {

      out.write("\r\n");
      out.write("\t\t<script language=\"JavaScript\">\r\n");
      out.write("\t\t\tdocument.location.href = '");
      out.print( request.getContextPath() );
      out.write("/authorize/login.jsp';\r\n");
      out.write("\t\t</script>\r\n");
	
		return ;
	}

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");

	if( !EbmsConstants.configured ) {

      out.write("\r\n");
      out.write("\t\t<script language=\"JavaScript\">\r\n");
      out.write("\t\t\tdocument.location.href = '");
      out.print( request.getContextPath() );
      out.write("/setup/setup.jsp';\r\n");
      out.write("\t\t</script>\r\n");
	
		return ;
	}

      out.write("\r\n");
      out.write("\r\n");

	String id = request.getParameter("id");
	String oldPassword = request.getParameter("oldPassword");
	String newPassword = request.getParameter("newPassword");
	
	EbmsMoniterManager manager = new EbmsMoniterManager();
	
	if( manager.authorizeAdmin(id, oldPassword) ) 
		manager.updateAdminPassword(id, newPassword);
	else {

      out.write("\r\n");
      out.write("\t\t<script language=\"JavaScript\">\r\n");
      out.write("\t\t\talert('기존 비밀번호가 일치하지 않습니다.');\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t\thistory.go(-1);\r\n");
      out.write("\t\t</script>\r\n");

	}

      out.write("\r\n");
      out.write("\r\n");
      out.write("<script language=\"JavaScript\">\r\n");
      out.write("\talert('비밀번호가 변경되었습니다.');\r\n");
      out.write("\t\r\n");
      out.write("\twindow.close();\r\n");
      out.write("</script>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
