public class SecurityWrapper {
  static Configuration config = Configuration.instance();
  static UserService userservice = UserService.instance();

  static Client client = new Client();
  static HuygensAuthorizationHandler hah =
      new HuygensAuthorizationHandler(
          client,
          config.getSetting("security.hss.url"),
          config.getSetting("security.hss.credentials"));

  public static Session createSession(String sessionToken) throws UnauthorizedException {
    SecurityInformation securityInformation = hah.getSecurityInformation(sessionToken);
    String emailAddress = securityInformation.getEmailAddress();
    User user = userservice.getByEmail(emailAddress);
    if (user == null) {
      throw new UnauthorizedException(
          "The email address given by the securityservice ("
              + emailAddress
              + ") is not registered to a user in elaborate");
    }
    return new Session(user.getId());
  }

  public static void delete(String sessionId) {
    try {
      hah.logout(sessionId);
    } catch (UnauthorizedException e) {
      e.printStackTrace();
    }
  }
}
 public static Session createSession(String sessionToken) throws UnauthorizedException {
   SecurityInformation securityInformation = hah.getSecurityInformation(sessionToken);
   String emailAddress = securityInformation.getEmailAddress();
   User user = userservice.getByEmail(emailAddress);
   if (user == null) {
     throw new UnauthorizedException(
         "The email address given by the securityservice ("
             + emailAddress
             + ") is not registered to a user in elaborate");
   }
   return new Session(user.getId());
 }