cat.debug("Verifying authoirization of '"+userdn);
log.debug("Verifying authoirization of '"+userdn);
    public GlobalConfiguration initialize(HttpServletRequest request, String resource) throws Exception{      String userdn = "";      CertificateFactory certfact =  CertificateFactory.getInstance("X.509");      certificates =   (X509Certificate[]) request.getAttribute( "javax.servlet.request.X509Certificate" );      if(certificates == null) throw new AuthenticationFailedException("Client certificate required.");      // Check if certificate is still valid      if(!initialized){        Admin administrator = new Admin(certificates[0]) ;                  InitialContext jndicontext = new InitialContext();        Object obj1 = jndicontext.lookup("UserAdminSession");        IUserAdminSessionHome adminsessionhome = (IUserAdminSessionHome) javax.rmi.PortableRemoteObject.narrow(obj1, IUserAdminSessionHome.class);        IUserAdminSessionRemote  adminsession = adminsessionhome.create();                obj1 = jndicontext.lookup("LogSession");        ILogSessionHome logsessionhome = (ILogSessionHome) javax.rmi.PortableRemoteObject.narrow(obj1, ILogSessionHome.class);           logsession = logsessionhome.create();                globaldataconfigurationdatahandler =  new GlobalConfigurationDataHandler(adminsession, administrator);        globalconfiguration = globaldataconfigurationdatahandler.loadGlobalConfiguration();        adminspreferences = new AdminPreferenceDataHandler(administrator);        weblanguages = new WebLanguages(globalconfiguration);                            userdn = certificates[0].getSubjectX500Principal().toString();                // Check if user certificate is revoked        authorizedatahandler = new AuthorizationDataHandler(globalconfiguration, logsession, administrator);        authorizedatahandler.authenticate(certificates[0]);                 // Check if certificate belongs to a RA Admin        cat.debug("Verifying authoirization of '"+userdn);                // Check that user is administrator.        adminsession.checkIfSubjectDNisAdmin(administrator, userdn);        logsession.log(administrator,LogEntry.MODULE_ADMINWEB,  new java.util.Date(),null, null, LogEntry.EVENT_INFO_ADMINISTRATORLOGGEDIN,"");                             }      try{        isAuthorized(URLDecoder.decode(resource,"UTF-8"));      }catch(AuthorizationDeniedException e){         throw new AuthorizationDeniedException("You are not authorized to view this page.");      }catch(java.io.UnsupportedEncodingException e) {}      if(!initialized){        certificateserialnumber = certificates[0].getSerialNumber();        // Get current admin preference.        currentadminpreference=null;        if(certificateserialnumber != null){          currentadminpreference = adminspreferences.getAdminPreference(certificateserialnumber);        }        if(currentadminpreference == null){           currentadminpreference = adminspreferences.getDefaultAdminPreference();        }        adminsweblanguage = new WebLanguages( currentadminpreference.getPreferedLanguage()                                          ,currentadminpreference.getSecondaryLanguage());       // set User Common Name        DNFieldExtractor dn = new DNFieldExtractor(userdn, DNFieldExtractor.TYPE_SUBJECTDN);        usercommonname = dn.getField(DNFieldExtractor.CN,0);        initialized=true;      }      return globalconfiguration;    }