title: Adding methods to AuthenticatedWebSession in Wicket 7 by extension
body: <p>I'm using Wicket 7 and extending <strong>AuthenticatedWebSession</strong> as a class called <strong>BasicAuthenticatedSession</strong>. While I'm doing this, I'd like to add a method that returns some additional information about the authenticated user.</p>
  
  <p>In <strong>BasicAuthenticatedSession#authenticate</strong>, I get a <strong>Sysuser</strong> object which is a wrapper for a user in the database. I use some of the information in this object for the authentication, but want to have access to all of the info (firstname, lastname, etc.) throughout the session.</p>
  
  <p>I was expecting to be able to create a new method call <strong>getUser</strong> which would return this database object to the caller.</p>
  
  <p>However, this method, even though declared public, isn't visible when attempting to call it. I'm not sure if this is something to do with Wicket, or just a general misunderstanding on my part how inheritance works. ;)</p>
  
  <p><strong>BasicAuthenticatedWebSession.java</strong></p>
  
  <pre><code>public class BasicAuthenticatedWebSession extends AuthenticatedWebSession {
  
      public BasicAuthenticatedWebSession(Request request) {
          super(request);
      }
  
      @Override
      protected boolean authenticate(String username, String password) {
          Sysuser[] sysusers;
  
          try {
              SysuserCriteria userCriteria = new SysuserCriteria();
  
              userCriteria.username.eq(username);
              sysusers = Sysuser.listSysuserByCriteria(userCriteria);
          } catch (PersistentException e) {
              e.printStackTrace();
  
              return false;
          }
  
          if (sysusers.length == 0) {
              return false;
          }
  
          this.username = username;
          this.userid   = sysusers[0].getId();
  
          return password.compareTo(sysusers[0].getPasswd()) == 0;
      }
  
      public Roles getRoles() {
          Roles     roles = new Roles();
          Sysuser[] sysusers;
  
          if (isSignedIn()) {
              roles.add("SIGNED_IN");
          }
  
          try {
              SysuserCriteria sysuserCriteria = new SysuserCriteria();
  
              sysuserCriteria.username.eq(username);
              sysusers = Sysuser.listSysuserByCriteria(sysuserCriteria);
  
              for (Object sysuser : sysusers) {
                  SysroleSetCollection sysroles = ((Sysuser) sysuser).sysrole;
  
                  for (Sysrole sysrole : sysroles.toArray()) {
                      roles.add(sysrole.getRolename().toUpperCase());
                  }
              }
          } catch (PersistentException e) {
              e.printStackTrace();
          }
  
          return roles;
      }
  
      public Sysuser getSysuser() {
          return sysuser;
      }
  }
  </code></pre>
  
  <p><strong>Test.java</strong> This class fails to compile as the <em>getSysuser</em> method in <strong>BasicAuthenticatedSession</strong> is not found.</p>
  
  <pre><code>public class Test {
      public Test() {
      }
  
      public void foo {
          if(BasicAuthenticatedSession.get().isSignedIn()) {
              Sysuser sysUser = BasicAuthenticatedSession.get().getSysuser();
              System.out.println(sysuser.getFirstname);
          }
      }
  }
  </code></pre>