List of usage examples for org.apache.wicket.protocol.http.servlet ServletWebRequest ServletWebRequest
public ServletWebRequest(HttpServletRequest httpServletRequest, String filterPrefix)
From source file:$.HippoAuthenticationRequestHandler.java
License:Apache License
public Response handleRequest(Message m, ClassResourceInfo resourceClass) { ISessionStore sessionStore = Application.get().getSessionStore(); Serializable attribute = sessionStore.getAttribute( new ServletWebRequest((HttpServletRequest) m.get(AbstractHTTPDestination.HTTP_REQUEST), ""), "session"); if (attribute instanceof PluginUserSession) { UserCredentials userCredentials = ((PluginUserSession) attribute).getUserCredentials(); if (userCredentials != null) { SimpleCredentials jcrCredentials = (SimpleCredentials) userCredentials.getJcrCredentials(); String username = jcrCredentials.getUserID(); String password = new String(jcrCredentials.getPassword()); try { session = JcrSessionUtil.createSession(username, password); if (isAuthenticated()) { HttpServletRequest request = (HttpServletRequest) m .get(AbstractHTTPDestination.HTTP_REQUEST); request.setAttribute(AuthenticationConstants.HIPPO_SESSION, session); return null; } else { throw new UnauthorizedException(); }/*w w w. j a v a 2 s .co m*/ } catch (LoginException e) { LOG.debug("Login failed: {}", e); throw new UnauthorizedException(e.getMessage()); } } } throw new UnauthorizedException(); }
From source file:nl.openweb.hippo.umd.webservices.HippoAuthenticationRequestHandler.java
License:Apache License
public Response handleRequest(Message m, ClassResourceInfo resourceClass) { ISessionStore sessionStore = Application.get().getSessionStore(); Serializable attribute = sessionStore.getAttribute( new ServletWebRequest((HttpServletRequest) m.get(AbstractHTTPDestination.HTTP_REQUEST), ""), "session"); if (attribute instanceof PluginUserSession) { UserCredentials userCredentials = ((PluginUserSession) attribute).getUserCredentials(); if (userCredentials != null) { SimpleCredentials jcrCredentials = (SimpleCredentials) userCredentials.getJcrCredentials(); String username = jcrCredentials.getUserID(); String password = new String(jcrCredentials.getPassword()); try { session = JcrSessionUtil.createSession(username, password); if (isAuthenticated()) { HttpServletRequest request = (HttpServletRequest) m .get(AbstractHTTPDestination.HTTP_REQUEST); request.setAttribute(AuthenticationConstants.HIPPO_SESSION, session); return null; } else { throw new UnauthorizedException(); }//from w ww .j av a 2 s. c o m } catch (LoginException e) { LOG.debug("Login failed: {}", e); throw new UnauthorizedException(e.getMessage()); } } } throw new UnauthorizedException(); }
From source file:org.apache.openmeetings.db.util.ApplicationHelper.java
License:Apache License
public static IApplication ensureApplication(Long langId) { IApplication a = null;//w ww .ja v a2s .c om if (Application.exists()) { a = (IApplication) Application.get(); } else { WebApplication app = (WebApplication) Application.get(wicketApplicationName); LabelDao.initLanguageMap(); if (app == null) { try { app = (WebApplication) LabelDao.getAppClass().newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { log.error("Failed to create Application"); return null; } app.setServletContext(new MockServletContext(app, null)); app.setName(wicketApplicationName); ServletContext sc = app.getServletContext(); OMContextListener omcl = new OMContextListener(); omcl.contextInitialized(new ServletContextEvent(sc)); XmlWebApplicationContext xmlContext = new XmlWebApplicationContext(); xmlContext.setConfigLocation("classpath:openmeetings-applicationContext.xml"); xmlContext.setServletContext(sc); xmlContext.refresh(); sc.setAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, xmlContext); app.setConfigurationType(RuntimeConfigurationType.DEPLOYMENT); ThreadContext.setApplication(app); app.initApplication(); } else { ThreadContext.setApplication(app); } a = (IApplication) Application.get(wicketApplicationName); } if (ThreadContext.getRequestCycle() == null) { ServletWebRequest req = new ServletWebRequest(new MockHttpServletRequest((Application) a, new MockHttpSession(a.getServletContext()), a.getServletContext()), ""); RequestCycleContext rctx = new RequestCycleContext(req, new MockWebResponse(), a.getRootRequestMapper(), a.getExceptionMapperProvider().get()); ThreadContext.setRequestCycle(new RequestCycle(rctx)); } if (ThreadContext.getSession() == null) { WebSession s = WebSession.get(); if (langId > 0) { ((IWebSession) s).setLanguage(langId); } } return a; }