Update application interceptor
Clean code
This commit is contained in:
parent
f8f426a7aa
commit
f6d6a2faf5
@ -1,12 +1,10 @@
|
|||||||
package com.jasamedika.medifirst2000.interceptor;
|
package com.jasamedika.medifirst2000.interceptor;
|
||||||
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interceptor class for All annotation method controller @AppPermission
|
* Interceptor class for All annotation method controller @AppPermission
|
||||||
@ -17,8 +15,6 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||||
HandlerMethod hm = (HandlerMethod) handler;
|
|
||||||
Method method = hm.getMethod();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -96,8 +96,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
return potongan.toString();
|
return potongan.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response, String AlamatUrlForm,
|
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
boolean supervisi) throws Exception {
|
|
||||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||||
namaUser = authentication.getName();
|
namaUser = authentication.getName();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
@ -176,7 +175,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
||||||
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
||||||
return true;
|
return true;
|
||||||
if (!checkAuthSecure(request, response, AlamatUrlForm, false))
|
if (!checkAuthSecure(request, response))
|
||||||
return false;
|
return false;
|
||||||
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
||||||
if (resultUser == 0) {
|
if (resultUser == 0) {
|
||||||
@ -228,7 +227,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
hm = (HandlerMethod) handler;
|
hm = (HandlerMethod) handler;
|
||||||
method = hm.getMethod();
|
method = hm.getMethod();
|
||||||
} else {
|
} else {
|
||||||
return checkAuthSecure(request, response, AlamatUrlForm, true);
|
return checkAuthSecure(request, response);
|
||||||
}
|
}
|
||||||
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
||||||
boolean postM = "POST".equals(methodHttp);
|
boolean postM = "POST".equals(methodHttp);
|
||||||
@ -292,7 +291,12 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
||||||
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
||||||
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
||||||
Integer ruanganAsalId = Integer.parseInt(KdRuangan);
|
Integer ruanganAsalId;
|
||||||
|
try {
|
||||||
|
ruanganAsalId = Integer.parseInt(KdRuangan);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ruanganAsalId = null;
|
||||||
|
}
|
||||||
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
||||||
if (notHttpOK || notLewatMenu || adaError)
|
if (notHttpOK || notLewatMenu || adaError)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -96,8 +96,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
return potongan.toString();
|
return potongan.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response, String AlamatUrlForm,
|
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
boolean supervisi) throws Exception {
|
|
||||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||||
namaUser = authentication.getName();
|
namaUser = authentication.getName();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
@ -176,7 +175,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
||||||
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
||||||
return true;
|
return true;
|
||||||
if (!checkAuthSecure(request, response, AlamatUrlForm, false))
|
if (!checkAuthSecure(request, response))
|
||||||
return false;
|
return false;
|
||||||
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
||||||
if (resultUser == 0) {
|
if (resultUser == 0) {
|
||||||
@ -228,7 +227,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
hm = (HandlerMethod) handler;
|
hm = (HandlerMethod) handler;
|
||||||
method = hm.getMethod();
|
method = hm.getMethod();
|
||||||
} else {
|
} else {
|
||||||
return checkAuthSecure(request, response, AlamatUrlForm, true);
|
return checkAuthSecure(request, response);
|
||||||
}
|
}
|
||||||
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
||||||
boolean postM = "POST".equals(methodHttp);
|
boolean postM = "POST".equals(methodHttp);
|
||||||
@ -293,7 +292,12 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
||||||
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
||||||
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
||||||
Integer ruanganAsalId = Integer.parseInt(KdRuangan);
|
Integer ruanganAsalId;
|
||||||
|
try {
|
||||||
|
ruanganAsalId = Integer.parseInt(KdRuangan);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ruanganAsalId = null;
|
||||||
|
}
|
||||||
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
||||||
if (notHttpOK || notLewatMenu || adaError)
|
if (notHttpOK || notLewatMenu || adaError)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -96,8 +96,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
return potongan.toString();
|
return potongan.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response, String AlamatUrlForm,
|
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
boolean supervisi) throws Exception {
|
|
||||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||||
namaUser = authentication.getName();
|
namaUser = authentication.getName();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
@ -176,7 +175,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
||||||
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
||||||
return true;
|
return true;
|
||||||
if (!checkAuthSecure(request, response, AlamatUrlForm, false))
|
if (!checkAuthSecure(request, response))
|
||||||
return false;
|
return false;
|
||||||
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
||||||
if (resultUser == 0) {
|
if (resultUser == 0) {
|
||||||
@ -228,7 +227,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
hm = (HandlerMethod) handler;
|
hm = (HandlerMethod) handler;
|
||||||
method = hm.getMethod();
|
method = hm.getMethod();
|
||||||
} else {
|
} else {
|
||||||
return checkAuthSecure(request, response, AlamatUrlForm, true);
|
return checkAuthSecure(request, response);
|
||||||
}
|
}
|
||||||
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
||||||
boolean postM = "POST".equals(methodHttp);
|
boolean postM = "POST".equals(methodHttp);
|
||||||
@ -292,7 +291,12 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
||||||
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
||||||
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
||||||
Integer ruanganAsalId = Integer.parseInt(KdRuangan);
|
Integer ruanganAsalId;
|
||||||
|
try {
|
||||||
|
ruanganAsalId = Integer.parseInt(KdRuangan);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ruanganAsalId = null;
|
||||||
|
}
|
||||||
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
||||||
if (notHttpOK || notLewatMenu || adaError)
|
if (notHttpOK || notLewatMenu || adaError)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -96,8 +96,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
return potongan.toString();
|
return potongan.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response, String AlamatUrlForm,
|
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
boolean supervisi) throws Exception {
|
|
||||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||||
namaUser = authentication.getName();
|
namaUser = authentication.getName();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
@ -176,7 +175,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
||||||
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
||||||
return true;
|
return true;
|
||||||
if (!checkAuthSecure(request, response, AlamatUrlForm, false))
|
if (!checkAuthSecure(request, response))
|
||||||
return false;
|
return false;
|
||||||
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
||||||
if (resultUser == 0) {
|
if (resultUser == 0) {
|
||||||
@ -228,7 +227,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
hm = (HandlerMethod) handler;
|
hm = (HandlerMethod) handler;
|
||||||
method = hm.getMethod();
|
method = hm.getMethod();
|
||||||
} else {
|
} else {
|
||||||
return checkAuthSecure(request, response, AlamatUrlForm, true);
|
return checkAuthSecure(request, response);
|
||||||
}
|
}
|
||||||
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
||||||
boolean postM = "POST".equals(methodHttp);
|
boolean postM = "POST".equals(methodHttp);
|
||||||
@ -292,7 +291,12 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
||||||
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
||||||
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
||||||
Integer ruanganAsalId = Integer.parseInt(KdRuangan);
|
Integer ruanganAsalId;
|
||||||
|
try {
|
||||||
|
ruanganAsalId = Integer.parseInt(KdRuangan);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ruanganAsalId = null;
|
||||||
|
}
|
||||||
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
||||||
if (notHttpOK || notLewatMenu || adaError)
|
if (notHttpOK || notLewatMenu || adaError)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -97,8 +97,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
return potongan.toString();
|
return potongan.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response, String AlamatUrlForm,
|
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
boolean supervisi) throws Exception {
|
|
||||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||||
namaUser = authentication.getName();
|
namaUser = authentication.getName();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
@ -177,7 +176,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
||||||
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
||||||
return true;
|
return true;
|
||||||
if (!checkAuthSecure(request, response, AlamatUrlForm, false))
|
if (!checkAuthSecure(request, response))
|
||||||
return false;
|
return false;
|
||||||
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
||||||
if (resultUser == 0) {
|
if (resultUser == 0) {
|
||||||
@ -229,7 +228,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
hm = (HandlerMethod) handler;
|
hm = (HandlerMethod) handler;
|
||||||
method = hm.getMethod();
|
method = hm.getMethod();
|
||||||
} else {
|
} else {
|
||||||
return checkAuthSecure(request, response, AlamatUrlForm, true);
|
return checkAuthSecure(request, response);
|
||||||
}
|
}
|
||||||
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
||||||
boolean postM = "POST".equals(methodHttp);
|
boolean postM = "POST".equals(methodHttp);
|
||||||
@ -293,7 +292,12 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
||||||
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
||||||
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
||||||
Integer ruanganAsalId = Integer.parseInt(KdRuangan);
|
Integer ruanganAsalId;
|
||||||
|
try {
|
||||||
|
ruanganAsalId = Integer.parseInt(KdRuangan);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ruanganAsalId = null;
|
||||||
|
}
|
||||||
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
||||||
if (notHttpOK || notLewatMenu || adaError)
|
if (notHttpOK || notLewatMenu || adaError)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -96,8 +96,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
return potongan.toString();
|
return potongan.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response, String AlamatUrlForm,
|
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
boolean supervisi) throws Exception {
|
|
||||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||||
namaUser = authentication.getName();
|
namaUser = authentication.getName();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
@ -176,7 +175,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
||||||
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
||||||
return true;
|
return true;
|
||||||
if (!checkAuthSecure(request, response, AlamatUrlForm, false))
|
if (!checkAuthSecure(request, response))
|
||||||
return false;
|
return false;
|
||||||
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
||||||
if (resultUser == 0) {
|
if (resultUser == 0) {
|
||||||
@ -228,7 +227,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
hm = (HandlerMethod) handler;
|
hm = (HandlerMethod) handler;
|
||||||
method = hm.getMethod();
|
method = hm.getMethod();
|
||||||
} else {
|
} else {
|
||||||
return checkAuthSecure(request, response, AlamatUrlForm, true);
|
return checkAuthSecure(request, response);
|
||||||
}
|
}
|
||||||
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
||||||
boolean postM = "POST".equals(methodHttp);
|
boolean postM = "POST".equals(methodHttp);
|
||||||
@ -292,7 +291,12 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
||||||
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
||||||
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
||||||
Integer ruanganAsalId = Integer.parseInt(KdRuangan);
|
Integer ruanganAsalId;
|
||||||
|
try {
|
||||||
|
ruanganAsalId = Integer.parseInt(KdRuangan);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ruanganAsalId = null;
|
||||||
|
}
|
||||||
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
||||||
if (notHttpOK || notLewatMenu || adaError)
|
if (notHttpOK || notLewatMenu || adaError)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -96,8 +96,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
return potongan.toString();
|
return potongan.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response, String AlamatUrlForm,
|
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
boolean supervisi) throws Exception {
|
|
||||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||||
namaUser = authentication.getName();
|
namaUser = authentication.getName();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
@ -176,7 +175,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
||||||
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
||||||
return true;
|
return true;
|
||||||
if (!checkAuthSecure(request, response, AlamatUrlForm, false))
|
if (!checkAuthSecure(request, response))
|
||||||
return false;
|
return false;
|
||||||
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
||||||
if (resultUser == 0) {
|
if (resultUser == 0) {
|
||||||
@ -228,7 +227,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
hm = (HandlerMethod) handler;
|
hm = (HandlerMethod) handler;
|
||||||
method = hm.getMethod();
|
method = hm.getMethod();
|
||||||
} else {
|
} else {
|
||||||
return checkAuthSecure(request, response, AlamatUrlForm, true);
|
return checkAuthSecure(request, response);
|
||||||
}
|
}
|
||||||
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
||||||
boolean postM = "POST".equals(methodHttp);
|
boolean postM = "POST".equals(methodHttp);
|
||||||
@ -292,7 +291,12 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
||||||
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
||||||
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
||||||
Integer ruanganAsalId = Integer.parseInt(KdRuangan);
|
Integer ruanganAsalId;
|
||||||
|
try {
|
||||||
|
ruanganAsalId = Integer.parseInt(KdRuangan);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ruanganAsalId = null;
|
||||||
|
}
|
||||||
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
||||||
if (notHttpOK || notLewatMenu || adaError)
|
if (notHttpOK || notLewatMenu || adaError)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -97,8 +97,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
return potongan.toString();
|
return potongan.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response, String AlamatUrlForm,
|
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
boolean supervisi) throws Exception {
|
|
||||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||||
namaUser = authentication.getName();
|
namaUser = authentication.getName();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
@ -177,7 +176,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
||||||
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
||||||
return true;
|
return true;
|
||||||
if (!checkAuthSecure(request, response, AlamatUrlForm, false))
|
if (!checkAuthSecure(request, response))
|
||||||
return false;
|
return false;
|
||||||
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
||||||
if (resultUser == 0) {
|
if (resultUser == 0) {
|
||||||
@ -229,7 +228,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
hm = (HandlerMethod) handler;
|
hm = (HandlerMethod) handler;
|
||||||
method = hm.getMethod();
|
method = hm.getMethod();
|
||||||
} else {
|
} else {
|
||||||
return checkAuthSecure(request, response, AlamatUrlForm, true);
|
return checkAuthSecure(request, response);
|
||||||
}
|
}
|
||||||
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
||||||
boolean postM = "POST".equals(methodHttp);
|
boolean postM = "POST".equals(methodHttp);
|
||||||
@ -293,7 +292,12 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
||||||
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
||||||
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
||||||
Integer ruanganAsalId = Integer.parseInt(KdRuangan);
|
Integer ruanganAsalId;
|
||||||
|
try {
|
||||||
|
ruanganAsalId = Integer.parseInt(KdRuangan);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ruanganAsalId = null;
|
||||||
|
}
|
||||||
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
||||||
if (notHttpOK || notLewatMenu || adaError)
|
if (notHttpOK || notLewatMenu || adaError)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -96,8 +96,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
return potongan.toString();
|
return potongan.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response, String AlamatUrlForm,
|
private boolean checkAuthSecure(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
boolean supervisi) throws Exception {
|
|
||||||
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
Authentication authentication = tokenAuthenticationService.getAuthentication(request);
|
||||||
namaUser = authentication.getName();
|
namaUser = authentication.getName();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
@ -176,7 +175,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
.findByAlamatUrlForm(filterUrlForm(AlamatUrlForm));
|
||||||
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
if (CommonUtil.isNullOrEmpty(objekModulAplikasi))
|
||||||
return true;
|
return true;
|
||||||
if (!checkAuthSecure(request, response, AlamatUrlForm, false))
|
if (!checkAuthSecure(request, response))
|
||||||
return false;
|
return false;
|
||||||
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
int resultUser = checkUserPermision(loginUser.get(0), objekModulAplikasi.get(0), action);
|
||||||
if (resultUser == 0) {
|
if (resultUser == 0) {
|
||||||
@ -228,7 +227,7 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
hm = (HandlerMethod) handler;
|
hm = (HandlerMethod) handler;
|
||||||
method = hm.getMethod();
|
method = hm.getMethod();
|
||||||
} else {
|
} else {
|
||||||
return checkAuthSecure(request, response, AlamatUrlForm, true);
|
return checkAuthSecure(request, response);
|
||||||
}
|
}
|
||||||
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
boolean usingAnno = method != null && method.isAnnotationPresent(AppPermission.class);
|
||||||
boolean postM = "POST".equals(methodHttp);
|
boolean postM = "POST".equals(methodHttp);
|
||||||
@ -292,7 +291,12 @@ public class AppInterceptor implements HandlerInterceptor {
|
|||||||
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
: request.getHeader(Constants.HttpHeader.TGL_KIRIM);
|
||||||
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
boolean notHttpOK = response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST;
|
||||||
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
boolean notLewatMenu = CommonUtil.isNullOrEmpty(AlamatUrlForm) || CommonUtil.isNullOrEmpty(KdRuangan);
|
||||||
Integer ruanganAsalId = Integer.parseInt(KdRuangan);
|
Integer ruanganAsalId;
|
||||||
|
try {
|
||||||
|
ruanganAsalId = Integer.parseInt(KdRuangan);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
ruanganAsalId = null;
|
||||||
|
}
|
||||||
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
boolean adaError = CommonUtil.isNotNullOrEmpty(ex);
|
||||||
if (notHttpOK || notLewatMenu || adaError)
|
if (notHttpOK || notLewatMenu || adaError)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user