Test your servlet using multiple authentication types

You can use a servlet that uses either basic or Guidewire authentication to log in to PolicyCenter. Test this type of servlet by following this procedure.

Before you begin

In Studio, create a servlet that implements the service method, which calls the necessary ServletUtils methods. This topic uses the mycompany.test.TestingServlet servlet, as shown in Example of a servlet using multiple authentication types.

Procedure

  1. Register this servlet in servlets.xml.
  2. Run the QuickStart server at the command prompt:
    gwb runServer

    Do not log in to the PolicyCenter application.

  3. Test the servlet with no authentication by going to the URL:
    http://localhost:8180/pc/service/test

    You see a message:

    HTTP ERROR 401
    Problem accessing /pc/service/test. Reason:
    Unauthorized. No valid user with session context or HTTP Basic.
  4. Log in to the PolicyCenter application with valid credentials.
  5. Test the servlet with the PolicyCenter authenticated user by going to the URL:
    http://localhost:8180/pc/service/test

    You see a message:

    REQUEST SUCCEEDED
    req.RequestURI: '/pc/service/test'
    req.PathInfo: '/test'
    req.RequestURL: 'http://localhost:8180/pc/service/test'
    authenticated user name: 'Super User'
  6. To test the HTTP basic authentication:
    1. Sign out of the PolicyCenter application to remove the session context.
    2. Re-test your servlet, using a tool that supports adding HTTP headers for HTTP basic authentication.