Guest User

Untitled

a guest
Jul 21st, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. public void doFilter(ServletRequest request, ServletResponse response,
  2. FilterChain chain) throws IOException,
  3. ServletException {
  4.  
  5.  
  6. // __TB__ 2009_11_06 added for customization
  7. String str_old_password = null;
  8. String str_new_password = null;
  9. String str_new_password_confirm = null;
  10. String str_action = null;
  11. String str_user = request.getParameterValues("p_username")[0];
  12.  
  13.  
  14. // __TB__ 2009_11_06 added for customization
  15. // Get the old password value
  16. try {
  17. str_old_password = request.getParameterValues("p_old_password")[0];
  18. } catch (Exception e) {
  19. str_old_password = "";
  20. logger.error("Problem s dohvaćanjem starog passworda za username: " +
  21. str_user);
  22. throw new IOException();
  23. }
  24.  
  25. // Get the new password
  26. try {
  27. str_new_password = request.getParameterValues("p_new_password")[0];
  28. } catch (Exception e) {
  29. str_new_password = "";
  30. logger.error("Problem s dohvaćanjem novog passworda za username: " +
  31. str_user);
  32. throw new IOException();
  33. }
  34.  
  35. // Get the new password confrimantion string
  36. try {
  37. str_new_password_confirm =
  38. request.getParameterValues("p_new_password_confirm")[0];
  39. } catch (Exception e) {
  40. str_new_password_confirm = "";
  41. logger.error("Problem s dohvaćanjem potvrde novog passworda za username: " +
  42. str_user);
  43. throw new IOException();
  44. }
  45.  
  46. // Get the action string
  47. try {
  48. str_action = request.getParameterValues("p_action")[0];
  49. } catch (Exception e) {
  50. str_action = "OK";
  51. }
  52.  
  53. if (logger.isDebugEnabled()) {
  54. logger.debug("Ulazak u RuPassFilter-doFilter za username: " +
  55. str_user);
  56. }
  57.  
  58. // Prevent update if passwords are not equal and action is not equal OK
  59. if (str_new_password.toString().equals(str_new_password_confirm.toString()) &&
  60. str_action.equals("OK")) {
  61. try {
  62. if (logger.isDebugEnabled()) {
  63. logger.debug("Novi password i njegova potvrda odgovaraju jedno drugom za username: " +
  64. str_user);
  65. }
  66. //Run update and on any exception pass request to password change servlet except on MyException
  67. MyChecker mc = new MyChecker();
  68.  
  69. if (logger.isDebugEnabled()) {
  70. logger.debug("Poziv check metode u RuPassFilter-u za username: " +
  71. str_user);
  72. }
  73. mc.check (str_user, str_old_password, str_new_password,
  74. _filterConfig.getServletContext());
  75. if (logger.isDebugEnabled()) {
  76. logger.debug("Odrađena check metoda u RuPassFilter-u za username: " +
  77. str_user);
  78. }
  79. //pass to servlet
  80. chain.doFilter(request, response);
  81.  
  82. } catch (UtilException ue) {
  83. logger.error("Dogodio se UtileException za username: " +
  84. str_user);
  85. logger.error(ue.getLocalizedMessage());
  86.  
  87. chain.doFilter(request, response);
  88.  
  89. } catch (NamingException ne) {
  90. logger.error("Dogodio se NamingException za username: " +
  91. str_user);
  92. logger.error(ne.getLocalizedMessage());
  93.  
  94. chain.doFilter(request, response);
  95.  
  96. } catch (IOException ioe) {
  97. logger.error("Dogodio se IOException u RuPassFilter-u za username: " +
  98. str_user);
  99. logger.error(ioe.getLocalizedMessage());
  100.  
  101. throw ioe;
  102. } catch (MyException me) {
  103. logger.error("Dogodio se MyException u RuPassFilter-u za username: " +
  104. str_user);
  105. logger.error(me.getLocalizedMessage());
  106.  
  107. //!!!!!!!!!!!!
  108. // At this point I need return response back to sender !!!!!!!!!!!!
  109. //!!!!!!!!!!!!!
  110. }
  111. } else {
  112. if (logger.isDebugEnabled()) {
  113. logger.debug("Passwordi ne odgovraju jedna drugom ili je action različit od OK u RuPassFilter-u za username: " +
  114. str_user);
  115.  
  116. }
  117. //!!!!!!!!!!!!
  118. // At this point I need return response back to sender !!!!!!!!!!!!
  119. //!!!!!!!!!!!!!
  120. }
  121.  
  122. // Everything is OK
  123. chain.doFilter(request, response);
  124. }
Add Comment
Please, Sign In to add comment