List of usage examples for org.apache.wicket.request.http WebRequest getContainerRequest
public abstract Object getContainerRequest();
From source file:au.org.theark.core.security.AAFRealm.java
License:Open Source License
@Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException { SimpleAuthenticationInfo sai = null; ArkUserVO userVO = null;/*from www . jav a 2 s .com*/ UsernamePasswordToken token = (UsernamePasswordToken) authcToken; //log.info("IN AAFRealm.doGetAuthenticationInfo"); //log.info("authToken: " + authcToken.getPrincipal().toString()); log.info("AAF token username: " + token.getUsername()); try { //log.info("checking user"); userVO = iArkCommonService.getUser(token.getUsername().trim()); if (userVO != null) { // Check if the user is in the Ark Database ArkUser arkUser = iArkCommonService.getArkUser(token.getUsername().trim()); // Also check if the Ark User is linked with any study and has roles. // If no roles found, stop the user from logging in until an administrator has set it up if (!iArkCommonService.isArkUserLinkedToStudies(arkUser)) { throw new UnknownAccountException(UNKNOWN_ACCOUNT); } final WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest(); final HttpServletRequest httpReq = (HttpServletRequest) webRequest.getContainerRequest(); //log.info("checking shib headers"); String userName = httpReq.getHeader("AJP_mail"); String password = httpReq.getHeader("AJP_Shib-Session-ID"); if (userName != null && password != null) { //log.info("creating SimpleAuthenticationInfo"); sai = new SimpleAuthenticationInfo(token.getPrincipal(), token.getCredentials(), getName()); } } } catch (ArkSystemException e) { log.error(e.getMessage()); } catch (EntityNotFoundException e) { throw new UnknownAccountException(UNKNOWN_ACCOUNT); } return sai; }
From source file:au.org.theark.web.pages.login.AAFLoginForm.java
License:Open Source License
private void checkAAFAuthentication() { final WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest(); final HttpServletRequest httpReq = (HttpServletRequest) webRequest.getContainerRequest(); ArkUserVO user = (ArkUserVO) getModelObject(); // TODO: UserName: httpReq.getHeader("AJP_mail").. should it be httpReq.getHeader("AJP_persistent-id") ? String userName = httpReq.getHeader("AJP_mail"); String password = httpReq.getHeader("AJP_Shib-Session-ID"); if (userName != null || password != null) { user.setUserName(userName);/*from ww w.j a va 2 s. c om*/ user.setPassword(password); setModelObject(user); if (authenticate(user)) { DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); log.info("\n ---- " + user.getUserName() + " logged in successfully at: " + dateFormat.format(new Date()) + " ---- \n"); // Place a default module into session ArkModule arkModule = iArkCommonService .getArkModuleByName(au.org.theark.core.Constants.ARK_MODULE_STUDY); // Place a default function into session ArkFunction arkFunction = iArkCommonService .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_STUDY); // Set session attributes SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.ARK_USERID, user.getUserName()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY, arkModule.getId()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.ARK_FUNCTION_KEY, arkFunction.getId()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.SHIB_SESSION_ID, password); setResponsePage(HomePage.class); } } else { this.error("There was an issue with AAF Authentication. Please contact your system administrator"); //throw new AuthenticationException(); } }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.publish.CrStates.java
License:Apache License
/** * Send out the json!!!!/* w w w . ja va2 s .com*/ */ @Override public JSONObject getJson(final PageParameters pp) throws JSONException { if (myPeerWatcher == null) { return null; } boolean raw = true; final MonitorConfig config = ConfigHandler.getConfig(); final RouterConfig crConfig = RouterConfig.getCrConfig(); if (crConfig == null || myCacheWatcher.getCycleCount() < config.getStartupMinCycles()) { return null; } if (pp == null || pp.getPosition("raw") == -1) { final WebRequest req = (WebRequest) RequestCycle.get().getRequest(); final HttpServletRequest httpReq = (HttpServletRequest) req.getContainerRequest(); clientIps.put(httpReq.getRemoteHost(), new Long(System.currentTimeMillis())); raw = false; } final JSONObject o = new JSONObject(); o.put("caches", getCrStates(crConfig, raw)); if (ConfigHandler.getConfig().getPublishDsStates()) { o.put("deliveryServices", getDsStates(crConfig)); } return o; }
From source file:com.evolveum.midpoint.web.security.MidPointAuthenticationProvider.java
License:Apache License
public static String getRemoteHost() { WebRequest req = (WebRequest) RequestCycle.get().getRequest(); HttpServletRequest httpReq = (HttpServletRequest) req.getContainerRequest(); return httpReq.getRemoteHost(); }
From source file:com.madalla.wicket.request.SwitchProtocolRequestHandler.java
License:Apache License
/** * {@inheritDoc}/*from w ww . j a va 2 s . c o m*/ */ public void respond(IRequestCycle requestCycle) { WebRequest webRequest = (WebRequest) requestCycle.getRequest(); HttpServletRequest request = (HttpServletRequest) webRequest.getContainerRequest(); Integer port = null; if (protocol == Protocol.HTTP) { if (httpsConfig.getHttpPort() != 80) { port = httpsConfig.getHttpPort(); } } else if (protocol == Protocol.HTTPS) { if (httpsConfig.getHttpsPort() != 443) { port = httpsConfig.getHttpsPort(); } } final String url = getUrl(protocol.toString().toLowerCase(), port, request); WebResponse response = (WebResponse) requestCycle.getResponse(); response.sendRedirect(url); }
From source file:com.madalla.wicket.request.SwitchProtocolRequestHandler.java
License:Apache License
/** * Returns a target that can be used to redirect to the specified protocol. If no change is * required {@code null} will be returned. * /*from www .ja v a 2s .c o m*/ * @param protocol * required protocol * @param httpsConfig * the https configuration * @return request handler or {@code null} */ public static IRequestHandler requireProtocol(Protocol protocol, final HttpsConfig httpsConfig) { IRequestCycle requestCycle = RequestCycle.get(); WebRequest webRequest = (WebRequest) requestCycle.getRequest(); HttpServletRequest request = (HttpServletRequest) webRequest.getContainerRequest(); if (protocol == null || protocol == Protocol.PRESERVE_CURRENT || request.getScheme().equals(protocol.toString().toLowerCase())) { return null; } else { return new SwitchProtocolRequestHandler(protocol, httpsConfig); } }
From source file:com.rex.crm.TemplatePage.java
License:Apache License
/** * Constructor//w w w .j a v a 2s. co m */ public TemplatePage() { final int roleId = ((SignIn2Session) getSession()).getRoleId(); add(new Label("title", new PropertyModel<String>(this, "pageTitle"))); UserInfo user = DAOImpl.getUserInfoById(Integer.parseInt(((SignIn2Session) getSession()).getUserId())); //TODO get function work with real id List<String> menulist = DAOImpl.getMenuByRole(roleId); //populate menu items. TODO componentize it. pass arg: menuList ArrayList<MenuItem> menu = Lists.newArrayList(); for (String key : menulist) { menu.add(pageMenuMap.get(key)); } //@SuppressWarnings("unchecked") ListView lv = new ListView("menu", menu) { @Override protected void populateItem(ListItem item) { MenuItem menuitem = (MenuItem) item.getModelObject(); BookmarkablePageLink link = new BookmarkablePageLink("link", menuitem.getDestination()); link.add(new Label("caption", menuitem.getCaption()).setEscapeModelStrings(false)); item.add(link); item.add(new AttributeAppender("id", Model.of(menuitem.getId()))); // item.add(new SimpleAttributeModifier("class", "my-css-class")); } }; add(lv); add(new Link("signout_link") { @Override public void onClick() { SignIn2Session session = (SignIn2Session) getSession(); LogInOut loginout = new LogInOut(); loginout.setLoginName(session.getUser()); loginout.setLogints(System.currentTimeMillis()); loginout.setSessionId(session.getId()); CRMUtility.printStat(CRMUtility.STAT_LOG_IN_OUT, loginout, LogInOut.class); session.invalidate(); this.setResponsePage(SignIn.class); } }); BookmarkablePageLink user_settings_link = new BookmarkablePageLink("user_settings_link", UserDeatialInfo.class); add(user_settings_link); user_settings_link.add(new Label("loginName", user.getName())); WebMarkupContainer admin_menu = new WebMarkupContainer("admin_menu"); add(admin_menu); BookmarkablePageLink adminTreePage = new BookmarkablePageLink("adminTreePage", AdminTreePage.class); admin_menu.add(adminTreePage); // BookmarkablePageLink positionTreePage = new BookmarkablePageLink("positionTreePage",PositionTreePage.class ); // admin_menu.add(positionTreePage); BookmarkablePageLink productTreePage = new BookmarkablePageLink("productTreePage", ProductTreePage.class); admin_menu.add(productTreePage); BookmarkablePageLink positionPage = new BookmarkablePageLink("positionPage", PositionPage.class); admin_menu.add(positionPage); // BookmarkablePageLink reportPage = new BookmarkablePageLink("reportPage",ReportPage.class ); // admin_menu.add(reportPage); // BookmarkablePageLink downloadPage = new BookmarkablePageLink("downloadPage",DownloadPage.class ); // admin_menu.add(downloadPage); BookmarkablePageLink userPage = new BookmarkablePageLink("userPage", UserPage.class); admin_menu.add(userPage); BookmarkablePageLink userPositionPage = new BookmarkablePageLink("userPositionPage", UserPositionPage.class); admin_menu.add(userPositionPage); // BookmarkablePageLink productPage = new BookmarkablePageLink("productPage",ProductPage.class ); // admin_menu.add(productPage); BookmarkablePageLink dataImportPage = new BookmarkablePageLink("dataImportPage", DataImportPage.class); admin_menu.add(dataImportPage); BookmarkablePageLink alertPage = new BookmarkablePageLink("alertPage", AlertPage.class); admin_menu.add(alertPage); BookmarkablePageLink areaPage = new BookmarkablePageLink("areaPage", AreaPage.class); admin_menu.add(areaPage); // // BookmarkablePageLink applicationPage = new BookmarkablePageLink("applicationPage",AreaPage.class ); // admin_menu.add(applicationPage); // // BookmarkablePageLink flowPage = new BookmarkablePageLink("flowPage",AreaPage.class ); // admin_menu.add(flowPage); // // BookmarkablePageLink jurisdictionPage = new BookmarkablePageLink("jurisdictionPage",AreaPage.class ); // admin_menu.add(jurisdictionPage); // // BookmarkablePageLink contentPage = new BookmarkablePageLink("contentPage",AreaPage.class ); // admin_menu.add(contentPage); // // BookmarkablePageLink integrationPage = new BookmarkablePageLink("integrationPage",AreaPage.class ); // admin_menu.add(integrationPage); BookmarkablePageLink importLogPage = new BookmarkablePageLink("importLog", ImportLogPage.class); admin_menu.add(importLogPage); // BookmarkablePageLink merge_data = new BookmarkablePageLink("merge_data",MergePage.class ); // admin_menu.add(merge_data); admin_menu.setVisible(false); if (roleId == 1) admin_menu.setVisible(true); //end of populate menu items AbstractAjaxBehavior ajaxBehaviour = new AbstractAjaxBehavior() { private static final long serialVersionUID = 1L; @Override public void onRequest() { RequestCycle requestCycle = RequestCycle.get(); readRequestData(requestCycle); } private void readRequestData(final RequestCycle requestCycle) { WebRequest wr = (WebRequest) requestCycle.getRequest(); HttpServletRequest hsr = (HttpServletRequest) wr.getContainerRequest(); String response = "{}"; try { BufferedReader br = hsr.getReader(); String jsonString = br.readLine(); if ((jsonString == null) || jsonString.isEmpty()) { logger.debug(" no json found"); } else { logger.debug(" json is :" + jsonString); } FunctionClass method = new Gson().fromJson(jsonString, FunctionClass.class); FunctionInvoker invoker = new FunctionInvoker(DataProvider.class); System.out.println(" method:" + method); response = (String) invoker.invoke(method.getF(), method.getP()); System.out.println("response:" + response); br.close(); } catch (Exception e) { e.printStackTrace(); } requestCycle .replaceAllRequestHandlers(new TextRequestHandler("application/json", "UTF-8", response)); } @Override public void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); final String posId = ((SignIn2Session) getSession()).getPositionId(); String callbackUrl = getCallbackUrl().toString(); Map<String, Object> map = new HashMap<>(); map.put("userInfo", DataProvider.getCRMUserInfoById(new String[] { posId })); map.put("ajaxURL", callbackUrl); //map.put("allUsers", DataProvider.getAllCRMUsers(new String[0])); //map.put("allAccounts", DataProvider.getAllAccounts(new String[0])); map.put("context_name", getRootContext()); PackageTextTemplate ptt = new PackageTextTemplate(getClass(), "template.js"); //System.out.println(ptt.asString(map)); response.render(JavaScriptHeaderItem.forScript(ptt.asString(map), null)); try { ptt.close(); } catch (IOException e) { e.printStackTrace(); } } }; add(ajaxBehaviour); }
From source file:de.alpharogroup.wicket.base.util.WicketComponentExtensions.java
License:Apache License
/** * Gets the http servlet request./*from ww w . j a va 2 s. co m*/ * * @param request * the request * @return the http servlet request */ public static HttpServletRequest getHttpServletRequest(final Request request) { final WebRequest webRequest = (WebRequest) request; final HttpServletRequest httpServletRequest = (HttpServletRequest) webRequest.getContainerRequest(); return httpServletRequest; }
From source file:org.brixcms.web.SwitchProtocolRequestHandler.java
License:Apache License
public static IRequestHandler requireProtocol(Protocol protocol) { RequestCycle requestCycle = RequestCycle.get(); WebRequest webRequest = (WebRequest) requestCycle.getRequest(); HttpServletRequest request = (HttpServletRequest) webRequest.getContainerRequest(); if (protocol == null || protocol == Protocol.PRESERVE_CURRENT || request.getScheme().equals(protocol.toString().toLowerCase())) { return null; } else {/*from w w w.jav a 2 s. c o m*/ return new SwitchProtocolRequestHandler(protocol); } }
From source file:org.cyclop.web.pages.authenticate.LoginPanel.java
License:Apache License
private HttpServletRequest getHttpServletRequest() { WebRequest req = (WebRequest) RequestCycle.get().getRequest(); HttpServletRequest httpReq = (HttpServletRequest) req.getContainerRequest(); return httpReq; }