Configuring TomEE Security Propagation

Tomcat web server does not propagate user's security context to the application server automatically. Web application developer has to call below documented APIs to pass user's credentials to the application server.

The TomEEUtils class contains all the methods necessary to propagate security context to SEE:

  • public static void addCredentials (String username, String password). This method propagates user credentials from web application to SIMULIA Execution Engine. Web application developer must invoke this method from each Servlet's service method before calling any SIMULIA Execution Engine APIs. Webtop keeps given user credentials in memory of webtop process until invocation of TomEEUtils.clearCredentials() method and use it as needed to call secured EJBs of SIMULIA Execution Engine.

  • public static void clearCredentials (). Web application developer must invoke this method inside finally block at end of each servlet's service method after calling SIMULIA Execution Engine APIs.

  • public static void clearContext (String username). Web application developer must invoke this method when a user logs out from the web application.

Following is the sample doPost() method of servlet which calls SIMULIA Execution Engine APIs and APIs required to propagate security context to SIMULIA Execution Engine.

public void doPost(HttpServletRequest request, HttpServletResponse response) {

 try {
      String username = (String) request.getSession().getAttribute("username");
      String password = (String) request.getSession().getAttribute("password");		
      TomEEUtils.addCredentials(username, password);
      // TODO: Write your business logic here. 
      // For example: 
      Iterator jobList = SysPSE.getPSE().getJobList(username).iterator();
 } 
 catch (PSEException e) {
      e.printStackTrace();
 } 
 finally {
      TomEEUtils.clearCredentials();
 }
}