/** * @see org.apache.wicket.Component#isVisible() */ @Override public boolean isVisible() { return MySession.get().getFeedbackMessages().hasMessage(containerFeedbackMessageFilter); } };
/** * From http://www.danwalmsley.com/2009/04/08/apache-wicket-on-google-app-engine-for-java/<br/> * Override the newSessionStore() method to return HttpSessionStore, because the default second level session store * uses java.io.File, which is sometimes not allowed. * * @see org.apache.wicket.Application#newSessionStore() */ /* * @Override protected ISessionStore newSessionStore() { return new * org.apache.wicket.protocol.http.HttpSessionStore(this); } */ @Override public Session newSession(final Request request, final Response response) { final MySession mySession = new MySession(request); return mySession; }
public synchronized void setUserContext(final UserContext userContext) { this.userContext = userContext; dirty(); }
/** * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class) */ @Override public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> componentClass) { if (WebPage.class.isAssignableFrom(componentClass) == true) { if (MySession.get().isAuthenticated() == true) { return true; } if (AbstractSecuredBasePage.class.isAssignableFrom(componentClass) == true || AbstractSecuredBasePage.class.isAssignableFrom(componentClass) == true || AbstractSecuredMobilePage.class.isAssignableFrom(componentClass) == true) { return false; } } return true; }
@Override public void onUnauthorizedInstantiation(final Component component) { if (MySession.get().isMobileUserAgent() == true) { throw new RestartResponseAtInterceptPageException(LoginMobilePage.class); } else { throw new RestartResponseAtInterceptPageException(LoginPage.class); } }
if (AccessChecker.isDemoUser(user) == true) { Object value = MySession.get().getAttribute(key); if (value != null) { return value; MySession.get().setAttribute(key, (Serializable) value); return value;
public MySession(final Request request) { super(request); setLocale(request); final ClientInfo info = getClientInfo(); if (info instanceof WebClientInfo) { clientProperties = ((WebClientInfo) clientInfo).getProperties(); clientProperties.setTimeZone(ThreadLocalUserContext.getTimeZone()); userAgent = ((WebClientInfo) info).getUserAgent(); userAgentDevice = UserAgentDevice.getUserAgentDevice(userAgent); userAgentOS = UserAgentOS.getUserAgentOS(userAgent); mobileUserAgent = userAgentDevice.isMobile(); final UserAgentDetection userAgentDetection = UserAgentDetection.browserDetect(userAgent); userAgentBrowser = userAgentDetection.getUserAgentBrowser(); userAgentBrowserVersionString = userAgentDetection.getUserAgentBrowserVersion(); } else { log.error("Oups, ClientInfo is not from type WebClientInfo: " + info); } setUserContext(ThreadLocalUserContext.getUserContext()); initActualTenant(); this.csrfToken = NumberHelper.getSecureRandomUrlSaveString(20); }
final WebMarkupContainer goMobile = new WebMarkupContainer("goMobile"); add(goMobile); if (page.getMySession().isMobileUserAgent() == true) { goMobile.add(new BookmarkablePageLink<Void>("link", MenuMobilePage.class)); } else { final UserContext userContext = MySession.get().getUserContext(); final WebMarkupContainer tenantMenu = new WebMarkupContainer("currentTenant"); add(tenantMenu);
/** * Stores the given value for the current user. * * @param key * @param value * @param persistent If true, the object will be persisted in the database. * @see UserXmlPreferencesCache#putEntry(Integer, String, Object, boolean) */ public static void putEntry(final String key, final Object value, final boolean persistent) { final PFUserDO user = ThreadLocalUserContext.getUser(); if (user == null || value == null) { // Should only occur, if user is not logged in. return; } if (AccessChecker.isDemoUser(user) == true && value instanceof Serializable) { // Store user pref for demo user only in user's session. MySession.get().setAttribute(key, (Serializable) value); return; } try { getUserXmlPreferencesCache().putEntry(user.getId(), key, value, persistent); } catch (final Exception ex) { log.error("Should only occur in maintenance mode: " + ex.getMessage(), ex); } }
/** * Removes the entry under the given key. * * @param key * @return The removed entry if found. */ public static Object removeEntry(final String key) { final PFUserDO user = ThreadLocalUserContext.getUser(); if (user == null) { // Should only occur, if user is not logged in. return null; } if (AccessChecker.isDemoUser(user) == true) { MySession.get().removeAttribute(key); } return getUserXmlPreferencesCache().removeEntry(user.getId(), key); }
public synchronized boolean isAuthenticated() { final PFUserDO user = getUser(); return (user != null); }
private void logout(final MySession mySession, final Cookie stayLoggedInCookie, final UserXmlPreferencesCache userXmlPreferencesCache) { final PFUserDO user = mySession.getUser(); if (user != null) { userXmlPreferencesCache.flushToDB(user.getId()); userXmlPreferencesCache.clear(user.getId()); } mySession.logout(); if (stayLoggedInCookie != null) { stayLoggedInCookie.setMaxAge(0); stayLoggedInCookie.setValue(null); stayLoggedInCookie.setPath("/"); } }
throw new RestartResponseException(SetupPage.class); if (getMySession().isMobileUserAgent() == true && UserFilter.isUpdateRequiredFirst() == false && "true".equals(WicketUtils.getAsString(parameters, PARAMETER_KEY_FORCE_NON_MOBILE)) == false) { throw new RestartResponseException(LoginMobilePage.class); final PFUserDO wicketSessionUser = getMySession().getUser(); final PFUserDO sessionUser = UserFilter.getUser(WicketUtils.getHttpServletRequest(getRequest()));
/** * This parameter should be set as hidden field in every formular and should be tested on every submit action for * preventing CSRF attacks. * * @return the randomized cross site request forgery token. */ private String getCsrfSessionToken() { final MySession session = (MySession) Session.get(); return session.getCsrfToken(); }
/** * @see MySession#getUser() */ protected UserContext getUserContext() { return getMySession().getUserContext(); }
/** * @see MySession#getUser() */ @Override protected PFUserDO getUser() { return getMySession().getUser(); }
/** * @return The id of the logged-in user or null if no user is logged-in. */ public synchronized Integer getUserId() { final PFUserDO user = getUser(); return user != null ? user.getId() : null; }
/** * @see MySession#getUser() */ @Override public PFUserDO getUser() { return getMySession().getUser(); }
public synchronized TimeZone getTimeZone() { final PFUserDO user = getUser(); return user != null ? user.getTimeZoneObject() : Configuration.getInstance().getDefaultTimeZone(); }
final PFUserDO wicketSessionUser = ((MySession) getSession()).getUser(); final PFUserDO sessionUser = UserFilter.getUser(WicketUtils.getHttpServletRequest(getRequest()));