Search in sources :

Example 6 with PermissionChecker

use of com.liferay.portal.security.permission.PermissionChecker in project liferay-ide by liferay.

the class SearchPortlet method getStatus.

protected int getStatus(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    if (!themeDisplay.isSignedIn()) {
        return WorkflowConstants.STATUS_APPROVED;
    }
    String value = renderRequest.getParameter("status");
    int status = GetterUtil.getInteger(value);
    if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) {
        return WorkflowConstants.STATUS_APPROVED;
    }
    long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey");
    if (resourcePrimKey == 0) {
        return WorkflowConstants.STATUS_APPROVED;
    }
    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) {
        return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
    }
    return WorkflowConstants.STATUS_APPROVED;
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 7 with PermissionChecker

use of com.liferay.portal.security.permission.PermissionChecker in project liferay-ide by liferay.

the class SectionPortlet method getStatus.

protected int getStatus(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    if (!themeDisplay.isSignedIn()) {
        return WorkflowConstants.STATUS_APPROVED;
    }
    String value = renderRequest.getParameter("status");
    int status = GetterUtil.getInteger(value);
    if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) {
        return WorkflowConstants.STATUS_APPROVED;
    }
    long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey");
    if (resourcePrimKey == 0) {
        return WorkflowConstants.STATUS_APPROVED;
    }
    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) {
        return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
    }
    return WorkflowConstants.STATUS_APPROVED;
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 8 with PermissionChecker

use of com.liferay.portal.security.permission.PermissionChecker in project liferay-ide by liferay.

the class AdminSubscriptionSender method hasPermission.

@Override
protected boolean hasPermission(Subscription subscription, String inferredClassName, long inferredClassPK, User user) throws Exception {
    String name = PrincipalThreadLocal.getName();
    PermissionChecker contextPermissionChecker = PermissionThreadLocal.getPermissionChecker();
    try {
        PrincipalThreadLocal.setName(user.getUserId());
        PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user);
        PermissionThreadLocal.setPermissionChecker(permissionChecker);
        return KBArticlePermission.contains(permissionChecker, _kbArticle, ActionKeys.VIEW);
    } finally {
        PrincipalThreadLocal.setName(name);
        PermissionThreadLocal.setPermissionChecker(contextPermissionChecker);
    }
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker)

Example 9 with PermissionChecker

use of com.liferay.portal.security.permission.PermissionChecker in project liferay-ide by liferay.

the class ArticlePortlet method getStatus.

protected int getStatus(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    if (!themeDisplay.isSignedIn()) {
        return WorkflowConstants.STATUS_APPROVED;
    }
    String value = renderRequest.getParameter("status");
    int status = GetterUtil.getInteger(value);
    if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) {
        return WorkflowConstants.STATUS_APPROVED;
    }
    long resourcePrimKey = getResourcePrimKey(renderRequest);
    if (resourcePrimKey == 0) {
        return WorkflowConstants.STATUS_APPROVED;
    }
    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) {
        return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
    }
    return WorkflowConstants.STATUS_APPROVED;
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 10 with PermissionChecker

use of com.liferay.portal.security.permission.PermissionChecker in project liferay-ide by liferay.

the class AdminPortlet method updateOAuthConsumers.

public void updateOAuthConsumers(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    long gadgetId = ParamUtil.getLong(actionRequest, "gadgetId");
    GadgetPermission.check(permissionChecker, themeDisplay.getScopeGroupId(), gadgetId, ActionKeys.UPDATE);
    ShindigUtil.updateOAuthConsumers(actionRequest, actionResponse);
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Aggregations

PermissionChecker (com.liferay.portal.security.permission.PermissionChecker)16 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)10 IOException (java.io.IOException)3 Gadget (com.liferay.opensocial.model.Gadget)2 User (com.liferay.portal.model.User)2 ServletException (javax.servlet.ServletException)2 Calendar (com.liferay.calendar.model.Calendar)1 CalendarResource (com.liferay.calendar.model.CalendarResource)1 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 NoSuchGroupException (com.liferay.portal.NoSuchGroupException)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 JSONArray (com.liferay.portal.kernel.json.JSONArray)1 JSONObject (com.liferay.portal.kernel.json.JSONObject)1 RepositoryException (com.liferay.portal.kernel.repository.RepositoryException)1 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)1 Folder (com.liferay.portal.kernel.repository.model.Folder)1 Indexer (com.liferay.portal.kernel.search.Indexer)1 SearchPermissionChecker (com.liferay.portal.kernel.search.SearchPermissionChecker)1 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)1