List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:org.artifactory.webapp.wicket.application.ArtifactoryApplication.java
License:Open Source License
public static ArtifactoryApplication get() { return (ArtifactoryApplication) Application.get(); }
From source file:org.artifactory.webapp.wicket.page.security.profile.ProfilePage.java
License:Open Source License
public ProfilePage() { if (!isEnabled()) { Class<? extends Page> accessDeniedPage = getApplication().getApplicationSettings() .getAccessDeniedPage();/*from w ww .j a va2 s.co m*/ setResponsePage(accessDeniedPage); } ProfileModel profile = new ProfileModel(); UserInfo userInfo = loadUserInfo(); profile.setEmail(userInfo.getEmail()); profile.setBintrayAuth(userInfo.getBintrayAuth()); setOutputMarkupId(true); setDefaultModel(new CompoundPropertyModel<>(profile)); form = new SecureForm("form"); //Submit updateLink = createUpdateProfileButton(form); updateLink.setEnabled(false); updateLink.setVisible(authorizationService.isUpdatableProfile()); add(updateLink); //Cancel cancelLink = new TitledAjaxLink("cancel", "Cancel") { @Override public void onClick(AjaxRequestTarget target) { setResponsePage(Application.get().getHomePage()); } }; add(cancelLink); form.add(new DefaultButtonBehavior(updateLink)); add(form); WebMarkupContainer adminAuthOverlay = new WebMarkupContainer("adminAuthOverlay"); form.add(adminAuthOverlay); profilePanel = new ProfilePanel("updatePanel", form, profile); form.add(profilePanel); bintrayProfilePanel = new BintrayProfilePanel<>("bintrayProfilePanel", profile, false); form.add(bintrayProfilePanel); ProfileLockPanel profileLockPanel = new ProfileLockPanel(profilePanel, bintrayProfilePanel, this, profile, adminAuthOverlay); form.add(profileLockPanel); WebMarkupContainer mavenSettingsPanel = new WebMarkupContainer("mavenSettingsPanel"); mavenSettingsPanel.setVisible(false); form.add(mavenSettingsPanel); }
From source file:org.brixcms.Brix.java
License:Apache License
public static Brix get() { Application application = Application.get(); if (application == null) { throw new IllegalStateException( "Could not find Application threadlocal; this method can only be called within a Wicket request"); }/*www.j a v a 2 s .c o m*/ return get(application); }
From source file:org.brixcms.markup.transform.EnclosureMarkupSourceTransformer.java
License:Apache License
private String getEnclosureTag() { return Application.get().getMapperContext().getNamespace() + ":enclosure"; }
From source file:org.brixcms.markup.transform.EnclosureMarkupSourceTransformer.java
License:Apache License
private String getIdAttribute() { return Application.get().getMapperContext().getNamespace() + ":id"; }
From source file:org.brixcms.rmiserver.web.admin.AdminAuthorizationStrategy.java
License:Apache License
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) { boolean authorized = false; if (Page.class.isAssignableFrom(componentClass)) { if (Application.get().getApplicationSettings().getAccessDeniedPage().isAssignableFrom(componentClass)) { return true; }//w ww .ja va 2 s . c o m AdminSession session = AdminSession.get(); HttpServletRequest req = (HttpServletRequest) RequestCycle.get().getRequest().getContainerRequest(); if (!session.isUserLoggedIn()) { boolean authenticated = false; String[] auth = parseAuthHeader(req.getHeader("Authorization")); if (auth != null) { try { session.loginUser(auth[0], auth[1]); authenticated = true; } catch (AuthenticationException e) { // noop } } if (authenticated == false) { RequestCycle.get().scheduleRequestHandlerAfterCurrent(new IRequestHandler() { public void detach(RequestCycle requestCycle) { } public void respond(RequestCycle rc) { HttpServletResponse res = (HttpServletResponse) rc.getResponse().getContainerResponse(); res.setHeader("WWW-Authenticate", "BASIC"); res.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } @Override public void respond(IRequestCycle requestCycle) { } @Override public void detach(IRequestCycle requestCycle) { } }); // throw new AbstractRestartResponseException() { // private static final long serialVersionUID = 1L; // }; } } // user is authenticated AllowedRoles ar = componentClass.getAnnotation(AllowedRoles.class); if (ar != null) { for (Role role : ar.value()) { if (session.loggedinUser().getRoles().contains(role)) { authorized = true; break; } } } else { authorized = true; } } else { // not a page authorized = true; } return authorized; }
From source file:org.brixcms.web.BrixRequestMapper.java
License:Apache License
@Override public int getCompatibilityScore(Request request) { Url url = request.getUrl();/*from w w w. ja v a 2s .c o m*/ if (url.getSegments().size() > 0) { if (url.getSegments().get(0).equals((Application.get().getMapperContext().getNamespace()))) { // starts with wicket namespace - is an internal wicket url return 0; } } // bluff we can parse all segments - makes sure we run first return request.getUrl().getSegments().size(); }
From source file:org.brixcms.web.BrixRequestMapper.java
License:Apache License
/** * Url encodes a string//from w ww . j a v a2s . c o m * * @param string string to be encoded * @return encoded string */ public static String urlEncode(String string) { try { return URLEncoder.encode(string, Application.get().getRequestCycleSettings().getResponseRequestEncoding()); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); return string; } }
From source file:org.brixcms.web.nodepage.BrixNodePageUrlCodingStrategy.java
License:Apache License
/** * Returns a decoded value of the given value * * @param value// www. j av a2s . com * @return Decodes the value */ public static String urlDecode(String value) { try { value = URLDecoder.decode(value, Application.get().getRequestCycleSettings().getResponseRequestEncoding()); } catch (UnsupportedEncodingException ex) { log.error("error decoding parameter", ex); } return value; }
From source file:org.brixcms.web.nodepage.BrixNodePageUrlCodingStrategy.java
License:Apache License
private Page getPage(PageInfo info) { Page page;// w ww. ja va 2 s . c o m if (Strings.isEmpty(info.getPageMapName()) && Application.exists() && Application.get().getSessionSettings().isPageIdUniquePerSession()) { page = Session.get().getPage(info.getPageId().intValue(), info.getVersionNumber() != null ? info.getVersionNumber().intValue() : 0); } else { page = Session.get().getPage(info.getPageMapName(), "" + info.getPageId(), info.getVersionNumber() != null ? info.getVersionNumber().intValue() : 0); } if (page != null && isBrixPage(page)) { return page; } else { return null; } }