package com.nitorcreations.willow.servers;

import java.util.concurrent.TimeUnit;

import javax.inject.Singleton;

import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;

import com.nitorcreations.willow.ssh.RawSecureShellWS;

@Singleton
public class RawTerminalServlet extends WebSocketServlet {
  private static final long serialVersionUID = -7940037116569261919L;

  @Override
  public void configure(WebSocketServletFactory factory) {
    factory.getPolicy().setIdleTimeout(TimeUnit.MINUTES.toMillis(5));
    factory.getPolicy().setMaxBinaryMessageBufferSize(1024 * 1024);
    factory.getPolicy().setMaxBinaryMessageSize(1024 * 1024 * 5);
    factory.register(RawSecureShellWS.class);
  }
}

@@ -37,16 +37,44 @@
 rvers;%0A%0A
+import java.io.IOException;%0A
 import j
@@ -135,16 +135,187 @@
 gleton;%0A
+import javax.servlet.ServletException;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0Aimport org.apache.shiro.SecurityUtils;
 %0Aimport 
@@ -634,16 +634,299 @@
 1919L;%0A%0A
+  @Override%0A  protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException %7B%0A    if (!SecurityUtils.getSubject().isPermitted(%22admin%22)) %7B%0A      resp.sendError(HttpServletResponse.SC_FORBIDDEN);%0A    %7D%0A    super.service(req, resp);%0A  %7D;%0A
   @Overr

Add permission check to terminal