List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:RedisSessionStore.java
License:Apache License
@Override public void bind(Request request, Session newSession) { if (getAttribute(request, Session.SESSION_ATTRIBUTE_NAME) != newSession) { // call template method onBind(request, newSession);// ww w. j a v a 2s .c o m for (BindListener listener : getBindListeners()) { listener.bindingSession(request, newSession); } HttpSession httpSession = getHttpSession(request, false); if (httpSession != null) { // register an unbinding listener for cleaning up String applicationKey = Application.get().getName(); httpSession.setAttribute("Wicket:SessionUnbindingListener-" + applicationKey, new SessionBindingListener(applicationKey, newSession)); } // register the session object itself setAttribute(request, Session.SESSION_ATTRIBUTE_NAME, newSession); } }
From source file:RedisSessionStore.java
License:Apache License
@Override public String getSessionId(Request request, boolean create) { String id = null;/* w ww. j a va2 s. c o m*/ HttpSession httpSession = getHttpSession(request, false); if (httpSession != null) { id = httpSession.getId(); } else { //Just because this server doesn't have a session doesn't mean the session doesn't already exist //see if the jsession id is being passed in String uri = ((HttpServletRequest) request.getContainerRequest()).getRequestURI(); String[] split = uri.split(";"); String jsessionid = null; if (split.length > 1 && split[1].contains("jsessionid=")) { //session exists, first check if it's already mapped: jsessionid = split[1].replace("jsessionid=", ""); } if (create || jsessionid != null) { //create a new session on this server httpSession = getHttpSession(request, true); id = httpSession.getId(); //now check whether this is a real new session or just a session that needs to be mapped if (jsessionid != null) { //session already exist in redis, but this tomcat needs to map back to it, so look up //the original session Object o = redisCache.getCacheObject(getKeyMapKey(jsessionid)); while (o != null) { //make sure this is the top jsessionid jsessionid = (String) o; o = redisCache.getCacheObject(getKeyMapKey(jsessionid)); } //we have the top session, so map it to this server's session id redisCache.storeCacheObject(getKeyMapKey(id), jsessionid); httpSession.setAttribute(KEY_REDIS_SESSION, jsessionid); } else { //no session being passed in and no existing session on this server, create a new one! log.info("New SessionId: " + id); IRequestLogger logger = Application.get().getRequestLogger(); if (logger != null) { logger.sessionCreated(id); } httpSession.setAttribute(KEY_REDIS_SESSION, id); } } } return id; }
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(); }//from w w w. j a v 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:abid.password.wicket.MutablePasswordApplication.java
License:Apache License
public static MutablePasswordApplication get() { return (MutablePasswordApplication) Application.get(); }
From source file:at.ac.tuwien.ifs.tita.ui.BasePage.java
License:Apache License
/** * initialize the page.//from w w w .ja v a2 s. c o m */ @SuppressWarnings("unchecked") protected void initLogoutLink() { // not a secure link because everyone can logoff. Link logoff = new Link("logoff") { private static final long serialVersionUID = 1L; @Override public void onClick() { TitaSession titaSession = TitaSession.getSession(); if (titaSession.logoff(getLogoffContext())) { try { TiTAUser user = userService.getUserByUsername(TitaSession.getSession().getUsername()); List<ActiveTaskId> activeTasks = timerCoordinator.getActiveTasks(user.getId()); for (ActiveTaskId at : activeTasks) { Effort e = timerCoordinator.stopIssueTimer(user.getId(), at); ITaskTrackable task = taskService.getIssueTrackerTaskById(at.getIssueId(), at.getIssueTProjetId(), at.getIssueTrackerId()); effortService.saveIssueTrackerTaskEfforts(e, at.getIssueId(), at.getIssueTProjetId(), task.getDescription(), user, at.getTitaProjectId()); } // ActiveTaskEffort ate = // timerCoordinator.findTiTATaskForUser(user.getId()); // if (ate != null && panel != null) { // Effort e = // timerCoordinator.stopTiTATimer(user.getId()); // effortService.saveEffortForTiTATask(e, // panel.getGeneralTimer().getDescription(), user, // panel.getProject()); // } timerCoordinator.unregisterUser(user.getId()); activeTasks = timerCoordinator.getActiveTasks(user.getId()); } catch (Exception e) { error("couldn't log out - user didn't exist in database"); } setResponsePage(Application.get().getHomePage()); titaSession.invalidate(); } else { error("A problem occured during the logoff process, please " + "try again or contact support"); } } }; add(logoff); }
From source file:at.ac.tuwien.ifs.tita.ui.BasePage.java
License:Apache License
/** * Allows subclasses to specify which context should be used when logging * off.// w ww . ja v a2 s . c om * * @return the context */ protected final LoginContext getLogoffContext() { Application app = Application.get(); if (app instanceof TiTAApplication) { return ((TiTAApplication) app).getLogoffContext(); } throw new WicketRuntimeException("Application is not a subclass of " + TiTAApplication.class); }
From source file:at.ac.tuwien.ifs.tita.ui.importing.effort.csv.EffortImportCSVPage.java
License:Apache License
/** * Get temp folder for uploads. * * @return the folder */ private Folder getUploadFolder() { return ((TiTAApplication) Application.get()).getUploadFolder(); }
From source file:at.molindo.esi4j.example.web.WicketApplication.java
License:Apache License
public static WicketApplication get() { Application application = Application.get(); if (application instanceof WicketApplication == false) { throw new WicketRuntimeException("The application attached to the current thread is not a " + WicketApplication.class.getSimpleName()); }//from w ww.java 2 s . c o m return (WicketApplication) application; }
From source file:at.molindo.wicketutils.migration.WicketURLDecoder.java
License:Apache License
public String decode(String s) { Application app = null;/*from ww w . ja v a 2 s . co m*/ try { app = Application.get(); } catch (WicketRuntimeException ignored) { log.warn("No current Application found - defaulting encoding to UTF-8"); } return decode(s, app == null ? "UTF-8" : app.getRequestCycleSettings().getResponseRequestEncoding()); }
From source file:at.molindo.wicketutils.migration.WicketURLEncoder.java
License:Apache License
public String encode(String s) { Application app = null;/*from w w w . ja va2 s . c o m*/ try { app = Application.get(); } catch (WicketRuntimeException ignored) { log.warn("No current Application found - defaulting encoding to UTF-8"); } return encode(s, app == null ? "UTF-8" : app.getRequestCycleSettings().getResponseRequestEncoding()); }