public abstract class SecuredServlet extends WOJServlet {
private final static Logger LOGGER = LoggingManager.getLogger(SecuredServlet.class.getName());
final protected void wojDoPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UAK uak = SecurityHelper.getUAK(request);
if (uak == null) {
throw new NoUAKException();
} else {
if (!uak.checkUserKey(WOJServer.getInstance().getPrivateKey())) {
// we try to authenticate again
// TODO : check if we are master or authenticate to master if we aren't
Authentification a = WOJServer.getInstance().getAuthentificationService().authenticate(uak.getUserName(), uak.getUserPass(), uak.getComputerId(), uak.getPluginVersion());
//Current server can not serve the request, we send a redirect to the good server
if(a instanceof AuthSuccessfull) {
AuthSuccessfull as = (AuthSuccessfull)a;
SecurityHelper.saveAuthentification(request.getSession(), a);