• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PermissionChecker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.liferay.portal.kernel.security.permission.PermissionChecker的典型用法代码示例。如果您正苦于以下问题:Java PermissionChecker类的具体用法?Java PermissionChecker怎么用?Java PermissionChecker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PermissionChecker类属于com.liferay.portal.kernel.security.permission包,在下文中一共展示了PermissionChecker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getFileEntryTypes

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
public Map<DLFileEntryType, List<DDMTemplate>> getFileEntryTypes(PermissionChecker permissionChecker, long groupId) throws PortalException {
    List<DLFileEntryType> fileEntryTypes = this.dlFileEntryTypeService.getFileEntryTypes(this.portal.getCurrentAndAncestorSiteGroupIds(groupId));
    HashMap<DLFileEntryType, List<DDMTemplate>> fileEntryTypeTemplateMapping = new HashMap<>(fileEntryTypes.size());

    Map<Group, List<DDMTemplate>> templatesByGroup = this.getDLFileEntryTypeTemplates(permissionChecker, groupId);
    List<DDMTemplate> templates = new ArrayList<>();
    for(List<DDMTemplate> groupTemplates : templatesByGroup.values()) {
        templates.addAll(groupTemplates);
    }

    // Put the default file entry type in there (because getFileEntryTypes won't do it)
    fileEntryTypeTemplateMapping.put(this.dlFileEntryTypeService.getDLFileEntryType(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT), templates);

    for(DLFileEntryType fileEntryType : fileEntryTypes) {
        fileEntryTypeTemplateMapping.put(fileEntryType, templates);
    }

    return fileEntryTypeTemplateMapping;
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:21,代码来源:FlashlightSearchServiceImpl.java


示例2: processLifecycleEvent

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
	User user;
	try {
		user = PortalUtil.getUser(lifecycleEvent.getRequest());
		
		PrincipalThreadLocal.setName(user.getUserId());

		PermissionChecker permissionChecker;

		permissionChecker = PermissionCheckerFactoryUtil.create(user);

		PermissionThreadLocal.setPermissionChecker(permissionChecker);

		String friendlyUrl = user.getSiteGroups().get(0).getFriendlyURL();

		lifecycleEvent.getResponse().sendRedirect("/group" + friendlyUrl);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:24,代码来源:LoginPostAction.java


示例3: updateFile

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static FileEntry updateFile(long userId, long companyId, long groupId, long fileEntryId,
		InputStream inputStream, String fileName, String fileType, long fileSize, String destination, String desc,
		ServiceContext serviceContext) throws Exception {
	FileEntry fileEntry = null;

	if (inputStream != null && fileSize > 0 && Validator.isNotNull(fileName)) {

		serviceContext.setAddGroupPermissions(true);
		serviceContext.setAddGuestPermissions(true);

		User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());

		PermissionChecker checker = PermissionCheckerFactoryUtil.create(user);
		PermissionThreadLocal.setPermissionChecker(checker);

		DLAppLocalServiceUtil.updateFileEntry(userId, fileEntryId, fileName, fileType,
				System.currentTimeMillis() + StringPool.DASH + fileName, desc, StringPool.BLANK, true, inputStream,
				fileSize, serviceContext);
	}

	return fileEntry;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:23,代码来源:FileUploadUtils.java


示例4: hasPermissions

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
protected boolean hasPermissions(PermissionChecker permissionChecker, SocialActivity activity, String actionId,
        ServiceContext serviceContext) throws Exception {

    TaskRecord taskRecord = _taskRecordLocalService.getTaskRecord(activity.getClassPK());

    return TaskRecordPermission.contains(permissionChecker, taskRecord.getTaskRecordId(), actionId);
}
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:9,代码来源:TaskRecordActivityInterpreter.java


示例5: check

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, long groupId, String actionId)
        throws PortalException {

    if (!contains(permissionChecker, groupId, actionId)) {

        throw new PrincipalException();
    }
}
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:9,代码来源:TimetrackerPortletPermission.java


示例6: check

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, TaskRecord taskRecord, String actionId)
        throws PortalException {

    if (!contains(permissionChecker, taskRecord, actionId)) {
        throw new PrincipalException();
    }
}
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:8,代码来源:TaskRecordPermission.java


示例7: contains

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static boolean contains(PermissionChecker permissionChecker, TaskRecord taskRecord, String actionId) {

        if (permissionChecker.hasOwnerPermission(taskRecord.getCompanyId(), TaskRecord.class.getName(),
                taskRecord.getTaskRecordId(), taskRecord.getUserId(), actionId)) {

            return true;
        }

        return permissionChecker.hasPermission(taskRecord.getGroupId(), TaskRecord.class.getName(),
                String.valueOf(taskRecord.getTaskRecordId()), actionId);
    }
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:12,代码来源:TaskRecordPermission.java


示例8: getApplicationDisplayTemplates

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
/**
 * Returns the DL File Entry types templates
 *
 * @param permissionChecker The current context's permission checker
 * @param groupId The current site ID
 * @param classNameId The template's classNameId
 * @return A list of templates indexed by file entry types
 *
 * @throws PortalException If an error occurs while searching templates
 */
private Map<Group, List<DDMTemplate>> getApplicationDisplayTemplates(PermissionChecker permissionChecker, long groupId, long classNameId) throws PortalException {
    HashMap<Group, List<DDMTemplate>> adts = new HashMap<>();

    long[] currentGroupIds = this.portal.getCurrentAndAncestorSiteGroupIds(groupId);
    long userId = permissionChecker.getUserId();
    for(long currentGroupId : currentGroupIds) {
        List<DDMTemplate> groupTemplates = this.ddmTemplateService.getTemplates(currentGroupId, classNameId)
            .stream()
            .filter(template -> {
                // See DDMTemplatePermission.java in Liferay's source code for the inspirational stuff
                String modelResourceName = DDMTemplate.class.getName();
                long companyId = template.getCompanyId();
                long templateId = template.getTemplateId();
                String actionKey = ActionKeys.VIEW;

                return (
                    permissionChecker.hasOwnerPermission(companyId, modelResourceName, templateId, userId, actionKey) ||
                    permissionChecker.hasPermission(companyId, modelResourceName, templateId, actionKey)
                );
            })
            .collect(Collectors.toList());

        // If we have templates to show, put it in the map
        if(!groupTemplates.isEmpty()) {
            Group group = this.groupService.getGroup(currentGroupId);
            adts.put(group, groupTemplates);
        }
    }

    return adts;
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:42,代码来源:FlashlightSearchServiceImpl.java


示例9: hasPermissions

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
protected boolean hasPermissions(PermissionChecker permissionChecker, SocialActivity activity, String actionId,
        ServiceContext serviceContext) throws Exception {

    Contact contact = _contactLocalService.getContact(activity.getClassPK());

    return ContactPermission.contains(permissionChecker, contact.getContactId(), actionId);
}
 
开发者ID:inofix,项目名称:ch-inofix-contact-manager,代码行数:9,代码来源:ContactActivityInterpreter.java


示例10: check

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, Contact contact, String actionId)
        throws PrincipalException {

    if (!contains(permissionChecker, contact, actionId)) {
        throw new PrincipalException();
    }
}
 
开发者ID:inofix,项目名称:ch-inofix-contact-manager,代码行数:8,代码来源:ContactPermission.java


示例11: contains

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static boolean contains(PermissionChecker permissionChecker, long contactId, String actionId) {

        Contact contact;
        try {
            contact = ContactLocalServiceUtil.getContact(contactId);
            return contains(permissionChecker, contact, actionId);
        } catch (PortalException e) {
            _log.error(e);
        }

        return false;

    }
 
开发者ID:inofix,项目名称:ch-inofix-contact-manager,代码行数:14,代码来源:ContactPermission.java


示例12: check

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, long groupId, String actionId)
        throws PrincipalException {

    if (!contains(permissionChecker, groupId, actionId)) {
        throw new PrincipalException();
    }
}
 
开发者ID:inofix,项目名称:ch-inofix-contact-manager,代码行数:8,代码来源:ContactManagerPortletPermission.java


示例13: addFolder

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static DLFolder addFolder(
	long userId, long groupId, long repositoryId, boolean mountPoint,
	long parentFolderId, String name, String description, boolean hidden,
	ServiceContext serviceContext) {

	DLFolder dlFolder = null;
	try {
		if (hasFolder(groupId, parentFolderId, name)) {
			dlFolder = DLFolderLocalServiceUtil.getFolder(
				groupId, parentFolderId, name);
			setFolderPermissions(dlFolder);
		}
		else {
			User user =
				UserLocalServiceUtil.getUser(serviceContext.getUserId());
			PermissionChecker checker =
				PermissionCheckerFactoryUtil.create(user);
			PermissionThreadLocal.setPermissionChecker(checker);
			//serviceContext.setAddGroupPermissions(true);
			//serviceContext.setAddGuestPermissions(true);

			dlFolder = DLFolderLocalServiceUtil.addFolder(
				userId, groupId, repositoryId, mountPoint, parentFolderId,
				name, description, hidden, serviceContext);

			setFolderPermissions(dlFolder);
		}

	}
	catch (Exception e) {
		_log.info(e);
	}

	return dlFolder;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:36,代码来源:DLFolderUtil.java


示例14: cloneFile

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static FileEntry cloneFile(long userId, long groupId, long fileEntryId, 
		String destination, ServiceContext serviceContext) 
	throws Exception {
	
	FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);

	serviceContext.setAddGroupPermissions(true);
	serviceContext.setAddGuestPermissions(true);

	Calendar calendar = Calendar.getInstance();

	calendar.setTime(new Date());
	
	if(Validator.isNull(destination)) {
		destination = StringPool.BLANK;
	} else if(destination.indexOf(StringPool.SLASH) < 0) {
	    destination += StringPool.SLASH;
	}

	destination += calendar.get(Calendar.YEAR) + StringPool.SLASH;
	destination += calendar.get(Calendar.MONTH) + StringPool.SLASH;
	destination += calendar.get(Calendar.DAY_OF_MONTH);

	DLFolder dlFolder = DLFolderUtil.getTargetFolder(userId, groupId, groupId, false, 0, destination,
			StringPool.BLANK, false, serviceContext);

	User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());

	PermissionChecker checker = PermissionCheckerFactoryUtil.create(user);
	PermissionThreadLocal.setPermissionChecker(checker);
	
	String title = getFileName(fileEntry.getTitle());
	
	return DLAppLocalServiceUtil.addFileEntry(userId, groupId, dlFolder.getFolderId(), title,
			fileEntry.getMimeType(), System.currentTimeMillis() + StringPool.DASH + title, title,
			StringPool.BLANK, fileEntry.getContentStream(), fileEntry.getSize(), serviceContext);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:38,代码来源:FileUploadUtils.java


示例15: check

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static void check(PermissionChecker permissionChecker, Measurement taskRecord, String actionId)
        throws PortalException {

    if (!contains(permissionChecker, taskRecord, actionId)) {
        throw new PrincipalException();
    }
}
 
开发者ID:inofix,项目名称:ch-inofix-data-manager,代码行数:8,代码来源:MeasurementPermission.java


示例16: contains

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
public static boolean contains(PermissionChecker permissionChecker, Measurement taskRecord, String actionId) {

        if (permissionChecker.hasOwnerPermission(taskRecord.getCompanyId(), Measurement.class.getName(),
                taskRecord.getMeasurementId(), taskRecord.getUserId(), actionId)) {

            return true;
        }

        return permissionChecker.hasPermission(taskRecord.getGroupId(), Measurement.class.getName(),
                String.valueOf(taskRecord.getMeasurementId()), actionId);
    }
 
开发者ID:inofix,项目名称:ch-inofix-data-manager,代码行数:12,代码来源:MeasurementPermission.java


示例17: isVisible

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
public boolean isVisible(
		PermissionChecker permissionChecker, Portlet portlet)
	throws Exception {

	return true;
}
 
开发者ID:jorgediaz-lr,项目名称:staging-checker,代码行数:8,代码来源:StagingCheckerControlPanelEntry.java


示例18: isShow

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
@Override
public boolean isShow(PermissionChecker permissionChecker, Group group)
	throws PortalException {

	if (group.isControlPanel()) {
		return false;
	}

	return true;
}
 
开发者ID:liferay,项目名称:liferay-blade-samples,代码行数:11,代码来源:BladeSimulationPanelApp.java


示例19: setAdminPermissionCheckerForThread

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
/**
 * Initializes permission checker for Liferay Admin. Used to grant access to
 * custom fields.
 *
 * @param companyId company ID
 * @throws Exception if cannot set permission checker
 */
private static void setAdminPermissionCheckerForThread(final long companyId) throws Exception {

    User adminUser = getAdminUser(companyId);
    PrincipalThreadLocal.setName(adminUser.getUserId());
    PermissionChecker permissionChecker;
    try {
        permissionChecker = PermissionCheckerFactoryUtil.create(adminUser);
    } catch (Exception e) {
        throw new Exception("Cannot obtain permission checker for Liferay Administrator user",
                e);
    }
    PermissionThreadLocal.setPermissionChecker(permissionChecker);
}
 
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:21,代码来源:LiferaySetup.java


示例20: getMBSubCategories

import com.liferay.portal.kernel.security.permission.PermissionChecker; //导入依赖的package包/类
/**
 * Method that get subcategories of particular category
 */
public static List<Object> getMBSubCategories(HttpServletRequest request,long selectedCategoryId){
	_log.debug("Entry : getMBSubCategories");
	List<Object> subCategoryList=new ArrayList<>();
	ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
	PortletPreferences preferences = PortletPreferencesFactoryUtil.getLayoutPortletSetup(themeDisplay.getLayout(), CustomConstants.MESSAGE_BOARDS);
	long preferenceCatId=GetterUtil.getLong(preferences.getValue(CustomConstants.PREFERENCE_CATEGORYID, String.valueOf(QueryUtil.ALL_POS)));
	long mbcatID=ParamUtil.getLong(request, "mbCategoryId");
	if(mbcatID !=CustomConstants.ZERO_INDEX){
		selectedCategoryId=mbcatID;
	}
	ParamUtil.getString(request, "mbCategoryId");
	int status = WorkflowConstants.STATUS_APPROVED;
	PermissionChecker permissionChecker =
			themeDisplay.getPermissionChecker();

		if (permissionChecker.isContentReviewer(
				themeDisplay.getCompanyId(),
				themeDisplay.getScopeGroupId())) {

			status = WorkflowConstants.STATUS_ANY;
		}
	subCategoryList= MBCategoryLocalServiceUtil.getCategoriesAndThreads(themeDisplay.getScopeGroupId(), selectedCategoryId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
		_log.debug("List Size:=>"+subCategoryList.size());
	return subCategoryList;
	
}
 
开发者ID:Azilen,项目名称:Discussion-Board-Liferay,代码行数:30,代码来源:CustomThreadCategoryList.java



注:本文中的com.liferay.portal.kernel.security.permission.PermissionChecker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WriteContents类代码示例发布时间:2022-05-22
下一篇:
Java Week类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap