当前位置: 首页>>代码示例>>Java>>正文


Java PermissionChecker类代码示例

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


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


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