Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package th.in.oneauth.servlet;
- import java.io.IOException;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.google.gson.JsonObject;
- import th.in.oneauthen.object.SftpProfileDB;
- import th.in.oneauthen.object.SignatureProfileDB;
- import th.in.oneauthen.object.UserUidDB;
- import th.in.oneauthen.object.DAO.SftpProfileDAO;
- import th.in.oneauthen.object.DAO.SignatureProfileDAO;
- @WebServlet("/signature")
- public class SignatureProfileServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
- public static final String PROFILE_NAME = "profilename";
- public static final String Month_session = "24";
- public static final String Year_session = "2561";
- public static final String SIGNING_URL = "dashboard.jsp?reqp=signing";
- public static final String URL_DASHBORD = "dashboard.jsp";
- public static String SFTP_ADDRESS = "sftpAddress";
- public static String SFTP_PORT = "8080";
- public static String SFTP_USERNAME = "username";
- public static String SFTP_PASSWORD = "password";
- public static String TARGETDIR = "targetDir";
- public static String PARAM_ACTION = "action";
- public static final String SESSION_PARAM_MONTH = "month";
- public static final String SESSION_PARAM_YEAR = "year";
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- // TODO Auto-generated method stub
- String profilename = request.getParameter(PROFILE_NAME);
- UserUidDB userIdForProfile = (UserUidDB) request.getSession().getAttribute(LoginServlet.SESSION_PARAM_USER);
- int ownerId =userIdForProfile.getUserId();
- // String month = request.getParameter(Month_session);
- // String year = request.getParameter(Year_session);
- //
- // request.getSession().setAttribute(SESSION_PARAM_MONTH,month);
- // request.getSession().setAttribute(SESSION_PARAM_MONTH,year);
- PARAM_ACTION ="selectProfile";
- switch (PARAM_ACTION) {
- case "delete":
- SignatureProfileDB delProfile = new SignatureProfileDAO().findByNameAndUserUID(profilename, ownerId);
- SignatureProfileDAO selectDel = new SignatureProfileDAO();
- try {
- selectDel.remove(delProfile.getProfileID());
- request.getRequestDispatcher(URL_DASHBORD).forward(request, response);
- } catch (Exception e1) {
- System.out.println("Error can not delete :"+delProfile.getProfileName());
- e1.printStackTrace();
- }
- break;
- case "selectProfile":
- request.getSession().setAttribute("profileName", profilename);//profile name
- request.getRequestDispatcher(SIGNING_URL).forward(request, response);
- break;
- }
- //
- //
- // String ipSftp = request.getParameter(SFTP_ADDRESS);
- // String sftpPortStr = request.getParameter(SFTP_PORT);
- // int sftpPort = Integer.parseInt("8080");
- // String profileSftp = request.getParameter(SFTP_USERNAME);
- // String keyPin = request.getParameter(SFTP_PASSWORD);
- // String locationSign = request.getParameter(TARGETDIR);
- //
- //
- //
- // //save in DB signatureprofileDB
- // SftpProfileDAO sftpProfile = new SftpProfileDAO();
- // SftpProfileDB setSftpProfile = new SftpProfileDB();
- // setSftpProfile.setSftpAddress("192.168.1.254");
- // setSftpProfile.setSftpDir("C//ballza");
- // setSftpProfile.setSftpPort(443);
- // setSftpProfile.setSftpUserName("chaichana");
- // setSftpProfile.setSftpPassword("chaichana2538");
- // setSftpProfile.setProfileID(delProfile);
- //
- // try {
- // sftpProfile .save(setSftpProfile);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- //
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement