List of usage examples for org.apache.wicket.markup.html.pages RedirectPage RedirectPage
public RedirectPage(final Page page)
From source file:com.genericconf.bbbgateway.web.panels.JoinMeetingLinkPanel.java
License:Apache License
public JoinMeetingLinkPanel(String id, final IModel<Meeting> meeting, final IModel<Attendee> attendee) { super(id);/*from ww w . j a va2s .c o m*/ setOutputMarkupId(true); add(new Link<Void>("join") { private static final long serialVersionUID = 1L; @SpringBean private IMeetingService meetingService; @Override public void onClick() { String url = meetingService.joinMeeting(meeting.getObject(), attendee.getObject()); throw new RestartResponseAtInterceptPageException(new RedirectPage(url)); } }); }
From source file:com.gitblit.wicket.pages.TicketPage.java
License:Apache License
private Link<Void> createDeletePatchsetLink(final RepositoryModel repositoryModel, final Patchset patchset) { Link<Void> deleteLink = new Link<Void>("deleteRevision") { private static final long serialVersionUID = 1L; @Override//ww w . j av a 2 s . c o m public void onClick() { Repository r = app().repositories().getRepository(repositoryModel.name); UserModel user = GitBlitWebSession.get().getUser(); if (r == null) { if (app().repositories().isCollectingGarbage(repositoryModel.name)) { error(MessageFormat.format(getString("gb.busyCollectingGarbage"), repositoryModel.name)); } else { error(MessageFormat.format("Failed to find repository {0}", repositoryModel.name)); } return; } //Construct the ref name based on the patchset String ticketShard = String.format("%02d", ticket.number); ticketShard = ticketShard.substring(ticketShard.length() - 2); final String refName = String.format("%s%s/%d/%d", Constants.R_TICKETS_PATCHSETS, ticketShard, ticket.number, patchset.number); Ref ref = null; boolean success = true; try { ref = r.findRef(refName); if (ref != null) { success = JGitUtils.deleteBranchRef(r, ref.getName()); } else { success = false; } if (success) { // clear commit cache CommitCache.instance().clear(repositoryModel.name, refName); // optionally update reflog if (RefLogUtils.hasRefLogBranch(r)) { RefLogUtils.deleteRef(user, r, ref); } TicketModel updatedTicket = app().tickets().deletePatchset(ticket, patchset, user.username); if (updatedTicket == null) { success = false; } } } catch (IOException e) { logger().error("failed to determine ticket from ref", e); success = false; } finally { r.close(); } if (success) { getSession().info(MessageFormat.format(getString("gb.deletePatchsetSuccess"), patchset.number)); logger().info(MessageFormat.format("{0} deleted patchset {1} from ticket {2}", user.username, patchset.number, ticket.number)); } else { getSession() .error(MessageFormat.format(getString("gb.deletePatchsetFailure"), patchset.number)); } //Force reload of the page to rebuild ticket change cache String absoluteUrl = GitBlitRequestUtils.toAbsoluteUrl(TicketsPage.class, getPageParameters()); setResponsePage(new RedirectPage(absoluteUrl)); } }; WicketUtils.setHtmlTooltip(deleteLink, MessageFormat.format(getString("gb.deletePatchset"), patchset.number)); deleteLink.add(new JavascriptEventConfirmation("click", MessageFormat.format(getString("gb.deletePatchset"), patchset.number))); return deleteLink; }
From source file:com.userweave.pages.homepage.IntroPage.java
License:Open Source License
public IntroPage() { add(new IntroPanel("introPanel") { @Override/*from ww w .java 2 s. c o m*/ protected void onOk(AjaxRequestTarget target) { ((WebResponse) getRequestCycle().getResponse()).addCookie(new Cookie(COOKIE_NAME, SKIP_TRUE_VALUE)); setResponsePage(getApplication().getHomePage()); } @Override protected void onCancel(AjaxRequestTarget target) { ((WebResponse) getRequestCycle().getResponse()) .addCookie(new Cookie(COOKIE_NAME, SKIP_FALSE_VALUE)); CharSequence redirectPage = "http://survey.userweave.net/beta/survey/8b4889f9b91e4a56afd5000c96883c4c/"; setResponsePage(new RedirectPage(redirectPage)); } }); }
From source file:edu.wfu.inotado.tool.pages.SchoolChaptersPage.java
License:Apache License
public SchoolChaptersPage() { disableLink(schoolChaptersLink);//www. j a v a 2 s . co m // gets the authStore object AuthStore authStore = inotadoService.getAuthStoreForCurrentUser(Constants.SCHOOL_CHAPTERS); if (authStore == null) { authStore = new AuthStore(); } final Notification notification = new Notification("scNotification"); this.add(notification); // Form Form<?> authForm = new Form("authenticationForm"); this.add(authForm); final SchoolChaptersAuthWindow settingWindow = new SchoolChaptersAuthWindow("settingWindow", "Settings", authStore); this.add(settingWindow); final AjaxButton editAuthButton = new AjaxButton("editAuthButton") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { settingWindow.setAuthStore(inotadoService.getAuthStoreForCurrentUser(Constants.SCHOOL_CHAPTERS)); settingWindow.open(target); } }; authForm.add(editAuthButton); final ModalWindow authWindow = new ModalWindow("authWindow"); this.add(authWindow); final AjaxButton authButton = new AjaxButton("authButton") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { // retrieve the url for OAuth authentication AuthStore authStore = inotadoService.getAuthStoreForCurrentUser(Constants.SCHOOL_CHAPTERS); final String authUrl = inotadoService.getSchoolChaptersAuthUrl(authStore); if (!StringUtils.isBlank(authUrl)) { notification.success(target, "Key and secret have been accepted"); authWindow.setPageCreator(new ModalWindow.PageCreator() { @Override public Page createPage() { return new RedirectPage(authUrl); } }); authWindow.show(target); } else { notification.error(target, "Invalid key or secret!"); } } }; authForm.add(authButton); final AjaxButton sendRequestButton = new AjaxButton("sendRequestButton") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { try { syncResourcesService.syncAssignments(); notification.success(target, "Data retrived successfully"); } catch (Exception e) { notification.error(target, "Unable to process request. " + e.getMessage()); } } }; authForm.add(sendRequestButton); }
From source file:gr.abiss.calipso.wicket.CalipsoApplication.java
License:Open Source License
@Override public void init() { super.init(); // DEVELOPMENT or DEPLOYMENT RuntimeConfigurationType configurationType = this.getConfigurationType(); if (RuntimeConfigurationType.DEVELOPMENT.equals(configurationType)) { logger.info("You are in DEVELOPMENT mode"); // getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND); // getDebugSettings().setComponentUseCheck(true); getResourceSettings().setResourcePollFrequency(null); getDebugSettings().setComponentUseCheck(false); // getDebugSettings().setSerializeSessionAttributes(true); // getMarkupSettings().setStripWicketTags(false); // getExceptionSettings().setUnexpectedExceptionDisplay( // UnexpectedExceptionDisplay.SHOW_EXCEPTION_PAGE); // getAjaxSettings().setAjaxDebugModeEnabled(true); } else if (RuntimeConfigurationType.DEPLOYMENT.equals(configurationType)) { getResourceSettings().setResourcePollFrequency(null); getDebugSettings().setComponentUseCheck(false); // getDebugSettings().setSerializeSessionAttributes(false); // getMarkupSettings().setStripWicketTags(true); // getExceptionSettings().setUnexpectedExceptionDisplay( // UnexpectedExceptionDisplay.SHOW_INTERNAL_ERROR_PAGE); // getAjaxSettings().setAjaxDebugModeEnabled(false); }/* w w w. java 2s.c o m*/ // initialize velocity try { Velocity.init(); if (logger.isInfoEnabled()) { logger.info("Initialized Velocity engine"); } } catch (Exception e) { // TODO Auto-generated catch block logger.error("Failed to initialize velocity engine", e); } // Set custom page for internal errors getApplicationSettings().setInternalErrorPage(CalipsoErrorPage.class); // don't break down on missing resources getResourceSettings().setThrowExceptionOnMissingResource(false); // Redirect to PageExpiredError Page if current page is expired getApplicationSettings().setPageExpiredErrorPage(CalipsoPageExpiredErrorPage.class); // get hold of spring managed service layer (see BasePage, BasePanel etc // for how it is used) ServletContext sc = getServletContext(); applicationContext = WebApplicationContextUtils.getWebApplicationContext(sc); calipsoService = (CalipsoService) applicationContext.getBean("calipsoService"); calipsoPropertiesEditor = new CalipsoPropertiesEditor(); // check if acegi-cas authentication is being used, get reference to // object to be used // by wicket authentication to redirect to right pages for login / // logout try { calipsoCasProxyTicketValidator = (CalipsoCasProxyTicketValidator) applicationContext .getBean("casProxyTicketValidator"); logger.info("casProxyTicketValidator retrieved from application context: " + calipsoCasProxyTicketValidator); } catch (NoSuchBeanDefinitionException nsbde) { logger.info( "casProxyTicketValidator not found in application context, CAS single-sign-on is not being used"); } // delegate wicket i18n support to spring i18n getResourceSettings().getStringResourceLoaders().add(new IStringResourceLoader() { @Override public String loadStringResource(Class<?> clazz, String key, Locale locale, String style, String variation) { return applicationContext.getMessage(key, null, null, locale); } @Override public String loadStringResource(Component component, String key, Locale locale, String style, String variation) { return applicationContext.getMessage(key, null, null, locale); } }); // add DB i18n resources getResourceSettings().getStringResourceLoaders().add(new IStringResourceLoader() { @Override public String loadStringResource(Class<?> clazz, String key, Locale locale, String style, String variation) { if (StringUtils.isNotBlank(locale.getVariant())) { // always ignore the variant locale = new Locale(locale.getLanguage(), locale.getCountry()); } String lang = locale.getLanguage(); I18nStringResource resource = CalipsoApplication.this.calipsoService .loadI18nStringResource(new I18nStringIdentifier(key, lang)); if (resource == null && !lang.equalsIgnoreCase("en")) { resource = CalipsoApplication.this.calipsoService .loadI18nStringResource(new I18nStringIdentifier(key, "en")); } return resource != null ? resource.getValue() : null; } @Override public String loadStringResource(Component component, String key, Locale locale, String style, String variation) { locale = component == null ? Session.get().getLocale() : component.getLocale(); if (StringUtils.isNotBlank(locale.getVariant())) { // always ignore the variant locale = new Locale(locale.getLanguage(), locale.getCountry()); } String lang = locale.getLanguage(); I18nStringResource resource = CalipsoApplication.this.calipsoService .loadI18nStringResource(new I18nStringIdentifier(key, lang)); if (resource == null && !lang.equalsIgnoreCase("en")) { resource = CalipsoApplication.this.calipsoService .loadI18nStringResource(new I18nStringIdentifier(key, "en")); } return resource != null ? resource.getValue() : null; } }); // cache resources. resource cache is cleared when creating/updating a space getResourceSettings().getLocalizer().setEnableCache(true); getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy() { @Override public boolean isActionAuthorized(Component c, Action a) { return true; } @Override public boolean isInstantiationAuthorized(Class clazz) { if (BasePage.class.isAssignableFrom(clazz)) { if (((CalipsoSession) Session.get()).isAuthenticated()) { return true; } if (calipsoCasProxyTicketValidator != null) { // attempt CAS authentication // ========================== // logger.debug("checking if context contains CAS authentication"); Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null && authentication.isAuthenticated()) { // logger.debug("security context contains CAS authentication, initializing session"); ((CalipsoSession) Session.get()).setUser((User) authentication.getPrincipal()); return true; } } // attempt remember-me auto login // ========================== if (attemptRememberMeAutoLogin()) { return true; } // attempt *anonymous* guest access if there are // spaces that allow it if (((CalipsoSession) Session.get()).getUser() == null) { List<Space> anonymousSpaces = getCalipso().findSpacesWhereAnonymousAllowed(); if (anonymousSpaces.size() > 0) { // logger.debug("Found "+anonymousSpaces.size() // + // " anonymousSpaces allowing ANONYMOUS access, initializing anonymous user"); User guestUser = new User();//getCalipso().loadUser(2); guestUser.setLoginName("guest"); guestUser.setName("Anonymous"); guestUser.setLastname("Guest"); guestUser.setLocale(Session.get().getLocale().getLanguage()); getCalipso().initImplicitRoles(guestUser, anonymousSpaces, RoleType.ANONYMOUS); // store user in session ((CalipsoSession) Session.get()).setUser(guestUser); return true; } else { if (logger.isDebugEnabled()) { // logger.debug("Found no public spaces."); } } } // allow registration if (clazz.equals(RegisterUserFormPage.class)) { return true; } // not authenticated, go to login page // logger.debug("not authenticated, forcing login, page requested was " // + clazz.getName()); if (calipsoCasProxyTicketValidator != null) { String serviceUrl = calipsoCasProxyTicketValidator.getLoginUrl(); // .getServiceProperties().getService(); String loginUrl = calipsoCasProxyTicketValidator.getLoginUrl(); // logger.debug("cas authentication: service URL: " // + serviceUrl); String redirectUrl = loginUrl + "?service=" + serviceUrl; // logger.debug("attempting to redirect to: " + // redirectUrl); throw new RestartResponseAtInterceptPageException(new RedirectPage(redirectUrl)); } else { throw new RestartResponseAtInterceptPageException(LoginPage.class); } } return true; } }); // TODO: create friendly URLs for all created pages // friendly URLs for selected pages if (calipsoCasProxyTicketValidator != null) { mountPage("/login", CasLoginPage.class); } else { mountPage("/login", LoginPage.class); } mountPage("/register", RegisterAnonymousUserFormPage.class); mountPage("/logout", LogoutPage.class); mountPage("/svn", SvnStatsPage.class); mountPage("/test", TestPage.class); mountPage("/casError", CasLoginErrorPage.class); mountPage("/item/", ItemViewPage.class); mountPage("/item/${itemId}", ItemViewPage.class); mountPage("/itemreport/", ItemTemplateViewPage.class); mountPage("/newItem/${spaceCode}", NewItemPage.class); // MixedParamUrlCodingStrategy newItemUrls = new MixedParamUrlCodingStrategy( // "/newItem", // NewItemPage.class, // new String[]{"spaceCode"} // ); // mount(newItemUrls); //fix for tinyMCE bug, see https://github.com/wicketstuff/core/issues/113 SecurePackageResourceGuard guard = (SecurePackageResourceGuard) getResourceSettings() .getPackageResourceGuard(); guard.addPattern("+*.htm"); this.getRequestCycleSettings().setTimeout(Duration.minutes(6)); this.getPageSettings().setVersionPagesByDefault(true); this.getExceptionSettings().setThreadDumpStrategy(ThreadDumpStrategy.THREAD_HOLDING_LOCK); }
From source file:info.jtrac.wicket.JtracApplication.java
License:Apache License
@Override public void init() { super.init(); /*//from w w w . ja va 2 s . c o m * Get hold of spring managed service layer (see BasePage, BasePanel, * etc. for how it is used). */ ServletContext sc = getServletContext(); applicationContext = WebApplicationContextUtils.getWebApplicationContext(sc); jtrac = (Jtrac) applicationContext.getBean("jtrac"); /* * Check if acegi-cas authentication is being used, get reference to * object to be used by Wicket authentication to redirect to right * pages for login/logout. */ try { jtracCasProxyTicketValidator = (JtracCasProxyTicketValidator) applicationContext .getBean("casProxyTicketValidator"); logger.info("casProxyTicketValidator retrieved from application " + "context: " + jtracCasProxyTicketValidator); } catch (NoSuchBeanDefinitionException nsbde) { logger.debug(nsbde.getMessage()); logger.info("casProxyTicketValidator not found in application " + "context, CAS single-sign-on is not being used"); } /* * Delegate Wicket i18n support to spring i18n */ getResourceSettings().addStringResourceLoader(new IStringResourceLoader() { /* (non-Javadoc) * @see org.apache.wicket.resource.loader.IStringResourceLoader#loadStringResource(java.lang.Class, java.lang.String, java.util.Locale, java.lang.String) */ @Override public String loadStringResource(@SuppressWarnings("rawtypes") Class clazz, String key, Locale locale, String style) { try { return applicationContext.getMessage(key, null, locale == null ? Session.get().getLocale() : locale); } catch (Exception e) { /* * For performance, Wicket expects null instead of * throwing an exception and Wicket may try to * re-resolve using prefixed variants of the key. */ return null; } } /* (non-Javadoc) * @see org.apache.wicket.resource.loader.IStringResourceLoader#loadStringResource(org.apache.wicket.Component, java.lang.String) */ @Override public String loadStringResource(Component component, String key) { String value = loadStringResource(null, key, component == null ? null : component.getLocale(), null); if (logger.isDebugEnabled() && value == null) { logger.debug("i18n failed for key: '" + key + "', component: " + component); } return value; } }); getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy() { /* (non-Javadoc) * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component, org.apache.wicket.authorization.Action) */ @Override public boolean isActionAuthorized(Component c, Action a) { return true; } /* (non-Javadoc) * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class) */ @Override public boolean isInstantiationAuthorized(@SuppressWarnings("rawtypes") Class clazz) { if (BasePage.class.isAssignableFrom(clazz)) { if (JtracSession.get().isAuthenticated()) { return true; } if (jtracCasProxyTicketValidator != null) { /* * ============================================ * Attempt CAS authentication * ============================================ */ logger.debug("checking if context contains CAS authentication"); Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null && authentication.isAuthenticated()) { logger.debug("security context contains CAS authentication, initializing session"); JtracSession.get().setUser((User) authentication.getPrincipal()); return true; } } /* * ================================================ * Attempt remember-me auto login * ================================================ */ if (attemptRememberMeAutoLogin()) { return true; } /* * ================================================= * Attempt guest access if there are "public" spaces * ================================================= */ List<Space> spaces = getJtrac().findSpacesWhereGuestAllowed(); if (spaces.size() > 0) { logger.debug(spaces.size() + " public space(s) available, initializing guest user"); User guestUser = new User(); guestUser.setLoginName("guest"); guestUser.setName("Guest"); for (Space space : spaces) { guestUser.addSpaceWithRole(space, Role.ROLE_GUEST); } JtracSession.get().setUser(guestUser); // and proceed return true; } /* * Not authenticated, go to login page. */ logger.debug("not authenticated, forcing login, " + "page requested was " + clazz.getName()); if (jtracCasProxyTicketValidator != null) { String serviceUrl = jtracCasProxyTicketValidator.getServiceProperties().getService(); String loginUrl = jtracCasProxyTicketValidator.getLoginUrl(); logger.debug("cas authentication: service URL: " + serviceUrl); String redirectUrl = loginUrl + "?service=" + serviceUrl; logger.debug("attempting to redirect to: " + redirectUrl); throw new RestartResponseAtInterceptPageException(new RedirectPage(redirectUrl)); } else { throw new RestartResponseAtInterceptPageException(LoginPage.class); } } return true; } }); /* * Friendly URLs for selected pages */ if (jtracCasProxyTicketValidator != null) { mountBookmarkablePage("/login", CasLoginPage.class); /* * This matches the value set in: * WEB-INF/applicationContext-acegi-cas.xml */ mountBookmarkablePage("/cas/error", CasLoginErrorPage.class); } else { mountBookmarkablePage("/login", LoginPage.class); } mountBookmarkablePage("/logout", LogoutPage.class); mountBookmarkablePage("/svn", SvnStatsPage.class); mountBookmarkablePage("/options", OptionsPage.class); mountBookmarkablePage("/item/form", ItemFormPage.class); /* * Bookmarkable URL for search and search results */ mount(new QueryStringUrlCodingStrategy("/item/search", ItemSearchFormPage.class)); mount(new QueryStringUrlCodingStrategy("/item/list", ItemListPage.class)); /* * Bookmarkable URL for viewing items */ mount(new IndexedParamUrlCodingStrategy("/item", ItemViewPage.class)); }
From source file:main.java.info.jtrac.wicket.JtracApplication.java
License:Apache License
@Override public void init() { super.init(); // get hold of spring managed service layer (see BasePage, BasePanel etc for how it is used) ServletContext sc = getServletContext(); // applicationContext = WebApplicationContextUtils.getWebApplicationContext(sc); jtrac = (Jtrac) applicationContext.getBean("jtrac"); // check if acegi-cas authentication is being used, get reference to object to be used // by wicket authentication to redirect to right pages for login / logout try {/*from w w w . ja v a 2s . co m*/ jtracCasProxyTicketValidator = (JtracCasProxyTicketValidator) applicationContext .getBean("casProxyTicketValidator"); logger.info( "casProxyTicketValidator retrieved from application context: " + jtracCasProxyTicketValidator); } catch (NoSuchBeanDefinitionException nsbde) { logger.info( "casProxyTicketValidator not found in application context, CAS single-sign-on is not being used"); } // delegate wicket i18n support to spring i18n getResourceSettings().addStringResourceLoader(new IStringResourceLoader() { public String loadStringResource(Class clazz, String key, Locale locale, String style) { try { return applicationContext.getMessage(key, null, locale); } catch (Exception e) { // have to return null so that wicket can try to resolve again // e.g. without prefixing component id etc. if (logger.isDebugEnabled()) { logger.debug("i18n failed for key: '" + key + "', Class: " + clazz + ", Style: " + style + ", Exception: " + e); } return null; } } public String loadStringResource(Component component, String key) { Class clazz = component == null ? null : component.getClass(); Locale locale = component == null ? Session.get().getLocale() : component.getLocale(); return loadStringResource(clazz, key, locale, null); } }); getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy() { public boolean isActionAuthorized(Component c, Action a) { return true; } public boolean isInstantiationAuthorized(Class clazz) { if (BasePage.class.isAssignableFrom(clazz)) { if (((JtracSession) Session.get()).isAuthenticated()) { return true; } if (jtracCasProxyTicketValidator != null) { // attempt CAS authentication ========================== logger.debug("checking if context contains CAS authentication"); Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null && authentication.isAuthenticated()) { logger.debug("security context contains CAS authentication, initializing session"); ((JtracSession) Session.get()).setUser((User) authentication.getPrincipal()); return true; } } // attempt remember-me auto login ========================== if (attemptRememberMeAutoLogin()) { return true; } // attempt guest access if there are "public" spaces ======= List<Space> spaces = getJtrac().findSpacesWhereGuestAllowed(); if (spaces.size() > 0) { logger.debug(spaces.size() + " public space(s) available, initializing guest user"); User guestUser = new User(); guestUser.setLoginName("guest"); guestUser.setName("Guest"); guestUser.addSpaceWithRole(null, "ROLE_GUEST"); for (Space space : spaces) { guestUser.addSpaceWithRole(space, "ROLE_GUEST"); } ((JtracSession) Session.get()).setUser(guestUser); // and proceed return true; } // not authenticated, go to login page logger.debug("not authenticated, forcing login, page requested was " + clazz.getName()); if (jtracCasProxyTicketValidator != null) { String serviceUrl = jtracCasProxyTicketValidator.getServiceProperties().getService(); String loginUrl = jtracCasProxyTicketValidator.getLoginUrl(); logger.debug("cas authentication: service URL: " + serviceUrl); String redirectUrl = loginUrl + "?service=" + serviceUrl; logger.debug("attempting to redirect to: " + redirectUrl); throw new RestartResponseAtInterceptPageException(new RedirectPage(redirectUrl)); } else { throw new RestartResponseAtInterceptPageException(LoginPage.class); } } return true; } }); // friendly urls for selected pages if (jtracCasProxyTicketValidator != null) { mountBookmarkablePage("/login", CasLoginPage.class); } else { mountBookmarkablePage("/login", LoginPage.class); } mountBookmarkablePage("/logout", LogoutPage.class); mountBookmarkablePage("/svn", SvnStatsPage.class); mountBookmarkablePage("/test", TestPage.class); mountBookmarkablePage("/casError", CasLoginErrorPage.class); // bookmarkable url for viewing items mount(new IndexedParamUrlCodingStrategy("/item", ItemViewPage.class)); }
From source file:nl.knaw.dans.common.wicket.rest.RESTcascadePage.java
License:Apache License
/** * Redirect to the first child of this page. Pages that want to react different should override. *//*from ww w . j a v a 2 s .c om*/ @Override protected void doDefaultDissemination() { if (getChildren().isEmpty()) { super.doDefaultDissemination(); } else { PageDescription description = getChildren().entrySet().iterator().next().getValue(); String targetUrl = composeUrl(getLevel() + 1, description.getName()); throw new RestartResponseException(new RedirectPage(targetUrl)); } }
From source file:ro.nextreports.server.web.core.HeaderPanel.java
License:Apache License
public HeaderPanel(String id) { super(id);/*from w w w . ja v a 2 s . c o m*/ final WebMarkupContainer imageContainer = new WebMarkupContainer("imageContainer"); imageContainer.setOutputMarkupPlaceholderTag(true); imageContainer.add(new Image("logoImage", new LogoResource())); add(imageContainer); add(new Label("currentUser", NextServerSession.get().getUsername())); add(new Label("realName", NextServerSession.get().getRealName())); final ModalWindow dialog = new ModalWindow("modal"); add(dialog); Link<String> logoutLink = new Link<String>("logout") { private static final long serialVersionUID = 1L; @Override public void onClick() { NextServerSession.get().signOut(); if (CasUtil.isCasUsed()) { setResponsePage(new RedirectPage(CasUtil.getLogoutUrl())); } else { setResponsePage(getApplication().getHomePage()); } } }; add(logoutLink); AjaxLink<String> changePassword = new AjaxLink<String>("changePassord") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { dialog.setTitle(getString("ChangePassword.change")); dialog.setInitialWidth(350); dialog.setUseInitialHeight(false); dialog.setContent(new ChangePasswordPanel(dialog.getContentId()) { private static final long serialVersionUID = 1L; @Override public void onChange(AjaxRequestTarget target) { ModalWindow.closeCurrent(target); try { User loggedUser = securityService.getUserByName(NextServerSession.get().getUsername()); loggedUser.setPassword(passwordEncoder.encodePassword(confirmPassword, null)); storageService.modifyEntity(loggedUser); } catch (Exception e) { e.printStackTrace(); add(new AlertBehavior(e.getMessage())); target.add(this); } } @Override public void onCancel(AjaxRequestTarget target) { ModalWindow.closeCurrent(target); } }); dialog.show(target); } }; add(changePassword); if (NextServerSession.get().isDemo()) { changePassword.setEnabled(false); } }
From source file:ro.nextreports.server.web.NextServerApplication.java
License:Apache License
protected void addSecurityAuthorization() { Class<? extends Page> signInPageClass = LoginPage.class; if (CasUtil.isCasUsed()) { signInPageClass = CasLoginPage.class; }//from www . j a v a 2 s. c o m IAuthorizationStrategy authStrategy = new SimplePageAuthorizationStrategy(SecurePage.class, signInPageClass) { @Override protected boolean isAuthorized() { boolean b = NextServerSession.get().isSignedIn(); if (!b) { if (CasUtil.isCasUsed()) { LOG.debug("Checking if context contains CAS authentication"); b = NextServerSession.get().checkForSignIn(); if (!b) { String serviceUrl = CasUtil.getServiceProperties().getService(); String loginUrl = CasUtil.getLoginUrl(); LOG.debug("cas authentication: service URL: " + serviceUrl); String redirectUrl = loginUrl + "?service=" + serviceUrl; LOG.debug("attempting to redirect to: " + redirectUrl); throw new RestartResponseAtInterceptPageException(new RedirectPage(redirectUrl)); } } } return b; } }; getSecuritySettings().setAuthorizationStrategy(authStrategy); }