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)));
}
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);
}
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();
}
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;
}
Aggregations