Search in sources :

Example 1 with PublicContentAuthorizationInfo

use of com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo in project entando-core by entando.

the class ProtectedResourceProvider method isAuthOnProtectedRes.

protected boolean isAuthOnProtectedRes(UserDetails currentUser, String resourceId, String contentId) {
    PublicContentAuthorizationInfo authInfo = this.getContentAuthorizationHelper().getAuthorizationInfo(contentId);
    IAuthorizationManager authManager = this.getAuthorizationManager();
    return (authInfo.isProtectedResourceReference(resourceId) && authInfo.isUserAllowed(authManager.getUserGroups(currentUser)));
}
Also used : IAuthorizationManager(com.agiletec.aps.system.services.authorization.IAuthorizationManager) PublicContentAuthorizationInfo(com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo)

Example 2 with PublicContentAuthorizationInfo

use of com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo in project entando-core by entando.

the class ContentPreviewDispenser method getRenderizationInfo.

@Override
public ContentRenderizationInfo getRenderizationInfo(String contentId, long modelId, String langCode, RequestContext reqCtx) {
    PublicContentAuthorizationInfo authInfo = null;
    try {
        Content content = this.extractContentOnSession(reqCtx);
        authInfo = new PublicContentAuthorizationInfo(content, this.getLangManager().getLangs());
    } catch (Throwable t) {
        _logger.error("error in getAuthorizationInfo for content {}", contentId, t);
    }
    return this.getRenderizationInfo(authInfo, contentId, modelId, langCode, reqCtx);
}
Also used : PublicContentAuthorizationInfo(com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 3 with PublicContentAuthorizationInfo

use of com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo in project entando-core by entando.

the class ContentInfoTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    try {
        IContentViewerHelper helper = (IContentViewerHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_VIEWER_HELPER, this.pageContext);
        PublicContentAuthorizationInfo authInfo = helper.getAuthorizationInfo(this.getContentId(), reqCtx);
        if (null == authInfo) {
            return super.doStartTag();
        }
        if (null == this.getParam() && null != this.getVar()) {
            this.pageContext.setAttribute(this.getVar(), authInfo);
        } else if (null != this.getParam()) {
            Object value = null;
            if ("contentId".equals(this.getParam())) {
                value = authInfo.getContentId();
            } else if ("modelId".equals(this.getParam())) {
                value = this.extractModelId(authInfo, reqCtx);
            } else if ("mainGroup".equals(this.getParam())) {
                value = authInfo.getMainGroup();
            } else if ("authToEdit".equals(this.getParam())) {
                IContentAuthorizationHelper contentAuthHelper = (IContentAuthorizationHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_AUTHORIZATION_HELPER, this.pageContext);
                HttpSession session = this.pageContext.getSession();
                UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
                boolean isAuth = contentAuthHelper.isAuthToEdit(currentUser, authInfo);
                value = Boolean.valueOf(isAuth);
            }
            if (null != value) {
                String var = this.getVar();
                if (null == var || "".equals(var)) {
                    this.pageContext.getOut().print(value);
                } else {
                    this.pageContext.setAttribute(this.getVar(), value);
                }
            }
        }
    } catch (Throwable t) {
        _logger.error("Error detected while initializing the tag", t);
        // ApsSystemUtils.logThrowable(t, this, "doStartTag");
        throw new JspException("Error detected while initializing the tag", t);
    }
    return super.doStartTag();
}
Also used : ServletRequest(javax.servlet.ServletRequest) IContentViewerHelper(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper) JspException(javax.servlet.jsp.JspException) PublicContentAuthorizationInfo(com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo) UserDetails(com.agiletec.aps.system.services.user.UserDetails) HttpSession(javax.servlet.http.HttpSession) RequestContext(com.agiletec.aps.system.RequestContext) IContentAuthorizationHelper(com.agiletec.plugins.jacms.aps.system.services.content.helper.IContentAuthorizationHelper)

Example 4 with PublicContentAuthorizationInfo

use of com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo in project entando-core by entando.

the class ContentViewerHelper method getAuthorizationInfo.

@Override
public PublicContentAuthorizationInfo getAuthorizationInfo(String contentId, RequestContext reqCtx) throws ApsSystemException {
    PublicContentAuthorizationInfo authInfo = null;
    try {
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        contentId = this.extractContentId(contentId, widget.getConfig(), reqCtx);
        if (null == contentId) {
            _logger.info("Null contentId");
            return null;
        }
        authInfo = this.getContentAuthorizationHelper().getAuthorizationInfo(contentId, true);
        if (null == authInfo) {
            _logger.info("Null authorization info by content '" + contentId + "'");
        }
    } catch (Throwable t) {
        _logger.error("Error extracting content authorization info by content {}", contentId, t);
        // ApsSystemUtils.logThrowable(t, this, "getAuthorizationInfo");
        throw new ApsSystemException("Error extracting content authorization info by content '" + contentId + "'", t);
    }
    return authInfo;
}
Also used : PublicContentAuthorizationInfo(com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo) Widget(com.agiletec.aps.system.services.page.Widget) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Aggregations

PublicContentAuthorizationInfo (com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo)4 RequestContext (com.agiletec.aps.system.RequestContext)1 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 IAuthorizationManager (com.agiletec.aps.system.services.authorization.IAuthorizationManager)1 Widget (com.agiletec.aps.system.services.page.Widget)1 UserDetails (com.agiletec.aps.system.services.user.UserDetails)1 IContentAuthorizationHelper (com.agiletec.plugins.jacms.aps.system.services.content.helper.IContentAuthorizationHelper)1 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)1 IContentViewerHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper)1 ServletRequest (javax.servlet.ServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1 JspException (javax.servlet.jsp.JspException)1