org.apache.wicket.Session Java Examples
The following examples show how to use
org.apache.wicket.Session.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignInPage.java From ontopia with Apache License 2.0 | 7 votes |
public SignInPage(PageParameters params) { super(params); add(new StartPageHeaderPanel("header")); add(new FooterPanel("footer")); add(new Label("title", new ResourceModel("page.title.signin"))); add(new Label("message", new AbstractReadOnlyModel<String>() { @Override public String getObject() { OntopolySession session = (OntopolySession)Session.findOrCreate(); return session.getSignInMessage(); } })); add(new SignInForm("form")); }
Example #2
Source File: ProjectDashboardPage.java From inception with Apache License 2.0 | 6 votes |
public ProjectDashboardPage(final PageParameters aPageParameters) { super(aPageParameters); User currentUser = userRepository.getCurrentUser(); // Check if use can access the project Project project = projectService.listAccessibleProjects(currentUser).stream() .filter(p -> p.getId().equals( aPageParameters.get(PAGE_PARAM_PROJECT_ID).toOptionalLong())) .findFirst() .orElse(null); // If the user has no access, send the user back to the overview page if (project == null) { setResponsePage(ProjectsOverviewPage.class); } // Otherwise make the project the current project Session.get().setMetaData(CURRENT_PROJECT, project); commonInit(); }
Example #3
Source File: LoginModalPanel.java From the-app with Apache License 2.0 | 6 votes |
private LoginPanel loginPanel() { return new LoginPanel("loginPanel") { @Override protected boolean isSubmitLinkVisible() { return false; } @Override protected void submitLoginForm(AjaxRequestTarget target, LoginInfo loginInfo) { boolean authenticate = authenticate(loginInfo); if (authenticate) { Session.get().info(getString("authentication.success")); setResponsePage(getPage()); send(getPage(), Broadcast.BREADTH, new LoginEvent(LoginModalPanel.this, target)); } else { error(getString("authentication.failed")); target.add(modalContainer); } } }; }
Example #4
Source File: OpenIdConnector.java From onedev with MIT License | 6 votes |
@Override public void initiateLogin() { try { ClientID clientID = new ClientID(clientId); State state = new State(UUID.randomUUID().toString()); Session.get().setAttribute(SESSION_ATTR_STATE, state.getValue()); Session.get().setAttribute(SESSION_ATTR_PROVIDER_METADATA, discoverProviderMetadata()); String scopes = "openid email profile"; if (groupsClaim != null) scopes = scopes + " " + groupsClaim; AuthenticationRequest request = new AuthenticationRequest( new URI(getCachedProviderMetadata().getAuthorizationEndpoint()), new ResponseType("code"), Scope.parse(scopes), clientID, getCallbackUri(), state, new Nonce()); throw new RedirectToUrlException(request.toURI().toString()); } catch (URISyntaxException|SerializeException e) { throw new RuntimeException(e); } }
Example #5
Source File: DeleteEmailHtmlNotificationDemoPage.java From artifact-listener with Apache License 2.0 | 6 votes |
public DeleteEmailHtmlNotificationDemoPage(PageParameters parameters) { super(parameters); User user = userService.getByUserName(ConsoleNotificationIndexPage.DEFAULT_USERNAME); EmailAddress emailAddress = null; if (user != null) { emailAddress = Iterables.getFirst(user.getAdditionalEmails(), null); } if (user == null || emailAddress == null) { LOGGER.error("There is no user or email address available"); Session.get().error(getString("console.notifications.noDataAvailable")); throw new RestartResponseException(ConsoleNotificationIndexPage.class); } if (emailAddress.getEmailHash() == null) { emailAddress.setEmailHash(userService.getHash(user, emailAddress.getEmail())); } add(new DeleteEmailHtmlNotificationPanel("htmlPanel", Model.of(emailAddress))); }
Example #6
Source File: CurationPage.java From webanno with Apache License 2.0 | 6 votes |
public CurationPage() { super(); LOG.debug("Setting up curation page without parameters"); commonInit(); Map<String, StringValue> fragmentParameters = Session.get() .getMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS); if (fragmentParameters != null) { // Clear the URL fragment parameters - we only use them once! Session.get().setMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS, null); StringValue project = fragmentParameters.get(PAGE_PARAM_PROJECT_ID); StringValue document = fragmentParameters.get(PAGE_PARAM_DOCUMENT_ID); StringValue focus = fragmentParameters.get(PAGE_PARAM_FOCUS); handleParameters(null, project, document, focus, false); } }
Example #7
Source File: LockPanel.java From ontopia with Apache License 2.0 | 6 votes |
protected boolean acquireLock() { // create lock id and lock key OntopolySession session = (OntopolySession)Session.get(); String lockerId = session.getLockerId(getRequest()); LockManager.Lock lock = session.lock((Topic)getDefaultModelObject(), lockerId); this.lockedBy = lock.getLockedBy(); this.lockedAt = new Date(lock.getLockTime()).toString(); this.lockKey = lock.getLockKey(); if (!lock.ownedBy(lockerId)) { this.lockedByOther = true; //! System.out.println("Got lock: false: " + lock); return false; } else { //! System.out.println("Got lock: true" + lock); return true; } }
Example #8
Source File: LoginModalPanel.java From AppStash with Apache License 2.0 | 6 votes |
private LoginPanel loginPanel() { return new LoginPanel("loginPanel") { @Override protected boolean isSubmitLinkVisible() { return false; } @Override protected void submitLoginForm(AjaxRequestTarget target, LoginInfo loginInfo) { boolean authenticate = authenticate(loginInfo); if (authenticate) { Session.get().info(getString("authentication.success")); setResponsePage(getPage()); send(getPage(), Broadcast.BREADTH, new LoginEvent(LoginModalPanel.this, target)); } else { error(getString("authentication.failed")); target.add(modalContainer); } } }; }
Example #9
Source File: LoginPage.java From webanno with Apache License 2.0 | 6 votes |
private void setDefaultResponsePageIfNecessary() { // This does not work because it was Spring Security that intercepted the access, not // Wicket continueToOriginalDestination(); String redirectUrl = getRedirectUrl(); if (redirectUrl == null || redirectUrl.contains(".IBehaviorListener.") || redirectUrl.contains("-logoutPanel-")) { log.debug("Redirecting to welcome page"); setResponsePage(getApplication().getHomePage()); } else { log.debug("Redirecting to saved URL: [{}]", redirectUrl); if (isNotBlank(form.urlfragment) && form.urlfragment.startsWith("!")) { Url url = Url.parse("http://dummy?" + form.urlfragment.substring(1)); UrlRequestParametersAdapter adapter = new UrlRequestParametersAdapter(url); LinkedHashMap<String, StringValue> params = new LinkedHashMap<>(); for (String name : adapter.getParameterNames()) { params.put(name, adapter.getParameterValue(name)); } Session.get().setMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS, params); } throw new NonResettingRestartException(redirectUrl); } }
Example #10
Source File: NewVersionsAdditionalEmailHtmlNotificationDemoPage.java From artifact-listener with Apache License 2.0 | 6 votes |
public NewVersionsAdditionalEmailHtmlNotificationDemoPage(PageParameters parameters) { super(parameters); User user = userService.getByUserName(ConsoleNotificationIndexPage.DEFAULT_USERNAME); if (user == null) { LOGGER.error("There is no user available"); Session.get().error(getString("console.notifications.noDataAvailable")); throw new RestartResponseException(ConsoleNotificationIndexPage.class); } Collection<EmailAddress> emailAddresses = user.getAdditionalEmails(); if (emailAddresses == null || emailAddresses.isEmpty()) { LOGGER.error("There is no additional email address available"); Session.get().error(getString("console.notifications.noDataAvailable")); throw new RestartResponseException(ConsoleNotificationIndexPage.class); } EmailAddress additionalEmail = Iterables.get(emailAddresses, 0); List<ArtifactVersionNotification> notifications = userService.listRecentNotifications(user); IModel<List<ArtifactVersionNotification>> notificationsModel = new ListModel<ArtifactVersionNotification>(notifications); add(new NewVersionsHtmlNotificationPanel("htmlPanel", notificationsModel, new GenericEntityModel<Long, EmailAddress>(additionalEmail))); }
Example #11
Source File: AjaxComponentFeedbackPanel.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void onConfigure() { super.onConfigure(); FeedbackMessages feedbackMessages = Session.get().getFeedbackMessages(); if(feedbackMessages.hasMessage(getFeedbackMessageFilter())){ messageHolder.setVisible(true); List<FeedbackMessage> messages = feedbackMessages.messages(getFeedbackMessageFilter()); FeedbackMessage message = messages.get(0); onDisplayError(message); message.markRendered(); } else { messageHolder.setVisible(false); } }
Example #12
Source File: KnowledgeBasePageMenuItem.java From inception with Apache License 2.0 | 6 votes |
@Override public boolean applies() { Project sessionProject = Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT); if (sessionProject == null) { return false; } // The project object stored in the session is detached from the persistence context and // cannot be used immediately in DB interactions. Fetch a fresh copy from the DB. Project project = projectService.getProject(sessionProject.getId()); // Not visible if the current user is not an annotator User user = userRepo.getCurrentUser(); if (!(projectService.isAnnotator(project, user) && WebAnnoConst.PROJECT_TYPE_ANNOTATION.equals(project.getMode()))) { return false; } // not visible if the current project does not have knowledge bases return !kbService.getKnowledgeBases(project).isEmpty(); }
Example #13
Source File: AnnotationPage.java From webanno with Apache License 2.0 | 6 votes |
public AnnotationPage() { super(); LOG.debug("Setting up annotation page without parameters"); setModel(Model.of(new AnnotatorStateImpl(Mode.ANNOTATION))); // Ensure that a user is set getModelObject().setUser(userRepository.getCurrentUser()); Map<String, StringValue> fragmentParameters = Session.get() .getMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS); StringValue focus = StringValue.valueOf(0); if (fragmentParameters != null) { // Clear the URL fragment parameters - we only use them once! Session.get().setMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS, null); StringValue project = fragmentParameters.get(PAGE_PARAM_PROJECT_ID); StringValue projectName = fragmentParameters.get(PAGE_PARAM_PROJECT_NAME); StringValue document = fragmentParameters.get(PAGE_PARAM_DOCUMENT_ID); StringValue name = fragmentParameters.get(PAGE_PARAM_DOCUMENT_NAME); focus = fragmentParameters.get(PAGE_PARAM_FOCUS); handleParameters(project, projectName, document, name, focus, false); } commonInit(focus); }
Example #14
Source File: AgreementPageMenuItem.java From inception with Apache License 2.0 | 6 votes |
/** * Only admins and project managers can see this page */ @Override public boolean applies() { Project sessionProject = Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT); if (sessionProject == null) { return false; } // The project object stored in the session is detached from the persistence context and // cannot be used immediately in DB interactions. Fetch a fresh copy from the DB. Project project = projectService.getProject(sessionProject.getId()); // Visible if the current user is a curator or project admin User user = userRepo.getCurrentUser(); return (projectService.isCurator(project, user) || projectService.isProjectAdmin(project, user)) && WebAnnoConst.PROJECT_TYPE_ANNOTATION.equals(project.getMode()); }
Example #15
Source File: InvalidBuildPage.java From onedev with MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); add(new Link<Void>("delete") { @Override public void onClick() { OneDev.getInstance(BuildManager.class).delete(getBuild()); Session.get().success("Build #" + getBuild().getNumber() + " deleted"); String redirectUrlAfterDelete = WebSession.get().getRedirectUrlAfterDelete(Build.class); if (redirectUrlAfterDelete != null) throw new RedirectToUrlException(redirectUrlAfterDelete); else setResponsePage(ProjectBuildsPage.class, ProjectBuildsPage.paramsOf(getProject())); } @Override protected void onConfigure() { super.onConfigure(); setVisible(SecurityUtils.canManage(getBuild())); } }.add(new ConfirmClickModifier("Do you really want to delete build #" + getBuild().getNumber() + "?"))); }
Example #16
Source File: GradebookPage.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Getter for the GradebookUiSettings. Used to store a few UI related settings in the PreferencesService (serialized to db) * */ public GradebookUiSettings getUiSettings() { GradebookUiSettings settings = (GradebookUiSettings) Session.get().getAttribute("GBNG_UI_SETTINGS"); if (settings == null) { settings = new GradebookUiSettings(); settings.initializeCategoryColors(this.businessService.getGradebookCategories()); settings.setCategoryColor(getString(GradebookPage.UNCATEGORISED), GradebookUiSettings.generateRandomRGBColorString(null)); setUiSettings(settings); } // See if the user has a database-persisted preference for Group by Category String userGbUiCatPref = this.businessService.getUserGbPreference("GROUP_BY_CAT"); if (StringUtils.isNotBlank(userGbUiCatPref)) { settings.setCategoriesEnabled(new Boolean(userGbUiCatPref)); } else { settings.setCategoriesEnabled(this.businessService.categoriesAreEnabled()); } return settings; }
Example #17
Source File: ActionHandler.java From JPPF with Apache License 2.0 | 6 votes |
/** * Update the actions managed by this handler based ont he selected nodes. * @param treeNodes the selected nodes. */ public void selectionChanged(final List<DefaultMutableTreeNode> treeNodes) { if (debugEnabled) log.debug("selected nodes: {}", treeNodes); for (final String id: actionLinks.keySet()) { final AbstractActionLink link = actionLinks.get(id); final UpdatableAction action = actions.get(id); if (action != null) { final JPPFWebSession session = (JPPFWebSession) Session.get(); action.setAuthorized(session.getRoles()); action.setEnabled(treeNodes); if (link != null) link.setEnabled(action.isAuthorized() && action.isEnabled()); } else { if (link != null) link.setEnabled(true); } } }
Example #18
Source File: GradebookPage.java From sakai with Educational Community License v2.0 | 5 votes |
public void setUiSettings(final GradebookUiSettings settings, final boolean persistToUserPrefs) { Session.get().setAttribute("GBNG_UI_SETTINGS", settings); // Save the setting to PreferencesService (database) if (persistToUserPrefs) { this.businessService.setUserGbPreference("GROUP_BY_CAT", settings.isGroupedByCategory() + ""); } }
Example #19
Source File: BasePage.java From sakai with Educational Community License v2.0 | 5 votes |
protected void initLocale(){ Locale l = getLocale(); if (l != null) { Session s = getSession(); s.setLocale(l); } }
Example #20
Source File: ToDoApplication.java From isis-app-todoapp with Apache License 2.0 | 5 votes |
@Override public Session newSession(final Request request, final Response response) { if(!DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS) { return super.newSession(request, response); } // else demo mode final AuthenticatedWebSessionForIsis s = (AuthenticatedWebSessionForIsis) super.newSession(request, response); final org.apache.wicket.util.string.StringValue user = request.getRequestParameters().getParameterValue("user"); final org.apache.wicket.util.string.StringValue password = request.getRequestParameters().getParameterValue("pass"); s.signIn(user.toString(), password.toString()); return s; }
Example #21
Source File: CommonUtils.java From Orienteer with Apache License 2.0 | 5 votes |
/** * Safe method to get String representation of an object. * Wicket convertions are also has been used * @param data * @return */ @SuppressWarnings("unchecked") public static String toString(Object data) { if(data==null) return "null"; else if (data instanceof CharSequence) return data.toString(); else { IConverter<Object> converter = (IConverter<Object>)OrienteerWebApplication.lookupApplication() .getConverterLocator().getConverter(data.getClass()); if(converter!=null) { return converter.convertToString(data, Session.exists()?Session.get().getLocale():Locale.getDefault()); } else { return data.toString(); } } }
Example #22
Source File: GradebookPage.java From sakai with Educational Community License v2.0 | 5 votes |
public void setUiSettings(final GradebookUiSettings settings, final boolean persistToUserPrefs) { Session.get().setAttribute("GBNG_UI_SETTINGS", settings); // Save the setting to PreferencesService (database) if (persistToUserPrefs) { this.businessService.setUserGbPreference("GROUP_BY_CAT", settings.isGroupedByCategory() + ""); } }
Example #23
Source File: WicketChangeLocaleCartCommandImpl.java From yes-cart with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) { // current locale may be null if it is new cart final String locale = shoppingCart.getCurrentLocale(); super.execute(shoppingCart, parameters); if (parameters.containsKey(getCmdKey()) && !shoppingCart.getCurrentLocale().equals(locale)) { Session.get().setLocale(new Locale(shoppingCart.getCurrentLocale())); } }
Example #24
Source File: UserOnlineModule.java From Orienteer with Apache License 2.0 | 5 votes |
private ISessionListener createUserOnlineListener() { return new ISessionListener() { @Override public void onCreated(Session session) {} @Override public void onUnbound(final String sessionId) { DBClosure.sudoConsumer(db -> { String sql = String.format("update %s set %s = ? where %s = ?", OUser.CLASS_NAME, PROP_ONLINE, PROP_LAST_SESSION_FIELD); db.command(new OCommandSQL(sql)).execute(false, sessionId); }); } }; }
Example #25
Source File: ProjectDetailPanel.java From webanno with Apache License 2.0 | 5 votes |
private void actionSave(AjaxRequestTarget aTarget, Form<Project> aForm) { aTarget.add(getPage()); // aTarget.add(((ApplicationPageBase) getPage()).getPageContent()); // aTarget.addChildren(getPage(), IFeedback.class); Project project = aForm.getModelObject(); if (isNull(project.getId())) { try { String username = SecurityContextHolder.getContext().getAuthentication().getName(); projectService.createProject(project); projectService.createProjectPermission( new ProjectPermission(project, username, PermissionLevel.MANAGER)); projectService.createProjectPermission( new ProjectPermission(project, username, PermissionLevel.CURATOR)); projectService.createProjectPermission( new ProjectPermission(project, username, PermissionLevel.ANNOTATOR)); projectService.initializeProject(project); } catch (IOException e) { error("Project repository path not found " + ":" + ExceptionUtils.getRootCauseMessage(e)); LOG.error("Project repository path not found " + ":" + ExceptionUtils.getRootCauseMessage(e)); } } else { projectService.updateProject(project); } Session.get().setMetaData(CURRENT_PROJECT, project); }
Example #26
Source File: SpringSecurityAuthorizationStrategy.java From the-app with Apache License 2.0 | 5 votes |
@Override public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) { if (!hasSpringSecuredAnnotation(componentClass)) { return true; } boolean authorized = isAuthorized(componentClass); if (Page.class.isAssignableFrom(componentClass) && !authorized) { String missingPermissions = ArrayUtils.toString(componentClass.getAnnotation(Secured.class).value()); Session.get().error("Zugriff verweigert fehlende Berechtigung(en): " + missingPermissions); throw new RestartResponseAtInterceptPageException(LoginPage.class); } return authorized; }
Example #27
Source File: LoginPanel.java From the-app with Apache License 2.0 | 5 votes |
protected void submitLoginForm(AjaxRequestTarget target, LoginInfo loginInfo) { boolean authenticate = authenticate(loginInfo); if (!authenticate) { error(getString("authentication.failed")); target.add(feedback); } else { getAuthenticationService().getAuthenticatedUserInfo(); Session.get().info(getString("authentication.success")); send(this, Broadcast.BREADTH, new LoginEvent(LoginPanel.this, target)); setResponsePage(Application.get().getHomePage()); } }
Example #28
Source File: LoginInfoPanel.java From the-app with Apache License 2.0 | 5 votes |
private Component logoutLink() { return new Link<Void>("logoutLnk") { private static final long serialVersionUID = 4400488573342897569L; @Override public void onClick() { getAuthenticationService().clearAuthentication(); setResponsePage(ShopApplication.get().getHomePage()); cart.clear(); Session.get().clear(); } }; }
Example #29
Source File: NewRolePage.java From onedev with MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); BeanEditor editor = BeanContext.edit("editor", role); Form<?> form = new Form<Void>("form") { @Override protected void onSubmit() { super.onSubmit(); RoleManager roleManager = OneDev.getInstance(RoleManager.class); Role roleWithSameName = roleManager.find(role.getName()); if (roleWithSameName != null) { editor.error(new Path(new PathNode.Named("name")), "This name has already been used by another role"); } if (editor.isValid()) { roleManager.save(role, null); Session.get().success("Role created"); setResponsePage(RoleListPage.class); } } }; form.add(editor); add(form); }
Example #30
Source File: NewMilestonePage.java From onedev with MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); Milestone milestone = new Milestone(); BeanEditor editor = BeanContext.edit("editor", milestone); Form<?> form = new Form<Void>("form") { @Override protected void onSubmit() { super.onSubmit(); MilestoneManager milestoneManager = OneDev.getInstance(MilestoneManager.class); Milestone milestoneWithSameName = milestoneManager.find(getProject(), milestone.getName()); if (milestoneWithSameName != null) { editor.error(new Path(new PathNode.Named("name")), "This name has already been used by another milestone in the project"); } if (editor.isValid()){ milestone.setProject(getProject()); milestoneManager.save(milestone); Session.get().success("New milestone created"); setResponsePage(MilestoneDetailPage.class, MilestoneDetailPage.paramsOf(milestone, null)); } } }; form.add(editor); add(form); }