Examples of RequestContext


Examples of org.apache.jetspeed.request.RequestContext

   
    @Override
    protected void doHeaders(RenderRequest request, RenderResponse response)
    {
        super.doHeaders(request, response);
        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
        Element headElem = response.createElement("script");
        headElem.setAttribute("language", "javascript");
        String scriptPath = rc.getRequest().getContextPath() + yuiScriptPath;
        headElem.setAttribute("id", HeaderPhaseSupportConstants.HEAD_ELEMENT_CONTRIBUTION_ELEMENT_ID_YUI_LIBRARY_INCLUDE);
        headElem.setAttribute("src", scriptPath);
        headElem.setAttribute("type", "text/javascript");
        response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, headElem);
    }
View Full Code Here

Examples of org.apache.jetspeed.request.RequestContext

            }
        }
       
        try
        {
            RequestContext requestContext = (RequestContext) actionRequest.getAttribute(RequestContext.REQUEST_PORTALENV);
            ContentPage contentPage = requestContext.getPage();
           
            String spacePath = space.getPath();
            String contentPagePath = contentPage.getPath();
            String contentFolderPath = StringUtils.defaultIfEmpty(StringUtils.substringBeforeLast(contentPagePath, "/"), "/");
            String nodeName = name.replace(' ', '_');
            String nodePath = null;
           
            if (contentFolderPath.startsWith(spacePath))
            {
                nodePath = StringUtils.removeEnd(contentFolderPath, "/") + "/" + StringUtils.removeStart(nodeName, "/");
            }
            else
            {
                nodePath = StringUtils.removeEnd(spacePath, "/") + "/" + StringUtils.removeStart(nodeName, "/");
            }
           
            if (Page.DOCUMENT_TYPE.equals(type))
            {
                String path = nodePath + Page.DOCUMENT_TYPE;
                Page source = pageManager.getPage(templatePage);
                Page newPage = pageManager.copyPage(source, path, false);
                newPage.setTitle(name);
                pageManager.updatePage(newPage);
               
                requestContext.setSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY, null);
               
                String redirect = admin.getPortalURL(actionRequest, actionResponse, path);
                actionResponse.sendRedirect(redirect);
            }
            else if (Folder.FOLDER_TYPE.equals(type))
            {
                String path = nodePath;
                Folder folder = pageManager.newFolder(path);
                folder.setTitle(name);
                pageManager.updateFolder(folder);
               
                String defaultPagePath = folder.getPath() + "/" + Folder.FALLBACK_DEFAULT_PAGE;
                Page source = pageManager.getPage(templatePage);
                Page newPage = pageManager.copyPage(source, defaultPagePath, false);
                pageManager.updatePage(newPage);
               
                requestContext.setSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY, null);
            }
            else if (Link.DOCUMENT_TYPE.equals(type))
            {
                String path = nodePath + Link.DOCUMENT_TYPE;
                Link link = pageManager.newLink(path);
                link.setTitle(name);
                pageManager.updateLink(link);
               
                requestContext.setSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY, null);
            }
        }
        catch (Exception e)
        {
            log.error("Failed to update page.", e);
View Full Code Here

Examples of org.apache.jetspeed.request.RequestContext

    {
        List<MenuElement> spaceMenuElements = null;
       
        try
        {
            RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
            PortalSiteRequestContext psrc = (PortalSiteRequestContext) rc.getAttribute(PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY);

            Menu spaceMenu = null;
           
            String menuName = request.getPreferences().getValue("Menu", defaultMenu);
           
View Full Code Here

Examples of org.apache.jetspeed.request.RequestContext

    {
        List<MenuElement> spaceLinkMenuElements = null;
       
        try
        {
            RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
            PortalSiteRequestContext psrc = (PortalSiteRequestContext) rc.getAttribute(PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY);

            Menu spaceLinksMenu = null;
           
            String linksMenuName = request.getPreferences().getValue("LinkMenu", defaultLinksMenu);
           
View Full Code Here

Examples of org.apache.jetspeed.request.RequestContext

        if (templateLocator == null)
        {
            return templateLocation + PATH_SEPARATOR + templateName;
        }

        RequestContext requestContext = (RequestContext) request
                .getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
        Locale locale = request.getLocale();

        try
        {
            LocatorDescriptor locator = templateLocator.createLocatorDescriptor("email");
            locator.setName(templateName);
            locator.setMediaType(requestContext.getMediaType());
            locator.setLanguage(locale.getLanguage());
            locator.setCountry(locale.getCountry());
            TemplateDescriptor template = templateLocator.locateTemplate(locator);

            return template.getAppRelativePath();
View Full Code Here

Examples of org.apache.jetspeed.request.RequestContext

     * @see org.apache.portals.applications.webcontent.portlet.WebContentPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
     */
    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
    {
        // portal request context
        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);

        // default page view rendering
        String viewPage = (String)request.getAttribute(PARAM_VIEW_PAGE);
        if (viewPage != null)
        {
            super.doView(request, response);
            return;
        }

        // get source web content URL, parameters, and method to view
        String sourceURL = null;
        Map sourceParams = null;
        boolean sourcePostMethod = false;
        WebContentHistoryPage webContentPage = (WebContentHistoryPage)PortletMessaging.receive(request, getClass().getName());
        if (webContentPage != null)
        {
            // view rewritten action URL page
            sourceURL = webContentPage.getUrl();
            sourceParams = webContentPage.getParams();
            sourcePostMethod = webContentPage.isPost();           
        }
        else
        {
            // load and validate preferences, (base url and portal base path
            // should both end in a "/" path separator to ensure that relative
            // urls in the content resolve predictably)
            String baseURL = request.getPreferences().getValue("SRC", null);
            String portalBasePath = request.getPreferences().getValue("PORTALPATH", null);
            if ((baseURL == null) || (portalBasePath == null))
            {
                throw new PortletException("Required SRC and PORTALPATH preferences not set");
            }
            if (!baseURL.endsWith("/"))
            {
                baseURL += "/";
            }
            if (!portalBasePath.startsWith("/"))
            {
                portalBasePath = "/"+portalBasePath;
            }       
            if (!portalBasePath.endsWith("/"))
            {
                portalBasePath += "/";
            }       
            // view content page based on portal request URL
            String portalRequestPath = rc.getPath();
            if (!portalRequestPath.startsWith(portalBasePath))
            {
                throw new PortletException("Unable to map portal request path: "+portalRequestPath+" onto portal base path: "+portalBasePath);
            }
            sourceURL = baseURL+portalRequestPath.substring(portalBasePath.length());           
        }

        // get web content
        byte[] content = null;
        try
        {
            // initialize and lock stateful rewriter
            String basePortalPath = rc.getPortalURL().getPageBasePath();
            initializeRewriter(DynamicWebContentRewriter.class);
            ((DynamicWebContentRewriter)getRewriter()).setBasePortalPath(basePortalPath);
       
            // get and rewrite web content
            if (log.isDebugEnabled())
            {
                log.debug("Portal request: "+rc.getPath()+", Web content: "+sourceURL);
            }
            try
            {
                content = doWebContent(sourceURL, sourceParams, sourcePostMethod, request, response);
            }
View Full Code Here

Examples of org.apache.jetspeed.request.RequestContext

        }
        else
        {
            if (view != null)
            {
                RequestContext rc = SecurityHelper.getRequestContext(request);               
                Integer ecode = (Integer)rc.getSessionAttribute(LoginConstants.ERRORCODE);
                if (ecode != null && (ecode.equals(LoginConstants.ERROR_USER_DISABLED) || ecode.equals(LoginConstants.ERROR_CREDENTIAL_DISABLED)))
                {
                    view = this.setView(request, "three", FAILURE2);
                }
                request.setAttribute(PARAM_VIEW_PAGE, view);
View Full Code Here

Examples of org.apache.jetspeed.request.RequestContext

                        int count = failures + 1;
                        if (count >= this.maxNumberOfAuthenticationFailures)
                        {
                            try
                            {
                                RequestContext rc = SecurityHelper.getRequestContext(actionRequest);
                                User user = userManager.getUser(userBean.getUsername());                                                       
                                PasswordCredential pwc = userManager.getPasswordCredential(user);
                                pwc.setEnabled(false);
                                userManager.storePasswordCredential(pwc);
                                SecurityHelper.updateCredentialInSession(rc, pwc);
                                userBean.setUser(user);
                                userAttributes = userBean.getUser().getSecurityAttributes().getAttributeMap();                               
                                user.getSecurityAttributes().getAttribute("user.question.failures", true).setStringValue("0");                               
                                userManager.updateUser(user);                               
                                audit.logUserActivity(userBean.getUsername(),
                                        rc.getRequest().getRemoteAddr(),
                                        AuditActivity.USER_DISABLE, "Failed question and answer limit reached");                               
                            }
                            catch (Exception e)
                            {
                            }
                            StatusMessage msg = new StatusMessage("Disabling user after too many failed questions.", StatusMessage.ERROR);
                            PortletMessaging.publish(actionRequest, STATUS_MESSAGE, msg);
                            setView(actionRequest, phase, FAILURE2);                           
                        }
                        else
                        {                           
                            try
                            {
                                userBean.getUser().getSecurityAttributes().getAttribute("user.question.failures", true).setStringValue(Integer.toString(count));                               
                                userManager.updateUser(userBean.getUser());
                            }
                            catch (SecurityException e)
                            {}
                            StatusMessage msg = new StatusMessage("Invalid answer to question.", StatusMessage.ERROR);
                            PortletMessaging.publish(actionRequest, STATUS_MESSAGE, msg);
                            setView(actionRequest, phase, FAILURE1);
                        }
                    }
                    else
                    {
                        try
                        {
                          userBean.setPassPhrase(getUserAttribute(userAttributes, "user.passphrase", ""));
                            userBean.getUser().getSecurityAttributes().getAttribute("user.question.failures", true).setStringValue("0");                               
                            userManager.updateUser(userBean.getUser());
                        }
                        catch (Exception e)
                        {}
                        setView(actionRequest, phase, SUCCESS1);                               
                    }
                }
            }
            else if (phase.equals("enroll"))
            {
                boolean success = false;
                String password = userBean.getPassword();
                User user = userBean.getUser();
                if (user != null && password != null)
                {
                    AuthenticatedUser authUser = null;
                    try
                    {
                        authUser = authorization.authenticate(userBean.getUsername(), password);
                    }
                    catch (SecurityException e)
                    {
                        RequestContext rc = SecurityHelper.getRequestContext(actionRequest);
                        audit.logUserActivity(userBean.getUsername(), rc.getRequest().getRemoteAddr(),
                                AuditActivity.AUTHENTICATION_FAILURE, "PortalFilter");                   
                    }
                    if (authUser != null)
                    {
                        // validate request parameers, if valid update user preferences
                        String question1 = actionRequest.getParameter("question1");
                        String question2 = actionRequest.getParameter("question2");
                        String question3 = actionRequest.getParameter("question3");
                        String answer1 = actionRequest.getParameter("answer1");
                        String answer2 = actionRequest.getParameter("answer2");
                        String answer3 = actionRequest.getParameter("answer3");
                        String passPhrase = actionRequest.getParameter("passphrase");
                       
                        // validation (SecurityHelper.isEmpty, unique questions)
                        if (SecurityHelper.isEmpty(answer1) || SecurityHelper.isEmpty(answer2) || SecurityHelper.isEmpty(answer3))
                        {
                            StatusMessage msg = new StatusMessage("Please enter a valid answer for all 3 questions.", StatusMessage.ERROR);
                            PortletMessaging.publish(actionRequest, STATUS_MESSAGE, msg);
                            setView(actionRequest, phase, FAILURE1);                                                                   
                            return;
                        }
                        if (SecurityHelper.isEmpty(passPhrase))
                        {
                            StatusMessage msg = new StatusMessage("Please enter a valid pass phrase.", StatusMessage.ERROR);
                            PortletMessaging.publish(actionRequest, STATUS_MESSAGE, msg);
                            setView(actionRequest, phase, FAILURE1);                                                                   
                            return;
                        }
                        if (question1.equals(question2) || question1.equals(question3) || question2.equals(question3))
                        {
                            StatusMessage msg = new StatusMessage("Please select a unique question in all cases.", StatusMessage.ERROR);
                            PortletMessaging.publish(actionRequest, STATUS_MESSAGE, msg);
                            setView(actionRequest, phase, FAILURE1);                                                                   
                            return;                   
                        }
       
                        // update the prefs db (we are not logged in yet
                        user = userBean.getUser();
                        try
                        {
                            user.getSecurityAttributes().getAttribute("user.question.1", true).setStringValue(question1);
                            user.getSecurityAttributes().getAttribute("user.question.2", true).setStringValue(question2);
                            user.getSecurityAttributes().getAttribute("user.question.3", true).setStringValue(question3);
                            user.getSecurityAttributes().getAttribute("user.answer.1", true).setStringValue(answer1);
                            user.getSecurityAttributes().getAttribute("user.answer.2", true).setStringValue(answer2);
                            user.getSecurityAttributes().getAttribute("user.answer.3", true).setStringValue(answer3);
                            user.getSecurityAttributes().getAttribute("user.passphrase", true).setStringValue(passPhrase);
                            user.getSecurityAttributes().getAttribute("user.cookie", true).setStringValue(CaptchaImageResource.randomString(8, 16));
                            userManager.updateUser(user);
                            success = true;
                        }
                        catch (SecurityException e)
                        {
                            success = false;
                            RequestContext rc = SecurityHelper.getRequestContext(actionRequest);
                            audit.logUserActivity(userBean.getUsername(), rc.getRequest().getRemoteAddr(), AuditActivity.AUTHENTICATION_FAILURE, "Exception updating attributes" );
                            setView(actionRequest, phase, FAILURE2);                                               
                        }
                        if (success)
                        {
                            String username = userBean.getUsername();
                            String redirect = actionRequest.getParameter("redirect");
                            RequestContext rc = SecurityHelper.getRequestContext(actionRequest);
                            audit.logUserActivity(username, rc.getRequest().getRemoteAddr(),
                                    LOGIN_ENROLL_ACTIVITY, "enrolling user with questions and passphrase");
                            redirect(actionRequest, actionResponse, redirect, username, password);
                        }
                    }
                }
                if (success == false)
                {
                    RequestContext rc = SecurityHelper.getRequestContext(actionRequest);
                    audit.logUserActivity(userBean.getUsername(), rc.getRequest().getRemoteAddr(), AuditActivity.AUTHENTICATION_FAILURE, "Unauthorized Attribute Modification Attempt.");
                    setView(actionRequest, phase, FAILURE2);                   
                }
            }
            else if (phase.equals("enroll-login"))
            {               
                String username = userBean.getUsername();
                String password = actionRequest.getParameter(LoginConstants.PASSWORD);
                if (SecurityHelper.isEmpty(password))
                {
                    RequestContext rc = SecurityHelper.getRequestContext(actionRequest);
                    rc.setSessionAttribute(MFALogin.ERRORCODE, LoginConstants.ERROR_INVALID_PASSWORD);                   
                    setView(actionRequest, phase, FAILURE1);
                    return;
                }               
                // are we in the enrollment phase?
                if (SecurityHelper.isEmpty(userBean.getPassPhrase()))
                {
                    AuthenticatedUser authUser = null;
                    boolean authenticated = false;
                    try
                    {
                        authUser = authorization.authenticate(username, password);
                        authenticated = true;
                    }
                    catch (SecurityException e)
                    {}
                    if (authenticated)
                    {
                        userBean.setPassword(password);
                        setView(actionRequest, phase, SUCCESS1);
                        clearLoginMessages(actionRequest);
                    }
                    else
                    {
                        failedLoginProcessing(actionRequest, phase, username, userBean);                       
                    }                   
                }
            }
            else if (phase.equals("three"))
            {
                String redirect = actionRequest.getParameter("redirect");

                String username = userBean.getUsername();
                String password = actionRequest.getParameter(LoginConstants.PASSWORD);
                if (SecurityHelper.isEmpty(password) || SecurityHelper.isEmpty(redirect))
                {
                    RequestContext rc = SecurityHelper.getRequestContext(actionRequest);                   
                    rc.setSessionAttribute(MFALogin.ERRORCODE, LoginConstants.ERROR_INVALID_PASSWORD);                                       
                    setView(actionRequest, phase, FAILURE1);
                    return;
                }               
                // process authentication
                AuthenticatedUser authUser = null;
View Full Code Here

Examples of org.apache.jetspeed.request.RequestContext

        {
            pwdCredential = SecurityHelper.getCredential(userManager, user);
        }
        catch (SecurityException e)
        {}
        RequestContext rc = SecurityHelper.getRequestContext(actionRequest);
        if (pwdCredential != null)
        {
            userBean.setUser(user);
            // Failed login processing
            HttpSession session = rc.getRequest().getSession(true);
            Integer retryCount = (Integer) session.getAttribute(MFALogin.RETRYCOUNT);
            if (retryCount == null)
                retryCount = new Integer(1);
            else
                retryCount = new Integer(retryCount.intValue() + 1);
            session.setAttribute(MFALogin.RETRYCOUNT, retryCount);
            if ( pwdCredential == null || !pwdCredential.isEnabled() )
            {
                rc.setSessionAttribute(MFALogin.ERRORCODE, LoginConstants.ERROR_CREDENTIAL_DISABLED);
                nextView = FAILURE2;
            }
            else if ( pwdCredential.isExpired() )
            {
                rc.setSessionAttribute(MFALogin.ERRORCODE, LoginConstants.ERROR_CREDENTIAL_EXPIRED);
            }
            else if ( maxNumberOfAuthenticationFailures > 1 && pwdCredential.getAuthenticationFailures() == maxNumberOfAuthenticationFailures -)
            {
                rc.setSessionAttribute(MFALogin.ERRORCODE, LoginConstants.ERROR_FINAL_LOGIN_ATTEMPT);
            }
            else
            {
                rc.setSessionAttribute(MFALogin.ERRORCODE, LoginConstants.ERROR_INVALID_PASSWORD);
            }
        }
        audit.logUserActivity(username, rc.getRequest().getRemoteAddr(), AuditActivity.AUTHENTICATION_FAILURE, "MFA");
        //StatusMessage msg = new StatusMessage("invalid password.", StatusMessage.ERROR);
        //PortletMessaging.publish(actionRequest, STATUS_MESSAGE, msg);
        setView(actionRequest, phase, nextView);
    }
View Full Code Here

Examples of org.apache.jetspeed.request.RequestContext

        setView(actionRequest, phase, nextView);
    }

    private void clearLoginMessages(PortletRequest actionRequest)
    {
        RequestContext rc = SecurityHelper.getRequestContext(actionRequest);
        HttpSession session = rc.getRequest().getSession(true);
        session.removeAttribute(MFALogin.RETRYCOUNT);
        session.removeAttribute(MFALogin.ERRORCODE);
        session.removeAttribute(LoginConstants.RETRYCOUNT);
        session.removeAttribute(LoginConstants.ERRORCODE);               
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.